<div dir="ltr">As pointed out, most "usual" algebraic equations simply do not hold for IEEE754 floating-point numbers. Another example is `1+x == 1 /\ x /= 0` is a satisfiable statement. Just wanted to point out you can use modern SMT solvers to analyze such equalities, and Haskell SBV package (shameless plug) provides a convenient interface. Here's the counter-example showing the non-associativity of addition:<div><br></div><div><a href="http://hackage.haskell.org/package/sbv-8.5/docs/Documentation-SBV-Examples-Misc-Floating.html#v:assocPlusRegular">http://hackage.haskell.org/package/sbv-8.5/docs/Documentation-SBV-Examples-Misc-Floating.html#v:assocPlusRegular</a><br></div><div><br></div><div>There are other examples in there as well that might be of interest.</div><div><br></div><div>Cheers,</div><div><br></div><div>-Levent.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 6, 2019 at 2:31 PM Lana Black <lanablack@amok.cc> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 06/11/2019 22:19, Dannyu NDos wrote:<br>
> Omg, addition is not even associative? The zeros truly ruined everything.<br>
> <br>
> 2019년 11월 7일 (목) 06:58, Brent Yorgey <<a href="mailto:byorgey@gmail.com" target="_blank">byorgey@gmail.com</a>>님이 작성:<br>
> <br>
>> How is that worse than the fact that addition is already not associative<br>
>> for floating point types?  At least +0 is really the identity up to (==).<br>
>><br>
>> On Wed, Nov 6, 2019, 3:49 PM Dannyu NDos <<a href="mailto:ndospark320@gmail.com" target="_blank">ndospark320@gmail.com</a>> wrote:<br>
>><br>
>>> Sum has bug with floating points. Current definition states +0 as the<br>
>>> identity element, while the actual identity is -0 since +0 + -0 = +0.<br>
>>> _______________________________________________<br>
>>> Libraries mailing list<br>
>>> <a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
>>> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
>>><br>
>><br>
> <br>
> <br>
> _______________________________________________<br>
> Libraries mailing list<br>
> <a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
> <br>
This has little to do with zeroes per se. IEEE 754 addition isn't <br>
associative for any numbers, and examples not involving zeroes aren't <br>
hard to find. Here's one:<br>
<br>
Prelude> let a = 1e30 :: Double<br>
Prelude> let b = -1e30 :: Double<br>
Prelude> let c = 1 :: Double<br>
Prelude> a + b + c<br>
1.0<br>
Prelude> a + (b + c)<br>
0.0<br>
<br>
There is a good document describing how IEEE754 works, including this <br>
kind of peculiarities: <br>
<a href="https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html" rel="noreferrer" target="_blank">https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html</a><br>
_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
</blockquote></div>