MGS.Size
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.Size where
open import MGS.Powerset public
open import MGS.Universe-Lifting public
open import MGS.Subsingleton-Truncation public
_has-size_ : ๐ค ฬ โ (๐ฅ : Universe) โ ๐ฅ โบ โ ๐ค ฬ
X has-size ๐ฅ = ฮฃ Y ๊ ๐ฅ ฬ , X โ Y
propositional-resizing : (๐ค ๐ฅ : Universe) โ (๐ค โ ๐ฅ)โบ ฬ
propositional-resizing ๐ค ๐ฅ = (P : ๐ค ฬ ) โ is-subsingleton P โ P has-size ๐ฅ
resize-up : (X : ๐ค ฬ ) โ X has-size (๐ค โ ๐ฅ)
resize-up {๐ค} {๐ฅ} X = (Lift ๐ฅ X , โ-Lift X)
resize-up-subsingleton : propositional-resizing ๐ค (๐ค โ ๐ฅ)
resize-up-subsingleton {๐ค} {๐ฅ} P i = resize-up {๐ค} {๐ฅ} P
resize : propositional-resizing ๐ค ๐ฅ
โ (P : ๐ค ฬ ) (i : is-subsingleton P) โ ๐ฅ ฬ
resize ฯ P i = prโ (ฯ P i)
resize-is-subsingleton : (ฯ : propositional-resizing ๐ค ๐ฅ)
(P : ๐ค ฬ ) (i : is-subsingleton P)
โ is-subsingleton (resize ฯ P i)
resize-is-subsingleton ฯ P i = equiv-to-subsingleton (โ-sym (prโ (ฯ P i))) i
to-resize : (ฯ : propositional-resizing ๐ค ๐ฅ)
(P : ๐ค ฬ ) (i : is-subsingleton P)
โ P โ resize ฯ P i
to-resize ฯ P i = โ prโ (ฯ P i) โ
from-resize : (ฯ : propositional-resizing ๐ค ๐ฅ)
(P : ๐ค ฬ ) (i : is-subsingleton P)
โ resize ฯ P i โ P
from-resize ฯ P i = โ โ-sym (prโ (ฯ P i)) โ
Propositional-resizing : ๐คฯ
Propositional-resizing = {๐ค ๐ฅ : Universe} โ propositional-resizing ๐ค ๐ฅ
EM-gives-PR : EM ๐ค โ propositional-resizing ๐ค ๐ฅ
EM-gives-PR {๐ค} {๐ฅ} em P i = Q (em P i) , e
where
Q : P + ยฌ P โ ๐ฅ ฬ
Q (inl p) = Lift ๐ฅ ๐
Q (inr n) = Lift ๐ฅ ๐
j : (d : P + ยฌ P) โ is-subsingleton (Q d)
j (inl p) = equiv-to-subsingleton (Lift-โ ๐) ๐-is-subsingleton
j (inr n) = equiv-to-subsingleton (Lift-โ ๐) ๐-is-subsingleton
f : (d : P + ยฌ P) โ P โ Q d
f (inl p) p' = lift โ
f (inr n) p = !๐ (Lift ๐ฅ ๐) (n p)
g : (d : P + ยฌ P) โ Q d โ P
g (inl p) q = p
g (inr n) q = !๐ P (lower q)
e : P โ Q (em P i)
e = logically-equivalent-subsingletons-are-equivalent
P (Q (em P i)) i (j (em P i)) (f (em P i) , g (em P i))
has-size-is-subsingleton : Univalence
โ (X : ๐ค ฬ ) (๐ฅ : Universe)
โ is-subsingleton (X has-size ๐ฅ)
has-size-is-subsingleton {๐ค} ua X ๐ฅ = univalenceโ' (ua ๐ฅ) (ua (๐ค โ ๐ฅ)) X
PR-is-subsingleton : Univalence โ is-subsingleton (propositional-resizing ๐ค ๐ฅ)
PR-is-subsingleton {๐ค} {๐ฅ} ua =
ฮ -is-subsingleton (univalence-gives-global-dfunext ua)
(ฮป P โ ฮ -is-subsingleton (univalence-gives-global-dfunext ua)
(ฮป i โ has-size-is-subsingleton ua P ๐ฅ))
Impredicativity : (๐ค ๐ฅ : Universe) โ (๐ค โ ๐ฅ )โบ ฬ
Impredicativity ๐ค ๐ฅ = (ฮฉ ๐ค) has-size ๐ฅ
is-impredicative : (๐ค : Universe) โ ๐ค โบ ฬ
is-impredicative ๐ค = Impredicativity ๐ค ๐ค
PR-gives-Impredicativityโบ : global-propext
โ global-dfunext
โ propositional-resizing ๐ฅ ๐ค
โ propositional-resizing ๐ค ๐ฅ
โ Impredicativity ๐ค (๐ฅ โบ)
PR-gives-Impredicativityโบ {๐ฅ} {๐ค} pe fe ฯ ฯ = ฮณ
where
ฯ : ฮฉ ๐ฅ โ ฮฉ ๐ค
ฯ (Q , j) = resize ฯ Q j , resize-is-subsingleton ฯ Q j
ฯ : ฮฉ ๐ค โ ฮฉ ๐ฅ
ฯ (P , i) = resize ฯ P i , resize-is-subsingleton ฯ P i
ฮท : (p : ฮฉ ๐ค) โ ฯ (ฯ p) ๏ผ p
ฮท (P , i) = ฮฉ-ext fe pe a b
where
Q : ๐ฅ ฬ
Q = resize ฯ P i
j : is-subsingleton Q
j = resize-is-subsingleton ฯ P i
a : resize ฯ Q j โ P
a = from-resize ฯ P i โ from-resize ฯ Q j
b : P โ resize ฯ Q j
b = to-resize ฯ Q j โ to-resize ฯ P i
ฮต : (q : ฮฉ ๐ฅ) โ ฯ (ฯ q) ๏ผ q
ฮต (Q , j) = ฮฉ-ext fe pe a b
where
P : ๐ค ฬ
P = resize ฯ Q j
i : is-subsingleton P
i = resize-is-subsingleton ฯ Q j
a : resize ฯ P i โ Q
a = from-resize ฯ Q j โ from-resize ฯ P i
b : Q โ resize ฯ P i
b = to-resize ฯ P i โ to-resize ฯ Q j
ฮณ : (ฮฉ ๐ค) has-size (๐ฅ โบ)
ฮณ = ฮฉ ๐ฅ , invertibility-gives-โ ฯ (ฯ , ฮท , ฮต)
PR-gives-impredicativityโบ : global-propext
โ global-dfunext
โ propositional-resizing (๐ค โบ) ๐ค
โ is-impredicative (๐ค โบ)
PR-gives-impredicativityโบ pe fe = PR-gives-Impredicativityโบ
pe fe (ฮป P i โ resize-up P)
PR-gives-impredicativityโ : global-propext
โ global-dfunext
โ propositional-resizing ๐ค ๐คโ
โ Impredicativity ๐ค ๐คโ
PR-gives-impredicativityโ pe fe = PR-gives-Impredicativityโบ
pe fe (ฮป P i โ resize-up P)
Impredicativity-gives-PR : propext ๐ค
โ dfunext ๐ค ๐ค
โ Impredicativity ๐ค ๐ฅ
โ propositional-resizing ๐ค ๐ฅ
Impredicativity-gives-PR {๐ค} {๐ฅ} pe fe (O , e) P i = Q , ฮต
where
๐'' : ๐ค ฬ
๐'' = Lift ๐ค ๐
k : is-subsingleton ๐''
k (lift โ) (lift โ) = refl (lift โ)
down : ฮฉ ๐ค โ O
down = โ e โ
O-is-set : is-set O
O-is-set = equiv-to-set (โ-sym e) (ฮฉ-is-set fe pe)
Q : ๐ฅ ฬ
Q = down (๐'' , k) ๏ผ down (P , i)
j : is-subsingleton Q
j = O-is-set (down (Lift ๐ค ๐ , k)) (down (P , i))
ฯ : Q โ P
ฯ q = Idโfun
(ap _holds (equivs-are-lc down (โโ-is-equiv e) q))
(lift โ)
ฮณ : P โ Q
ฮณ p = ap down (to-subtype-๏ผ
(ฮป _ โ being-subsingleton-is-subsingleton fe)
(pe k i (ฮป _ โ p) (ฮป _ โ lift โ)))
ฮต : P โ Q
ฮต = logically-equivalent-subsingletons-are-equivalent P Q i j (ฮณ , ฯ)
PR-gives-existence-of-truncations : global-dfunext
โ Propositional-resizing
โ subsingleton-truncations-exist
PR-gives-existence-of-truncations fe R =
record
{
โฅ_โฅ =
ฮป {๐ค} X โ resize R
(is-inhabited X)
(inhabitation-is-subsingleton fe X) ;
โฅโฅ-is-subsingleton =
ฮป {๐ค} {X} โ resize-is-subsingleton R
(is-inhabited X)
(inhabitation-is-subsingleton fe X) ;
โฃ_โฃ =
ฮป {๐ค} {X} x โ to-resize R
(is-inhabited X)
(inhabitation-is-subsingleton fe X)
(inhabited-intro x) ;
โฅโฅ-recursion =
ฮป {๐ค} {๐ฅ} {X} {P} i u s โ from-resize R P i
(inhabited-recursion
(resize-is-subsingleton R P i)
(to-resize R P i โ u)
(from-resize R
(is-inhabited X)
(inhabitation-is-subsingleton fe X) s))
}
module powerset-union-existence
(pt : subsingleton-truncations-exist)
(hfe : global-hfunext)
where
open basic-truncation-development pt hfe
family-union : {X : ๐ค โ ๐ฅ ฬ } {I : ๐ฅ ฬ } โ (I โ ๐ X) โ ๐ X
family-union {๐ค} {๐ฅ} {X} {I} A = ฮป x โ (โ i ๊ I , x โ A i) , โ-is-subsingleton
๐๐ : ๐ค ฬ โ ๐ค โบโบ ฬ
๐๐ X = ๐ (๐ X)
existence-of-unions : (๐ค : Universe) โ ๐ค โบโบ ฬ
existence-of-unions ๐ค =
(X : ๐ค ฬ ) (๐ : ๐๐ X) โ ฮฃ B ๊ ๐ X , ((x : X) โ (x โ B) โ (โ A ๊ ๐ X , (A โ ๐) ร (x โ A)))
existence-of-unionsโ : (๐ค : Universe) โ _ ฬ
existence-of-unionsโ ๐ค =
(X : ๐ค ฬ )
(๐ : (X โ ฮฉ _) โ ฮฉ _)
โ ฮฃ B ๊ (X โ ฮฉ _) , ((x : X) โ (x โ B) โ (โ A ๊ (X โ ฮฉ _) , (A โ ๐) ร (x โ A)))
existence-of-unionsโ : (๐ค : Universe) โ ๐ค โบโบ ฬ
existence-of-unionsโ ๐ค =
(X : ๐ค ฬ )
(๐ : (X โ ฮฉ ๐ค) โ ฮฉ (๐ค โบ))
โ ฮฃ B ๊ (X โ ฮฉ ๐ค) , ((x : X) โ (x โ B) โ (โ A ๊ (X โ ฮฉ ๐ค) , (A โ ๐) ร (x โ A)))
existence-of-unions-agreement : existence-of-unions ๐ค ๏ผ existence-of-unionsโ ๐ค
existence-of-unions-agreement = refl _
existence-of-unions-gives-PR : existence-of-unions ๐ค
โ propositional-resizing (๐ค โบ) ๐ค
existence-of-unions-gives-PR {๐ค} ฮฑ = ฮณ
where
ฮณ : (P : ๐ค โบ ฬ ) โ (i : is-subsingleton P) โ P has-size ๐ค
ฮณ P i = Q , e
where
๐แตค : ๐ค ฬ
๐แตค = Lift ๐ค ๐
โแตค : ๐แตค
โแตค = lift โ
๐แตค-is-subsingleton : is-subsingleton ๐แตค
๐แตค-is-subsingleton = equiv-to-subsingleton (Lift-โ ๐) ๐-is-subsingleton
๐ : ๐๐ ๐แตค
๐ = ฮป (A : ๐ ๐แตค) โ P , i
B : ๐ ๐แตค
B = prโ (ฮฑ ๐แตค ๐)
ฯ : (x : ๐แตค) โ (x โ B) โ (โ A ๊ ๐ ๐แตค , (A โ ๐) ร (x โ A))
ฯ = prโ (ฮฑ ๐แตค ๐)
Q : ๐ค ฬ
Q = โแตค โ B
j : is-subsingleton Q
j = โ-is-subsingleton B โแตค
f : P โ Q
f p = b
where
a : ฮฃ A ๊ ๐ ๐แตค , (A โ ๐) ร (โแตค โ A)
a = (ฮป (x : ๐แตค) โ ๐แตค , ๐แตค-is-subsingleton) , p , โแตค
b : โแตค โ B
b = rl-implication (ฯ โแตค) โฃ a โฃ
g : Q โ P
g q = โฅโฅ-recursion i b a
where
a : โ A ๊ ๐ ๐แตค , (A โ ๐) ร (โแตค โ A)
a = lr-implication (ฯ โแตค) q
b : (ฮฃ A ๊ ๐ ๐แตค , (A โ ๐) ร (โแตค โ A)) โ P
b (A , m , _) = m
e : P โ Q
e = logically-equivalent-subsingletons-are-equivalent P Q i j (f , g)
PR-gives-existence-of-unions : propositional-resizing (๐ค โบ) ๐ค
โ existence-of-unions ๐ค
PR-gives-existence-of-unions {๐ค} ฯ X ๐ = B , (ฮป x โ lr x , rl x)
where
ฮฒ : X โ ๐ค โบ ฬ
ฮฒ x = โ A ๊ ๐ X , (A โ ๐) ร (x โ A)
i : (x : X) โ is-subsingleton (ฮฒ x)
i x = โ-is-subsingleton
B : ๐ X
B x = (resize ฯ (ฮฒ x) (i x) , resize-is-subsingleton ฯ (ฮฒ x) (i x))
lr : (x : X) โ x โ B โ โ A ๊ ๐ X , (A โ ๐) ร (x โ A)
lr x = from-resize ฯ (ฮฒ x) (i x)
rl : (x : X) โ (โ A ๊ ๐ X , (A โ ๐) ร (x โ A)) โ x โ B
rl x = to-resize ฯ (ฮฒ x) (i x)
module basic-powerset-development
(hfe : global-hfunext)
(ฯ : Propositional-resizing)
where
pt : subsingleton-truncations-exist
pt = PR-gives-existence-of-truncations (hfunext-gives-dfunext hfe) ฯ
open basic-truncation-development pt hfe
open powerset-union-existence pt hfe
โ : {X : ๐ค ฬ } โ ๐๐ X โ ๐ X
โ ๐ = prโ (PR-gives-existence-of-unions ฯ _ ๐)
โ-property : {X : ๐ค ฬ } (๐ : ๐๐ X)
โ (x : X) โ (x โ โ ๐) โ (โ A ๊ ๐ X , (A โ ๐) ร (x โ A))
โ-property ๐ = prโ (PR-gives-existence-of-unions ฯ _ ๐)
intersections-exist :
(X : ๐ค ฬ )
(๐ : ๐๐ X)
โ ฮฃ B ๊ ๐ X , ((x : X) โ (x โ B) โ ((A : ๐ X) โ A โ ๐ โ x โ A))
intersections-exist {๐ค} X ๐ = B , (ฮป x โ lr x , rl x)
where
ฮฒ : X โ ๐ค โบ ฬ
ฮฒ x = (A : ๐ X) โ A โ ๐ โ x โ A
i : (x : X) โ is-subsingleton (ฮฒ x)
i x = ฮ -is-subsingleton hunapply
(ฮป A โ ฮ -is-subsingleton hunapply
(ฮป _ โ โ-is-subsingleton A x))
B : ๐ X
B x = (resize ฯ (ฮฒ x) (i x) , resize-is-subsingleton ฯ (ฮฒ x) (i x))
lr : (x : X) โ x โ B โ (A : ๐ X) โ A โ ๐ โ x โ A
lr x = from-resize ฯ (ฮฒ x) (i x)
rl : (x : X) โ ((A : ๐ X) โ A โ ๐ โ x โ A) โ x โ B
rl x = to-resize ฯ (ฮฒ x) (i x)
โ : {X : ๐ค ฬ } โ ๐๐ X โ ๐ X
โ {๐ค} {X} ๐ = prโ (intersections-exist X ๐)
โ-property : {X : ๐ค ฬ } (๐ : ๐๐ X)
โ (x : X) โ (x โ โ ๐) โ ((A : ๐ X) โ A โ ๐ โ x โ A)
โ-property {๐ค} {X} ๐ = prโ (intersections-exist X ๐)
โ
full : {X : ๐ค ฬ } โ ๐ X
โ
= ฮป x โ (Lift _ ๐ , equiv-to-subsingleton (Lift-โ ๐) ๐-is-subsingleton)
full = ฮป x โ (Lift _ ๐ , equiv-to-subsingleton (Lift-โ ๐) ๐-is-subsingleton)
โ
-property : (X : ๐ค ฬ ) โ (x : X) โ ยฌ (x โ โ
)
โ
-property X x = lower
full-property : (X : ๐ค ฬ ) โ (x : X) โ x โ full
full-property X x = lift โ
_โฉ_ _โช_ : {X : ๐ค ฬ } โ ๐ X โ ๐ X โ ๐ X
(A โช B) = ฮป x โ ((x โ A) โจ (x โ B)) , โจ-is-subsingleton
(A โฉ B) = ฮป x โ ((x โ A) ร (x โ B)) ,
ร-is-subsingleton
(โ-is-subsingleton A x)
(โ-is-subsingleton B x)
โช-property : {X : ๐ค ฬ } (A B : ๐ X)
โ (x : X) โ x โ (A โช B) โ (x โ A) โจ (x โ B)
โช-property {๐ค} {X} A B x = id , id
โฉ-property : {X : ๐ค ฬ } (A B : ๐ X)
โ (x : X) โ x โ (A โฉ B) โ (x โ A) ร (x โ B)
โฉ-property {๐ค} {X} A B x = id , id
infix 20 _โฉ_
infix 20 _โช_
Top : (๐ค : Universe) โ ๐ค โบโบ ฬ
Top ๐ค = ฮฃ X ๊ ๐ค ฬ , is-set X
ร (ฮฃ ๐ ๊ ๐๐ X , full โ ๐
ร ((U V : ๐ X) โ U โ ๐ โ V โ ๐ โ (U โฉ V) โ ๐)
ร ((๐ : ๐๐ X) โ ๐ โ ๐ โ โ ๐ โ ๐))