-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problems with and limitations of recursive lists #1150
Comments
Here is a much simplyer way to trigger the crash:
|
@fingolfin : Yes, indeed. -- What I wanted to show is what one might want to work. |
@Stefan-Kohl Well for debugging the issue, the most simple way to reproduce it is best :-). And a crash is a bug that must be fixed, regardless of whether the example to reproduce it is contrived or not... Anyway: I think we all agree that a crash is not an acceptable outcome for such an comparision. However, it is less clear to me what the correct result should be. Maybe For recursive structures, fully solving this would require solving graph isomorphism problems, as you example shows. I do not think we should attempt to do that! So all in all, producing an error seems to be the only sensible solution to me. |
Another option would be to at least produce a stack overflow. The reason this currently crashes, rather than producing GAP's normal |
@fingolfin Indeed solving graph isomorphism problems might be unreasonable -- though why not make this work for small cases, and if the graphs to be compared get too big, isomorphism testing just takes too long? -- Where things seem to work is the case that the compared objects are even identical (at least in the cases I have tried). |
Comparing identical objects indeed always works in GAP, because we assume the axiom that identity implies equality (footnote: this is actually not always satisfied on computers; for some reasons I'll never agree with, the IEEE 754 committee thought it to be a good idea to define As to solving graph isomorphism for "small cases": What should that even mean? How do we define the "size" of the graph, given that it's not really a graph, but possibly a complicated structure consisting of nested lists, records, and other objects? The relevant code necessarily would be horribly complicated and error prone -- yet I fail to see any substantial advante for that. If somebody really, really wanted to use recursive data structures to e.g. represent graphs like that, I think it would be reasonable to expect them to provide their own equality test function. So I'd prefer if our current recursive equality test also marks objects it already saw, and raises an error if it sees an object again. But of course that is also non-trivial (and one has to be careful to make this work in HPC-GAP; e.g. by using the objset code). Alternatively, the equality code could have a recursion depth counter, and refuse to compare objects which are nested beyind a certain depth, say 1000. |
One problem I have with explicitly fixing = is where to stop... obviously then have to do <, then what about say Now, GAP shouldn't crash to the command line certainly, and we should have a good plan (for example, I noticed while you can output recursive lists to the terminal, |
@ChrisJefferson I am not sure what you mean with "explicitly fixing" -- for me, "fixing" means "not crash". And as I described earlier, I'd be fine if comparing recursive data structures (RDS) leads to an error. Bow, things that are implemented on the library level should be fine because the GAP interpreter already has a recursion depth trap. E.g.
and I think that's perfectly fine: it's an error, but not a crash. So, the point where we stop should be when we fixed all kernel functions to correctly deal with RDS. We also should add test for these cases, of course. |
Ah, I interpreted fix to mean "produce the logically correct answer". |
As I said, it's not clear to me whether there really is a "logically correct answer" in all conceivable cases... And even if there is, as explained, I don't think it's reasonable to solve a problem that is at least as complicated as graph isomorphism to achieve this :-). Just not crashing is IMHO enough here. But even if people disagree, I hope we can agree that making it not crash should be the top priorit. |
Perhaps we can simply reuse the existing E.g. we could modify the EQ and LT macros to check it. Or at least the |
and also |
In the past I've steered clear of doing this because it seemed likely to slow down lots of useful things like matric comparison, just in order to produce an error from code that was essentially never going to do anything useful. However now we have an implementation in @fingolfin's branch, we can actually check whether it does slow things down noticeably. |
@stevelinton Would such checks really cause a significant slowdown for comparisons that work? -- If so, then likely introducing these checks is too much overhead (in the end, what may otherwise happen is only a crash, and not wrong results). |
Observed behaviour
Expected behaviour
Observed behaviour
Expected behaviour
Copy and paste GAP banner (to tell us about your setup)
The text was updated successfully, but these errors were encountered: