The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V02. Numbers

Mathlib.Data.Rat.Cast.Defs

44 declarations. Mathlib docs · Source

Casts for Rational Numbers

Summary

We define the canonical injection from ℚ into an arbitrary division ring and prove various casting lemmas showing the well-behavedness of this injection.

Tags

rat, rationals, field, ℚ, numerator, denominator, num, denom, cast, coercion, casting

theorem Mathlib.Tactic.TermCongr.cHole.congr_simp E1 #

∀ {α : Sort u} (val val_1 : α), val = val_1 → ∀ {p p_1 : Prop} (e_p : p = p_1) (_pf : p), val = val_1

theorem ZeroHom.mk.congr_simp E1 #

∀ {M : Type u_10} {N : Type u_11} [inst : Zero M] [inst_1 : Zero N] (toFun toFun_1 : M → N) (e_toFun : toFun = toFun_1)
  (map_zero' : toFun 0 = 0), { toFun := toFun, map_zero' := map_zero' } = { toFun := toFun_1, map_zero' := ⋯ }

theorem MonoidWithZeroHom.ofClass.congr_simp E1 #

∀ {F : Type u_1} {α : Type u_2} {β : Type u_3} [inst : MulZeroOneClass α] [inst_1 : MulZeroOneClass β]
  [inst_2 : FunLike F α β] [inst_3 : MonoidWithZeroHomClass F α β] (f f_1 : F),
  f = f_1 → MonoidWithZeroHom.ofClass f = MonoidWithZeroHom.ofClass f_1

theorem NNRat.cast_natCast E0 #

∀ {α : Type u_2} [inst : DivisionSemiring α] (n : ℕ), ↑↑n = ↑n

theorem NNRat.cast_ofNat E0 #

∀ {α : Type u_2} [inst : DivisionSemiring α] (n : ℕ) [inst_1 : n.AtLeastTwo], ↑(OfNat.ofNat n) = OfNat.ofNat n

theorem NNRat.cast_zero E0 #

∀ {α : Type u_2} [inst : DivisionSemiring α], ↑0 = 0

theorem NNRat.cast_one E0 #

∀ {α : Type u_2} [inst : DivisionSemiring α], ↑1 = 1

theorem NNRat.cast_commute E1 #

∀ {α : Type u_2} [inst : DivisionSemiring α] (q : ℚ≥0) (a : α), Commute (↑q) a

theorem NNRat.commute_cast E1 #

∀ {α : Type u_2} [inst : DivisionSemiring α] (a : α) (q : ℚ≥0), Commute a ↑q

theorem NNRat.cast_comm E1 #

∀ {α : Type u_2} [inst : DivisionSemiring α] (q : ℚ≥0) (a : α), ↑q * a = a * ↑q

theorem NNRat.cast_divNat_of_ne_zero E1 #

∀ {α : Type u_2} [inst : DivisionSemiring α] (a : ℕ) {b : ℕ}, ↑b ≠ 0 → ↑(NNRat.divNat a b) = ↑a / ↑b

theorem NNRat.cast_add_of_ne_zero E1 #

∀ {α : Type u_2} [inst : DivisionSemiring α] {q r : ℚ≥0}, ↑q.den ≠ 0 → ↑r.den ≠ 0 → ↑(q + r) = ↑q + ↑r

theorem NNRat.cast_mul_of_ne_zero E1 #

∀ {α : Type u_2} [inst : DivisionSemiring α] {q r : ℚ≥0}, ↑q.den ≠ 0 → ↑r.den ≠ 0 → ↑(q * r) = ↑q * ↑r

theorem NNRat.cast_inv_of_ne_zero E1 #

∀ {α : Type u_2} [inst : DivisionSemiring α] {q : ℚ≥0}, ↑q.num ≠ 0 → ↑q⁻¹ = (↑q)⁻¹

theorem NNRat.cast_div_of_ne_zero E1 #

∀ {α : Type u_2} [inst : DivisionSemiring α] {q r : ℚ≥0}, ↑q.den ≠ 0 → ↑r.num ≠ 0 → ↑(q / r) = ↑q / ↑r

