Cast of integers #
This file defines the canonical homomorphism from the integers into an
additive group with a one (typically a Ring
). In additive groups with a one
element, there exists a unique such homomorphism and we store it in the
intCast : ℤ → R
field.
Preferentially, the homomorphism is written as a coercion.
Main declarations #
Int.cast
: Canonical homomorphismℤ → R
.AddGroupWithOne
: Type class forInt.cast
.
Default value for IntCast.intCast
in an AddGroupWithOne
.
Equations
- Int.castDef x = match x with | Int.ofNat n => ↑n | Int.negSucc n => -↑(n + 1)
Instances For
Additive groups with one #
An AddGroupWithOne
is an AddGroup
with a 1. It also contains data for the unique
homomorphisms ℕ → R
and ℤ → R
.
- intCast : ℤ → R
- natCast : ℕ → R
- add : R → R → R
- zero : R
- nsmul : ℕ → R → R
- nsmul_zero : ∀ (x : R), AddMonoid.nsmul 0 x = 0
- nsmul_succ : ∀ (n : ℕ) (x : R), AddMonoid.nsmul (n + 1) x = AddMonoid.nsmul n x + x
- one : R
- natCast_zero : NatCast.natCast 0 = 0
- natCast_succ : ∀ (n : ℕ), NatCast.natCast (n + 1) = NatCast.natCast n + 1
- neg : R → R
- sub : R → R → R
- zsmul : ℤ → R → R
Multiplication by an integer. Set this to
zsmulRec
unlessModule
diamonds are possible. - zsmul_zero' : ∀ (a : R), AddGroupWithOne.zsmul 0 a = 0
- zsmul_succ' : ∀ (n : ℕ) (a : R), AddGroupWithOne.zsmul (Int.ofNat (Nat.succ n)) a = AddGroupWithOne.zsmul (Int.ofNat n) a + a
- zsmul_neg' : ∀ (n : ℕ) (a : R), AddGroupWithOne.zsmul (Int.negSucc n) a = -AddGroupWithOne.zsmul (↑(Nat.succ n)) a
- intCast_ofNat : ∀ (n : ℕ), IntCast.intCast ↑n = ↑n
The canonical homomorphism
ℤ → R
agrees with the one fromℕ → R
onℕ
. - intCast_negSucc : ∀ (n : ℕ), IntCast.intCast (Int.negSucc n) = -↑(n + 1)
The canonical homomorphism
ℤ → R
for negative values is just the negation of the values of the canonical homomorphismℕ → R
.
Instances
An AddCommGroupWithOne
is an AddGroupWithOne
satisfying a + b = b + a
.
- add : R → R → R
- zero : R
- nsmul : ℕ → R → R
- nsmul_zero : ∀ (x : R), AddMonoid.nsmul 0 x = 0
- nsmul_succ : ∀ (n : ℕ) (x : R), AddMonoid.nsmul (n + 1) x = AddMonoid.nsmul n x + x
- neg : R → R
- sub : R → R → R
- zsmul : ℤ → R → R
- zsmul_zero' : ∀ (a : R), SubNegMonoid.zsmul 0 a = 0
- zsmul_succ' : ∀ (n : ℕ) (a : R), SubNegMonoid.zsmul (Int.ofNat (Nat.succ n)) a = SubNegMonoid.zsmul (Int.ofNat n) a + a
- zsmul_neg' : ∀ (n : ℕ) (a : R), SubNegMonoid.zsmul (Int.negSucc n) a = -SubNegMonoid.zsmul (↑(Nat.succ n)) a
- intCast : ℤ → R
- natCast : ℕ → R
- one : R
- natCast_zero : NatCast.natCast 0 = 0
The canonical map
ℕ → R
sends0 : ℕ
to0 : R
. - natCast_succ : ∀ (n : ℕ), NatCast.natCast (n + 1) = NatCast.natCast n + 1
The canonical map
ℕ → R
is a homomorphism. - intCast_ofNat : ∀ (n : ℕ), IntCast.intCast ↑n = ↑n
The canonical homomorphism
ℤ → R
agrees with the one fromℕ → R
onℕ
. - intCast_negSucc : ∀ (n : ℕ), IntCast.intCast (Int.negSucc n) = -↑(n + 1)
The canonical homomorphism
ℤ → R
for negative values is just the negation of the values of the canonical homomorphismℕ → R
.