feat: Exact precision representable reals #477
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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! :)