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.Int.Cast.Defs

30 declarations. Mathlib docs · Source

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 for Int.cast.

Additive groups with one

def AddGroupWithOne.ctorIdx E1 #

{R : Type u} → AddGroupWithOne R → ℕ

def AddCommGroupWithOne.ctorIdx E1 #

{R : Type u} → AddCommGroupWithOne R → ℕ

def Int.castDef E1 #

{R : Type u} → [NatCast R] → [Neg R] → ℤ → R

Default value for IntCast.intCast in an AddGroupWithOne.

class AddGroupWithOne E3 #

Type u → Type u

An AddGroupWithOne is an AddGroup with a 1. It also contains data for the unique homomorphisms ℕ → R and ℤ → R.

instance AddGroupWithOne.toAddGroup E0 #

{R : Type u} → [self : AddGroupWithOne R] → AddGroup R

instance AddGroupWithOne.toAddMonoidWithOne E0 #

{R : Type u} → [self : AddGroupWithOne R] → AddMonoidWithOne R

theorem AddGroupWithOne.sub_eq_add_neg E2 #

∀ {R : Type u} [self : AddGroupWithOne R] (a b : R), a - b = a + -b

abbrev AddGroupWithOne.toNeg E1 #

{R : Type u} → [self : AddGroupWithOne R] → Neg R

theorem AddGroupWithOne.zsmul_succ' E2 #

∀ {R : Type u} [self : AddGroupWithOne R] (n : ℕ) (a : R), ↑n.succ • a = ↑n • a + a

theorem AddGroupWithOne.zsmul_neg' E2 #

∀ {R : Type u} [self : AddGroupWithOne R] (n : ℕ) (a : R), Int.negSucc n • a = -(↑n.succ • a)

instance AddGroupWithOne.toIntCast E0 #

{R : Type u} → [self : AddGroupWithOne R] → IntCast R

abbrev AddGroupWithOne.toZSMul E1 #

{R : Type u} → [self : AddGroupWithOne R] → ZSMul R

theorem AddGroupWithOne.neg_add_cancel E2 #

∀ {R : Type u} [self : AddGroupWithOne R] (a : R), -a + a = 0

ctor AddGroupWithOne.mk E0 #

{R : Type u} →
  [toIntCast : IntCast R] →
    [toAddMonoidWithOne : AddMonoidWithOne R] →
      [toNeg : Neg R] →
        [toSub : Sub R] →
          [toZSMul : ZSMul R] →
            autoParam (∀ (a b : R), a - b = a + -b) SubNegMonoid.sub_eq_add_neg._autoParam →
              autoParam (∀ (a : R), 0 • a = 0) SubNegMonoid.zsmul_zero'._autoParam →
                autoParam (∀ (n : ℕ) (a : R), ↑n.succ • a = ↑n • a + a) SubNegMonoid.zsmul_succ'._autoParam →
                  autoParam (∀ (n : ℕ) (a : R), Int.negSucc n • a = -(↑n.succ • a)) SubNegMonoid.zsmul_neg'._autoParam →
                    (∀ (a : R), -a + a = 0) →
                      autoParam (∀ (n : ℕ), IntCast.intCast ↑n = ↑n) AddGroupWithOne.intCast_ofNat._autoParam →
                        autoParam (∀ (n : ℕ), IntCast.intCast (Int.negSucc n) = -↑(n + 1))
                            AddGroupWithOne.intCast_negSucc._autoParam →
                          AddGroupWithOne R

abbrev AddGroupWithOne.toSub E1 #

{R : Type u} → [self : AddGroupWithOne R] → Sub R

theorem AddGroupWithOne.zsmul_zero' E2 #

∀ {R : Type u} [self : AddGroupWithOne R] (a : R), 0 • a = 0

theorem AddGroupWithOne.intCast_ofNat E2 #

∀ {R : Type u} [self : AddGroupWithOne R] (n : ℕ), IntCast.intCast ↑n = ↑n

The canonical homomorphism ℤ → R agrees with the one from ℕ → R on ℕ.

theorem AddGroupWithOne.intCast_negSucc E2 #

∀ {R : Type u} [self : AddGroupWithOne R] (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.

class AddCommGroupWithOne E1 #

Type u → Type u

An AddCommGroupWithOne is an AddGroupWithOne satisfying a + b = b + a.

abbrev AddCommGroupWithOne.toOne E1 #

{R : Type u} → [self : AddCommGroupWithOne R] → One R

ctor AddCommGroupWithOne.mk E0 #

{R : Type u} →
  [toAddCommGroup : AddCommGroup R] →
    [toIntCast : IntCast R] →
      [toNatCast : NatCast R] →
        [toOne : One R] →
          autoParam (↑0 = 0) AddMonoidWithOne.natCast_zero._autoParam →
            autoParam (∀ (n : ℕ), ↑(n + 1) = ↑n + 1) AddMonoidWithOne.natCast_succ._autoParam →
              autoParam (∀ (n : ℕ), IntCast.intCast ↑n = ↑n) AddGroupWithOne.intCast_ofNat._autoParam →
                autoParam (∀ (n : ℕ), IntCast.intCast (Int.negSucc n) = -↑(n + 1))
                    AddGroupWithOne.intCast_negSucc._autoParam →
                  AddCommGroupWithOne R

instance AddCommGroupWithOne.toAddCommMonoidWithOne E0 #

{R : Type u} → [self : AddCommGroupWithOne R] → AddCommMonoidWithOne R

abbrev AddCommGroupWithOne.toNatCast E1 #

{R : Type u} → [self : AddCommGroupWithOne R] → NatCast R

abbrev AddCommGroupWithOne.toIntCast E1 #

{R : Type u} → [self : AddCommGroupWithOne R] → IntCast R

instance AddCommGroupWithOne.toAddGroupWithOne E0 #

{R : Type u} → [self : AddCommGroupWithOne R] → AddGroupWithOne R

instance AddCommGroupWithOne.toAddCommGroup E0 #

{R : Type u} → [self : AddCommGroupWithOne R] → AddCommGroup R

theorem AddCommGroupWithOne.natCast_succ E1 #

∀ {R : Type u} [self : AddCommGroupWithOne R] (n : ℕ), ↑(n + 1) = ↑n + 1

The canonical map ℕ → R is a homomorphism.

theorem AddCommGroupWithOne.natCast_zero E1 #

∀ {R : Type u} [self : AddCommGroupWithOne R], ↑0 = 0

The canonical map ℕ → R sends 0 : ℕ to 0 : R.

theorem AddCommGroupWithOne.intCast_negSucc E1 #

∀ {R : Type u} [self : AddCommGroupWithOne R] (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.

theorem AddCommGroupWithOne.intCast_ofNat E1 #

∀ {R : Type u} [self : AddCommGroupWithOne R] (n : ℕ), IntCast.intCast ↑n = ↑n

The canonical homomorphism ℤ → R agrees with the one from ℕ → R on ℕ.