MGS.More-FunExt-Consequences
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.More-FunExt-Consequences where
open import MGS.HAE public
open import MGS.Subsingleton-Theorems public
being-subsingleton-is-subsingleton : dfunext š¤ š¤
ā {X : š¤ Ģ }
ā is-subsingleton (is-subsingleton X)
being-subsingleton-is-subsingleton fe {X} i j = c
where
l : is-set X
l = subsingletons-are-sets X i
a : (x y : X) ā i x y ļ¼ j x y
a x y = l x y (i x y) (j x y)
b : (x : X) ā i x ļ¼ j x
b x = fe (a x)
c : i ļ¼ j
c = fe b
being-center-is-subsingleton : dfunext š¤ š¤
ā {X : š¤ Ģ } (c : X)
ā is-subsingleton (is-center X c)
being-center-is-subsingleton fe {X} c Ļ Ī³ = k
where
i : is-singleton X
i = c , Ļ
j : (x : X) ā is-subsingleton (c ļ¼ x)
j x = singletons-are-sets X i c x
k : Ļ ļ¼ Ī³
k = fe (Ī» x ā j x (Ļ x) (γ x))
Ī -is-set : hfunext š¤ š„
ā {X : š¤ Ģ } {A : X ā š„ Ģ }
ā ((x : X) ā is-set (A x)) ā is-set (Ī A)
Ī -is-set hfe s f g = b
where
a : is-subsingleton (f ā¼ g)
a p q = γ
where
h : ā x ā p x ļ¼ q x
h x = s x (f x) (g x) (p x) (q x)
γ : p ļ¼ q
γ = hfunext-gives-dfunext hfe h
e : (f ļ¼ g) ā (f ā¼ g)
e = (happly f g , hfe f g)
b : is-subsingleton (f ļ¼ g)
b = equiv-to-subsingleton e a
being-set-is-subsingleton : dfunext š¤ š¤
ā {X : š¤ Ģ }
ā is-subsingleton (is-set X)
being-set-is-subsingleton fe = Ī -is-subsingleton fe
(Ī» x ā Ī -is-subsingleton fe
(Ī» y ā being-subsingleton-is-subsingleton fe))
hlevel-relation-is-subsingleton : dfunext š¤ š¤
ā (n : ā) (X : š¤ Ģ )
ā is-subsingleton (X is-of-hlevel n)
hlevel-relation-is-subsingleton {š¤} fe zero X =
being-singleton-is-subsingleton fe
hlevel-relation-is-subsingleton fe (succ n) X =
Ī -is-subsingleton fe
(Ī» x ā Ī -is-subsingleton fe
(Ī» x' ā hlevel-relation-is-subsingleton fe n (x ļ¼ x')))
ā-assoc : dfunext š£ (š¤ ā š£) ā dfunext (š¤ ā š£) (š¤ ā š£)
ā {X : š¤ Ģ } {Y : š„ Ģ } {Z : š¦ Ģ } {T : š£ Ģ }
(α : X ā Y) (β : Y ā Z) (γ : Z ā T)
ā α ā (β ā γ) ļ¼ (α ā β) ā γ
ā-assoc fe fe' (f , a) (g , b) (h , c) = ap (h ā g ā f ,_) q
where
d e : is-equiv (h ā g ā f)
d = ā-is-equiv (ā-is-equiv c b) a
e = ā-is-equiv c (ā-is-equiv b a)
q : d ļ¼ e
q = being-equiv-is-subsingleton fe fe' (h ā g ā f) _ _
ā-sym-involutive : dfunext š„ (š¤ ā š„) ā dfunext (š¤ ā š„) (š¤ ā š„) ā
{X : š¤ Ģ } {Y : š„ Ģ } (α : X ā Y)
ā ā-sym (ā-sym α) ļ¼ Ī±
ā-sym-involutive fe fe' (f , a) = to-subtype-ļ¼
(being-equiv-is-subsingleton fe fe')
(inversion-involutive f a)
ā-sym-is-equiv : dfunext š„ (š¤ ā š„) ā dfunext š¤ (š¤ ā š„) ā dfunext (š¤ ā š„) (š¤ ā š„)
ā {X : š¤ Ģ } {Y : š„ Ģ }
ā is-equiv (ā-sym {š¤} {š„} {X} {Y})
ā-sym-is-equiv feā feā feā = invertibles-are-equivs ā-sym
(ā-sym ,
ā-sym-involutive feā feā ,
ā-sym-involutive feā feā)
ā-sym-ā : dfunext š„ (š¤ ā š„) ā dfunext š¤ (š¤ ā š„) ā dfunext (š¤ ā š„) (š¤ ā š„)
ā (X : š¤ Ģ ) (Y : š„ Ģ )
ā (X ā Y) ā (Y ā X)
ā-sym-ā feā feā feā X Y = ā-sym , ā-sym-is-equiv feā feā feā
Ī -cong : dfunext š¤ š„ ā dfunext š¤ š¦
ā {X : š¤ Ģ } {Y : X ā š„ Ģ } {Y' : X ā š¦ Ģ }
ā ((x : X) ā Y x ā Y' x) ā Ī Y ā Ī Y'
Ī -cong fe fe' {X} {Y} {Y'} Ļ = invertibility-gives-ā F (G , GF , FG)
where
f : (x : X) ā Y x ā Y' x
f x = ā Ļ x ā
e : (x : X) ā is-equiv (f x)
e x = āā-is-equiv (Ļ x)
g : (x : X) ā Y' x ā Y x
g x = inverse (f x) (e x)
fg : (x : X) (y' : Y' x) ā f x (g x y') ļ¼ y'
fg x = inverses-are-sections (f x) (e x)
gf : (x : X) (y : Y x) ā g x (f x y) ļ¼ y
gf x = inverses-are-retractions (f x) (e x)
F : ((x : X) ā Y x) ā ((x : X) ā Y' x)
F Ļ x = f x (Ļ x)
G : ((x : X) ā Y' x) ā (x : X) ā Y x
G γ x = g x (γ x)
FG : (γ : ((x : X) ā Y' x)) ā F (G γ) ļ¼ Ī³
FG γ = fe' (Ī» x ā fg x (γ x))
GF : (Ļ : ((x : X) ā Y x)) ā G (F Ļ) ļ¼ Ļ
GF Ļ = fe (Ī» x ā gf x (Ļ x))
hfunext-ā : hfunext š¤ š„
ā {X : š¤ Ģ } {A : X ā š„ Ģ } (f g : Ī A)
ā (f ļ¼ g) ā (f ā¼ g)
hfunext-ā hfe f g = (happly f g , hfe f g)
hfunextā-ā : hfunext š¤ (š„ ā š¦) ā hfunext š„ š¦
ā {X : š¤ Ģ } {Y : X ā š„ Ģ } {A : (x : X) ā Y x ā š¦ Ģ }
(f g : (x : X) (y : Y x) ā A x y)
ā (f ļ¼ g) ā (ā x y ā f x y ļ¼ g x y)
hfunextā-ā fe fe' {X} f g =
(f ļ¼ g) ā⨠i ā©
(ā x ā f x ļ¼ g x) ā⨠ii ā©
(ā x y ā f x y ļ¼ g x y) ā
where
i = hfunext-ā fe f g
ii = Ī -cong
(hfunext-gives-dfunext fe)
(hfunext-gives-dfunext fe)
(Ī» x ā hfunext-ā fe' (f x) (g x))
precomp-invertible : dfunext š„ š¦ ā dfunext š¤ š¦
ā {X : š¤ Ģ } {Y : š„ Ģ } {Z : š¦ Ģ } (f : X ā Y)
ā invertible f
ā invertible (Ī» (h : Y ā Z) ā h ā f)
precomp-invertible fe fe' {X} {Y} {Z} f (g , η , ε) = (g' , η' , ε')
where
f' : (Y ā Z) ā (X ā Z)
f' h = h ā f
g' : (X ā Z) ā (Y ā Z)
g' k = k ā g
Ī·' : (h : Y ā Z) ā g' (f' h) ļ¼ h
Ī·' h = fe (Ī» y ā ap h (ε y))
ε' : (k : X ā Z) ā f' (g' k) ļ¼ k
ε' k = fe' (Ī» x ā ap k (Ī· x))
dprecomp : {X : š¤ Ģ } {Y : š„ Ģ } (A : Y ā š¦ Ģ ) (f : X ā Y)
ā Ī A ā Ī (A ā f)
dprecomp A f = _ā f
dprecomp-is-equiv : dfunext š¤ š¦
ā dfunext š„ š¦
ā {X : š¤ Ģ } {Y : š„ Ģ } (A : Y ā š¦ Ģ ) (f : X ā Y)
ā is-equiv f
ā is-equiv (dprecomp A f)
dprecomp-is-equiv fe fe' {X} {Y} A f i = invertibles-are-equivs Ļ (Ļ , ĻĻ , ĻĻ)
where
g = inverse f i
Ī· = inverses-are-retractions f i
ε = inverses-are-sections f i
Ļ : (x : X) ā ap f (Ī· x) ļ¼ Īµ (f x)
Ļ = half-adjoint-condition f i
Ļ : Ī A ā Ī (A ā f)
Ļ = dprecomp A f
Ļ : Ī (A ā f) ā Ī A
Ļ k y = transport A (ε y) (k (g y))
ĻĻā : (k : Ī (A ā f)) (x : X) ā transport A (ε (f x)) (k (g (f x))) ļ¼ k x
ĻĻā k x = transport A (ε (f x)) (k (g (f x))) ļ¼āØ a ā©
transport A (ap f (Ī· x))(k (g (f x))) ļ¼āØ b ā©
transport (A ā f) (Ī· x) (k (g (f x))) ļ¼āØ c ā©
k x ā
where
a = ap (Ī» - ā transport A - (k (g (f x)))) ((Ļ x)ā»Ā¹)
b = (transport-ap A f (Ī· x) (k (g (f x))))ā»Ā¹
c = apd k (Ī· x)
ĻĻ : Ļ ā Ļ ā¼ id
ĻĻ k = fe (ĻĻā k)
ĻĻā : (h : Ī A) (y : Y) ā transport A (ε y) (h (f (g y))) ļ¼ h y
ĻĻā h y = apd h (ε y)
ĻĻ : Ļ ā Ļ ā¼ id
ĻĻ h = fe' (ĻĻā h)
Ī -change-of-variable : dfunext š¤ š¦
ā dfunext š„ š¦
ā {X : š¤ Ģ } {Y : š„ Ģ } (A : Y ā š¦ Ģ ) (f : X ā Y)
ā is-equiv f
ā (Ī y ź Y , A y) ā (Ī x ź X , A (f x))
Ī -change-of-variable fe fe' A f i = dprecomp A f , dprecomp-is-equiv fe fe' A f i
at-most-one-section : dfunext š„ š¤ ā hfunext š„ š„
ā {X : š¤ Ģ } {Y : š„ Ģ } (f : X ā Y)
ā has-retraction f
ā is-subsingleton (has-section f)
at-most-one-section {š„} {š¤} fe hfe {X} {Y} f (g , gf) (h , fh) = d
where
fe' : dfunext š„ š„
fe' = hfunext-gives-dfunext hfe
a : invertible f
a = joyal-equivs-are-invertible f ((h , fh) , (g , gf))
b : is-singleton (fiber (Ī» h ā f ā h) id)
b = invertibles-are-equivs (Ī» h ā f ā h) (postcomp-invertible fe fe' f a) id
r : fiber (Ī» h ā f ā h) id ā has-section f
r (h , p) = (h , happly (f ā h) id p)
s : has-section f ā fiber (Ī» h ā f ā h) id
s (h , Ī·) = (h , fe' Ī·)
rs : (Ļ : has-section f) ā r (s Ļ) ļ¼ Ļ
rs (h , Ī·) = to-Ī£-ļ¼' q
where
q : happly (f ā h) id (inverse (happly (f ā h) id) (hfe (f ā h) id) Ī·) ļ¼ Ī·
q = inverses-are-sections (happly (f ā h) id) (hfe (f ā h) id) Ī·
c : is-singleton (has-section f)
c = retract-of-singleton (r , s , rs) b
d : (Ļ : has-section f) ā h , fh ļ¼ Ļ
d = singletons-are-subsingletons (has-section f) c (h , fh)
at-most-one-retraction : hfunext š¤ š¤ ā dfunext š„ š¤
ā {X : š¤ Ģ } {Y : š„ Ģ } (f : X ā Y)
ā has-section f
ā is-subsingleton (has-retraction f)
at-most-one-retraction {š¤} {š„} hfe fe' {X} {Y} f (g , fg) (h , hf) = d
where
fe : dfunext š¤ š¤
fe = hfunext-gives-dfunext hfe
a : invertible f
a = joyal-equivs-are-invertible f ((g , fg) , (h , hf))
b : is-singleton (fiber (Ī» h ā h ā f) id)
b = invertibles-are-equivs (Ī» h ā h ā f) (precomp-invertible fe' fe f a) id
r : fiber (Ī» h ā h ā f) id ā has-retraction f
r (h , p) = (h , happly (h ā f) id p)
s : has-retraction f ā fiber (Ī» h ā h ā f) id
s (h , Ī·) = (h , fe Ī·)
rs : (Ļ : has-retraction f) ā r (s Ļ) ļ¼ Ļ
rs (h , Ī·) = to-Ī£-ļ¼' q
where
q : happly (h ā f) id (inverse (happly (h ā f) id) (hfe (h ā f) id) Ī·) ļ¼ Ī·
q = inverses-are-sections (happly (h ā f) id) (hfe (h ā f) id) Ī·
c : is-singleton (has-retraction f)
c = retract-of-singleton (r , s , rs) b
d : (Ļ : has-retraction f) ā h , hf ļ¼ Ļ
d = singletons-are-subsingletons (has-retraction f) c (h , hf)
being-joyal-equiv-is-subsingleton : hfunext š¤ š¤ ā hfunext š„ š„ ā dfunext š„ š¤
ā {X : š¤ Ģ } {Y : š„ Ģ }
ā (f : X ā Y)
ā is-subsingleton (is-joyal-equiv f)
being-joyal-equiv-is-subsingleton feā feā feā f = Ć-is-subsingleton'
(at-most-one-section feā feā f ,
at-most-one-retraction feā feā f)
being-hae-is-subsingleton : dfunext š„ š¤ ā hfunext š„ š„ ā dfunext š¤ (š„ ā š¤)
ā {X : š¤ Ģ } {Y : š„ Ģ } (f : X ā Y)
ā is-subsingleton (is-hae f)
being-hae-is-subsingleton feā feā feā {X} {Y} f = subsingleton-criterion' γ
where
a = λ g ε x
ā ((g (f x) , ε (f x)) ļ¼ (x , refl (f x))) ā⨠i g ε x ā©
(Ī£ p ź g (f x) ļ¼ x , transport (Ī» - ā f - ļ¼ f x) p (ε (f x)) ļ¼ refl (f x)) ā⨠ii g ε x ā©
(Ī£ p ź g (f x) ļ¼ x , ap f p ļ¼ Īµ (f x)) ā
where
i = Ī» g ε x ā Ī£-ļ¼-ā (g (f x) , ε (f x)) (x , refl (f x))
ii = Ī» g ε x ā Ī£-cong (Ī» p ā transport-ap-ā f p (ε (f x)))
b = (Ī£ (g , ε) ź has-section f , ā x ā (g (f x) , ε (f x)) ļ¼ (x , refl (f x))) ā⨠i ā©
(Ī£ (g , ε) ź has-section f , ā x ā Ī£ p ź g (f x) ļ¼ x , ap f p ļ¼ Īµ (f x)) ā⨠ii ā©
(Ī£ g ź (Y ā X) , Ī£ ε ź f ā g ā¼ id , ā x ā Ī£ p ź g (f x) ļ¼ x , ap f p ļ¼ Īµ (f x)) ā⨠iii ā©
(Ī£ g ź (Y ā X) , Ī£ ε ź f ā g ā¼ id , Ī£ Ī· ź g ā f ā¼ id , ā x ā ap f (Ī· x) ļ¼ Īµ (f x)) ā⨠iv ā©
is-hae f ā
where
i = Ī£-cong (Ī» (g , ε) ā Ī -cong feā feā (a g ε))
ii = Σ-assoc
iii = Ī£-cong (Ī» g ā Ī£-cong (Ī» ε ā ΠΣ-distr-ā))
iv = Ī£-cong (Ī» g ā Ī£-flip)
γ : is-hae f ā is-subsingleton (is-hae f)
γ (gā , εā , Ī·ā , Ļā) = i
where
c : (x : X) ā is-set (fiber f (f x))
c x = singletons-are-sets (fiber f (f x)) (haes-are-equivs f (gā , εā , Ī·ā , Ļā) (f x))
d : ((g , ε) : has-section f) ā is-subsingleton (ā x ā (g (f x) , ε (f x)) ļ¼ (x , refl (f x)))
d (g , ε) = Ī -is-subsingleton feā (Ī» x ā c x (g (f x) , ε (f x)) (x , refl (f x)))
e : is-subsingleton (Ī£ (g , ε) ź has-section f , ā x ā (g (f x) , ε (f x)) ļ¼ (x , refl (f x)))
e = Ī£-is-subsingleton (at-most-one-section feā feā f (gā , εā)) d
i : is-subsingleton (is-hae f)
i = equiv-to-subsingleton (ā-sym b) e
emptiness-is-subsingleton : dfunext š¤ š¤ā ā (X : š¤ Ģ )
ā is-subsingleton (is-empty X)
emptiness-is-subsingleton fe X f g = fe (Ī» x ā !š (f x ļ¼ g x) (f x))
+-is-subsingleton : {P : š¤ Ģ } {Q : š„ Ģ }
ā is-subsingleton P
ā is-subsingleton Q
ā (P ā Q ā š) ā is-subsingleton (P + Q)
+-is-subsingleton {š¤} {š„} {P} {Q} i j f = γ
where
γ : (x y : P + Q) ā x ļ¼ y
γ (inl p) (inl p') = ap inl (i p p')
γ (inl p) (inr q) = !š (inl p ļ¼ inr q) (f p q)
γ (inr q) (inl p) = !š (inr q ļ¼ inl p) (f p q)
γ (inr q) (inr q') = ap inr (j q q')
+-is-subsingleton' : dfunext š¤ š¤ā
ā {P : š¤ Ģ } ā is-subsingleton P ā is-subsingleton (P + ¬ P)
+-is-subsingleton' fe {P} i = +-is-subsingleton i
(emptiness-is-subsingleton fe P)
(Ī» p n ā n p)
EM-is-subsingleton : dfunext (š¤ āŗ) š¤ ā dfunext š¤ š¤ ā dfunext š¤ š¤ā
ā is-subsingleton (EM š¤)
EM-is-subsingleton feāŗ fe feā = Ī -is-subsingleton feāŗ
(Ī» P ā Ī -is-subsingleton fe
(Ī» i ā +-is-subsingleton' feā i))