Built with Alectryon, running Coq+SerAPI v8.16.0+0.16.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.
From Tealeaves Require Export
Tactics.Prelude.(** This file defines the monoidal-category-theoretic structure on the category of types and functions given by the Cartesian product [prod]. It supplies generally useful definitions like [copy] and [map_snd] related to the product functor. *)#[local] Generalizable All Variables.(** * Monoidal Category-Theoretic Structure on <<Type>> *)(**********************************************************************)(** ** Reassociating Cartesian Products *)(**********************************************************************)Sectionassociator.Context
{XYZW: Type}.(* Recall Coq's notation "_ * _" associates to the left. *)Definitionassociator: (X * Y) * Z -> X * (Y * Z) :=
funp => match p with
| ((x, y), z) => (x, (y, z))
end.Definitionassociator_inv: (X * (Y * Z)) -> (X * Y) * Z :=
funp => match p with
| (x, (y, z)) => ((x, y), z)
end.
X, Y, Z, W: Type
associator_inv ∘ associator = id
X, Y, Z, W: Type
associator_inv ∘ associator = id
now ext [[? ?] ?].Qed.
X, Y, Z, W: Type
associator ∘ associator_inv = id
X, Y, Z, W: Type
associator ∘ associator_inv = id
now ext [? [? ?]].Qed.Endassociator.(** ** Notations *)(**********************************************************************)ModuleNotations.Notation"'α'" := (associator): tealeaves_scope.Notation"'α^-1'" := (associator_inv): tealeaves_scope.Notation"( X × )" := (prod X) (only parsing): function_scope.EndNotations.Import Notations.(** ** Monoidal Category Theory Laws *)(**********************************************************************)Definitionmap_tensor `(f: X -> Z) `(g: Y -> W) `(p: X * Y): Z * W :=
match p with
| (x, y) => (f x, g y)
end.Definitionmap_fst {Y} `(f: X -> Z): X * Y -> Z * Y :=
map_tensor f id.Definitionmap_snd {X} `(f: Y -> W): X * Y -> X * W :=
map_tensor id f.Definitionmap_both `(f: X -> Z): X * X -> Z * Z :=
map_tensor f f.Definitionleft_unitor {X}: unit * X -> X := snd.Definitionleft_unitor_inv {X}: X -> unit * X := pair tt.Definitionright_unitor {X}: (X * unit) -> X := fst.Definitionright_unitor_inv {X}: X -> X * unit := funx => (x, tt).
forallA : Type, left_unitor_inv ∘ left_unitor = id
forallA : Type, left_unitor_inv ∘ left_unitor = id
introv; now ext [[] ?].Qed.
forallA : Type, left_unitor ∘ left_unitor_inv = id
forallA : Type, left_unitor ∘ left_unitor_inv = id
A: Type
left_unitor ∘ left_unitor_inv = id
now ext a.Qed.
forallA : Type, right_unitor_inv ∘ right_unitor = id
forallA : Type, right_unitor_inv ∘ right_unitor = id
introv; now ext [? []].Qed.
forallA : Type, right_unitor ∘ right_unitor_inv = id
forallA : Type, right_unitor ∘ right_unitor_inv = id
introv; now ext a.Qed.
X, Y: Type
map_fst right_unitor = map_snd left_unitor ∘ α
X, Y: Type
map_fst right_unitor = map_snd left_unitor ∘ α
now ext [[? ?] ?].Qed.
X, Y, Z, W: Type
map_snd α ∘ α ∘ map_fst α = α ∘ α
X, Y, Z, W: Type
map_snd α ∘ α ∘ map_fst α = α ∘ α
now ext [[[? ?] ?] ?].Qed.Definitionbraiding {XY: Type}: X * Y -> Y * X :=
funp => match p with
| (x, y) => (y, x)
end.
X, Y: Type
braiding ∘ braiding = id
X, Y: Type
braiding ∘ braiding = id
now ext [? ?].Qed.(** ** Currying and Uncurrying *)(**********************************************************************)Definitionuncurry {XYZ}: (X -> Y -> Z) -> (X * Y -> Z) :=
funfp => let '(x, y) := p in f x y.Definitioncurry {XYZ}: (X * Y -> Z) -> (X -> Y -> Z) :=
funfxy => f (x, y).
X, Y, Z: Type
forallf : X -> Y -> Z, f = curry (uncurry f)
X, Y, Z: Type
forallf : X -> Y -> Z, f = curry (uncurry f)
nowintros.Qed.
X, Y, Z: Type
forallf : X * Y -> Z, f = uncurry (curry f)
X, Y, Z: Type
forallf : X * Y -> Z, f = uncurry (curry f)
X, Y, Z: Type f: X * Y -> Z
f = uncurry (curry f)
now ext [? ?].Qed.(** ** Deletions/Projections *)(**********************************************************************)
X, Y, Z: Type
forall (f : X -> Z) (p : X * Y),
snd (map_fst f p) = snd p
X, Y, Z: Type
forall (f : X -> Z) (p : X * Y),
snd (map_fst f p) = snd p
nowintros ? [? ?].Qed.
X, Y, W: Type
forall (f : Y -> W) (p : X * Y),
fst (map_snd f p) = fst p
X, Y, W: Type
forall (f : Y -> W) (p : X * Y),
fst (map_snd f p) = fst p
nowintros ? [? ?].Qed.
X, Y, Z: Type
forall (f : Y -> Z) (p : X * Y),
snd (map_snd f p) = f (snd p)
X, Y, Z: Type
forall (f : Y -> Z) (p : X * Y),
snd (map_snd f p) = f (snd p)
nowintros ? [? ?].Qed.
X, Y, W: Type
forall (f : X -> W) (p : X * Y),
fst (map_fst f p) = f (fst p)
X, Y, W: Type
forall (f : X -> W) (p : X * Y),
fst (map_fst f p) = f (fst p)
forall (f : X -> Z) (g : Y -> W) (p : X * Y),
map_fst f (map_snd g p) = map_snd g (map_fst f p)
X, Y, Z, W: Type
forall (f : X -> Z) (g : Y -> W) (p : X * Y),
map_fst f (map_snd g p) = map_snd g (map_fst f p)
nowintros ? ? [? ?].Qed.
X, Y, Z, W: Type
forall (f : X -> Z) (g : Y -> W),
map_fst f ∘ map_snd g = map_snd g ∘ map_fst f
X, Y, Z, W: Type
forall (f : X -> Z) (g : Y -> W),
map_fst f ∘ map_snd g = map_snd g ∘ map_fst f
X, Y, Z, W: Type f: X -> Z g: Y -> W
map_fst f ∘ map_snd g = map_snd g ∘ map_fst f
now ext [x y].Qed.Definitiondup_left {AB}: A * B -> A * (A * B) :=
fun '(a, b) => (a, (a, b)).(** ** Commuting Maps *)(**********************************************************************)
A, B, C, X: Type
forall (f : A -> B) (g : B -> C),
map_fst g ∘ map_fst f = map_fst (g ∘ f)
A, B, C, X: Type
forall (f : A -> B) (g : B -> C),
map_fst g ∘ map_fst f = map_fst (g ∘ f)