Martin Escardo 2012. Part of Kraus, N., EscardΓ³, M., Coquand, T., Altenkirch, T. Generalizations of Hedbergβs Theorem. In: Hasegawa, M. (eds) Typed Lambda Calculi and Applications. TLCA 2013. Lecture Notes in Computer Science, vol 7941. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-38946-7_14 \begin{code} {-# OPTIONS --safe --without-K #-} module UF.Hedberg where open import MLTT.Spartan open import UF.Base open import UF.Sets open import UF.Subsingletons wconstant : {X : π€ Μ } {Y : π₯ Μ } β (f : X β Y) β π€ β π₯ Μ wconstant f = β x y β f x οΌ f y wconstant-pre-comp : {X : π€ Μ } {Y : π₯ Μ } {Z : π¦ Μ } (f : X β Y) (g : Y β Z) β wconstant f β wconstant (g β f) wconstant-pre-comp f g c x x' = ap g (c x x') wconstant-post-comp : {X : π€ Μ } {Y : π₯ Μ } {Z : π¦ Μ } (f : X β Y) (g : Y β Z) β wconstant g β wconstant (g β f) wconstant-post-comp f g c x x' = c (f x) (f x') collapsible : π€ Μ β π€ Μ collapsible X = Ξ£ f κ (X β X) , wconstant f Id-collapsible' : {X : π€ Μ } β X β π€ Μ Id-collapsible' x = β {y} β collapsible (x οΌ y) Id-collapsible : π€ Μ β π€ Μ Id-collapsible X = {x : X} β Id-collapsible' x h-isolated-points-are-Id-collapsible : {X : π€ Μ } {x : X} β is-h-isolated x β Id-collapsible' x h-isolated-points-are-Id-collapsible h = id , h sets-are-Id-collapsible : {X : π€ Μ } β is-set X β Id-collapsible X sets-are-Id-collapsible u = (id , u) local-hedberg : {X : π€ Μ } (x : X) β ((y : X) β collapsible (x οΌ y)) β (y : X) β is-prop (x οΌ y) local-hedberg {π€} {X} x pc y p q = p οΌβ¨ c y p β© f x refl β»ΒΉ β f y p οΌβ¨ ap (Ξ» - β (f x refl)β»ΒΉ β -) (ΞΊ y p q) β© f x refl β»ΒΉ β f y q οΌβ¨ (c y q)β»ΒΉ β© q β where f : (y : X) β x οΌ y β x οΌ y f y = prβ (pc y) ΞΊ : (y : X) (p q : x οΌ y) β f y p οΌ f y q ΞΊ y = prβ (pc y) c : (y : X) (r : x οΌ y) β r οΌ (f x refl)β»ΒΉ β f y r c _ refl = sym-is-inverse (f x refl) Id-collapsibles-are-h-isolated : {X : π€ Μ } (x : X) β Id-collapsible' x β is-h-isolated x Id-collapsibles-are-h-isolated x pc {y} p q = local-hedberg x (Ξ» y β (prβ (pc {y})) , (prβ (pc {y}))) y p q Id-collapsibles-are-sets : {X : π€ Μ } β Id-collapsible X β is-set X Id-collapsibles-are-sets pc {x} = Id-collapsibles-are-h-isolated x pc \end{code} We also need the following symmetrical version of local Hedberg, which can be proved by reduction to the above (using the fact that collapsible types are closed under equivalence), but at this point we don't have the machinery at our disposal (which is developed in modules that depend on this one), and hence we prove it directly by symmetrizing the proof. \begin{code} local-hedberg' : {X : π€ Μ } (x : X) β ((y : X) β collapsible (y οΌ x)) β (y : X) β is-prop (y οΌ x) local-hedberg' {π€} {X} x pc y p q = p οΌβ¨ c y p β© f y p β (f x refl)β»ΒΉ οΌβ¨ ap (Ξ» - β - β (f x refl)β»ΒΉ) (ΞΊ y p q) β© f y q β (f x refl)β»ΒΉ οΌβ¨ (c y q)β»ΒΉ β© q β where f : (y : X) β y οΌ x β y οΌ x f y = prβ (pc y) ΞΊ : (y : X) (p q : y οΌ x) β f y p οΌ f y q ΞΊ y = prβ (pc y) c : (y : X) (r : y οΌ x) β r οΌ f y r β (f x refl)β»ΒΉ c _ refl = sym-is-inverse' (f x refl) \end{code} Here is an example (added some time after the pandemic, not sure when). Any type that admits a prop-valued, reflexive and antisymmetric relation is a set. \begin{code} type-with-prop-valued-refl-antisym-rel-is-set : {X : π€ Μ } β (_β€_ : X β X β π₯ Μ ) β ((x y : X) β is-prop (x β€ y)) β ((x : X) β x β€ x) β ((x y : X) β x β€ y β y β€ x β x οΌ y) β is-set X type-with-prop-valued-refl-antisym-rel-is-set {π€} {π₯} {X} _β€_ β€-prop-valued β€-refl β€-anti = Ξ³ where Ξ± : β {x y} (l l' : x β€ y) (m m' : y β€ x) β β€-anti x y l m οΌ β€-anti x y l' m' Ξ± {x} {y} l l' m m' = apβ (β€-anti x y) (β€-prop-valued x y l l') (β€-prop-valued y x m m') g : β {x y} β x οΌ y β x β€ y g {x} p = transport (x β€_) p (β€-refl x) h : β {x y} β x οΌ y β y β€ x h p = g (p β»ΒΉ) f : β {x y} β x οΌ y β x οΌ y f {x} {y} p = β€-anti x y (g p) (h p) ΞΊ : β {x y} p q β f {x} {y} p οΌ f {x} {y} q ΞΊ p q = Ξ± (g p) (g q) (h p) (h q) Ξ³ : is-set X Ξ³ = Id-collapsibles-are-sets (f , ΞΊ) \end{code}