-
Notifications
You must be signed in to change notification settings - Fork 463
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
RFC: add definitions for Float
and Float32
#6797
Comments
Hi, thanks for creating this RFC. Float specs are a delicate issue, what we would need to see here at minimum to consider inclusion is a full-featured, robust implementation out of core with references to the literature and prior work. Then a new RFC for upstreaming this work could be opened. |
I am in favor of developing a flocq port as part of batteries with an eye to upstreaming it eventually. |
How do you think should the floating point definitions be integrated into Lean? The coq implementation (and flocq indirectly) defines the native floating point operations by axiomatically asserting that they are equivalent to the definitions in their spec float definition. I don't think this approach would fit for Lean though because pretty much everything only uses 3 axioms and axiomatically declaring the behavior of floats is anyways not necessary because you can't even use hardware floats in proofs (without |
This discussion should probably move to batteries.
|
Proposal
Add some definitions for simple floating point operations like additions, multiplication, division, etc.
I have a simple draft here: https://github.com/Rob23oba/lean4/blob/float-definitions/src/Init/Data/Float.lean
I decided to do an RFC first instead of immediately a PR though because this might be controversial.
The reason you'd want to have this is to in general allow reasoning about floats, even if we don't actually define any theorems in
Init
directly: without such definitions, reasoning about floats is completely impossible unless you add auxiliary axioms that declare that the floating point numbers work as expected (which is not preferable). Floats actually do have capabilities for approximate reasoning (e.g. if floats a and b are at most 1 ulp away from rational numbers x and y respectively then a + b is at most 3 ulps away from x + y) and to get access to such reasoning you would otherwise need to redefine your own floats which is also weird because then you'd have two types for the same thing!An example of something I would find this useful for is the formalization of video games (or of course programs in general).
I don't expect the theorems or whatever to be in
Init
or core lean in general though, they'd probably live in some part of batteries or mathlib instead, this is just supposed to be a simple definition of the functions that would be used externally.I am aware that this creates some kind of maintainability problem though because changes to these definitions would also need to be accompanied by changes to any kind of proof infrastructure on batteries or mathlib or whereever. My hope is that the definitions won't need to be changed after being written but that obviously means that they need to be correct and that there's nothing about the definitions worth changing. Because of that, I'm very much okay with any kind of small improvement suggestions and, of course, "bug reports" on the definitions (e.g. any special cases I missed?).
In general, feedback and discussion is very much appreciated.
Impact
Add 👍 to issues you consider important. If others benefit from the changes in this proposal being added, please ask them to add 👍 to it.
The text was updated successfully, but these errors were encountered: