You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Disastrous expansion of operations in Data.Rational.Base #1753
The operations such as addition and multiplication in Data.Rational.Base are defined in terms of the numerator and denominator projection operations, e.g.
p + q = (↥ p ℤ.* ↧ q ℤ.+ ↥ q ℤ.* ↧ p) / (↧ₙ p ℕ.* ↧ₙ q)
This is beautiful and elegant, and arguably the right way to define them. However, it does mean that Agda unfolds these definitions automatically. By the time you have an expression x + y + z + a + b + c the unfolded expression is over 200 lines long.
This makes the rational numbers almost impossible to work with in large proofs. In recent proofs I've resorted to redefining everything that's needed under the abstract keyword.
Activity
MatthewDaggitt commentedon Apr 15, 2022
See also the recent mailing list issue which was also caused by this problem.
MatthewDaggitt commentedon May 3, 2022
Suggestion from @andreasabel: investigate using --no-eta-equality in record
andreasabel commentedon May 3, 2022
Turn off
eta-equalitybut still allowpatternmatching:As @gallais said, you need to match on some arguments to enable reductions:
You can force matching with
p@(mkQ _ _ _)to make things reduce more lazily:andreasabel commentedon May 5, 2022
Alternative way to force matching:
x@record{}(closer to Haskell, don't need to mention constructor name):MatthewDaggitt commentedon May 5, 2022
Ooh that's even nicer. Yup, I'm happy with that solution.
MatthewDaggitt commentedon May 5, 2022
Going to have a hack at this now.
MatthewDaggitt commentedon May 5, 2022
Hmm, we have the same issue with multiplication in
Data.Integerbut that's appears harder to fix as there's no one constructor to pattern match on....