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.normalize_eq_mk'
(n : ℤ)
(d : ℕ)
(h : d ≠ 0)
(c : Nat.gcd (Int.natAbs n) d = 1)
:
Rat.normalize n d = Rat.mk' n d
theorem
Rat.num_den'
{n : ℤ}
{d : ℕ}
{h : d ≠ 0}
{c : Nat.Coprime (Int.natAbs n) d}
:
Rat.mk' n d = Rat.divInt n ↑d
def
Rat.numDenCasesOn
{C : ℚ → Sort u}
(a : ℚ)
:
((n : ℤ) → (d : ℕ) → 0 < d → Nat.Coprime (Int.natAbs n) 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
- Rat.numDenCasesOn x✝ x = match x✝, x with | Rat.mk' n d, H => Eq.mpr (_ : C (Rat.mk' n d) = C (Rat.divInt n ↑d)) (H n d (_ : 0 < 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
- Rat.numDenCasesOn' a H = Rat.numDenCasesOn a fun (n : ℤ) (d : ℕ) (h : 0 < d) (x : Nat.Coprime (Int.natAbs n) d) => H n d (_ : d ≠ 0)
Instances For
theorem
Rat.lift_binop_eq
(f : ℚ → ℚ → ℚ)
(f₁ : ℤ → ℤ → ℤ → ℤ → ℤ)
(f₂ : ℤ → ℤ → ℤ → ℤ → ℤ)
(fv : ∀ {n₁ : ℤ} {d₁ : ℕ} {h₁ : d₁ ≠ 0} {c₁ : Nat.Coprime (Int.natAbs n₁) d₁} {n₂ : ℤ} {d₂ : ℕ} {h₂ : d₂ ≠ 0}
{c₂ : Nat.Coprime (Int.natAbs n₂) d₂},
f (Rat.mk' n₁ d₁) (Rat.mk' n₂ d₂) = 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.add_def''
{a : ℤ}
{b : ℤ}
{c : ℤ}
{d : ℤ}
(b0 : b ≠ 0)
(d0 : d ≠ 0)
:
Rat.divInt a b + Rat.divInt c d = Rat.divInt (a * d + c * b) (b * d)
@[simp]
theorem
Rat.sub_def''
{a : ℤ}
{b : ℤ}
{c : ℤ}
{d : ℤ}
(b0 : b ≠ 0)
(d0 : d ≠ 0)
:
Rat.divInt a b - Rat.divInt c d = Rat.divInt (a * d - c * b) (b * d)
@[simp]
theorem
Rat.mul_def'
{a : ℤ}
{b : ℤ}
{c : ℤ}
{d : ℤ}
(b0 : b ≠ 0)
(d0 : d ≠ 0)
:
Rat.divInt a b * Rat.divInt c d = Rat.divInt (a * c) (b * d)
At this point in the import hierarchy we have not defined the Field
typeclass.
Instead we'll instantiate CommRing
and CommGroupWithZero
at this point.
The Rat.field
instance and any field-specific lemmas can be found in Mathlib.Data.Rat.Basic
.
Equations
- Rat.addLeftCancelSemigroup = inferInstance
Equations
- Rat.addRightCancelSemigroup = inferInstance
Equations
- Rat.addCommSemigroup = inferInstance
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.add_divInt
(a : ℤ)
(b : ℤ)
(c : ℤ)
:
Rat.divInt (a + b) c = Rat.divInt a c + Rat.divInt b c
theorem
Rat.divInt_mul_divInt_cancel
{x : ℤ}
(hx : x ≠ 0)
(n : ℤ)
(d : ℤ)
:
Rat.divInt n x * Rat.divInt x d = Rat.divInt n d
theorem
Rat.divInt_div_divInt_cancel_left
{x : ℤ}
(hx : x ≠ 0)
(n : ℤ)
(d : ℤ)
:
Rat.divInt n x / Rat.divInt d x = Rat.divInt n d
theorem
Rat.divInt_div_divInt_cancel_right
{x : ℤ}
(hx : x ≠ 0)
(n : ℤ)
(d : ℤ)
:
Rat.divInt x n / Rat.divInt x d = Rat.divInt d n