Built with Alectryon, running Coq+SerAPI v8.18.0+0.18.3. Bubbles () indicate interactive fragments: hover for details, tap to reveal contents. Use Ctrl+↑Ctrl+↓ to navigate, Ctrl+🖱️ to focus. On Mac, use ⌘ instead of Ctrl.
[Loading ML file number_string_notation_plugin.cmxs (using legacy method) ... done]
Require Import Algebra.AbGroups.Require Import Algebra.Rings.CRing.Require Import Spaces.Int Spaces.Pos.Require Import WildCat.Core.(** In this file we define the ring Z of integers. The underlying abelian group is already defined in Algebra.AbGroups.Z. Many of the ring axioms are proven and made opaque. Typically, everything inside IsCRing can be opaque since we will only ever rewrite along them and they are hprops. This also means we don't have to be too careful with how our proofs are structured. This allows us to freely use tactics such as rewrite. It would perhaps be possible to shorten many of the proofs here, but it would probably be unneeded due to the opacicty. *)(** The ring of integers *)
CRing
CRing
AbGroup
One ?R
Mult ?R
Commutative mult
LeftDistribute mult plus
IsMonoid ?R
AbGroup
exact abgroup_Z.
One abgroup_Z
exact1%int.
Mult abgroup_Z
exact int_mul.
Commutative mult
exact int_mul_comm.
LeftDistribute mult plus
exact int_mul_add_distr_l.
IsMonoid abgroup_Z
IsSemiGroup abgroup_Z
LeftIdentity sg_op mon_unit
RightIdentity sg_op mon_unit
IsSemiGroup abgroup_Z
IsHSet abgroup_Z
Associative sg_op
IsHSet abgroup_Z
exact _.
Associative sg_op
exact int_mul_assoc.
LeftIdentity sg_op mon_unit
exact int_mul_1_l.
RightIdentity sg_op mon_unit
exact int_mul_1_r.Defined.LocalOpen Scope mc_scope.(** Multiplication of a ring element by an integer. *)(** We call this a "catamorphism" which is the name of the map from an initial object. It seems to be a more common terminology in computer science. *)Definitioncring_catamorphism_fun (R : CRing) (z : cring_Z) : R
:= match z with
| neg z => pos_peano_rec R (-1) (funnnr => -1 + nr) z
| 0%int => 0
| pos z => pos_peano_rec R 1 (funnnr => 1 + nr) z
end.(** TODO: remove these (they will be cleaned up in the future)*)(** Left multiplication is an equivalence *)
G: Type Aop: SgOp G Aunit: MonUnit G Anegate: Negate G H: IsGroup G
forallx : G, IsEquiv (funt : G => sg_op x t)
G: Type Aop: SgOp G Aunit: MonUnit G Anegate: Negate G H: IsGroup G
forallx : G, IsEquiv (funt : G => sg_op x t)
G: Type Aop: SgOp G Aunit: MonUnit G Anegate: Negate G H: IsGroup G x: G
IsEquiv (funt : G => sg_op x t)
G: Type Aop: SgOp G Aunit: MonUnit G Anegate: Negate G H: IsGroup G x: G
G -> G
G: Type Aop: SgOp G Aunit: MonUnit G Anegate: Negate G H: IsGroup G x: G
(funt : G => sg_op x t) o ?g == idmap
G: Type Aop: SgOp G Aunit: MonUnit G Anegate: Negate G H: IsGroup G x: G
?g o (funt : G => sg_op x t) == idmap
G: Type Aop: SgOp G Aunit: MonUnit G Anegate: Negate G H: IsGroup G x: G
(funt : G => sg_op x t) o sg_op (- x) == idmap
G: Type Aop: SgOp G Aunit: MonUnit G Anegate: Negate G H: IsGroup G x: G
sg_op (- x) o (funt : G => sg_op x t) == idmap
G: Type Aop: SgOp G Aunit: MonUnit G Anegate: Negate G H: IsGroup G x, y: G
sg_op x (sg_op (- x) y) = y
G: Type Aop: SgOp G Aunit: MonUnit G Anegate: Negate G H: IsGroup G x, y: G
sg_op (- x) (sg_op x y) = y
G: Type Aop: SgOp G Aunit: MonUnit G Anegate: Negate G H: IsGroup G x, y: G
sg_op (sg_op x (- x)) y = sg_op mon_unit y
G: Type Aop: SgOp G Aunit: MonUnit G Anegate: Negate G H: IsGroup G x, y: G
sg_op (sg_op (- x) x) y = sg_op mon_unit y
G: Type Aop: SgOp G Aunit: MonUnit G Anegate: Negate G H: IsGroup G x, y: G
sg_op x (- x) = mon_unit
G: Type Aop: SgOp G Aunit: MonUnit G Anegate: Negate G H: IsGroup G x, y: G
sg_op (- x) x = mon_unit
G: Type Aop: SgOp G Aunit: MonUnit G Anegate: Negate G H: IsGroup G x, y: G
sg_op (- x) x = mon_unit
apply left_inverse.Defined.(** Right multiplication is an equivalence *)
G: Type Aop: SgOp G Aunit: MonUnit G Anegate: Negate G H: IsGroup G
forallx : G, IsEquiv (funy : G => sg_op y x)
G: Type Aop: SgOp G Aunit: MonUnit G Anegate: Negate G H: IsGroup G
forallx : G, IsEquiv (funy : G => sg_op y x)
G: Type Aop: SgOp G Aunit: MonUnit G Anegate: Negate G H: IsGroup G x: G
IsEquiv (funy : G => sg_op y x)
G: Type Aop: SgOp G Aunit: MonUnit G Anegate: Negate G H: IsGroup G x: G
G -> G
G: Type Aop: SgOp G Aunit: MonUnit G Anegate: Negate G H: IsGroup G x: G
(funy : G => sg_op y x) o ?g == idmap
G: Type Aop: SgOp G Aunit: MonUnit G Anegate: Negate G H: IsGroup G x: G
?g o (funy : G => sg_op y x) == idmap
G: Type Aop: SgOp G Aunit: MonUnit G Anegate: Negate G H: IsGroup G x: G
(funy : G => sg_op y x)
o (funy : G => sg_op y (- x)) == idmap
G: Type Aop: SgOp G Aunit: MonUnit G Anegate: Negate G H: IsGroup G x: G
(funy : G => sg_op y (- x))
o (funy : G => sg_op y x) == idmap
G: Type Aop: SgOp G Aunit: MonUnit G Anegate: Negate G H: IsGroup G x, y: G
sg_op (sg_op y (- x)) x = y
G: Type Aop: SgOp G Aunit: MonUnit G Anegate: Negate G H: IsGroup G x, y: G
sg_op (sg_op y x) (- x) = y
G: Type Aop: SgOp G Aunit: MonUnit G Anegate: Negate G H: IsGroup G x, y: G
sg_op y (sg_op (- x) x) = sg_op y mon_unit
G: Type Aop: SgOp G Aunit: MonUnit G Anegate: Negate G H: IsGroup G x, y: G
sg_op y (sg_op x (- x)) = sg_op y mon_unit
G: Type Aop: SgOp G Aunit: MonUnit G Anegate: Negate G H: IsGroup G x, y: G
sg_op (- x) x = mon_unit
G: Type Aop: SgOp G Aunit: MonUnit G Anegate: Negate G H: IsGroup G x, y: G
sg_op x (- x) = mon_unit
G: Type Aop: SgOp G Aunit: MonUnit G Anegate: Negate G H: IsGroup G x, y: G
sg_op x (- x) = mon_unit
apply right_inverse.Defined.(** Preservation of + *)
R: CRing
IsSemiGroupPreserving
(cring_catamorphism_fun R : cring_Z -> R)
R: CRing
IsSemiGroupPreserving
(cring_catamorphism_fun R : cring_Z -> R)
(** Unfortunately, due to how we have defined things we need to seperate this out into 9 cases. *)
R: CRing
forallxy : cring_Z,
cring_catamorphism_fun R (sg_op x y) =
sg_op (cring_catamorphism_fun R x)
(cring_catamorphism_fun R y)
R: CRing x, y: Pos
cring_catamorphism_fun R (sg_op (neg x) (neg y)) =
sg_op (cring_catamorphism_fun R (neg x))
(cring_catamorphism_fun R (neg y))
R: CRing x: Pos
cring_catamorphism_fun R (sg_op (neg x) 0%int) =
sg_op (cring_catamorphism_fun R (neg x))
(cring_catamorphism_fun R 0%int)
R: CRing x, y: Pos
cring_catamorphism_fun R (sg_op (neg x) (pos y)) =
sg_op (cring_catamorphism_fun R (neg x))
(cring_catamorphism_fun R (pos y))
R: CRing y: Pos
cring_catamorphism_fun R (sg_op 0%int (neg y)) =
sg_op (cring_catamorphism_fun R 0%int)
(cring_catamorphism_fun R (neg y))
R: CRing
cring_catamorphism_fun R (sg_op 0%int 0%int) =
sg_op (cring_catamorphism_fun R 0%int)
(cring_catamorphism_fun R 0%int)
R: CRing y: Pos
cring_catamorphism_fun R (sg_op 0%int (pos y)) =
sg_op (cring_catamorphism_fun R 0%int)
(cring_catamorphism_fun R (pos y))
R: CRing x, y: Pos
cring_catamorphism_fun R (sg_op (pos x) (neg y)) =
sg_op (cring_catamorphism_fun R (pos x))
(cring_catamorphism_fun R (neg y))
R: CRing x: Pos
cring_catamorphism_fun R (sg_op (pos x) 0%int) =
sg_op (cring_catamorphism_fun R (pos x))
(cring_catamorphism_fun R 0%int)
R: CRing x, y: Pos
cring_catamorphism_fun R (sg_op (pos x) (pos y)) =
sg_op (cring_catamorphism_fun R (pos x))
(cring_catamorphism_fun R (pos y))
(** Some of these cases are easy however *)
R: CRing x, y: Pos
cring_catamorphism_fun R (sg_op (neg x) (neg y)) =
sg_op (cring_catamorphism_fun R (neg x))
(cring_catamorphism_fun R (neg y))
R: CRing x, y: Pos
cring_catamorphism_fun R (sg_op (neg x) (pos y)) =
sg_op (cring_catamorphism_fun R (neg x))
(cring_catamorphism_fun R (pos y))
R: CRing y: Pos
cring_catamorphism_fun R (sg_op 0%int (neg y)) =
sg_op (cring_catamorphism_fun R 0%int)
(cring_catamorphism_fun R (neg y))
R: CRing y: Pos
cring_catamorphism_fun R (sg_op 0%int (pos y)) =
sg_op (cring_catamorphism_fun R 0%int)
(cring_catamorphism_fun R (pos y))
R: CRing x, y: Pos
cring_catamorphism_fun R (sg_op (pos x) (neg y)) =
sg_op (cring_catamorphism_fun R (pos x))
(cring_catamorphism_fun R (neg y))
R: CRing x, y: Pos
cring_catamorphism_fun R (sg_op (pos x) (pos y)) =
sg_op (cring_catamorphism_fun R (pos x))
(cring_catamorphism_fun R (pos y))
R: CRing x, y: Pos
cring_catamorphism_fun R (sg_op (neg x) (neg y)) =
sg_op (cring_catamorphism_fun R (neg x))
(cring_catamorphism_fun R (neg y))
R: CRing x, y: Pos
cring_catamorphism_fun R (sg_op (neg x) (pos y)) =
sg_op (cring_catamorphism_fun R (neg x))
(cring_catamorphism_fun R (pos y))
R: CRing x, y: Pos
cring_catamorphism_fun R (sg_op (pos x) (neg y)) =
sg_op (cring_catamorphism_fun R (pos x))
(cring_catamorphism_fun R (neg y))
R: CRing x, y: Pos
cring_catamorphism_fun R (sg_op (pos x) (pos y)) =
sg_op (cring_catamorphism_fun R (pos x))
(cring_catamorphism_fun R (pos y))
(** This leaves us with four cases to consider *)(** x < 0 , y < 0 *)
R: CRing x, y: Pos
cring_catamorphism_fun R (sg_op (neg x) (neg y)) =
sg_op (cring_catamorphism_fun R (neg x))
(cring_catamorphism_fun R (neg y))
R: CRing x, y: Pos
cring_catamorphism_fun R (neg x + neg y)%int =
cring_catamorphism_fun R (neg x) +
cring_catamorphism_fun R (neg y)
R: CRing x: Pos
cring_catamorphism_fun R (neg x + -1)%int =
cring_catamorphism_fun R (neg x) +
cring_catamorphism_fun R (-1)%int
R: CRing x, y: Pos IHy: cring_catamorphism_fun R (neg x + neg y)%int =
cring_catamorphism_fun R (neg x) + cring_catamorphism_fun R (neg y)
cring_catamorphism_fun R
(neg x + neg (pos_succ y))%int =
cring_catamorphism_fun R (neg x) +
cring_catamorphism_fun R (neg (pos_succ y))
R: CRing x: Pos
cring_catamorphism_fun R (neg x + -1)%int =
cring_catamorphism_fun R (neg x) +
cring_catamorphism_fun R (-1)%int
cring_catamorphism_fun R (- x) =
- cring_catamorphism_fun R x
R: CRing x: cring_Z
cring_catamorphism_fun R (- x) =
- cring_catamorphism_fun R x
R: CRing x: cring_Z
SgOp cring_Z
R: CRing x: cring_Z
MonUnit cring_Z
R: CRing x: cring_Z
IsGroup cring_Z
R: CRing x: cring_Z
SgOp R
R: CRing x: cring_Z
MonUnit R
R: CRing x: cring_Z
IsGroup R
R: CRing x: cring_Z
IsMonoidPreserving (cring_catamorphism_fun R)
R: CRing x: cring_Z
IsMonoidPreserving (cring_catamorphism_fun R)
R: CRing x: cring_Z
IsSemiGroupPreserving (cring_catamorphism_fun R)
R: CRing x: cring_Z
IsUnitPreserving (cring_catamorphism_fun R)
R: CRing x: cring_Z
IsUnitPreserving (cring_catamorphism_fun R)
split.Defined.
R: CRing x, y: Pos
cring_catamorphism_fun R (pos x * pos y)%int =
cring_catamorphism_fun R (pos x) *
cring_catamorphism_fun R (pos y)
R: CRing x, y: Pos
cring_catamorphism_fun R (pos x * pos y)%int =
cring_catamorphism_fun R (pos x) *
cring_catamorphism_fun R (pos y)
R: CRing x: Pos
forally : Pos,
cring_catamorphism_fun R (pos x * pos y)%int =
cring_catamorphism_fun R (pos x) *
cring_catamorphism_fun R (pos y)
R: CRing y: Pos
cring_catamorphism_fun R (1 * pos y)%int =
cring_catamorphism_fun R 1%int *
cring_catamorphism_fun R (pos y)
R: CRing x: Pos IHx: forally : Pos,
cring_catamorphism_fun R (pos x * pos y)%int =
cring_catamorphism_fun R (pos x) * cring_catamorphism_fun R (pos y) y: Pos
cring_catamorphism_fun R
(pos (pos_succ x) * pos y)%int =
cring_catamorphism_fun R (pos (pos_succ x)) *
cring_catamorphism_fun R (pos y)
R: CRing y: Pos
cring_catamorphism_fun R (1 * pos y)%int =
cring_catamorphism_fun R 1%int *
cring_catamorphism_fun R (pos y)
R: CRing y: Pos
cring_catamorphism_fun R 1%int *
cring_catamorphism_fun R (pos y) =
cring_catamorphism_fun R (1 * pos y)%int
apply left_identity.
R: CRing x: Pos IHx: forally : Pos,
cring_catamorphism_fun R (pos x * pos y)%int =
cring_catamorphism_fun R (pos x) * cring_catamorphism_fun R (pos y) y: Pos
cring_catamorphism_fun R
(pos (pos_succ x) * pos y)%int =
cring_catamorphism_fun R (pos (pos_succ x)) *
cring_catamorphism_fun R (pos y)
R: CRing x: Pos IHx: forally : Pos,
cring_catamorphism_fun R (pos x * pos y)%int =
cring_catamorphism_fun R (pos x) * cring_catamorphism_fun R (pos y) y: Pos
cring_catamorphism_fun R (pos (pos_succ x * y)) =
cring_catamorphism_fun R (pos (pos_succ x)) *
cring_catamorphism_fun R (pos y)
R: CRing x: Pos IHx: forally : Pos,
cring_catamorphism_fun R (pos x * pos y)%int =
cring_catamorphism_fun R (pos x) * cring_catamorphism_fun R (pos y) y: Pos
cring_catamorphism_fun R (pos ((x * y)%pos + y)) =
cring_catamorphism_fun R (pos (pos_succ x)) *
cring_catamorphism_fun R (pos y)
R: CRing x: Pos IHx: forally : Pos,
cring_catamorphism_fun R (pos x * pos y)%int =
cring_catamorphism_fun R (pos x) * cring_catamorphism_fun R (pos y) y: Pos
sg_op (cring_catamorphism_fun R (pos (x * y)))
(cring_catamorphism_fun R (pos y)) =
cring_catamorphism_fun R (pos (pos_succ x)) *
cring_catamorphism_fun R (pos y)
R: CRing x: Pos IHx: forally : Pos,
cring_catamorphism_fun R (pos x * pos y)%int =
cring_catamorphism_fun R (pos x) * cring_catamorphism_fun R (pos y) y: Pos
sg_op
(cring_catamorphism_fun R (pos x) *
cring_catamorphism_fun R (pos y))
(cring_catamorphism_fun R (pos y)) =
cring_catamorphism_fun R (pos (pos_succ x)) *
cring_catamorphism_fun R (pos y)
R: CRing x: Pos IHx: forally : Pos,
cring_catamorphism_fun R (pos x * pos y)%int =
cring_catamorphism_fun R (pos x) * cring_catamorphism_fun R (pos y) y: Pos
sg_op
(cring_catamorphism_fun R (pos x) *
cring_catamorphism_fun R (pos y))
(cring_catamorphism_fun R (pos y)) =
(1 + cring_catamorphism_fun R (pos x)) *
cring_catamorphism_fun R (pos y)
R: CRing x: Pos IHx: forally : Pos,
cring_catamorphism_fun R (pos x * pos y)%int =
cring_catamorphism_fun R (pos x) * cring_catamorphism_fun R (pos y) y: Pos
(1 + cring_catamorphism_fun R (pos x)) *
cring_catamorphism_fun R (pos y) =
cring_catamorphism_fun R (pos (pos_succ x)) *
cring_catamorphism_fun R (pos y)
R: CRing x: Pos IHx: forally : Pos,
cring_catamorphism_fun R (pos x * pos y)%int =
cring_catamorphism_fun R (pos x) * cring_catamorphism_fun R (pos y) y: Pos
sg_op
(cring_catamorphism_fun R (pos x) *
cring_catamorphism_fun R (pos y))
(cring_catamorphism_fun R (pos y)) =
(1 + cring_catamorphism_fun R (pos x)) *
cring_catamorphism_fun R (pos y)
R: CRing x: Pos IHx: forally : Pos,
cring_catamorphism_fun R (pos x * pos y)%int =
cring_catamorphism_fun R (pos x) * cring_catamorphism_fun R (pos y) y: Pos
sg_op
(cring_catamorphism_fun R (pos x) *
cring_catamorphism_fun R (pos y))
(cring_catamorphism_fun R (pos y)) =
1 * cring_catamorphism_fun R (pos y) +
cring_catamorphism_fun R (pos x) *
cring_catamorphism_fun R (pos y)
R: CRing x: Pos IHx: forally : Pos,
cring_catamorphism_fun R (pos x * pos y)%int =
cring_catamorphism_fun R (pos x) * cring_catamorphism_fun R (pos y) y: Pos
sg_op
(cring_catamorphism_fun R (pos x) *
cring_catamorphism_fun R (pos y))
(cring_catamorphism_fun R (pos y)) =
cring_catamorphism_fun R (pos y) +
cring_catamorphism_fun R (pos x) *
cring_catamorphism_fun R (pos y)
apply commutativity.Qed.(** Preservation of * (multiplication) *)
R: CRing
IsSemiGroupPreserving
(cring_catamorphism_fun R : cring_Z -> R)
R: CRing
IsSemiGroupPreserving
(cring_catamorphism_fun R : cring_Z -> R)
R: CRing
forallxy : cring_Z,
cring_catamorphism_fun R (sg_op x y) =
sg_op (cring_catamorphism_fun R x)
(cring_catamorphism_fun R y)
R: CRing x, y: Pos
cring_catamorphism_fun R (sg_op (neg x) (neg y)) =
sg_op (cring_catamorphism_fun R (neg x))
(cring_catamorphism_fun R (neg y))
R: CRing x: Pos
cring_catamorphism_fun R (sg_op (neg x) 0%int) =
sg_op (cring_catamorphism_fun R (neg x))
(cring_catamorphism_fun R 0%int)
R: CRing x, y: Pos
cring_catamorphism_fun R (sg_op (neg x) (pos y)) =
sg_op (cring_catamorphism_fun R (neg x))
(cring_catamorphism_fun R (pos y))
R: CRing y: Pos
cring_catamorphism_fun R (sg_op 0%int (neg y)) =
sg_op (cring_catamorphism_fun R 0%int)
(cring_catamorphism_fun R (neg y))
R: CRing
cring_catamorphism_fun R (sg_op 0%int 0%int) =
sg_op (cring_catamorphism_fun R 0%int)
(cring_catamorphism_fun R 0%int)
R: CRing y: Pos
cring_catamorphism_fun R (sg_op 0%int (pos y)) =
sg_op (cring_catamorphism_fun R 0%int)
(cring_catamorphism_fun R (pos y))
R: CRing x, y: Pos
cring_catamorphism_fun R (sg_op (pos x) (neg y)) =
sg_op (cring_catamorphism_fun R (pos x))
(cring_catamorphism_fun R (neg y))
R: CRing x: Pos
cring_catamorphism_fun R (sg_op (pos x) 0%int) =
sg_op (cring_catamorphism_fun R (pos x))
(cring_catamorphism_fun R 0%int)
R: CRing x, y: Pos
cring_catamorphism_fun R (sg_op (pos x) (pos y)) =
sg_op (cring_catamorphism_fun R (pos x))
(cring_catamorphism_fun R (pos y))
R: CRing x, y: Pos
cring_catamorphism_fun R (sg_op (neg x) (neg y)) =
sg_op (cring_catamorphism_fun R (neg x))
(cring_catamorphism_fun R (neg y))
R: CRing x, y: Pos
cring_catamorphism_fun R (sg_op (neg x) (pos y)) =
sg_op (cring_catamorphism_fun R (neg x))
(cring_catamorphism_fun R (pos y))
R: CRing y: Pos
cring_catamorphism_fun R (sg_op 0%int (neg y)) =
sg_op (cring_catamorphism_fun R 0%int)
(cring_catamorphism_fun R (neg y))
R: CRing y: Pos
cring_catamorphism_fun R (sg_op 0%int (pos y)) =
sg_op (cring_catamorphism_fun R 0%int)
(cring_catamorphism_fun R (pos y))
R: CRing x, y: Pos
cring_catamorphism_fun R (sg_op (pos x) (neg y)) =
sg_op (cring_catamorphism_fun R (pos x))
(cring_catamorphism_fun R (neg y))
R: CRing x, y: Pos
cring_catamorphism_fun R (sg_op (pos x) (pos y)) =
sg_op (cring_catamorphism_fun R (pos x))
(cring_catamorphism_fun R (pos y))
R: CRing x, y: Pos
cring_catamorphism_fun R (sg_op (neg x) (neg y)) =
sg_op (cring_catamorphism_fun R (neg x))
(cring_catamorphism_fun R (neg y))
R: CRing x, y: Pos
cring_catamorphism_fun R (sg_op (neg x) (pos y)) =
sg_op (cring_catamorphism_fun R (neg x))
(cring_catamorphism_fun R (pos y))
R: CRing x, y: Pos
cring_catamorphism_fun R (sg_op (pos x) (neg y)) =
sg_op (cring_catamorphism_fun R (pos x))
(cring_catamorphism_fun R (neg y))
R: CRing x, y: Pos
cring_catamorphism_fun R (sg_op (pos x) (pos y)) =
sg_op (cring_catamorphism_fun R (pos x))
(cring_catamorphism_fun R (pos y))
R: CRing x, y: Pos
cring_catamorphism_fun R (sg_op (neg x) (neg y)) =
sg_op (cring_catamorphism_fun R (neg x))
(cring_catamorphism_fun R (neg y))
R: CRing x, y: Pos
cring_catamorphism_fun R (pos (x * y)) =
cring_catamorphism_fun R (- (pos x : cring_Z)) *
cring_catamorphism_fun R (- (pos y : cring_Z))