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
\begin{code}
{-# OPTIONS --safe --without-K #-}
module MGS.Yoneda where
open import MGS.Unique-Existence public
open import MGS.Embeddings public
π¨ : {X : π€ Μ } β X β (X β π€ Μ )
π¨ {π€} {X} = Id X
π : (X : π€ Μ ) β X β (X β π€ Μ )
π {π€} X = π¨ {π€} {X}
transport-lemma : {X : π€ Μ } (A : X β π₯ Μ ) (x : X)
β (Ο : Nat (π¨ x) A)
β (y : X) (p : x οΌ y) β Ο y p οΌ transport A p (Ο x (refl x))
transport-lemma A x Ο x (refl x) = refl (Ο x (refl x))
π : {X : π€ Μ } (A : X β π₯ Μ ) (x : X) β Nat (π¨ x) A β A x
π A x Ο = Ο x (refl x)
π : {X : π€ Μ } (A : X β π₯ Μ ) (x : X) β A x β Nat (π¨ x) A
π A x a y p = transport A p a
yoneda-Ξ· : dfunext π€ (π€ β π₯) β dfunext π€ π₯
β {X : π€ Μ } (A : X β π₯ Μ ) (x : X)
β π A x β π A x βΌ id
yoneda-Ξ· fe fe' A x = Ξ³
where
Ξ³ : (Ο : Nat (π¨ x) A) β (Ξ» y p β transport A p (Ο x (refl x))) οΌ Ο
Ξ³ Ο = fe (Ξ» y β fe' (Ξ» p β (transport-lemma A x Ο y p)β»ΒΉ))
yoneda-Ξ΅ : {X : π€ Μ } (A : X β π₯ Μ ) (x : X)
β π A x β π A x βΌ id
yoneda-Ξ΅ A x = Ξ³
where
Ξ³ : (a : A x) β transport A (refl x) a οΌ a
Ξ³ = refl
is-fiberwise-equiv : {X : π€ Μ } {A : X β π₯ Μ } {B : X β π¦ Μ } β Nat A B β π€ β π₯ β π¦ Μ
is-fiberwise-equiv Ο = β x β is-equiv (Ο x)
π-is-equiv : dfunext π€ (π€ β π₯) β dfunext π€ π₯
β {X : π€ Μ } (A : X β π₯ Μ )
β is-fiberwise-equiv (π A)
π-is-equiv fe fe' A x = invertibles-are-equivs (π A x )
(π A x , yoneda-Ξ· fe fe' A x , yoneda-Ξ΅ A x)
π-is-equiv : dfunext π€ (π€ β π₯) β dfunext π€ π₯
β {X : π€ Μ } (A : X β π₯ Μ )
β is-fiberwise-equiv (π A)
π-is-equiv fe fe' A x = invertibles-are-equivs (π A x)
(π A x , yoneda-Ξ΅ A x , yoneda-Ξ· fe fe' A x)
Yoneda-Lemma : dfunext π€ (π€ β π₯) β dfunext π€ π₯
β {X : π€ Μ } (A : X β π₯ Μ ) (x : X)
β Nat (π¨ x) A β A x
Yoneda-Lemma fe fe' A x = π A x , π-is-equiv fe fe' A x
retract-universal-lemma : {X : π€ Μ } (A : X β π₯ Μ ) (x : X)
β ((y : X) β A y β (x οΌ y))
β β! A
retract-universal-lemma A x Ο = i
where
Ο : Ξ£ A β singleton-type' x
Ο = Ξ£-retract Ο
i : β! A
i = retract-of-singleton Ο (singleton-types'-are-singletons (domain A) x)
fiberwise-equiv-universal : {X : π€ Μ } (A : X β π₯ Μ )
(x : X) (Ο : Nat (π¨ x) A)
β is-fiberwise-equiv Ο
β β! A
fiberwise-equiv-universal A x Ο e = retract-universal-lemma A x Ο
where
Ο : β y β A y β (x οΌ y)
Ο y = β-gives-β· ((Ο y) , e y)
universal-fiberwise-equiv : {X : π€ Μ } (A : X β π₯ Μ )
β β! A
β (x : X) (Ο : Nat (π¨ x) A) β is-fiberwise-equiv Ο
universal-fiberwise-equiv {π€} {π₯} {X} A u x Ο = Ξ³
where
g : singleton-type' x β Ξ£ A
g = NatΞ£ Ο
e : is-equiv g
e = maps-of-singletons-are-equivs g (singleton-types'-are-singletons X x) u
Ξ³ : is-fiberwise-equiv Ο
Ξ³ = NatΞ£-equiv-gives-fiberwise-equiv Ο e
hfunextβ : hfunext π€ π₯
β ((X : π€ Μ ) (A : X β π₯ Μ ) (f : Ξ A) β β! g κ Ξ A , f βΌ g)
hfunextβ hfe X A f = fiberwise-equiv-universal (f βΌ_) f (happly f) (hfe f)
βhfunext : ((X : π€ Μ ) (A : X β π₯ Μ ) (f : Ξ A) β β! g κ Ξ A , f βΌ g)
β hfunext π€ π₯
βhfunext Ο {X} {A} f = universal-fiberwise-equiv (f βΌ_) (Ο X A f) f (happly f)
fiberwise-equiv-criterion : {X : π€ Μ } (A : X β π₯ Μ )
(x : X)
β ((y : X) β A y β (x οΌ y))
β (Ο : Nat (π¨ x) A) β is-fiberwise-equiv Ο
fiberwise-equiv-criterion A x Ο Ο = universal-fiberwise-equiv A
(retract-universal-lemma A x Ο) x Ο
fiberwise-equiv-criterion' : {X : π€ Μ } (A : X β π₯ Μ )
(x : X)
β ((y : X) β (x οΌ y) β A y)
β (Ο : Nat (π¨ x) A) β is-fiberwise-equiv Ο
fiberwise-equiv-criterion' A x e = fiberwise-equiv-criterion A x
(Ξ» y β β-gives-β· (e y))
_βΜ_ : {X : π€ Μ } β (X β π₯ Μ ) β (X β π¦ Μ ) β π€ β π₯ β π¦ Μ
A βΜ B = β x β A x β B x
is-representable : {X : π€ Μ } β (X β π₯ Μ ) β π€ β π₯ Μ
is-representable A = Ξ£ x κ domain A , π¨ x βΜ A
representable-universal : {X : π€ Μ } (A : X β π₯ Μ )
β is-representable A
β β! A
representable-universal A (x , e) = retract-universal-lemma A x
(Ξ» x β β-gives-β· (e x))
universal-representable : {X : π€ Μ } {A : X β π₯ Μ }
β β! A
β is-representable A
universal-representable {π€} {π₯} {X} {A} ((x , a) , p) = x , Ο
where
e : is-fiberwise-equiv (π A x a)
e = universal-fiberwise-equiv A ((x , a) , p) x (π A x a)
Ο : (y : X) β (x οΌ y) β A y
Ο y = (π A x a y , e y)
fiberwise-retractions-are-equivs : {X : π€ Μ } (A : X β π₯ Μ ) (x : X)
β (Ο : Nat (π¨ x) A)
β ((y : X) β has-section (Ο y))
β is-fiberwise-equiv Ο
fiberwise-retractions-are-equivs {π€} {π₯} {X} A x Ο s = Ξ³
where
Ο : (y : X) β A y β (x οΌ y)
Ο y = Ο y , s y
i : β! A
i = retract-universal-lemma A x Ο
Ξ³ : is-fiberwise-equiv Ο
Ξ³ = universal-fiberwise-equiv A i x Ο
fiberwise-β-gives-β : (X : π€ Μ ) (A : X β π₯ Μ ) (x : X)
β ((y : X) β A y β (x οΌ y))
β ((y : X) β A y β (x οΌ y))
fiberwise-β-gives-β X A x Ο = Ξ³
where
f : (y : X) β (x οΌ y) β A y
f y = retraction (Ο y)
e : is-fiberwise-equiv f
e = fiberwise-retractions-are-equivs A x f (Ξ» y β retraction-has-section (Ο y))
Ξ³ : (y : X) β A y β (x οΌ y)
Ξ³ y = β-sym (f y , e y)
embedding-criterion' : {X : π€ Μ } {Y : π₯ Μ } (f : X β Y)
β ((x x' : X) β (f x οΌ f x') β (x οΌ x'))
β is-embedding f
embedding-criterion' f Ο = embedding-criterion f
(Ξ» x β fiberwise-β-gives-β (domain f)
(Ξ» - β f x οΌ f -) x (Ο x))
being-fiberwise-equiv-is-subsingleton : global-dfunext
β {X : π€ Μ } {A : X β π₯ Μ } {B : X β π¦ Μ }
β (Ο : Nat A B)
β is-subsingleton (is-fiberwise-equiv Ο)
being-fiberwise-equiv-is-subsingleton fe Ο =
Ξ -is-subsingleton fe (Ξ» y β being-equiv-is-subsingleton fe fe (Ο y))
being-representable-is-subsingleton : global-dfunext
β {X : π€ Μ } (A : X β π₯ Μ )
β is-subsingleton (is-representable A)
being-representable-is-subsingleton fe {X} A rβ rβ = Ξ³
where
u : β! A
u = representable-universal A rβ
i : (x : X) (Ο : Nat (π¨ x) A) β is-singleton (is-fiberwise-equiv Ο)
i x Ο = pointed-subsingletons-are-singletons
(is-fiberwise-equiv Ο)
(universal-fiberwise-equiv A u x Ο)
(being-fiberwise-equiv-is-subsingleton fe Ο)
Ξ΅ : (x : X) β (π¨ x βΜ A) β A x
Ξ΅ x = ((y : X) β π¨ x y β A y) ββ¨ Ξ Ξ£-distr-β β©
(Ξ£ Ο κ Nat (π¨ x) A , is-fiberwise-equiv Ο) ββ¨ prβ-β (i x) β©
Nat (π¨ x) A ββ¨ Yoneda-Lemma fe fe A x β©
A x β
Ξ΄ : is-representable A β Ξ£ A
Ξ΄ = Ξ£-cong Ξ΅
v : is-singleton (is-representable A)
v = equiv-to-singleton Ξ΄ u
Ξ³ : rβ οΌ rβ
Ξ³ = singletons-are-subsingletons (is-representable A) v rβ rβ
π¨-is-embedding : Univalence β (X : π€ Μ ) β is-embedding (π X)
π¨-is-embedding {π€} ua X A = Ξ³
where
hfe : global-hfunext
hfe = univalence-gives-global-hfunext ua
dfe : global-dfunext
dfe = univalence-gives-global-dfunext ua
p = Ξ» x β (π¨ x οΌ A) ββ¨ i x β©
((y : X) β π¨ x y οΌ A y) ββ¨ ii x β©
((y : X) β π¨ x y β A y) β
where
i = Ξ» x β (happly (π¨ x) A , hfe (π¨ x) A)
ii = Ξ» x β Ξ -cong dfe dfe
(Ξ» y β univalence-β (ua π€)
(π¨ x y) (A y))
e : fiber π¨ A β is-representable A
e = Ξ£-cong p
Ξ³ : is-subsingleton (fiber π¨ A)
Ξ³ = equiv-to-subsingleton e (being-representable-is-subsingleton dfe A)
\end{code}