Additional lemmas about the Rational Numbers #
@[simp]
theorem
Rat.maybeNormalize_eq
{num : Int}
{den : Nat}
{g : Nat}
(den_nz : den / g ≠ 0)
(reduced : Nat.Coprime (Int.natAbs (Int.div num ↑g)) (den / g))
:
Rat.maybeNormalize num den g den_nz reduced = Rat.mk' (Int.div num ↑g) (den / g)
theorem
Rat.normalize.reduced'
{num : Int}
{den : Nat}
{g : Nat}
(den_nz : den ≠ 0)
(e : g = Nat.gcd (Int.natAbs num) den)
:
Nat.Coprime (Int.natAbs (num / ↑g)) (den / g)
theorem
Rat.normalize_eq
{num : Int}
{den : Nat}
(den_nz : den ≠ 0)
:
Rat.normalize num den = Rat.mk' (num / ↑(Nat.gcd (Int.natAbs num) den)) (den / Nat.gcd (Int.natAbs num) den)
theorem
Rat.mk_eq_normalize
(num : Int)
(den : Nat)
(nz : den ≠ 0)
(c : Nat.Coprime (Int.natAbs num) den)
:
Rat.mk' num den = Rat.normalize num den
theorem
Rat.normalize_mul_left
{d : Nat}
{n : Int}
{a : Nat}
(d0 : d ≠ 0)
(a0 : a ≠ 0)
:
Rat.normalize (↑a * n) (a * d) = Rat.normalize n d
theorem
Rat.normalize_mul_right
{d : Nat}
{n : Int}
{a : Nat}
(d0 : d ≠ 0)
(a0 : a ≠ 0)
:
Rat.normalize (n * ↑a) (d * a) = Rat.normalize n d
theorem
Rat.normalize_eq_iff
{d₁ : Nat}
{d₂ : Nat}
{n₁ : Int}
{n₂ : Int}
(z₁ : d₁ ≠ 0)
(z₂ : d₂ ≠ 0)
:
Rat.normalize n₁ d₁ = Rat.normalize n₂ d₂ ↔ n₁ * ↑d₂ = n₂ * ↑d₁
theorem
Rat.maybeNormalize_eq_normalize
{num : Int}
{den : Nat}
{g : Nat}
(den_nz : den / g ≠ 0)
(reduced : Nat.Coprime (Int.natAbs (Int.div num ↑g)) (den / g))
(hn : ↑g ∣ num)
(hd : g ∣ den)
:
Rat.maybeNormalize num den g den_nz reduced = Rat.normalize num den
@[simp]
theorem
Rat.normalize_num_den'
(num : Int)
(den : Nat)
(nz : den ≠ 0)
:
∃ d, d ≠ 0 ∧ num = (Rat.normalize num den).num * ↑d ∧ den = (Rat.normalize num den).den * d
theorem
Rat.normalize_num_den
{n : Int}
{d : Nat}
{z : d ≠ 0}
{n' : Int}
{d' : Nat}
{z' : d' ≠ 0}
{c : Nat.Coprime (Int.natAbs n') d'}
(h : Rat.normalize n d = Rat.mk' n' d')
:
theorem
Rat.normalize_eq_mkRat
{num : Int}
{den : Nat}
(den_nz : den ≠ 0)
:
Rat.normalize num den = mkRat num den
theorem
Rat.mk_eq_mkRat
(num : Int)
(den : Nat)
(nz : den ≠ 0)
(c : Nat.Coprime (Int.natAbs num) den)
:
theorem
Rat.mk_eq_divInt
(num : Int)
(den : Nat)
(nz : den ≠ 0)
(c : Nat.Coprime (Int.natAbs num) den)
:
Rat.mk' num den = Rat.divInt num ↑den
theorem
Rat.divInt_eq_iff
{d₁ : Int}
{d₂ : Int}
{n₁ : Int}
{n₂ : Int}
(z₁ : d₁ ≠ 0)
(z₂ : d₂ ≠ 0)
:
Rat.divInt n₁ d₁ = Rat.divInt n₂ d₂ ↔ n₁ * d₂ = n₂ * d₁
theorem
Rat.divInt_mul_left
{n : Int}
{d : Int}
{a : Int}
(a0 : a ≠ 0)
:
Rat.divInt (a * n) (a * d) = Rat.divInt n d
theorem
Rat.divInt_mul_right
{n : Int}
{d : Int}
{a : Int}
(a0 : a ≠ 0)
:
Rat.divInt (n * a) (d * a) = Rat.divInt n d
theorem
Rat.divInt_num_den
{d : Int}
{n : Int}
{n' : Int}
{d' : Nat}
{z' : d' ≠ 0}
{c : Nat.Coprime (Int.natAbs n') d'}
(z : d ≠ 0)
(h : Rat.divInt n d = Rat.mk' n' d')
:
theorem
Rat.normalize_add_normalize
(n₁ : Int)
(n₂ : Int)
{d₁ : Nat}
{d₂ : Nat}
(z₁ : d₁ ≠ 0)
(z₂ : d₂ ≠ 0)
:
Rat.normalize n₁ d₁ + Rat.normalize n₂ d₂ = Rat.normalize (n₁ * ↑d₂ + n₂ * ↑d₁) (d₁ * d₂)
theorem
Rat.divInt_add_divInt
(n₁ : Int)
(n₂ : Int)
{d₁ : Int}
{d₂ : Int}
(z₁ : d₁ ≠ 0)
(z₂ : d₂ ≠ 0)
:
Rat.divInt n₁ d₁ + Rat.divInt n₂ d₂ = Rat.divInt (n₁ * d₂ + n₂ * d₁) (d₁ * d₂)
theorem
Rat.neg_normalize
(n : Int)
(d : Nat)
(z : d ≠ 0)
:
-Rat.normalize n d = Rat.normalize (-n) d
theorem
Rat.divInt_sub_divInt
(n₁ : Int)
(n₂ : Int)
{d₁ : Int}
{d₂ : Int}
(z₁ : d₁ ≠ 0)
(z₂ : d₂ ≠ 0)
:
Rat.divInt n₁ d₁ - Rat.divInt n₂ d₂ = Rat.divInt (n₁ * d₂ - n₂ * d₁) (d₁ * d₂)
theorem
Rat.normalize_mul_normalize
(n₁ : Int)
(n₂ : Int)
{d₁ : Nat}
{d₂ : Nat}
(z₁ : d₁ ≠ 0)
(z₂ : d₂ ≠ 0)
:
Rat.normalize n₁ d₁ * Rat.normalize n₂ d₂ = Rat.normalize (n₁ * n₂) (d₁ * d₂)
theorem
Rat.divInt_mul_divInt
(n₁ : Int)
(n₂ : Int)
{d₁ : Int}
{d₂ : Int}
(z₁ : d₁ ≠ 0)
(z₂ : d₂ ≠ 0)
:
Rat.divInt n₁ d₁ * Rat.divInt n₂ d₂ = Rat.divInt (n₁ * n₂) (d₁ * d₂)
theorem
Rat.ofScientific_true_def
{m : Nat}
{e : Nat}
:
Rat.ofScientific m true e = mkRat (↑m) (10 ^ e)
The following lemmas are later subsumed by e.g. Int.cast_add
and Int.cast_mul
in Mathlib
but it is convenient to have these earlier, for users who only need Int
and Rat
.