Zulip Chat Archive

Stream: Is there code for X?

Topic: IEEE floats


Geoffrey Irving (Feb 14 2023 at 10:30):

Has anyone formalized the IEEE float rounding semantics in Lean?

I’m specifically interested in whether one could prove the correctness of interval arithmetic and expansion arithmetic routines written in Lean using Lean’s float, then use code extraction to get straight line routines for use in high performance contexts.

Eric Wieser (Feb 14 2023 at 10:52):

docs#fp.float is the closest thing I'm aware of in Lean 3.

Eric Wieser (Feb 14 2023 at 10:55):

It's not possible to prove anything useful about the builtin docs#native.float (because it's meta) or docs4#Float (because it's opaque and secretly an alias for Unit!)

Eric Wieser (Feb 14 2023 at 10:55):

See also this thread in #lean4

Geoffrey Irving (Feb 14 2023 at 10:56):

But that doesn’t have any of the rounding theorems, right? I.e., “rounded x * y is the closest float to x * y”?

Geoffrey Irving (Feb 14 2023 at 10:58):

Thanks! That Lean4 thread is a good summary.

Eric Wieser (Feb 14 2023 at 11:00):

Worse than that, the * that docs#fp.float has is meta (there is a TODO in the source) so you can't even prove anything about it!

Geoffrey Irving (Feb 14 2023 at 11:01):

Sure, though to clarify I meant fp.float didn’t have those theorems about the non-meta type.

Edit: Ah, I see what you mean.

Mario Carneiro (Feb 14 2023 at 11:25):

In case it wasn't clear, fp.float is absolutely not supposed to actually be meta, it just was not a high priority to finish those theorems because no one wanted to see it completed

Mario Carneiro (Feb 14 2023 at 11:26):

So I wouldn't say "you can't prove anything about it", it's rather the other way around - if you prove things about it then it won't need to be meta anymore

Eric Wieser (Feb 14 2023 at 11:33):

I guess what would be more accurate would be to say is "you can't prove things about the current * without first redefining * to contain the currently missing proofs"?


Last updated: Dec 20 2023 at 11:08 UTC