feat: Exact precision representable reals#477
feat: Exact precision representable reals#477tiferrei wants to merge 5 commits intoformalsec:mainfrom
Conversation
|
Thank you for doing this! I'm a bit overwhelmed this week so I will try to review and give more feedback later on the week. |
|
I am wondering if there is actually a need to keep the |
|
My initial thinking was that, as there are many operations that are not closed over the rationals, such as That being said, this is all dependent on the mappings of the solvers providing such information. If at the end of the day the solvers always provide a "forced" Q.t for reals (or a forced float instead) then there is no point in having the distinction. However I really am not familiar how solvers like CVC5 and Z3 behave in these cases, and the guarantees of the format of their outputs. |
This PR aims to add exact precision real support for the rationals. (#464)
It does so mostly through
Value.real = Exact of Q.t | Approx of floatAs already mentioned before, this has interesting consequences when it comes to conversions and comparison.
Design Decisions
Here is an (expanding) list of design decisions made that I would like to discuss:
Approxis sticky, i.e., operations with approximates do not return exacts.OfString/ToStringare specific to the representation.1.5gets parsed to an Approx,3/2to an Exact.String_to_floatdoes what it says on the tin: gives you a float, i.e., an Approx. We may want to change this to aString_to_real.Real.sqrtreturns Exact on perfect square num/den, Approx otherwise.Real.powis lossy, and always returns Approx. This can be improved, but requires some care.TODO
PS: I am generally not experienced with Smtml, or even OCaml. I would appreciate any and all feedback you have for improving the code. Thanks again for this project! :)