Rational numbers for implementing decision procedures. We should not confuse them with the Mathlib rational numbers.
Equations
- Lean.instInhabitedRat = { default := { num := default, den := default } }
Equations
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
- Lean.Rat.normalize a = let n := Nat.gcd (Int.natAbs a.num) a.den; if (n == 1) = true then a else { num := Int.div a.num ↑n, den := a.den / n }
Instances For
Equations
- Lean.mkRat num den = if (den == 0) = true then { num := 0, den := 1 } else Lean.Rat.normalize { num := num, den := den }
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Lean.Rat.mul a b = let g1 := Nat.gcd a.den (Int.natAbs b.num); let g2 := Nat.gcd (Int.natAbs a.num) b.den; { num := Int.div a.num ↑g2 * Int.div b.num ↑g1, den := b.den / g2 * (a.den / g1) }
Instances For
Equations
- Lean.Rat.inv a = if a.num < 0 then { num := -↑a.den, den := Int.natAbs a.num } else if (a.num == 0) = true then a else { num := ↑a.den, den := Int.natAbs a.num }
Instances For
Equations
- Lean.Rat.div a b = Lean.Rat.mul a (Lean.Rat.inv b)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Lean.Rat.neg a = { num := -a.num, den := a.den }
Instances For
Equations
- Lean.Rat.instLTRat = { lt := fun (a b : Lean.Rat) => Lean.Rat.lt a b = true }
Equations
Equations
- Lean.Rat.instLERat = { le := fun (a b : Lean.Rat) => ¬b < a }
Equations
Equations
- Lean.Rat.instAddRat = { add := Lean.Rat.add }
Equations
- Lean.Rat.instSubRat = { sub := Lean.Rat.sub }
Equations
- Lean.Rat.instNegRat = { neg := Lean.Rat.neg }
Equations
- Lean.Rat.instMulRat = { mul := Lean.Rat.mul }
Equations
- Lean.Rat.instDivRat = { div := fun (a b : Lean.Rat) => a * Lean.Rat.inv b }
Equations
- Lean.Rat.instCoeIntRat = { coe := fun (num : Int) => { num := num, den := 1 } }