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 *)
(**********************************************************************)
Section associator.

  Context
    {X Y Z W: Type}.

  (* Recall Coq's notation "_ * _" associates to the left. *)
  Definition associator: (X * Y) * Z -> X * (Y * Z) :=
    fun p => match p with
             | ((x, y), z) => (x, (y, z))
             end.

  Definition associator_inv: (X * (Y * Z)) -> (X * Y) * Z :=
    fun p => 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. End associator. (** ** Notations *) (**********************************************************************) Module Notations. Notation "'α'" := (associator): tealeaves_scope. Notation "'α^-1'" := (associator_inv): tealeaves_scope. Notation "( X × )" := (prod X) (only parsing): function_scope. End Notations. Import Notations. (** ** Monoidal Category Theory Laws *) (**********************************************************************) Definition map_tensor `(f: X -> Z) `(g: Y -> W) `(p: X * Y): Z * W := match p with | (x, y) => (f x, g y) end. Definition map_fst {Y} `(f: X -> Z): X * Y -> Z * Y := map_tensor f id. Definition map_snd {X} `(f: Y -> W): X * Y -> X * W := map_tensor id f. Definition map_both `(f: X -> Z): X * X -> Z * Z := map_tensor f f. Definition left_unitor {X}: unit * X -> X := snd. Definition left_unitor_inv {X}: X -> unit * X := pair tt. Definition right_unitor {X}: (X * unit) -> X := fst. Definition right_unitor_inv {X}: X -> X * unit := fun x => (x, tt).

forall A : Type, left_unitor_inv ∘ left_unitor = id

forall A : Type, left_unitor_inv ∘ left_unitor = id
introv; now ext [[] ?]. Qed.

forall A : Type, left_unitor ∘ left_unitor_inv = id

forall A : Type, left_unitor ∘ left_unitor_inv = id
A: Type

left_unitor ∘ left_unitor_inv = id
now ext a. Qed.

forall A : Type, right_unitor_inv ∘ right_unitor = id

forall A : Type, right_unitor_inv ∘ right_unitor = id
introv; now ext [? []]. Qed.

forall A : Type, right_unitor ∘ right_unitor_inv = id

forall A : 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. Definition braiding {X Y: Type}: X * Y -> Y * X := fun p => 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 *) (**********************************************************************) Definition uncurry {X Y Z}: (X -> Y -> Z) -> (X * Y -> Z) := fun f p => let '(x, y) := p in f x y. Definition curry {X Y Z}: (X * Y -> Z) -> (X -> Y -> Z) := fun f x y => f (x, y).
X, Y, Z: Type

forall f : X -> Y -> Z, f = curry (uncurry f)
X, Y, Z: Type

forall f : X -> Y -> Z, f = curry (uncurry f)
now intros. Qed.
X, Y, Z: Type

forall f : X * Y -> Z, f = uncurry (curry f)
X, Y, Z: Type

forall f : 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
now intros ? [? ?]. 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
now intros ? [? ?]. 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)
now intros ? [? ?]. 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)
now intros ? [? ?]. Qed. (** ** Miscellaneous *) (**********************************************************************) Definition swap_middle {X Y Z W}: (X * Y) * (Z * W) -> (X * Z) * (Y * W) := fun p => associator_inv (map_snd associator (map_snd (map_fst braiding) (map_snd associator_inv (associator 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)
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)
now intros ? ? [? ?]. 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. Definition dup_left {A B}: 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)
A, B, C, X: Type
f: A -> B
g: B -> C

map_fst g ∘ map_fst f = map_fst (g ∘ f)
A, B, C, X: Type
f: A -> B
g: B -> C
a: A
x: X

(map_fst g ∘ map_fst f) (a, x) = map_fst (g ∘ f) (a, x)
reflexivity. Qed.
A, B, C, X: Type

forall (f : A -> B) (g : B -> C), map_snd g ∘ map_snd f = map_snd (g ∘ f)
A, B, C, X: Type

forall (f : A -> B) (g : B -> C), map_snd g ∘ map_snd f = map_snd (g ∘ f)
A, B, C, X: Type
f: A -> B
g: B -> C

map_snd g ∘ map_snd f = map_snd (g ∘ f)
A, B, C, X: Type
f: A -> B
g: B -> C
x: X
a: A

(map_snd g ∘ map_snd f) (x, a) = map_snd (g ∘ f) (x, a)
reflexivity. Qed.
A, B, C, D: Type

forall (f : A -> B) (g : C -> D), map_snd g ∘ map_fst f = map_fst f ∘ map_snd g
A, B, C, D: Type

forall (f : A -> B) (g : C -> D), map_snd g ∘ map_fst f = map_fst f ∘ map_snd g
A, B, C, D: Type
f: A -> B
g: C -> D

map_snd g ∘ map_fst f = map_fst f ∘ map_snd g
A, B, C, D: Type
f: A -> B
g: C -> D
a: A
c: C

(map_snd g ∘ map_fst f) (a, c) = (map_fst f ∘ map_snd g) (a, c)
reflexivity. Qed.