Zulip Chat Archive
Stream: lean4
Topic: Pattern matching on float
Andrés Goens (Aug 25 2023 at 17:49):
I tried pattern matching on floats and it seems to fail. I presume it's because Float
is opaque. Is there anything I could do to make this go through?
def Float.isZero : Float -> Bool
| 0 => true
| _ => false
/-
dependent elimination failed, type mismatch when solving alternative with type
motive (Float.ofScientific 0 false 0)
but expected
motive x
-/
Martin Dvořák (Aug 25 2023 at 17:59):
I am not surprised because =
doesn't work on floats either.
Tomas Skrivan (Aug 25 2023 at 18:01):
Is Float.isZero -0
true or false? :) Yeah Float is a bit messed up here and there is a reason no decidable equality is defined on Float. For "deciding" float equality x = y
I'm using x ≤ y && y ≤ x
.
Martin Dvořák (Aug 25 2023 at 18:01):
Does x ≤ y && y ≤ x
ever give a different result than x == y
on Floats?
Tomas Skrivan (Aug 25 2023 at 19:26):
:man_facepalming: I didn't notice that Float has BEq
Henrik Böving (Aug 25 2023 at 19:28):
Martin Dvořák said:
Does
x ≤ y && y ≤ x
ever give a different result thanx == y
on Floats?
I would ask that the IEEE standard
Henrik Böving (Aug 25 2023 at 19:28):
knowing how funky said standard can be my bet is: yes
MangoIV (Aug 25 2023 at 19:31):
What does it give on NaN and NaN
Ruben Van de Velde (Aug 25 2023 at 19:32):
false
Mario Carneiro (Aug 25 2023 at 20:59):
Henrik Böving said:
Martin Dvořák said:
Does
x ≤ y && y ≤ x
ever give a different result thanx == y
on Floats?I would ask that the IEEE standard
I think that one is actually true (that is, there are no such counterexamples)
Last updated: Dec 20 2023 at 11:08 UTC