Documentation

Std.Internal.Rat

Rational numbers for implementing decision procedures. We should not confuse them with the Mathlib rational numbers.

Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.
@[inline]
Equations
  • a.normalize = if (a.num.natAbs.gcd a.den == 1) = true then a else { num := a.num.tdiv (a.num.natAbs.gcd a.den), den := a.den / a.num.natAbs.gcd a.den }
def Std.Internal.mkRat (num : Int) (den : Nat) :
Equations
Equations
  • a.isInt = (a.den == 1)
Equations
  • One or more equations did not get rendered due to their size.
Equations
  • a.mul b = { num := a.num.tdiv (a.num.natAbs.gcd b.den) * b.num.tdiv (a.den.gcd b.num.natAbs), den := b.den / a.num.natAbs.gcd b.den * (a.den / a.den.gcd b.num.natAbs) }
Equations
  • a.inv = if a.num < 0 then { num := -a.den, den := a.num.natAbs } else if (a.num == 0) = true then a else { num := a.den, den := a.num.natAbs }
Equations
  • a.div b = a.mul b.inv
Equations
  • One or more equations did not get rendered due to their size.
Equations
  • One or more equations did not get rendered due to their size.
Equations
  • a.neg = { num := -a.num, den := a.den }
Equations
  • a.floor = if (a.den == 1) = true then a.num else let r := a.num.tmod a.den; if a.num < 0 then r - 1 else r
Equations
  • a.ceil = if (a.den == 1) = true then a.num else let r := a.num.tmod a.den; if a.num > 0 then r + 1 else r
Equations
Equations
Equations
Equations
Equations
Equations
Equations