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 Prelude
in order to import all the functions from the Prelude
module. Finally, write
private variable
: Level ℓ ℓ' ℓ''
In order to have Agda automatically, generate implicit arguments for
universe level variables ℓ
(typed \ell
).
Show that equality is symmetric by defining a function
: {A : Type ℓ} {x y : A} → x ≡ y → y ≡ x sym
In the course, we sometimes write \(p^-\) for sym p
.
Define the eliminator
: {A : Type ℓ} {x : A} (P : (y : A) → x ≡ y → Type ℓ') → P x refl → {y : A} (p : x ≡ y) → P y p J
Use it in order to define again symmetry (without using pattern matching)
: {A : Type ℓ} {x y : A} → x ≡ y → y ≡ x sym'
Show that equality is transitive
: {A : Type ℓ} {x y z : A} → x ≡ y → y ≡ z → x ≡ z trans
We can then define the usual notation for path composition as
infixr 30 _∙_
_∙_ = trans
where the point “∙
” is typed \.
.
Show that path composition admits refl
as neutral
element on the left
: {A : Type ℓ} {x y : A} (p : x ≡ y) → p ≡ refl ∙ p lUnit
Show that path composition admits refl
as neutral
element on the right
: {A : Type ℓ} {x y : A} (p : x ≡ y) → p ≡ p ∙ refl rUnit
Show that path composition is cancelative on the left
: {A : Type ℓ} {x y : A} (p : x ≡ y) → sym p ∙ p ≡ refl lCancel
and on the right
: {A : Type ℓ} {x y : A} (p : x ≡ y) → p ∙ sym p ≡ refl rCancel
Show that path composition is associative
: {A : Type ℓ} {x y z w : A} (p : x ≡ y) (q : y ≡ z) (r : z ≡ w) → p ∙ (q ∙ r) ≡ (p ∙ q) ∙ r assoc
Show that symmetry
: {A : Type ℓ} {x y : A} (p : x ≡ y) → p ≡ sym (sym p) symInvo
Show that equality is a congruence / that all functions are functorial, by proving
: {A : Type ℓ} {B : Type ℓ'} (f : A → B) {x y : A} (p : x ≡ y) → f x ≡ f y cong
Note 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
:
: {A : Type ℓ} {B : Type ℓ'} {x' : B} {x y : A} (p : x ≡ y) → cong (λ _ → x') p ≡ refl congConst
Define 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
: {A : Type ℓ} {x y y' : A} (p : x ≡ y) (q : y ≡ y') (p' : x ≡ y') → p ∙ q ≡ p' → sym p ∙ p' ≡ q rotate∙≡
We 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
: {A : Type ℓ} (B : A → Type ℓ') {x y : A} (p : x ≡ y) → B x → B y subst
which shows that equality is substitutive. This function is called transport in the course.
Show that true is not false:
: ¬ true ≡ false true≢false
Change your proof in order to use subst
instead of
pattern matching.
Define a function
: {A B : Type ℓ} → A ≡ B → A → B transport
which 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
: {A : Type ℓ} (B : A → Type ℓ') {x y : A} (p : x ≡ y) → B x → B y subst'
without using pattern matching.
Show that
transporting along composite paths corresponds to successively substituting
: {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') substComposite
transporting a path along its right end amounts to composition
: {A : Type ℓ} {x y y' : A} (p : x ≡ y) (q : y ≡ y') → subst (λ y → x ≡ y) q p ≡ p ∙ q substInPathsL
transporting a path along its left end amounts to reverse composition
: {A : Type ℓ} {x x' y : A} (p : x ≡ x') (q : x ≡ y) → subst (λ x → x ≡ y) p q ≡ sym p ∙ q substInPathsR
the following generalization of the two previous lemmas
: {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 p substInPaths
Define the type of paths in a type family over another path as
: {A : Type ℓ} (B : A → Type ℓ') {x y : A} (p : x ≡ y) (x' : B x) (y' : B y) → Type ℓ'
PathOver = subst B p x' ≡ y' PathOver 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
: {A : Type ℓ} (B : A → Type ℓ') (f : (x : A) → B x) {x y : A} (p : x ≡ y) → PathOver B p (f x) (f y) congP
This function is called apd in the course.
Show the following results about the transport of functions:
transporting the target of a function:
: {A : Type ℓ} {B B' : Type ℓ'} (p : B ≡ B') (f : A → B) → subst (λ X → A → X) p f ≡ transport p ∘ f funTypeTranspR
transporting the source of a function:
: {A A' : Type ℓ} {B : Type ℓ'} (p : A ≡ A') (f : A → B) → subst (λ X → X → B) p f ≡ f ∘ transport (sym p) funTypeTranspL
transporting both the source and target of a function:
: {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)) funTypeTransp
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:
: Type₁
UIP = {A : Type} {x y : A} (p q : x ≡ y) → p ≡ q UIP
uniqueness of reflexivity proofs:
: Type₁
URP = {A : Set} {x : A} (p : x ≡ x) → p ≡ refl URP
Streicher’s axiom K
: Type₁
K = {A : Type} {x : A} (P : (x ≡ x) → Set) → P refl → (p : x ≡ x) → P p K
Show that they are logically equivalent by proving the following implications
: UIP → URP UIP→URP
: URP → UIP URP→UIP
: URP → K URP→K
: K → URP K→URP
Define Leibniz equality as
_==_ : {ℓ : Level} {A : Type ℓ} → A → A → Type _
_==_ {ℓ} {A} x y = (P : A → Type ℓ) → P x → P y
Show that Leibniz equality is reflexive
: {A : Type ℓ} {x : A} → x == x Lrefl
symmetric
: {A : Type ℓ} {x y : A} → x == y → y == x Lsym
and transitive
: {A : Type ℓ} {x y z : A} → x == y → y == z → x == z Ltrans
Show that we can convert Leibniz equalities to identity types
: {A : Type ℓ} {x y : A} → x == y → x ≡ y Lto≡
and the converse
: {A : Type ℓ} {x y : A} → x ≡ y → x == y ≡toL
Show that those functions form a section retraction pair:
: {A : Type ℓ} {x y : A} (p : x ≡ y) → Lto≡ (≡toL p) ≡ p ≡to≡
Show the Eckmann-Hilton
property: composition is commutative for paths between
refl
.
: {A : Type ℓ} {x : A} (α β : refl {x = x} ≡ refl) → α ∙ β ≡ β ∙ α EH
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.