theorem Rat.cast_intCast E0 #

∀ {α : Type u_2} [inst : DivisionRing α] (n : ℤ), ↑↑n = ↑n

theorem Rat.cast_natCast E0 #

∀ {α : Type u_2} [inst : DivisionRing α] (n : ℕ), ↑↑n = ↑n

theorem Rat.cast_ofNat E0 #

∀ {α : Type u_2} [inst : DivisionRing α] (n : ℕ) [inst_1 : n.AtLeastTwo], ↑(OfNat.ofNat n) = OfNat.ofNat n

theorem Rat.cast_zero E0 #

∀ {α : Type u_2} [inst : DivisionRing α], ↑0 = 0

theorem Rat.cast_one E0 #

∀ {α : Type u_2} [inst : DivisionRing α], ↑1 = 1

theorem Rat.cast_commute E1 #

∀ {α : Type u_2} [inst : DivisionRing α] (r : ℚ) (a : α), Commute (↑r) a

theorem Rat.cast_comm E1 #

∀ {α : Type u_2} [inst : DivisionRing α] (r : ℚ) (a : α), ↑r * a = a * ↑r

theorem Rat.commute_cast E1 #

∀ {α : Type u_2} [inst : DivisionRing α] (a : α) (r : ℚ), Commute a ↑r

theorem Rat.cast_divInt_of_ne_zero E1 #

∀ {α : Type u_2} [inst : DivisionRing α] (a : ℤ) {b : ℤ}, ↑b ≠ 0 → ↑(Rat.divInt a b) = ↑a / ↑b

theorem Rat.cast_mkRat_of_ne_zero E1 #

∀ {α : Type u_2} [inst : DivisionRing α] (a : ℤ) {b : ℕ}, ↑b ≠ 0 → ↑(mkRat a b) = ↑a / ↑b

theorem Rat.cast_add_of_ne_zero E1 #

∀ {α : Type u_2} [inst : DivisionRing α] {q r : ℚ}, ↑q.den ≠ 0 → ↑r.den ≠ 0 → ↑(q + r) = ↑q + ↑r

theorem Rat.cast_neg E0 #

∀ {α : Type u_2} [inst : DivisionRing α] (q : ℚ), ↑(-q) = -↑q

theorem Rat.cast_sub_of_ne_zero E1 #

∀ {α : Type u_2} [inst : DivisionRing α] {p q : ℚ}, ↑p.den ≠ 0 → ↑q.den ≠ 0 → ↑(p - q) = ↑p - ↑q

theorem Rat.cast_mul_of_ne_zero E1 #

∀ {α : Type u_2} [inst : DivisionRing α] {p q : ℚ}, ↑p.den ≠ 0 → ↑q.den ≠ 0 → ↑(p * q) = ↑p * ↑q

theorem Rat.cast_inv_of_ne_zero E1 #

∀ {α : Type u_2} [inst : DivisionRing α] {q : ℚ}, ↑q.num ≠ 0 → ↑q⁻¹ = (↑q)⁻¹

theorem Rat.cast_div_of_ne_zero E1 #

∀ {α : Type u_2} [inst : DivisionRing α] {p q : ℚ}, ↑p.den ≠ 0 → ↑q.num ≠ 0 → ↑(p / q) = ↑p / ↑q

theorem map_nnratCast E0 #

∀ {F : Type u_1} {α : Type u_2} {β : Type u_3} [inst : FunLike F α β] [inst_1 : DivisionSemiring α]
  [inst_2 : DivisionSemiring β] [RingHomClass F α β] (f : F) (q : ℚ≥0), f ↑q = ↑q

theorem map_ratCast E0 #

∀ {F : Type u_1} {α : Type u_2} {β : Type u_3} [inst : FunLike F α β] [inst_1 : DivisionRing α]
  [inst_2 : DivisionRing β] [RingHomClass F α β] (f : F) (q : ℚ), f ↑q = ↑q

theorem MonoidWithZeroHomClass.ext_nnrat' E1 #

∀ {F : Type u_1} {M₀ : Type u_4} [inst : MonoidWithZero M₀] [inst_1 : FunLike F ℚ≥0 M₀]
  [MonoidWithZeroHomClass F ℚ≥0 M₀] {f g : F}, (∀ (n : ℕ), f ↑n = g ↑n) → f = g

If monoid with zero homs f and g from ℚ≥0 agree on the naturals then they are equal.

theorem MonoidWithZeroHomClass.ext_nnrat E1 #

∀ {M₀ : Type u_4} [inst : MonoidWithZero M₀] {f g : ℚ≥0 →*₀ M₀},
  f.comp ↑(Nat.castRingHom ℚ≥0) = g.comp ↑(Nat.castRingHom ℚ≥0) → f = g

If monoid with zero homs f and g from ℚ≥0 agree on the naturals then they are equal.

See note [partially-applied ext lemmas] for why comp is used here.

theorem MonoidWithZeroHomClass.ext_nnrat_iff E0 #

∀ {M₀ : Type u_4} [inst : MonoidWithZero M₀] {f g : ℚ≥0 →*₀ M₀},
  f = g ↔ f.comp ↑(Nat.castRingHom ℚ≥0) = g.comp ↑(Nat.castRingHom ℚ≥0)

theorem MonoidWithZeroHomClass.ext_nnrat_on_pnat E1 #

∀ {F : Type u_1} {M₀ : Type u_4} [inst : MonoidWithZero M₀] [inst_1 : FunLike F ℚ≥0 M₀]
  [MonoidWithZeroHomClass F ℚ≥0 M₀] {f g : F}, (∀ (n : ℕ), 0 < n → f ↑n = g ↑n) → f = g

If monoid with zero homs f and g from ℚ≥0 agree on the positive naturals then they are equal.

theorem MonoidWithZeroHomClass.ext_rat' E1 #

∀ {F : Type u_1} {M₀ : Type u_4} [inst : MonoidWithZero M₀] [inst_1 : FunLike F ℚ M₀] [MonoidWithZeroHomClass F ℚ M₀]
  {f g : F}, (∀ (m : ℤ), f ↑m = g ↑m) → f = g

If monoid with zero homs f and g from ℚ agree on the integers then they are equal.

theorem MonoidWithZeroHomClass.ext_rat E1 #

∀ {M₀ : Type u_4} [inst : MonoidWithZero M₀] {f g : ℚ →*₀ M₀},
  f.comp ↑(Int.castRingHom ℚ) = g.comp ↑(Int.castRingHom ℚ) → f = g

If monoid with zero homs f and g from ℚ agree on the integers then they are equal.

See note [partially-applied ext lemmas] for why comp is used here.

theorem MonoidWithZeroHomClass.ext_rat_iff E0 #

∀ {M₀ : Type u_4} [inst : MonoidWithZero M₀] {f g : ℚ →*₀ M₀},
  f = g ↔ f.comp ↑(Int.castRingHom ℚ) = g.comp ↑(Int.castRingHom ℚ)

theorem MonoidWithZeroHomClass.ext_rat_on_pnat E1 #

∀ {F : Type u_1} {M₀ : Type u_4} [inst : MonoidWithZero M₀] [inst_1 : FunLike F ℚ M₀] [MonoidWithZeroHomClass F ℚ M₀]
  {f g : F}, f (-1) = g (-1) → (∀ (n : ℕ), 0 < n → f ↑n = g ↑n) → f = g

If monoid with zero homs f and g from ℚ agree on the positive naturals and -1 then they are equal.

theorem RingHom.ext_rat E1 #

∀ {F : Type u_1} {R : Type u_4} [inst : Semiring R] [inst_1 : FunLike F ℚ R] [RingHomClass F ℚ R] (f g : F), f = g

Any two ring homomorphisms from ℚ to a semiring are equal. If the codomain is a division ring, then this lemma follows from eq_ratCast.

instance NNRat.subsingleton_ringHom E0 #

∀ {R : Type u_4} [inst : Semiring R], Subsingleton (ℚ≥0 →+* R)

instance Rat.subsingleton_ringHom E0 #

∀ {R : Type u_4} [inst : Semiring R], Subsingleton (ℚ →+* R)