Cast of integers #
This file defines the canonical homomorphism from the integers into a type α
with 0
,
1
, +
and -
(typically a ring
).
Main declarations #
cast
: Canonical homomorphismℤ → α
whereα
has a0
,1
,+
and-
.cast_add_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].
Coercion ℕ → ℤ
as a ring_hom
.
Equations
- int.of_nat_hom = {to_fun := coe coe_to_lift, map_one' := int.of_nat_hom._proof_1, map_mul' := int.of_nat_mul, map_zero' := int.of_nat_hom._proof_2, map_add' := int.of_nat_add}
@[simp, norm_cast]
@[simp, norm_cast]
theorem
int.cast_neg_of_nat
{α : Type u_1}
[add_group α]
[has_one α]
(n : ℕ) :
↑(int.neg_of_nat n) = -↑n
coe : ℤ → α
as an add_monoid_hom
.
Equations
- int.cast_add_hom α = {to_fun := coe coe_to_lift, map_zero' := _, map_add' := _}
@[simp]
@[simp]
@[simp, norm_cast]
@[simp, norm_cast]
@[simp]
@[simp]
@[simp]
@[simp, norm_cast]
@[simp, norm_cast]
@[ext]
theorem
add_monoid_hom.ext_int
{A : Type u_1}
[add_monoid A]
{f g : ℤ →+ A}
(h1 : ⇑f 1 = ⇑g 1) :
f = g
Two additive monoid homomorphisms f
, g
from ℤ
to an additive monoid are equal
if f 1 = g 1
.
theorem
add_monoid_hom.eq_int_cast_hom
{A : Type u_1}
[add_group A]
[has_one A]
(f : ℤ →+ A)
(h1 : ⇑f 1 = 1) :
f = int.cast_add_hom A
@[ext]
theorem
monoid_hom.ext_mint
{M : Type u_1}
[monoid M]
{f g : multiplicative ℤ →* M}
(h1 : ⇑f (⇑multiplicative.of_add 1) = ⇑g (⇑multiplicative.of_add 1)) :
f = g
@[ext]
theorem
monoid_hom.ext_int
{M : Type u_1}
[monoid M]
{f g : ℤ →* M}
(h_neg_one : ⇑f (-1) = ⇑g (-1))
(h_nat : f.comp int.of_nat_hom.to_monoid_hom = g.comp int.of_nat_hom.to_monoid_hom) :
f = g
If two monoid_hom
s agree on -1
and the naturals then they are equal.
@[ext]
theorem
monoid_with_zero_hom.ext_int
{M : Type u_1}
[monoid_with_zero M]
{f g : ℤ →*₀ M}
(h_neg_one : ⇑f (-1) = ⇑g (-1))
(h_nat : f.comp int.of_nat_hom.to_monoid_with_zero_hom = g.comp int.of_nat_hom.to_monoid_with_zero_hom) :
f = g
If two monoid_with_zero_hom
s agree on -1
and the naturals then they are equal.
@[protected, instance]