In this lab, we are going to define the basic functions for working with identity types. The names for the functions have been chosen so that we are mostly compatible with the cubical Agda library, even though we are not using it for now. You should work in the same directory as for previous lab. In particular, it should contain the Prelude.agda file. The labs will be following each other starting from now: it is important for you to work regularly! Many of the functions have similar proofs, so that the proofs are not always fascinating, but the functions will still turn out to be very useful in the following.
TODO: read Prelude……………..
Create a file Path.agda. Start your file with
{-# OPTIONS --without-K #-}which indicates that we want to use the variant of the pattern matching algorithm which does not enforce uniqueness of identity proofs (more details here). Then write
open import Preludein order to import all the functions from the Prelude
module. Finally, write
private variable
ℓ ℓ' ℓ'' : LevelIn order to have Agda automatically, generate implicit arguments for
universe level variables ℓ (typed \ell).
Show that equality is symmetric by defining a function
sym : {A : Type ℓ} {x y : A} → x ≡ y → y ≡ xIn the course, we sometimes write \(p^-\) for sym p.
Define the eliminator
J : {A : Type ℓ} {x : A} (P : (y : A) → x ≡ y → Type ℓ') → P x refl → {y : A} (p : x ≡ y) → P y pUse it in order to define again symmetry (without using pattern matching)
sym' : {A : Type ℓ} {x y : A} → x ≡ y → y ≡ xShow that equality is transitive
trans : {A : Type ℓ} {x y z : A} → x ≡ y → y ≡ z → x ≡ zWe can then define the usual notation for path composition as
infixr 30 _∙_
_∙_ = transwhere the point “∙” is typed \..
Show that path composition admits refl as neutral
element on the left
lUnit : {A : Type ℓ} {x y : A} (p : x ≡ y) → p ≡ refl ∙ pShow that path composition admits refl as neutral
element on the right
rUnit : {A : Type ℓ} {x y : A} (p : x ≡ y) → p ≡ p ∙ reflShow that path composition is cancelative on the left
lCancel : {A : Type ℓ} {x y : A} (p : x ≡ y) → sym p ∙ p ≡ refland on the right
rCancel : {A : Type ℓ} {x y : A} (p : x ≡ y) → p ∙ sym p ≡ reflShow that path composition is associative
assoc : {A : Type ℓ} {x y z w : A} (p : x ≡ y) (q : y ≡ z) (r : z ≡ w) → p ∙ (q ∙ r) ≡ (p ∙ q) ∙ rShow that symmetry
symInvo : {A : Type ℓ} {x y : A} (p : x ≡ y) → p ≡ sym (sym p)Show that equality is a congruence / that all functions are functorial, by proving
cong : {A : Type ℓ} {B : Type ℓ'} (f : A → B) {x y : A} (p : x ≡ y) → f x ≡ f yNote that cong is noted ap in the
course.
Show that we can extract the components of a path:
≡× : {A : Type ℓ} {B : Type ℓ'} {x x' : A} {y y' : B} → (x , y) ≡ (x' , y') → (x ≡ x') × (y ≡ y')You are not allowed to perform pattern matching in the above definition.
Show that applying a constant function to a path gives
refl:
congConst : {A : Type ℓ} {B : Type ℓ'} {x' : B} {x y : A} (p : x ≡ y) → cong (λ _ → x') p ≡ reflDefine the following functions
congComposite: applying a function to a composite of
paths is the composite of their applicationcongSym: applying a function to the symmetric of a path
is the symmetric of the applicationcongId: applying the identity (id) to a
path leaves the path unchangedcong∘: applying the composite of two functions to a
paths amounts to successively apply the two functionscong₂: we can apply a function taking two arguments to
two paths simultaneouslyAbove, “∘” is typed \circ and
“₂” is typed \_2.
Using the previous functions, show the following lemma
rotate∙≡ : {A : Type ℓ} {x y y' : A} (p : x ≡ y) (q : y ≡ y') (p' : x ≡ y') → p ∙ q ≡ p' → sym p ∙ p' ≡ qWe advise you to use the notation for equational reasoning and begin with
rotate∙≡ p q p' α =
sym p ∙ p' ≡⟨ ? ⟩
q ∎You can then insert lines of the form
? ≡⟨ ? ⟩in the middle in order to add intermediate steps.
Define a function
subst : {A : Type ℓ} (B : A → Type ℓ') {x y : A} (p : x ≡ y) → B x → B ywhich shows that equality is substitutive. This function is called transport in the course.
Show that true is not false:
true≢false : ¬ true ≡ falseChange your proof in order to use subst instead of
pattern matching.
Define a function
transport : {A B : Type ℓ} → A ≡ B → A → Bwhich corresponds to coe in the course. If you used pattern matching, modify your definition in order not to.
Above, you have defined transport from
subst. Show that we could do the converse by defining
subst' : {A : Type ℓ} (B : A → Type ℓ') {x y : A} (p : x ≡ y) → B x → B ywithout using pattern matching.
Show that
transporting along composite paths corresponds to successively substituting
substComposite : {A : Type ℓ} (B : A → Type ℓ) {x y z : A} (p : x ≡ y) (q : y ≡ z) (x' : B x) → subst B (p ∙ q) x' ≡ subst B q (subst B p x')transporting a path along its right end amounts to composition
substInPathsL : {A : Type ℓ} {x y y' : A} (p : x ≡ y) (q : y ≡ y') → subst (λ y → x ≡ y) q p ≡ p ∙ qtransporting a path along its left end amounts to reverse composition
substInPathsR : {A : Type ℓ} {x x' y : A} (p : x ≡ x') (q : x ≡ y) → subst (λ x → x ≡ y) p q ≡ sym p ∙ qthe following generalization of the two previous lemmas
substInPaths : {A : Type ℓ} {B : Type ℓ'} {x y : A} (f g : A → B) (p : x ≡ y) (q : f x ≡ g x) → subst (λ x → f x ≡ g x) p q ≡ sym (cong f p) ∙ q ∙ cong g pDefine the type of paths in a type family over another path as
PathOver : {A : Type ℓ} (B : A → Type ℓ') {x y : A} (p : x ≡ y) (x' : B x) (y' : B y) → Type ℓ'
PathOver B p x' y' = subst B p x' ≡ y'Show that we can construct paths in a product type as a pair of paths:
×≡ : {A : Type ℓ} {B : Type ℓ'} {x x' : A} {y y' : B} → (p : x ≡ x') (q : y ≡ y') → (x , y) ≡ (x' , y')Generalize the previous definition to dependent sums:
Σ≡ : {A : Type ℓ} {B : A → Type ℓ'} {x x' : A} (p : x ≡ x') {y : B x} {y' : B x'} → PathOver B p y y' → (x , y) ≡ (x' , y')Define the following generalization of application of
cong
congP : {A : Type ℓ} (B : A → Type ℓ') (f : (x : A) → B x) {x y : A} (p : x ≡ y) → PathOver B p (f x) (f y)This function is called apd in the course.
Show the following results about the transport of functions:
transporting the target of a function:
funTypeTranspR : {A : Type ℓ} {B B' : Type ℓ'} (p : B ≡ B') (f : A → B) → subst (λ X → A → X) p f ≡ transport p ∘ ftransporting the source of a function:
funTypeTranspL : {A A' : Type ℓ} {B : Type ℓ'} (p : A ≡ A') (f : A → B) → subst (λ X → X → B) p f ≡ f ∘ transport (sym p)transporting both the source and target of a function:
funTypeTransp : {A : Type ℓ} (B : A → Type ℓ') (C : A → Type ℓ'') {x y : A} (p : x ≡ y) (f : B x → C x) → PathOver (λ x → B x → C x) p f (subst C p ∘ f ∘ subst B (sym p))The goal here is to show the equivalence between the various formulations of uniqueness of identity proofs.
Define the following logical principles:
uniqueness of identity proofs:
UIP : Type₁
UIP = {A : Type} {x y : A} (p q : x ≡ y) → p ≡ quniqueness of reflexivity proofs:
URP : Type₁
URP = {A : Set} {x : A} (p : x ≡ x) → p ≡ reflStreicher’s axiom K
K : Type₁
K = {A : Type} {x : A} (P : (x ≡ x) → Set) → P refl → (p : x ≡ x) → P pShow that they are logically equivalent by proving the following implications
UIP→URP : UIP → URPURP→UIP : URP → UIPURP→K : URP → KK→URP : K → URPDefine Leibniz equality as
_==_ : {ℓ : Level} {A : Type ℓ} → A → A → Type _
_==_ {ℓ} {A} x y = (P : A → Type ℓ) → P x → P yShow that Leibniz equality is reflexive
Lrefl : {A : Type ℓ} {x : A} → x == xsymmetric
Lsym : {A : Type ℓ} {x y : A} → x == y → y == xand transitive
Ltrans : {A : Type ℓ} {x y z : A} → x == y → y == z → x == zShow that we can convert Leibniz equalities to identity types
Lto≡ : {A : Type ℓ} {x y : A} → x == y → x ≡ yand the converse
≡toL : {A : Type ℓ} {x y : A} → x ≡ y → x == yShow that those functions form a section retraction pair:
≡to≡ : {A : Type ℓ} {x y : A} (p : x ≡ y) → Lto≡ (≡toL p) ≡ pShow the Eckmann-Hilton
property: composition is commutative for paths between
refl.
EH : {A : Type ℓ} {x : A} (α β : refl {x = x} ≡ refl) → α ∙ β ≡ β ∙ αThe general idea is to show the following sequence of equalities:
This requires intermediate lemmas, and you might want to have a look at Theorem 2.1.6 in the HoTT book.