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.Choice where
open import MGS.Unique-Existence public
open import MGS.Yoneda public
open import MGS.Subsingleton-Truncation public
open import MGS.Universe-Lifting public
simple-unique-choice : (X : π€ Μ ) (A : X β π₯ Μ ) (R : (x : X) β A x β π¦ Μ )
β ((x : X) β β! a κ A x , R x a)
β Ξ£ f κ Ξ A , ((x : X) β R x (f x))
simple-unique-choice X A R s = f , Ο
where
f : (x : X) β A x
f x = prβ (center (Ξ£ a κ A x , R x a) (s x))
Ο : (x : X) β R x (f x)
Ο x = prβ (center (Ξ£ a κ A x , R x a) (s x))
Unique-Choice : (π€ π₯ π¦ : Universe) β (π€ β π₯ β π¦)βΊ Μ
Unique-Choice π€ π₯ π¦ = (X : π€ Μ ) (A : X β π₯ Μ ) (R : (x : X) β A x β π¦ Μ )
β ((x : X) β β! a κ A x , R x a)
β β! f κ Ξ A , ((x : X) β R x (f x))
vvfunext-gives-unique-choice : vvfunext π€ (π₯ β π¦) β Unique-Choice π€ π₯ π¦
vvfunext-gives-unique-choice vv X A R s = c
where
a : ((x : X) β Ξ£ a κ A x , R x a)
β (Ξ£ f κ ((x : X) β A x), ((x : X) β R x (f x)))
a = Ξ Ξ£-distr-β
b : is-singleton ((x : X) β Ξ£ a κ A x , R x a)
b = vv s
c : is-singleton (Ξ£ f κ ((x : X) β A x), ((x : X) β R x (f x)))
c = equiv-to-singleton' a b
unique-choice-gives-vvfunext : Unique-Choice π€ π₯ π₯ β vvfunext π€ π₯
unique-choice-gives-vvfunext {π€} {π₯} uc {X} {A} Ο = Ξ³
where
R : (x : X) β A x β π₯ Μ
R x a = A x
s' : (x : X) β is-singleton (A x Γ A x)
s' x = Γ-is-singleton (Ο x) (Ο x)
s : (x : X) β β! y κ A x , R x y
s = s'
e : β! f κ Ξ A , ((x : X) β R x (f x))
e = uc X A R s
e' : is-singleton (Ξ A Γ Ξ A)
e' = e
Ο : Ξ A β Ξ A Γ Ξ A
Ο = prβ , (Ξ» y β y , y) , refl
Ξ³ : is-singleton (Ξ A)
Ξ³ = retract-of-singleton Ο e'
unique-choice-gives-hfunext : Unique-Choice π€ π₯ π₯ β hfunext π€ π₯
unique-choice-gives-hfunext {π€} {π₯} uc = βhfunext Ξ³
where
Ξ³ : (X : π€ Μ ) (A : X β π₯ Μ ) (f : Ξ A) β β! g κ Ξ A , f βΌ g
Ξ³ X A f = uc X A R e
where
R : (x : X) β A x β π₯ Μ
R x a = f x οΌ a
e : (x : X) β β! a κ A x , f x οΌ a
e x = singleton-types'-are-singletons (A x) (f x)
unique-choiceβvvfunext : Unique-Choice π€ π₯ π₯ β vvfunext π€ π₯
unique-choiceβvvfunext = unique-choice-gives-vvfunext ,
vvfunext-gives-unique-choice
module _ (hfe : global-hfunext) where
private
hunapply : {X : π€ Μ } {A : X β π₯ Μ } {f g : Ξ A} β f βΌ g β f οΌ g
hunapply = inverse (happly _ _) (hfe _ _)
transport-hunapply : {X : π€ Μ } (A : X β π₯ Μ ) (R : (x : X) β A x β π¦ Μ )
(f g : Ξ A)
(Ο : (x : X) β R x (f x))
(h : f βΌ g)
(x : X)
β transport (Ξ» - β (x : X) β R x (- x)) (hunapply h) Ο x
οΌ transport (R x) (h x) (Ο x)
transport-hunapply A R f g Ο h x =
transport (Ξ» - β β x β R x (- x)) (hunapply h) Ο x οΌβ¨ i β©
transport (R x) (happly f g (hunapply h) x) (Ο x) οΌβ¨ ii β©
transport (R x) (h x) (Ο x) β
where
a : {f g : Ξ A} {Ο : β x β R x (f x)} (p : f οΌ g) (x : domain A)
β transport (Ξ» - β β x β R x (- x)) p Ο x
οΌ transport (R x) (happly f g p x) (Ο x)
a (refl _) x = refl _
b : happly f g (hunapply h) οΌ h
b = inverses-are-sections (happly f g) (hfe f g) h
i = a (hunapply h) x
ii = ap (Ξ» - β transport (R x) (- x) (Ο x)) b
unique-choice : (X : π€ Μ ) (A : X β π₯ Μ ) (R : (x : X) β A x β π¦ Μ )
β ((x : X) β β! a κ A x , R x a)
β β! f κ ((x : X) β A x), ((x : X) β R x (f x))
unique-choice X A R s = C , Ξ¦
where
fβ : (x : X) β A x
fβ x = prβ (center (Ξ£ a κ A x , R x a) (s x))
Οβ : (x : X) β R x (fβ x)
Οβ x = prβ (center (Ξ£ a κ A x , R x a) (s x))
C : Ξ£ f κ ((x : X) β A x), ((x : X) β R x (f x))
C = fβ , Οβ
c : (x : X) β (Ο : Ξ£ a κ A x , R x a) β fβ x , Οβ x οΌ Ο
c x = centrality (Ξ£ a κ A x , R x a) (s x)
cβ : (x : X) (a : A x) (r : R x a) β fβ x οΌ a
cβ x a r = ap prβ (c x (a , r))
cβ : (x : X) (a : A x) (r : R x a)
β transport (Ξ» - β R x (prβ -)) (c x (a , r)) (Οβ x) οΌ r
cβ x a r = apd prβ (c x (a , r))
Ξ¦ : (Ο : Ξ£ f κ ((x : X) β A x), ((x : X) β R x (f x))) β C οΌ Ο
Ξ¦ (f , Ο) = to-Ξ£-οΌ (p , hunapply q)
where
p : fβ οΌ f
p = hunapply (Ξ» x β cβ x (f x) (Ο x))
q : transport (Ξ» - β (x : X) β R x (- x)) p Οβ βΌ Ο
q x = transport (Ξ» - β (x : X) β R x (- x)) p Οβ x οΌβ¨ i β©
transport (R x) (ap prβ (c x (f x , Ο x))) (Οβ x) οΌβ¨ ii β©
transport (Ξ» Ο β R x (prβ Ο)) (c x (f x , Ο x)) (Οβ x) οΌβ¨ iii β©
Ο x β
where
i = transport-hunapply A R fβ f Οβ (Ξ» x β cβ x (f x) (Ο x)) x
ii = (transport-ap (R x) prβ (c x (f x , Ο x)) (Οβ x))β»ΒΉ
iii = cβ x (f x) (Ο x)
module choice
(pt : subsingleton-truncations-exist)
(hfe : global-hfunext)
where
open basic-truncation-development pt hfe public
simple-unique-choice' : (X : π€ Μ ) (A : X β π₯ Μ ) (R : (x : X) β A x β π¦ Μ )
β ((x : X) β is-subsingleton (Ξ£ a κ A x , R x a))
β ((x : X) β β a κ A x , R x a)
β Ξ£ f κ Ξ A , ((x : X) β R x (f x))
simple-unique-choice' X A R u Ο = simple-unique-choice X A R s
where
s : (x : X) β β! a κ A x , R x a
s x = inhabited-subsingletons-are-singletons (Ξ£ a κ A x , R x a) (Ο x) (u x)
AC : β π£ (X : π€ Μ ) (A : X β π₯ Μ )
β is-set X β ((x : X) β is-set (A x)) β π£ βΊ β π€ β π₯ Μ
AC π£ X A i j = (R : (x : X) β A x β π£ Μ )
β ((x : X) (a : A x) β is-subsingleton (R x a))
β ((x : X) β β a κ A x , R x a)
β β f κ Ξ A , ((x : X) β R x (f x))
Choice : β π€ β π€ βΊ Μ
Choice π€ = (X : π€ Μ ) (A : X β π€ Μ ) (i : is-set X) (j : (x : X) β is-set (A x))
β AC π€ X A i j
IAC : (X : π€ Μ ) (Y : X β π₯ Μ ) β is-set X β ((x : X) β is-set (Y x)) β π€ β π₯ Μ
IAC X Y i j = ((x : X) β β₯ Y x β₯) β β₯ Ξ Y β₯
IChoice : β π€ β π€ βΊ Μ
IChoice π€ = (X : π€ Μ ) (Y : X β π€ Μ ) (i : is-set X) (j : (x : X) β is-set (Y x))
β IAC X Y i j
Choice-gives-IChoice : Choice π€ β IChoice π€
Choice-gives-IChoice {π€} ac X Y i j Ο = Ξ³
where
R : (x : X) β Y x β π€ Μ
R x y = x οΌ x
k : (x : X) (y : Y x) β is-subsingleton (R x y)
k x y = i x x
h : (x : X) β Y x β Ξ£ y κ Y x , R x y
h x y = (y , refl x)
g : (x : X) β β y κ Y x , R x y
g x = β₯β₯-functor (h x) (Ο x)
c : β f κ Ξ Y , ((x : X) β R x (f x))
c = ac X Y i j R k g
Ξ³ : β₯ Ξ Y β₯
Ξ³ = β₯β₯-functor prβ c
IChoice-gives-Choice : IChoice π€ β Choice π€
IChoice-gives-Choice {π€} iac X A i j R k Ο = Ξ³
where
Y : X β π€ Μ
Y x = Ξ£ a κ A x , R x a
l : (x : X) β is-set (Y x)
l x = subsets-of-sets-are-sets (A x) (R x) (j x) (k x)
a : β₯ Ξ Y β₯
a = iac X Y i l Ο
h : Ξ Y β Ξ£ f κ Ξ A , ((x : X) β R x (f x))
h g = (Ξ» x β prβ (g x)) , (Ξ» x β prβ (g x))
Ξ³ : β f κ Ξ A , ((x : X) β R x (f x))
Ξ³ = β₯β₯-functor h a
TAC : (X : π€ Μ ) (A : X β π₯ Μ ) β is-set X β ((x : X) β is-set (A x)) β π€ β π₯ Μ
TAC X A i j = β₯ ((x : X) β β₯ A x β₯ β A x)β₯
TChoice : β π€ β π€ βΊ Μ
TChoice π€ = (X : π€ Μ ) (A : X β π€ Μ ) (i : is-set X) (j : (x : X) β is-set (A x))
β TAC X A i j
IChoice-gives-TChoice : IChoice π€ β TChoice π€
IChoice-gives-TChoice {π€} iac X A i j = Ξ³
where
B : (x : X) β β₯ A x β₯ β π€ Μ
B x s = A x
k : (x : X) (s : β₯ A x β₯) β is-set (B x s)
k x s = j x
l : (x : X) β is-set β₯ A x β₯
l x = subsingletons-are-sets β₯ A x β₯ β₯β₯-is-subsingleton
m : (x : X) β is-set (β₯ A x β₯ β A x)
m x = Ξ -is-set hfe (Ξ» s β j x)
Ο : (x : X) β β₯ (β₯ A x β₯ β A x) β₯
Ο x = iac β₯ A x β₯ (B x) (l x) (k x) (ππ β₯ A x β₯)
Ξ³ : β₯ ((x : X) β β₯ A x β₯ β A x)β₯
Ξ³ = iac X (Ξ» x β β₯ A x β₯ β A x) i m Ο
TChoice-gives-IChoice : TChoice π€ β IChoice π€
TChoice-gives-IChoice tac X A i j = Ξ³
where
Ξ³ : ((x : X) β β₯ A x β₯) β β₯ Ξ A β₯
Ξ³ g = β₯β₯-functor Ο (tac X A i j)
where
Ο : ((x : X) β β₯ A x β₯ β A x) β Ξ A
Ο f x = f x (g x)
decidable-equality-criterion : {X : π€ Μ } (Ξ± : π β X)
β ((x : X) β (β n κ π , Ξ± n οΌ x)
β (Ξ£ n κ π , Ξ± n οΌ x))
β decidable (Ξ± β οΌ Ξ± β)
decidable-equality-criterion Ξ± c = Ξ³ d
where
r : π β image Ξ±
r = corestriction Ξ±
Ο : (y : image Ξ±) β Ξ£ n κ π , r n οΌ y
Ο (x , t) = f u
where
u : Ξ£ n κ π , Ξ± n οΌ x
u = c x t
f : (Ξ£ n κ π , Ξ± n οΌ x) β Ξ£ n κ π , r n οΌ (x , t)
f (n , p) = n , to-subtype-οΌ (Ξ» _ β β-is-subsingleton) p
s : image Ξ± β π
s y = prβ (Ο y)
Ξ· : (y : image Ξ±) β r (s y) οΌ y
Ξ· y = prβ (Ο y)
l : left-cancellable s
l = sections-are-lc s (r , Ξ·)
Ξ±r : {m n : π} β Ξ± m οΌ Ξ± n β r m οΌ r n
Ξ±r p = to-subtype-οΌ (Ξ» _ β β-is-subsingleton) p
rΞ± : {m n : π} β r m οΌ r n β Ξ± m οΌ Ξ± n
rΞ± = ap prβ
Ξ±s : {m n : π} β Ξ± m οΌ Ξ± n β s (r m) οΌ s (r n)
Ξ±s p = ap s (Ξ±r p)
sΞ± : {m n : π} β s (r m) οΌ s (r n) β Ξ± m οΌ Ξ± n
sΞ± p = rΞ± (l p)
Ξ³ : decidable (s (r β) οΌ s (r β)) β decidable (Ξ± β οΌ Ξ± β)
Ξ³ (inl p) = inl (sΞ± p)
Ξ³ (inr u) = inr (contrapositive Ξ±s u)
d : decidable (s (r β) οΌ s (r β))
d = π-has-decidable-equality (s (r β)) (s (r β))
choice-gives-decidable-equality : TChoice π€
β (X : π€ Μ ) β is-set X β has-decidable-equality X
choice-gives-decidable-equality {π€} tac X i xβ xβ = Ξ³
where
Ξ± : π β X
Ξ± β = xβ
Ξ± β = xβ
A : X β π€ Μ
A x = Ξ£ n κ π , Ξ± n οΌ x
l : is-subsingleton (decidable (xβ οΌ xβ))
l = +-is-subsingleton' hunapply (i (Ξ± β) (Ξ± β))
Ξ΄ : β₯ ((x : X) β β₯ A x β₯ β A x)β₯ β decidable (xβ οΌ xβ)
Ξ΄ = β₯β₯-recursion l (decidable-equality-criterion Ξ±)
j : (x : X) β is-set (A x)
j x = subsets-of-sets-are-sets π (Ξ» n β Ξ± n οΌ x) π-is-set (Ξ» n β i (Ξ± n) x)
h : β₯ ((x : X) β β₯ A x β₯ β A x)β₯
h = tac X A i j
Ξ³ : decidable (xβ οΌ xβ)
Ξ³ = Ξ΄ h
choice-gives-EM : propext π€ β TChoice (π€ βΊ) β EM π€
choice-gives-EM {π€} pe tac = em
where
β€ : Ξ© π€
β€ = (Lift π€ π , equiv-to-subsingleton (Lift-β π) π-is-subsingleton)
Ξ΄ : (Ο : Ξ© π€) β decidable (β€ οΌ Ο)
Ξ΄ = choice-gives-decidable-equality tac (Ξ© π€) (Ξ©-is-set hunapply pe) β€
em : (P : π€ Μ ) β is-subsingleton P β P + Β¬ P
em P i = Ξ³ (Ξ΄ (P , i))
where
Ξ³ : decidable (β€ οΌ (P , i)) β P + Β¬ P
Ξ³ (inl r) = inl (Idβfun s (lift β))
where
s : Lift π€ π οΌ P
s = ap prβ r
Ξ³ (inr n) = inr (contrapositive f n)
where
f : P β β€ οΌ P , i
f p = Ξ©-ext hunapply pe (Ξ» (_ : Lift π€ π) β p) (Ξ» (_ : P) β lift β)
global-choice : (π€ : Universe) β π€ βΊ Μ
global-choice π€ = (X : π€ Μ ) β X + is-empty X
global-β₯β₯-choice : (π€ : Universe) β π€ βΊ Μ
global-β₯β₯-choice π€ = (X : π€ Μ ) β β₯ X β₯ β X
open exit-β₯β₯ pt hfe
global-choice-gives-wconstant : global-choice π€
β (X : π€ Μ ) β wconstant-endomap X
global-choice-gives-wconstant g X = decidable-has-wconstant-endomap (g X)
global-choice-gives-global-β₯β₯-choice : global-choice π€
β global-β₯β₯-choice π€
global-choice-gives-global-β₯β₯-choice {π€} c X = Ξ³ (c X)
where
Ξ³ : X + is-empty X β β₯ X β₯ β X
Ξ³ (inl x) s = x
Ξ³ (inr n) s = !π X (β₯β₯-recursion π-is-subsingleton n s)
global-β₯β₯-choice-gives-all-types-are-sets : global-β₯β₯-choice π€
β (X : π€ Μ ) β is-set X
global-β₯β₯-choice-gives-all-types-are-sets {π€} c X =
types-with-wconstant-οΌ-endomaps-are-sets X
(Ξ» x y β β₯β₯-choice-function-gives-wconstant-endomap (c (x οΌ y)))
global-β₯β₯-choice-gives-universe-is-set : global-β₯β₯-choice (π€ βΊ)
β is-set (π€ Μ )
global-β₯β₯-choice-gives-universe-is-set {π€} c =
global-β₯β₯-choice-gives-all-types-are-sets c (π€ Μ )
global-β₯β₯-choice-gives-choice : global-β₯β₯-choice π€
β TChoice π€
global-β₯β₯-choice-gives-choice {π€} c X A i j = β£(Ξ» x β c (A x))β£
global-β₯β₯-choice-gives-EM : propext π€
β global-β₯β₯-choice (π€ βΊ)
β EM π€
global-β₯β₯-choice-gives-EM {π€} pe c =
choice-gives-EM pe (global-β₯β₯-choice-gives-choice c)
global-β₯β₯-choice-gives-global-choice : propext π€
β global-β₯β₯-choice π€
β global-β₯β₯-choice (π€ βΊ)
β global-choice π€
global-β₯β₯-choice-gives-global-choice {π€} pe c cβΊ X = Ξ³
where
d : decidable β₯ X β₯
d = global-β₯β₯-choice-gives-EM pe cβΊ β₯ X β₯ β₯β₯-is-subsingleton
f : decidable β₯ X β₯ β X + is-empty X
f (inl i) = inl (c X i)
f (inr Ο) = inr (contrapositive β£_β£ Ο)
Ξ³ : X + is-empty X
Ξ³ = f d
Global-Choice Global-β₯β₯-Choice : π€Ο
Global-Choice = β π€ β global-choice π€
Global-β₯β₯-Choice = β π€ β global-β₯β₯-choice π€
Global-Choice-gives-Global-β₯β₯-Choice : Global-Choice β Global-β₯β₯-Choice
Global-Choice-gives-Global-β₯β₯-Choice c π€ =
global-choice-gives-global-β₯β₯-choice (c π€)
Global-β₯β₯-Choice-gives-Global-Choice : global-propext
β Global-β₯β₯-Choice β Global-Choice
Global-β₯β₯-Choice-gives-Global-Choice pe c π€ =
global-β₯β₯-choice-gives-global-choice pe (c π€) (c (π€ βΊ))
global-β₯β₯-choice-inconsistent-with-univalence : Global-β₯β₯-Choice
β Univalence
β π
global-β₯β₯-choice-inconsistent-with-univalence g ua = Ξ³ (g π€β) (ua π€β)
where
open example-of-a-nonset
Ξ³ : global-β₯β₯-choice π€β β is-univalent π€β β π
Ξ³ g ua = π€β-is-not-a-set ua (global-β₯β₯-choice-gives-universe-is-set g)
global-choice-inconsistent-with-univalence : Global-Choice
β Univalence
β π
global-choice-inconsistent-with-univalence g =
global-β₯β₯-choice-inconsistent-with-univalence
(Global-Choice-gives-Global-β₯β₯-Choice g)
global-choice-gives-all-types-are-sets : global-choice π€
β (X : π€ Μ ) β is-set X
global-choice-gives-all-types-are-sets {π€} c X = hedberg (Ξ» x y β c (x οΌ y))
\end{code}