Cast of naturals #
This file defines the canonical homomorphism from the natural numbers into a type α
with 0
,
1
and +
(typically an add_monoid
with one).
Main declarations #
cast
: Canonical homomorphismℕ → α
whereα
has a0
,1
and+
.bin_cast
: Binary representation version ofcast
.cast_add_monoid_hom
:cast
bundled as anadd_monoid_hom
.cast_ring_hom
:cast
bundled as aring_hom
.
Implementation note #
Setting up the coercions priorities is tricky. See Note [coercion into rings].
@[simp, norm_cast]
@[simp]
coe : ℕ → α
as an add_monoid_hom
.
Equations
- nat.cast_add_monoid_hom α = {to_fun := coe coe_to_lift, map_zero' := _, map_add' := _}
@[simp]
@[simp, norm_cast]
@[simp, norm_cast]
@[simp, norm_cast]
Equations
- nat.cast_ring_hom α = {to_fun := coe coe_to_lift, map_one' := _, map_mul' := _, map_zero' := _, map_add' := _}
@[simp]
@[simp, norm_cast]
@[simp, norm_cast]
@[simp]
@[simp, norm_cast]
@[simp, norm_cast]
@[simp, norm_cast]
@[simp, norm_cast]
@[simp, norm_cast]
@[simp, norm_cast]
@[simp, norm_cast]
Natural division is always less than division in the field.
theorem
ext_nat'
{A : Type u_1}
{F : Type u_3}
[add_zero_class A]
[add_monoid_hom_class F ℕ A]
(f g : F)
(h : ⇑f 1 = ⇑g 1) :
f = g
@[ext]
theorem
add_monoid_hom.ext_nat
{A : Type u_1}
[add_zero_class A]
{f g : ℕ →+ A}
(h : ⇑f 1 = ⇑g 1) :
f = g
theorem
eq_nat_cast'
{A : Type u_1}
{F : Type u_3}
[add_zero_class A]
[has_one A]
[add_monoid_hom_class F ℕ A]
(f : F)
(h1 : ⇑f 1 = 1)
(n : ℕ) :
theorem
map_nat_cast'
{B : Type u_2}
{F : Type u_3}
[add_monoid B]
[has_one B]
{A : Type u_1}
[add_monoid A]
[has_one A]
[add_monoid_hom_class F A B]
(f : F)
(h : ⇑f 1 = 1)
(n : ℕ) :
theorem
ext_nat''
{A : Type u_1}
{F : Type u_2}
[mul_zero_one_class A]
[monoid_with_zero_hom_class F ℕ A]
(f g : F)
(h_pos : ∀ {n : ℕ}, 0 < n → ⇑f n = ⇑g n) :
f = g
If two monoid_with_zero_hom
s agree on the positive naturals they are equal.
@[simp]
theorem
eq_nat_cast
{R : Type u_1}
{F : Type u_3}
[non_assoc_semiring R]
[ring_hom_class F ℕ R]
(f : F)
(n : ℕ) :
@[simp]
theorem
map_nat_cast
{R : Type u_1}
{S : Type u_2}
{F : Type u_3}
[non_assoc_semiring R]
[non_assoc_semiring S]
[ring_hom_class F R S]
(f : F)
(n : ℕ) :
theorem
ext_nat
{R : Type u_1}
{F : Type u_3}
[non_assoc_semiring R]
[ring_hom_class F ℕ R]
(f g : F) :
f = g
theorem
ring_hom.eq_nat_cast'
{R : Type u_1}
[non_assoc_semiring R]
(f : ℕ →+* R) :
f = nat.cast_ring_hom R
This is primed to match ring_hom.eq_int_cast'
.
@[protected, instance]
Equations
- nat.unique_ring_hom = {to_inhabited := {default := nat.cast_ring_hom R _inst_1}, uniq := _}
@[simp, norm_cast]
theorem
mul_opposite.op_nat_cast
{α : Type u_1}
[has_zero α]
[has_one α]
[has_add α]
(n : ℕ) :
mul_opposite.op ↑n = ↑n
@[simp, norm_cast]
theorem
mul_opposite.unop_nat_cast
{α : Type u_1}
[has_zero α]
[has_one α]
[has_add α]
(n : ℕ) :
mul_opposite.unop ↑n = ↑n