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

Generalizable All Variables.

Isomorphism

Inverse of a morphism definition

Class IsInverse {π’ž : Category} {A B : π’ž} (f : A β‡’ B) (g : B β‡’ A) : Prop ≔ mkInverse
{ iso_left: f ∘ g β‰ˆ id
; iso_right : g ∘ f β‰ˆ id }.

Arguments mkInverse {_ _ _ _ _} _ _.

Definition inverse_of {π’ž : Category} {A B : π’ž} {g : B β‡’ A} (f : A β‡’ B) `{!IsInverse f g} : B β‡’ A ≔ g.

Arguments inverse_of {_ _ _ _} _ {_}.

Notation "f ⁻¹" ≔ (inverse_of f) (at level 0, no associativity).

Isomorphism between objects

Structure Iso {π’ž : Category} (A B : π’ž) ≔ mkIso
{ iso_from:> A β‡’ B
; iso_to: B β‡’ A
; iso_inverse : IsInverse iso_from iso_to }.

Existing Instance iso_inverse.

Arguments mkIso{_ _ _ _} _ _.
Arguments iso_from {_ _ _} _.
Arguments iso_to{_ _ _} _.

Infix "β‰…" ≔ Iso (at level 70).
Notation "I 'β‹…β‰…-left'"≔ (iso_left I) (at level 0, only parsing).
Notation "I 'β‹…β‰…-right'"≔ (iso_left I) (at level 0, only parsing).

Notation "'Iso.make' ⦃ 'from' ≔ from ; 'to' ≔ to ⦄" ≔
  (@mkIso _ _ _ from to (mkInverse _ _)) (only parsing).

β‰…_ is an equivalence relation

Section Iso_Equivalence.

  Context {π’ž : Category}.

  Program Definition refl {A : π’ž} : A β‰… A ≔
    Iso.make ⦃ from ≔ id
             ; to≔ id ⦄.
  Show proof.
    now rewrite left_id.
  Show proof.
    now rewrite right_id.

  Program Definition sym {A B : π’ž} (iso_AB : A β‰… B) : B β‰… A ≔
    Iso.make ⦃ from ≔ iso_AB⁻¹
             ; to≔ iso_AB ⦄.
  Show proof.
    now rewrite iso_right.
  Show proof.
    now rewrite iso_left.

  Program Definition trans {A B C : π’ž} (iso_AB : A β‰… B) (iso_BC : B β‰… C) : A β‰… C ≔
    Iso.make ⦃ from ≔ iso_BC ∘ iso_AB
             ; to≔ iso_AB ⁻¹ ∘ iso_BC ⁻¹ ⦄.
  Show proof.
    rewrite compose_assoc; setoid_rewrite <- compose_assoc at 2.
    now rewrite iso_left, left_id, iso_left.
  Show proof.
    rewrite compose_assoc; setoid_rewrite <- compose_assoc at 2.
    now rewrite iso_right, left_id, iso_right.

End Iso_Equivalence.

Notation "β‰…-refl" ≔ refl (only parsing).
Notation "β‰…-sym" ≔ sym (only parsing).
Notation "β‰…-trans" ≔ trans (only parsing).
Benedikt Ahrens and RΓ©gis Spadotti— Terminal semantics for codata types in intensional Martin-Löf type theory
Table of contents
Index