Basics for the Rational Numbers #
Summary #
We define the integral domain structure on ℚ
and prove basic lemmas about it.
The definition of the field structure on ℚ
will be done in Mathlib.Data.Rat.Basic
once the
Field
class has been defined.
Main Definitions #
Rat.divInt n d
constructs a rational numberq = n / d
fromn d : ℤ
.
Notations #
/.
is infix notation forRat.divInt
.
@[simp]
theorem
Rat.mk'_zero
(d : ℕ)
(h : d ≠ 0)
(w : (Int.natAbs 0).Coprime d)
:
{ num := 0, den := d, den_nz := h, reduced := w } = 0
theorem
Rat.normalize_eq_mk'
(n : ℤ)
(d : ℕ)
(h : d ≠ 0)
(c : n.natAbs.gcd d = 1)
:
Rat.normalize n d h = { num := n, den := d, den_nz := h, reduced := c }
theorem
Rat.mk'_eq_divInt
{n : ℤ}
{d : ℕ}
{h : d ≠ 0}
{c : n.natAbs.Coprime d}
:
{ num := n, den := d, den_nz := h, reduced := c } = Rat.divInt n ↑d
def
Rat.numDenCasesOn
{C : ℚ → Sort u}
(a : ℚ)
:
((n : ℤ) → (d : ℕ) → 0 < d → n.natAbs.Coprime d → C (Rat.divInt n ↑d)) → C a
Define a (dependent) function or prove ∀ r : ℚ, p r
by dealing with rational
numbers of the form n /. d
with 0 < d
and coprime n
, d
.
Equations
- { num := n, den := d, den_nz := h, reduced := c }.numDenCasesOn x✝ = ⋯.mpr (x✝ n d ⋯ c)
Instances For
def
Rat.numDenCasesOn'
{C : ℚ → Sort u}
(a : ℚ)
(H : (n : ℤ) → (d : ℕ) → d ≠ 0 → C (Rat.divInt n ↑d))
:
C a
Define a (dependent) function or prove ∀ r : ℚ, p r
by dealing with rational
numbers of the form n /. d
with d ≠ 0
.
Equations
Instances For
def
Rat.numDenCasesOn''
{C : ℚ → Sort u}
(a : ℚ)
(H :
(n : ℤ) →
(d : ℕ) → (nz : d ≠ 0) → (red : n.natAbs.Coprime d) → C { num := n, den := d, den_nz := nz, reduced := red })
:
C a
Define a (dependent) function or prove ∀ r : ℚ, p r
by dealing with rational
numbers of the form mk' n d
with d ≠ 0
.
Equations
Instances For
theorem
Rat.lift_binop_eq
(f : ℚ → ℚ → ℚ)
(f₁ f₂ : ℤ → ℤ → ℤ → ℤ → ℤ)
(fv :
∀ {n₁ : ℤ} {d₁ : ℕ} {h₁ : d₁ ≠ 0} {c₁ : n₁.natAbs.Coprime d₁} {n₂ : ℤ} {d₂ : ℕ} {h₂ : d₂ ≠ 0}
{c₂ : n₂.natAbs.Coprime d₂},
f { num := n₁, den := d₁, den_nz := h₁, reduced := c₁ } { num := n₂, den := d₂, den_nz := h₂, reduced := c₂ } = Rat.divInt (f₁ n₁ (↑d₁) n₂ ↑d₂) (f₂ n₁ (↑d₁) n₂ ↑d₂))
(f0 : ∀ {n₁ d₁ n₂ d₂ : ℤ}, d₁ ≠ 0 → d₂ ≠ 0 → f₂ n₁ d₁ n₂ d₂ ≠ 0)
(a b c d : ℤ)
(b0 : b ≠ 0)
(d0 : d ≠ 0)
(H : ∀ {n₁ d₁ n₂ d₂ : ℤ}, a * d₁ = n₁ * b → c * d₂ = n₂ * d → f₁ n₁ d₁ n₂ d₂ * f₂ a b c d = f₁ a b c d * f₂ n₁ d₁ n₂ d₂)
:
f (Rat.divInt a b) (Rat.divInt c d) = Rat.divInt (f₁ a b c d) (f₂ a b c d)
@[simp]
theorem
Rat.divInt_mul_divInt'
(n₁ d₁ n₂ d₂ : ℤ)
:
Rat.divInt n₁ d₁ * Rat.divInt n₂ d₂ = Rat.divInt (n₁ * n₂) (d₁ * d₂)
theorem
Rat.mk'_mul_mk'
(n₁ n₂ : ℤ)
(d₁ d₂ : ℕ)
(hd₁ : d₁ ≠ 0)
(hd₂ : d₂ ≠ 0)
(hnd₁ : n₁.natAbs.Coprime d₁)
(hnd₂ : n₂.natAbs.Coprime d₂)
(h₁₂ : n₁.natAbs.Coprime d₂)
(h₂₁ : n₂.natAbs.Coprime d₁)
:
theorem
Rat.divInt_eq_divInt
{d₁ d₂ n₁ n₂ : ℤ}
(z₁ : d₁ ≠ 0)
(z₂ : d₂ ≠ 0)
:
Rat.divInt n₁ d₁ = Rat.divInt n₂ d₂ ↔ n₁ * d₂ = n₂ * d₁
Alias of Rat.divInt_eq_iff
.
@[simp]
theorem
Rat.divInt_div_divInt
(n₁ d₁ n₂ d₂ : ℤ)
:
Rat.divInt n₁ d₁ / Rat.divInt n₂ d₂ = Rat.divInt (n₁ * d₂) (d₁ * n₂)
The rational numbers are a group #
Equations
Equations
theorem
Rat.mk_num_ne_zero_of_ne_zero
{q : ℚ}
{n d : ℤ}
(hq : q ≠ 0)
(hqnd : q = Rat.divInt n d)
:
n ≠ 0
theorem
Rat.mk_denom_ne_zero_of_ne_zero
{q : ℚ}
{n d : ℤ}
(hq : q ≠ 0)
(hqnd : q = Rat.divInt n d)
:
d ≠ 0
theorem
Rat.divInt_mul_divInt_cancel
{x : ℤ}
(hx : x ≠ 0)
(n d : ℤ)
:
Rat.divInt n x * Rat.divInt x d = Rat.divInt n d