-
Notifications
You must be signed in to change notification settings - Fork 644
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
Unifier thinks 0.0 = -0.0 which means you can prove Void #2609
Comments
This originally came about as a discussion of:
Which itself came about in a discussion of how NaN behaves in types (it's interesting when |
I'll add that the fact that two NaNs won't unify is also potentially an issue, but we weren't able to find a way to get |
The suggestion in the channel was bit-pattern identity for floats. This would make some The proposal would also make |
IEEE describes an equality test (and indeed a partial order) for floats which includes that negative zero is equal to positive zero, and that every NaN is incomparable with every NaN including itself. However it also describes a total order which will differentiate these cases, including different NaNs, and order them all, in such a way that Which is to say, there is apparently a specific provision for this sort of requirement, and even a stronger one than ours. Now we just have to find implementations. |
Interesting! My feeling about comparisons is that The unification thing for NaNs means that writing patterns is hard, but in practice we would be better served by some sort of |
Since there is no literal form for NaNs, you can’t match on them in the first place. Edit: Wait, you mean |
Allow me to add a possibly slightly prettier version of the proof at the beginning:
|
Change the conversion checker to use bit-pattern identity on Double instead of the IEEE comparison that Haskell's Eq type class implements. Previously, we had definitionally equal values like -0.0 and 0.0 that could nevertheless be distinguished by programs. This breaking of functionality allowed proving a contradiction. Thanks to Ryan Scott for the tip on how to do the bit-pattern comparison! Fixes idris-lang#2609.
I think that my concerns about bit-pattern identity for |
Change the conversion checker to use bit-pattern identity on Double instead of the IEEE comparison that Haskell's Eq type class implements. Previously, we had definitionally equal values like -0.0 and 0.0 that could nevertheless be distinguished by programs. This breaking of functionality allowed proving a contradiction. Thanks to Ryan Scott for the tip on how to do the bit-pattern comparison! Fixes #2609.
This isn't my discovery, this is copypasta from discussion on the IRC. Credit to {AS}, scshunt, Melvar and ladyfriday.
To explain, 1/-0.0 is -Infinity and 1/0.0 is +Infinity, so we have -Infinity = Infinity, False = True, and then Void. The unifier needs to be more precise about what floats are and aren't equal.
The text was updated successfully, but these errors were encountered: