Benedikt Ahrens and RΓ©gis Spadotti— Terminal semantics for codata types in intensional Martin-Löf type theory
Table of contents
Index
Require Import Category.Types.
Require Import Category.Setoids.
Require Import Category.Types_Setoids.
Require Import Category.RComod.
Require Import Category.RComonadWithCut.
Require Import Theory.Category.
Require Import Theory.Functor.
Require Import Theory.RelativeComonadWithCut.
Require Import Theory.Comodule.
Require Import Theory.Product.
Require Import Theory.PrecompositionWithProduct.
Require Import Theory.PushforwardComodule.

Generalizable All Variables.

Category of triangular matrices

Object and morphism definitions

Module TriMat.

  Structure Obj (E : π‘»π’šπ’‘π’†) : Type ≔ mkObj
  { T:>𝑹π‘ͺπ’π’Žπ’π’π’‚π’…π‘Ύπ’Šπ’•π’‰π‘ͺ𝒖𝒕 𝑬𝑸 E
  ; rest:>[T] β‡’ [T][E×─]
  ; rest_cut:βˆ€ {A}, rest(A) ∘ Tβ‹…cut β‰ˆ Tβ‹…cut ∘ rest(E Γ— A) }.

  Arguments mkObj{_ _ _} _.
  Arguments T{_} _.
  Arguments rest{_} _.
  Arguments rest_cut{_} _ {_ _ _ _}.

  Notation "'TriMat.make' ⦃ 'T' ≔ T ; 'rest' ≔ rest ⦄" ≔
           (@mkObj _ T rest _) (only parsing).

  Structure Morphism {E} (T S : Obj E) : Type ≔ mkMorphism
  { Ο„:> T β‡’ S
  ; Ο„_commutes: βŸ¨Ο„βŸ©οΌ»E×─] ∘ Ξ¦ ∘ Ο„βŽβ‹…T β‰ˆ S ∘ βŸ¨Ο„βŸ© }.

  Arguments mkMorphism{_ _ _ _} _.
  Arguments Ο„{_ _ _} _.
  Arguments Ο„_commutes{_ _ _} _ {_ _ _ _}.

  Notation "'TriMat.make' ⦃ 'Ο„' ≔ Ο„ ⦄" ≔ (@mkMorphism _ _ _ Ο„ _) (only parsing).

  Program Definition Hom {E} (T S : Obj E) : Setoid ≔
    Setoid.make⦃ Carrier≔ Morphism T S
    ; Equiv≔ (Ξ» g f βˆ™ g β‰ˆ f) ⦄.
equivalence
  Show proof.
    constructor.
    - repeat intro. now rewrite H.
    - repeat intro. symmetry; now rewrite H.
    - repeat intro; etransitivity; eauto. now apply H0.

End TriMat.

Export TriMat.

Identity and compositon definitions

Section Defs.

  Variable (E : π‘»π’šπ’‘π’†).

  Implicit Types (T S R U : Obj E).

  Infix "β‡’" ≔ Hom.

  Program Definition id {T} : T β‡’ T ≔
    TriMat.make ⦃ Ο„ ≔ id[T] ⦄.
Ο„-cong
  Show proof.
    now rewrite H.

  Obligation Tactic ≔ idtac.
  Program Definition compose {T S R} : [ S β‡’ R ⟢ T β‡’ S ⟢ T β‡’ R ] ≔
    Ξ» g f ↦₂ TriMat.make ⦃ Ο„ ≔ g ∘ f ⦄.
Ο„-commutes
  Show proof.
    intros T S R g f.
    destruct g as [g g_commutes]. simpl in g_commutes.
    destruct f as [f f_commutes]. simpl in f_commutes. simpl.
    intros.
    rewrite H.
    etransitivity.
    eapply Setoids.cong.
    apply f_commutes.
    reflexivity.
    apply g_commutes.
    reflexivity.
Ο„-cong
  Show proof.
    repeat intro.
    simpl.
    etransitivity. eapply Setoids.cong.
    eapply Setoids.cong. apply H1.
    etransitivity. eapply Setoids.cong.
    apply H0. reflexivity.
    apply H.
    reflexivity.

  Infix "∘" ≔ compose.

  Lemma left_id : βˆ€ T S (f : T β‡’ S), id ∘ f β‰ˆ f.
  Show proof.
    intros. simpl. intros. rewrite H.
    reflexivity.

  Lemma right_id : βˆ€ T S (f : T β‡’ S), f ∘ id β‰ˆ f.
  Show proof.
    repeat intro. simpl. now rewrite H.

  Lemma compose_assoc T R S U (f : T β‡’ R) (g : R β‡’ S) (h : S β‡’ U) : h ∘ g ∘ f β‰ˆ h ∘ (g ∘ f).
  Show proof.
    repeat intro.
    simpl. now rewrite H.

  Canonical Structure π‘»π’“π’Šπ‘΄π’‚π’• : Category ≔
    mkCategory left_id right_id compose_assoc.

End Defs.
Benedikt Ahrens and RΓ©gis Spadotti— Terminal semantics for codata types in intensional Martin-Löf type theory
Table of contents
Index