Equivalence-Induction
Martin Escardo 1st May 2020.
This is ported from the Midlands Graduate School 2019 lecture notes
https://www.cs.bham.ac.uk/~mhe/HoTT-UF.in-Agda-Lecture-Notes/HoTT-UF-Agda.html
https://github.com/martinescardo/HoTT-UF.Agda-Lecture-Notes
{-# OPTIONS --safe --without-K #-}
module MGS.Equivalence-Induction where
open import MGS.Univalence public
open import MGS.Solved-Exercises public
equiv-singleton-lemma : {X : ๐ค ฬ } {A : X โ ๐ฅ ฬ } (x : X)
(f : (y : X) โ x ๏ผ y โ A y)
โ ((y : X) โ is-equiv (f y))
โ is-singleton (ฮฃ A)
equiv-singleton-lemma {๐ค} {๐ฅ} {X} {A} x f i = ฮณ
where
e : (y : X) โ (x ๏ผ y) โ A y
e y = (f y , i y)
d : singleton-type' x โ ฮฃ A
d = ฮฃ-cong e
abstract
ฮณ : is-singleton (ฮฃ A)
ฮณ = equiv-to-singleton (โ-sym d) (singleton-types'-are-singletons X x)
singleton-equiv-lemma : {X : ๐ค ฬ } {A : X โ ๐ฅ ฬ } (x : X)
(f : (y : X) โ x ๏ผ y โ A y)
โ is-singleton (ฮฃ A)
โ (y : X) โ is-equiv (f y)
singleton-equiv-lemma {๐ค} {๐ฅ} {X} {A} x f i = ฮณ
where
g : singleton-type' x โ ฮฃ A
g = Natฮฃ f
e : is-equiv g
e = maps-of-singletons-are-equivs g (singleton-types'-are-singletons X x) i
abstract
ฮณ : (y : X) โ is-equiv (f y)
ฮณ = Natฮฃ-equiv-gives-fiberwise-equiv f e
univalenceโ : is-univalent ๐ค
โ (X : ๐ค ฬ ) โ is-singleton (ฮฃ Y ๊ ๐ค ฬ , X โ Y)
univalenceโ ua X = equiv-singleton-lemma X (IdโEq X) (ua X)
โunivalence : ((X : ๐ค ฬ ) โ is-singleton (ฮฃ Y ๊ ๐ค ฬ , X โ Y))
โ is-univalent ๐ค
โunivalence i X = singleton-equiv-lemma X (IdโEq X) (i X)
univalenceโ : is-univalent ๐ค
โ (X : ๐ค ฬ ) โ is-subsingleton (ฮฃ Y ๊ ๐ค ฬ , X โ Y)
univalenceโ ua X = singletons-are-subsingletons
(ฮฃ (X โ_)) (univalenceโ ua X)
โunivalence : ((X : ๐ค ฬ ) โ is-subsingleton (ฮฃ Y ๊ ๐ค ฬ , X โ Y))
โ is-univalent ๐ค
โunivalence i = โunivalence (ฮป X โ pointed-subsingletons-are-singletons
(ฮฃ (X โ_)) (X , id-โ X) (i X))
๐พ-โ : is-univalent ๐ค
โ (X : ๐ค ฬ ) (A : (ฮฃ Y ๊ ๐ค ฬ , X โ Y) โ ๐ฅ ฬ )
โ A (X , id-โ X) โ (Y : ๐ค ฬ ) (e : X โ Y) โ A (Y , e)
๐พ-โ {๐ค} ua X A a Y e = transport A p a
where
t : ฮฃ Y ๊ ๐ค ฬ , X โ Y
t = (X , id-โ X)
p : t ๏ผ (Y , e)
p = univalenceโ {๐ค} ua X t (Y , e)
๐พ-โ-equation : (ua : is-univalent ๐ค)
โ (X : ๐ค ฬ ) (A : (ฮฃ Y ๊ ๐ค ฬ , X โ Y) โ ๐ฅ ฬ ) (a : A (X , id-โ X))
โ ๐พ-โ ua X A a X (id-โ X) ๏ผ a
๐พ-โ-equation {๐ค} {๐ฅ} ua X A a =
๐พ-โ ua X A a X (id-โ X) ๏ผโจ refl _ โฉ
transport A p a ๏ผโจ ap (ฮป - โ transport A - a) q โฉ
transport A (refl t) a ๏ผโจ refl _ โฉ
a โ
where
t : ฮฃ Y ๊ ๐ค ฬ , X โ Y
t = (X , id-โ X)
p : t ๏ผ t
p = univalenceโ {๐ค} ua X t t
q : p ๏ผ refl t
q = subsingletons-are-sets (ฮฃ Y ๊ ๐ค ฬ , X โ Y)
(univalenceโ {๐ค} ua X) t t p (refl t)
โ-โ : is-univalent ๐ค
โ (X : ๐ค ฬ ) (A : (Y : ๐ค ฬ ) โ X โ Y โ ๐ฅ ฬ )
โ A X (id-โ X) โ (Y : ๐ค ฬ ) (e : X โ Y) โ A Y e
โ-โ ua X A = ๐พ-โ ua X (ฮฃ-induction A)
โ-โ-equation : (ua : is-univalent ๐ค)
โ (X : ๐ค ฬ ) (A : (Y : ๐ค ฬ ) โ X โ Y โ ๐ฅ ฬ ) (a : A X (id-โ X))
โ โ-โ ua X A a X (id-โ X) ๏ผ a
โ-โ-equation ua X A = ๐พ-โ-equation ua X (ฮฃ-induction A)
๐-โ : is-univalent ๐ค
โ (A : (X Y : ๐ค ฬ ) โ X โ Y โ ๐ฅ ฬ )
โ ((X : ๐ค ฬ ) โ A X X (id-โ X))
โ (X Y : ๐ค ฬ ) (e : X โ Y) โ A X Y e
๐-โ ua A ฯ X = โ-โ ua X (A X) (ฯ X)
๐-โ-equation : (ua : is-univalent ๐ค)
โ (A : (X Y : ๐ค ฬ ) โ X โ Y โ ๐ฅ ฬ )
โ (ฯ : (X : ๐ค ฬ ) โ A X X (id-โ X))
โ (X : ๐ค ฬ ) โ ๐-โ ua A ฯ X X (id-โ X) ๏ผ ฯ X
๐-โ-equation ua A ฯ X = โ-โ-equation ua X (A X) (ฯ X)
โ-equiv : is-univalent ๐ค
โ (X : ๐ค ฬ ) (A : (Y : ๐ค ฬ ) โ (X โ Y) โ ๐ฅ ฬ )
โ A X (๐๐ X) โ (Y : ๐ค ฬ ) (f : X โ Y) โ is-equiv f โ A Y f
โ-equiv {๐ค} {๐ฅ} ua X A a Y f i = ฮณ (f , i)
where
B : (Y : ๐ค ฬ ) โ X โ Y โ ๐ฅ ฬ
B Y (f , i) = A Y f
b : B X (id-โ X)
b = a
ฮณ : (e : X โ Y) โ B Y e
ฮณ = โ-โ ua X B b Y
๐-equiv : is-univalent ๐ค
โ (A : (X Y : ๐ค ฬ ) โ (X โ Y) โ ๐ฅ ฬ )
โ ((X : ๐ค ฬ ) โ A X X (๐๐ X))
โ (X Y : ๐ค ฬ ) (f : X โ Y) โ is-equiv f โ A X Y f
๐-equiv ua A ฯ X = โ-equiv ua X (A X) (ฯ X)
๐-invertible : is-univalent ๐ค
โ (A : (X Y : ๐ค ฬ ) โ (X โ Y) โ ๐ฅ ฬ )
โ ((X : ๐ค ฬ ) โ A X X (๐๐ X))
โ (X Y : ๐ค ฬ ) (f : X โ Y) โ invertible f โ A X Y f
๐-invertible ua A ฯ X Y f i = ๐-equiv ua A ฯ X Y f (invertibles-are-equivs f i)
automatic-equiv-functoriality :
(F : ๐ค ฬ โ ๐ค ฬ )
(๐ : {X Y : ๐ค ฬ } โ (X โ Y) โ F X โ F Y)
(๐-id : {X : ๐ค ฬ } โ ๐ (๐๐ X) ๏ผ ๐๐ (F X))
{X Y Z : ๐ค ฬ }
(f : X โ Y)
(g : Y โ Z)
โ is-univalent ๐ค โ is-equiv f + is-equiv g โ ๐ (g โ f) ๏ผ ๐ g โ ๐ f
automatic-equiv-functoriality {๐ค} F ๐ ๐-id {X} {Y} {Z} f g ua = ฮณ
where
ฮณ : is-equiv f + is-equiv g โ ๐ (g โ f) ๏ผ ๐ g โ ๐ f
ฮณ (inl i) = โ-equiv ua X A a Y f i g
where
A : (Y : ๐ค ฬ ) โ (X โ Y) โ ๐ค ฬ
A Y f = (g : Y โ Z) โ ๐ (g โ f) ๏ผ ๐ g โ ๐ f
a : (g : X โ Z) โ ๐ g ๏ผ ๐ g โ ๐ id
a g = ap (๐ g โ_) (๐-id โปยน)
ฮณ (inr j) = โ-equiv ua Y B b Z g j f
where
B : (Z : ๐ค ฬ ) โ (Y โ Z) โ ๐ค ฬ
B Z g = (f : X โ Y) โ ๐ (g โ f) ๏ผ ๐ g โ ๐ f
b : (f : X โ Y) โ ๐ f ๏ผ ๐ (๐๐ Y) โ ๐ f
b f = ap (_โ ๐ f) (๐-id โปยน)
ฮฃ-change-of-variable' : is-univalent ๐ค
โ {X : ๐ค ฬ } {Y : ๐ค ฬ } (A : X โ ๐ฅ ฬ ) (f : X โ Y)
โ (i : is-equiv f)
โ (ฮฃ x ๊ X , A x) ๏ผ (ฮฃ y ๊ Y , A (inverse f i y))
ฮฃ-change-of-variable' {๐ค} {๐ฅ} ua {X} {Y} A f i = โ-โ ua X B b Y (f , i)
where
B : (Y : ๐ค ฬ ) โ X โ Y โ (๐ค โ ๐ฅ)โบ ฬ
B Y (f , i) = ฮฃ A ๏ผ (ฮฃ (A โ inverse f i))
b : B X (id-โ X)
b = refl (ฮฃ A)
ฮฃ-change-of-variable'' : is-univalent ๐ค
โ {X : ๐ค ฬ } {Y : ๐ค ฬ } (A : Y โ ๐ฅ ฬ ) (f : X โ Y)
โ is-equiv f
โ (ฮฃ y ๊ Y , A y) ๏ผ (ฮฃ x ๊ X , A (f x))
ฮฃ-change-of-variable'' ua A f i = ฮฃ-change-of-variable' ua A
(inverse f i)
(inverses-are-equivs f i)
transport-map-along-๏ผ : {X Y Z : ๐ค ฬ }
(p : X ๏ผ Y) (g : X โ Z)
โ transport (ฮป - โ - โ Z) p g
๏ผ g โ Idโfun (p โปยน)
transport-map-along-๏ผ (refl X) = refl
transport-map-along-โ : (ua : is-univalent ๐ค) {X Y Z : ๐ค ฬ }
(e : X โ Y) (g : X โ Z)
โ transport (ฮป - โ - โ Z) (EqโId ua X Y e) g
๏ผ g โ โ โ-sym e โ
transport-map-along-โ {๐ค} ua {X} {Y} {Z} = ๐-โ ua A a X Y
where
A : (X Y : ๐ค ฬ ) โ X โ Y โ ๐ค ฬ
A X Y e = (g : X โ Z) โ transport (ฮป - โ - โ Z) (EqโId ua X Y e) g
๏ผ g โ โ โ-sym e โ
a : (X : ๐ค ฬ ) โ A X X (id-โ X)
a X g = transport (ฮป - โ - โ Z) (EqโId ua X X (id-โ X)) g ๏ผโจ q โฉ
transport (ฮป - โ - โ Z) (refl X) g ๏ผโจ refl _ โฉ
g โ
where
p : EqโId ua X X (id-โ X) ๏ผ refl X
p = inverses-are-retractions (IdโEq X X) (ua X X) (refl X)
q = ap (ฮป - โ transport (ฮป - โ - โ Z) - g) p