Skip to content
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

Prove properties of rounding functions in Data.Rational(.Unnormalised).Base #1591

Open
MatthewDaggitt opened this issue Sep 21, 2021 · 2 comments

Comments

@MatthewDaggitt
Copy link
Contributor

Follow up to #1063, which was partially addressed in #1585. Once the properties have been proved, there's an argument that we can remove the test suite added in #1585, though I'm open to counter-arguments for keeping it...

@barrettj12
Copy link
Contributor

Some examples of properties that we might like to prove for each of floor, ceiling, truncate, round:

  • Monotonicity: floor p ≤ p*, ceiling p ≥ p, | truncate p | ≤ p, | round p - p | ≤ ½
  • That each one is the "optimal" integer satisfying the above, e.g. (z : ℤ) → z ≤ p → z ≤ floor p, (z : ℤ) → | round p - p | ≤ | z - p |
  • Identity on integers, e.g. (z : ℤ) → floor z ≡ z (and maybe converses?)
  • Symmetry and relations between them: floor (- p) ≡ - (ceiling p), truncate p ≡ truncate (- p), round p ≡ round (- p)

* I'm convinced this one needs [n/d]*d≤n from Data.Integer.DivMod, but I can't work it out.

@MatthewDaggitt
Copy link
Contributor Author

MatthewDaggitt commented Sep 21, 2021

In my opinion I think the relationships between the number being rounded and the result of rounding, e.g. floor p + fracPart p ≡ p and 0 ≤ fracPart x < 1 are the most important. The rest should all be derivable from those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants