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.Nat.Cast.Basic

26 declarations. Mathlib docs · Source

Cast of natural numbers (additional theorems)

This file proves additional properties about the canonical homomorphism from the natural numbers into an additive monoid with a one (Nat.cast).

Main declarations

  • castAddMonoidHom: cast bundled as an AddMonoidHom.
  • castRingHom: cast bundled as a RingHom.

def Nat.castAddMonoidHom E3 #

(α : Type u_3) → [inst : AddMonoidWithOne α] → ℕ →+ α

Nat.cast : ℕ → α as an AddMonoidHom.

theorem Nat.coe_castAddMonoidHom E0 #

∀ {α : Type u_1} [inst : AddMonoidWithOne α], ⇑(Nat.castAddMonoidHom α) = Nat.cast

theorem Even.natCast E1 #

∀ {α : Type u_1} [inst : AddMonoidWithOne α] {n : ℕ}, Even n → Even ↑n

theorem Nat.cast_mul E0 #

∀ {α : Type u_1} [inst : NonAssocSemiring α] (m n : ℕ), ↑(m * n) = ↑m * ↑n

def Nat.castRingHom E1 #

(α : Type u_1) → [inst : NonAssocSemiring α] → ℕ →+* α

Nat.cast : ℕ → α as a RingHom

theorem Nat.coe_castRingHom E0 #

∀ {α : Type u_1} [inst : NonAssocSemiring α], ⇑(Nat.castRingHom α) = Nat.cast

theorem nsmul_eq_mul' E1 #

∀ {α : Type u_1} [inst : NonAssocSemiring α] (a : α) (n : ℕ), n • a = a * ↑n

theorem Nat.ofNat_nsmul_eq_mul E1 #

∀ {α : Type u_1} [inst : NonAssocSemiring α] (n : ℕ) [inst_1 : n.AtLeastTwo] (a : α),
  OfNat.ofNat n • a = OfNat.ofNat n * a

theorem Nat.cast_pow E0 #

∀ {α : Type u_1} [inst : Semiring α] (m n : ℕ), ↑(m ^ n) = ↑m ^ n

theorem Nat.cast_dvd_cast E1 #

∀ {α : Type u_1} [inst : Semiring α] {m n : ℕ}, m ∣ n → ↑m ∣ ↑n

theorem Dvd.dvd.natCast E1 #

∀ {α : Type u_1} [inst : Semiring α] {m n : ℕ}, m ∣ n → ↑m ∣ ↑n

Alias of Nat.cast_dvd_cast.

theorem map_natCast' E0 #

∀ {B : Type u_4} {F : Type u_5} [inst : AddMonoidWithOne B] {A : Type u_6} [inst_1 : AddMonoidWithOne A]
  [inst_2 : FunLike F A B] [AddMonoidHomClass F A B] (f : F), f 1 = 1 → ∀ (n : ℕ), f ↑n = ↑n

theorem map_ofNat' E0 #

∀ {B : Type u_4} {F : Type u_5} [inst : AddMonoidWithOne B] {A : Type u_6} [inst_1 : AddMonoidWithOne A]
  [inst_2 : FunLike F A B] [AddMonoidHomClass F A B] (f : F),
  f 1 = 1 → ∀ (n : ℕ) [inst_4 : n.AtLeastTwo], f (OfNat.ofNat n) = OfNat.ofNat n

theorem ext_nat'' E1 #

∀ {A : Type u_3} {F : Type u_4} [inst : MulZeroOneClass A] [inst_1 : FunLike F ℕ A] [ZeroHomClass F ℕ A] (f g : F),
  (∀ {n : ℕ}, 0 < n → f n = g n) → f = g

If two MonoidWithZeroHoms agree on the positive naturals they are equal.

theorem MonoidWithZeroHom.ext_nat E1 #

∀ {A : Type u_3} [inst : MulZeroOneClass A] {f g : ℕ →*₀ A}, (∀ {n : ℕ}, 0 < n → f n = g n) → f = g

theorem MonoidWithZeroHom.ext_nat_iff E0 #

∀ {A : Type u_3} [inst : MulZeroOneClass A] {f g : ℕ →*₀ A}, f = g ↔ ∀ {n : ℕ}, 0 < n → f n = g n

theorem map_natCast E0 #

∀ {R : Type u_3} {S : Type u_4} {F : Type u_5} [inst : NonAssocSemiring R] [inst_1 : NonAssocSemiring S]
  [inst_2 : FunLike F R S] [RingHomClass F R S] (f : F) (n : ℕ), f ↑n = ↑n

theorem map_ofNat E0 #

∀ {R : Type u_3} {S : Type u_4} {F : Type u_5} [inst : NonAssocSemiring R] [inst_1 : NonAssocSemiring S]
  [inst_2 : FunLike F R S] [RingHomClass F R S] (f : F) (n : ℕ) [inst_4 : n.AtLeastTwo],
  f (OfNat.ofNat n) = OfNat.ofNat n

This lemma is not marked @[simp] lemma because its #discr_tree_key (for the LHS) would just be DFunLike.coe _ _, due to the ofNat that https://github.com/leanprover/lean4/issues/2867 forces us to include, and therefore it would negatively impact performance.

If that issue is resolved, this can be marked @[simp].

theorem ext_nat E1 #

∀ {R : Type u_3} {F : Type u_5} [inst : NonAssocSemiring R] [inst_1 : FunLike F ℕ R] [RingHomClass F ℕ R] (f g : F),
  f = g

theorem NeZero.nat_of_neZero E1 #

∀ {R : Type u_6} {S : Type u_7} [inst : NonAssocSemiring R] [inst_1 : NonAssocSemiring S] {F : Type u_8}
  [inst_2 : FunLike F R S] [RingHomClass F R S] (f : F) {n : ℕ} [hn : NeZero ↑n], NeZero ↑n

theorem Nat.cast_id E0 #

∀ (n : ℕ), ↑n = n

theorem Nat.castRingHom_nat E0 #

Nat.castRingHom ℕ = RingHom.id ℕ

instance Nat.uniqueRingHom E0 #

{R : Type u_3} → [inst : NonAssocSemiring R] → Unique (ℕ →+* R)

We don't use RingHomClass here, since that might cause type-class slowdown for Subsingleton.

instance Pi.instOfNat E0 #

{α : Type u_1} → {π : α → Type u_3} → (n : ℕ) → [(i : α) → OfNat (π i) n] → OfNat ((i : α) → π i) n

theorem Pi.ofNat_apply E0 #

∀ {α : Type u_1} {π : α → Type u_3} (n : ℕ) [inst : (i : α) → OfNat (π i) n] (a : α), (OfNat.ofNat n) a = OfNat.ofNat n

theorem Pi.ofNat_def E0 #

∀ {α : Type u_1} {π : α → Type u_3} (n : ℕ) [inst : (i : α) → OfNat (π i) n], OfNat.ofNat n = fun x ↦ OfNat.ofNat n