Martin Escardo In univalent logic, as opposed to Curry-Howard logic, a proposition is a subsingleton or a type such that any two of its elements are identified. https://www.newton.ac.uk/files/seminar/20170711100011001-1442677.pdf https://unimath.github.io/bham2017/uf.pdf \begin{code} {-# OPTIONS --safe --without-K #-} module UF.Subsingletons where open import MLTT.Plus-Properties open import MLTT.Spartan open import MLTT.Unit-Properties open import UF.Base is-prop : π€ Μ β π€ Μ is-prop X = (x y : X) β x οΌ y is-prop-valued-family : {X : π€ Μ } β (X β π₯ Μ ) β π€ β π₯ Μ is-prop-valued-family A = β x β is-prop (A x) \end{code} And of course we could adopt a terminology borrowed from topos logic: \begin{code} is-truth-value is-subsingleton : π€ Μ β π€ Μ is-truth-value = is-prop is-subsingleton = is-prop Ξ£-is-prop : {X : π€ Μ } {A : X β π₯ Μ } β is-prop X β ((x : X) β is-prop (A x)) β is-prop (Ξ£ A) Ξ£-is-prop {π€} {π₯} {X} {A} i j (x , a) (y , b) = to-Ξ£-οΌ (i x y , j y (transport A (i x y) a) b) \end{code} Next we define singleton (or contractible types). The terminology "contractible" is due to Voevodsky. I currently prefer the terminology "singleton type", because it makes more sense when we consider univalent type theory as interesting on its own right independently of its homotopical (originally motivating) models. Also it emphasizes that we don't require homotopy theory as a prerequisite to understand univalent type theory. \begin{code} is-central : (X : π€ Μ ) β X β π€ Μ is-central X c = (x : X) β c οΌ x is-singleton : π€ Μ β π€ Μ is-singleton X = Ξ£ c κ X , is-central X c center : {X : π€ Μ } β is-singleton X β X center = prβ centrality : {X : π€ Μ } (i : is-singleton X) β is-central X (center i) centrality = prβ \end{code} For compatibility with the homotopical terminology: \begin{code} is-center-of-contraction-of : (X : π€ Μ ) β X β π€ Μ is-center-of-contraction-of = is-central is-contr : π€ Μ β π€ Μ is-contr = is-singleton π-is-singleton : is-singleton (π {π€}) π-is-singleton = β , (Ξ» (x : π) β (π-all-β x)β»ΒΉ) singletons-are-props : {X : π€ Μ } β is-singleton X β is-prop X singletons-are-props (c , Ο) x y = x οΌβ¨ (Ο x) β»ΒΉ β© c οΌβ¨ Ο y β© y β prop-criterion' : {X : π€ Μ } β (X β is-singleton X) β is-prop X prop-criterion' Ο x = singletons-are-props (Ο x) x prop-criterion : {X : π€ Μ } β (X β is-prop X) β is-prop X prop-criterion Ο x = Ο x x pointed-props-are-singletons : {X : π€ Μ } β X β is-prop X β is-singleton X pointed-props-are-singletons x h = x , h x \end{code} The two prototypical propositions: \begin{code} π-is-prop : is-prop (π {π€}) π-is-prop {π€} x y = unique-from-π {π€} {π€} x π-is-prop : is-prop (π {π€}) π-is-prop {π€} β β = refl {π€} singleton-type : {X : π€ Μ } (x : X) β π€ Μ singleton-type x = Ξ£ y κ type-of x , x οΌ y singleton-center : {X : π€ Μ } (x : X) β singleton-type x singleton-center x = (x , refl) singleton-types-are-singletons'' : {X : π€ Μ } {x x' : X} (r : x οΌ x') β singleton-center x οΌ (x' , r) singleton-types-are-singletons'' {π€} {X} = J A (Ξ» x β refl) where A : (x x' : X) β x οΌ x' β π€ Μ A x x' r = singleton-center x οΌ[ Ξ£ x' κ X , x οΌ x' ] (x' , r) singleton-types-are-singletons : {X : π€ Μ } (xβ : X) β is-singleton (singleton-type xβ) singleton-types-are-singletons xβ = singleton-center xβ , (Ξ» t β singleton-types-are-singletons'' (prβ t)) singleton-types-are-singletons' : {X : π€ Μ } {x : X} β is-central (singleton-type x) (singleton-center x) singleton-types-are-singletons' {π€} {X} (y , refl) = refl singleton-types-are-props : {X : π€ Μ } (x : X) β is-prop (singleton-type x) singleton-types-are-props x = singletons-are-props (singleton-types-are-singletons x) singleton-type' : {X : π€ Μ } β X β π€ Μ singleton-type' x = Ξ£ y κ type-of x , y οΌ x singleton'-center : {X : π€ Μ } (x : X) β singleton-type' x singleton'-center x = (x , refl) Γ-prop-criterion-necessity : {X : π€ Μ } {Y : π₯ Μ } β is-prop (X Γ Y) β (Y β is-prop X) Γ (X β is-prop Y) Γ-prop-criterion-necessity i = (Ξ» y x x' β ap prβ (i (x , y) (x' , y))) , (Ξ» x y y' β ap prβ (i (x , y) (x , y'))) Γ-prop-criterion : {X : π€ Μ } {Y : π₯ Μ } β (Y β is-prop X) Γ (X β is-prop Y) β is-prop (X Γ Y) Γ-prop-criterion (i , j) (x , y) (x' , y') = to-Ξ£-οΌ (i y x x' , j x _ _) Γ-π-is-prop : {X : π€ Μ } β is-prop (X Γ π {π₯}) Γ-π-is-prop (x , z) _ = π-elim z π-Γ-is-prop : {X : π€ Μ } β is-prop (π {π₯} Γ X) π-Γ-is-prop (z , x) _ = π-elim z Γ-is-prop : {X : π€ Μ } {Y : π₯ Μ } β is-prop X β is-prop Y β is-prop (X Γ Y) Γ-is-prop i j = Γ-prop-criterion ((Ξ» _ β i) , (Ξ» _ β j)) to-subtype-οΌ : {X : π¦ Μ } {A : X β π₯ Μ } {x y : X} {a : A x} {b : A y} β ((x : X) β is-prop (A x)) β x οΌ y β (x , a) οΌ (y , b) to-subtype-οΌ {π€} {π₯} {X} {A} {x} {y} {a} {b} s p = to-Ξ£-οΌ (p , s y (transport A p a) b) subtypes-of-props-are-props' : {X : π€ Μ } {Y : π₯ Μ } (m : X β Y) β left-cancellable m β is-prop Y β is-prop X subtypes-of-props-are-props' m lc i x x' = lc (i (m x) (m x')) prβ-lc : {X : π€ Μ } {Y : X β π₯ Μ } β ({x : X} β is-prop (Y x)) β left-cancellable (prβ {π€} {π₯} {X} {Y}) prβ-lc f p = to-Ξ£-οΌ (p , (f _ _)) subsets-of-props-are-props : (X : π€ Μ ) (Y : X β π₯ Μ ) β is-prop X β ({x : X} β is-prop (Y x)) β is-prop (Ξ£ x κ X , Y x) subsets-of-props-are-props X Y h p = subtypes-of-props-are-props' prβ (prβ-lc p) h inl-lc-is-section : {X : π€ Μ } {Y : π₯ Μ } {x x' : X} (p : inl {π€} {π₯} {X} {Y} x οΌ inl x') β p οΌ ap inl (inl-lc p) inl-lc-is-section refl = refl inr-lc-is-section : {X : π€ Μ } {Y : π₯ Μ } {y y' : Y} (p : inr {π€} {π₯} {X} {Y} y οΌ inr y') β p οΌ ap inr (inr-lc p) inr-lc-is-section refl = refl \end{code} The following says that, in particular, for any proposition P, we have that P + Β¬ P is a proposition, or that the decidability of a proposition is a proposition: \begin{code} sum-of-contradictory-props : {P : π€ Μ } {Q : π₯ Μ } β is-prop P β is-prop Q β (P β Q β π {π¦}) β is-prop (P + Q) sum-of-contradictory-props {π€} {π₯} {π¦} {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) = π-elim {π€ β π₯} {π¦} (f p q) Ξ³ (inr q) (inl p) = π-elim (f p q) Ξ³ (inr q) (inr q') = ap inr (j q q') sum-of-contradictory-props' : {P : π€ Μ } {Q : π₯ Μ } β (is-prop P Γ is-prop Q Γ (P β Q β π {π¦})) β is-prop (P + Q) sum-of-contradictory-props' (i , j , f) = sum-of-contradictory-props i j f sum-of-contradictory-props'-converse : {P : π€ Μ } {Q : π₯ Μ } β is-prop (P + Q) β (is-prop P Γ is-prop Q Γ (P β Q β π {π¦})) sum-of-contradictory-props'-converse k = (Ξ» p p' β inl-lc (k (inl p) (inl p'))) , (Ξ» q q' β inr-lc (k (inr q) (inr q'))) , (Ξ» p q β π-elim (+disjoint (k (inl p) (inr q)))) \end{code} Formulation of propositional extensionality: \begin{code} propext : β π€ β π€ βΊ Μ propext π€ = {P Q : π€ Μ } β is-prop P β is-prop Q β (P β Q) β (Q β P) β P οΌ Q PropExt : π€Ο PropExt = β π€ β propext π€ Prop-Ext : π€Ο Prop-Ext = β {π€} β propext π€ \end{code} Without assuming excluded middle, we have that there are no truth values other than π and π: \begin{code} no-props-other-than-π-or-π : propext π€ β Β¬ (Ξ£ P κ π€ Μ , is-prop P Γ (P β π) Γ (P β π)) no-props-other-than-π-or-π pe (P , i , f , g) = π-elim (Ο u) where u : Β¬ P u p = g l where l : P οΌ π l = pe i π-is-prop unique-to-π (Ξ» _ β p) Ο : ¬¬ P Ο u = f l where l : P οΌ π l = pe i π-is-prop (Ξ» p β π-elim (u p)) π-elim \end{code} Notice how we used π-elim above to coerce a hypothetical value in π {π€β}, arising from negation, to a value in π {π€}. Otherwise "u" would have sufficed in place of "Ξ» p β π-elim (u p)". The same technique is used in the following construction. \begin{code} π-is-not-π : π {π€} β π {π€} π-is-not-π p = π-elim (Idtofun (p β»ΒΉ) β) universe-has-two-distinct-points : has-two-distinct-points (π€ Μ ) universe-has-two-distinct-points = ((π , π) , π-is-not-π) \end{code} Unique existence. \begin{code} β! : {X : π€ Μ } (A : X β π₯ Μ ) β π€ β π₯ Μ β! A = is-singleton (Ξ£ A) existsUnique : (X : π€ Μ ) (A : X β π₯ Μ ) β π€ β π₯ Μ existsUnique X A = β! A syntax existsUnique X (Ξ» x β b) = β! x κ X , b witness-uniqueness : {X : π€ Μ } (A : X β π₯ Μ ) β (β! x κ X , A x) β (x y : X) β A x β A y β x οΌ y witness-uniqueness A e x y a b = ap prβ (singletons-are-props e (x , a) (y , b)) infixr -1 existsUnique β!-intro : {X : π€ Μ } {A : X β π₯ Μ } (x : X) (a : A x) β ((Ο : Ξ£ A) β (x , a) οΌ Ο) β β! A β!-intro x a o = (x , a) , o β!-witness : {X : π€ Μ } {A : X β π₯ Μ } β β! A β X β!-witness ((x , a) , o) = x β!-is-witness : {X : π€ Μ } {A : X β π₯ Μ } (u : β! A) β A (β!-witness u) β!-is-witness ((x , a) , o) = a description : {X : π€ Μ } {A : X β π₯ Μ } β β! A β Ξ£ A description (Ο , o) = Ο β!-uniqueness' : {X : π€ Μ } {A : X β π₯ Μ } (u : β! A) β (Ο : Ξ£ A) β description u οΌ Ο β!-uniqueness' ((x , a) , o) = o β!-uniqueness : {X : π€ Μ } {A : X β π₯ Μ } (u : β! A) β (x : X) (a : A x) β description u οΌ (x , a) β!-uniqueness u x a = β!-uniqueness' u (x , a) β!-uniqueness'' : {X : π€ Μ } {A : X β π₯ Μ } (u : β! A) β (Ο Ο : Ξ£ A) β Ο οΌ Ο β!-uniqueness'' u Ο Ο = β!-uniqueness' u Ο β»ΒΉ β β!-uniqueness' u Ο \end{code} Added 5 March 2020 by Tom de Jong. \begin{code} +-is-prop : {X : π€ Μ } {Y : π₯ Μ } β is-prop X β is-prop Y β (X β Β¬ Y) β is-prop (X + Y) +-is-prop = sum-of-contradictory-props +-is-prop' : {X : π€ Μ } {Y : π₯ Μ } β is-prop X β is-prop Y β (Y β Β¬ X) β is-prop (X + Y) +-is-prop' {π€} {π₯} {X} {Y} i j f = +-is-prop i j (Ξ» y x β f x y) \end{code} Added 16th June 2020 by Martin Escardo. (Should have added this ages ago to avoid boiler-plate code.) \begin{code} Γβ-is-prop : {π₯β π₯β π₯β : Universe} {Xβ : π₯β Μ } {Xβ : π₯β Μ } {Xβ : π₯β Μ } β is-prop Xβ β is-prop Xβ β is-prop Xβ β is-prop (Xβ Γ Xβ Γ Xβ) Γβ-is-prop iβ iβ iβ = Γ-is-prop iβ (Γ-is-prop iβ iβ) Γβ-is-prop : {π₯β π₯β π₯β π₯β : Universe} {Xβ : π₯β Μ } {Xβ : π₯β Μ } {Xβ : π₯β Μ } {Xβ : π₯β Μ } β is-prop Xβ β is-prop Xβ β is-prop Xβ β is-prop Xβ β is-prop (Xβ Γ Xβ Γ Xβ Γ Xβ) Γβ-is-prop iβ iβ iβ iβ = Γ-is-prop iβ (Γβ-is-prop iβ iβ iβ) Γβ -is-prop : {π₯β π₯β π₯β π₯β π₯β : Universe} {Xβ : π₯β Μ } {Xβ : π₯β Μ } {Xβ : π₯β Μ } {Xβ : π₯β Μ } {Xβ : π₯β Μ } β is-prop Xβ β is-prop Xβ β is-prop Xβ β is-prop Xβ β is-prop Xβ β is-prop (Xβ Γ Xβ Γ Xβ Γ Xβ Γ Xβ) Γβ -is-prop iβ iβ iβ iβ iβ = Γ-is-prop iβ (Γβ-is-prop iβ iβ iβ iβ) Γβ-is-prop : {π₯β π₯β π₯β π₯β π₯β π₯β : Universe} {Xβ : π₯β Μ } {Xβ : π₯β Μ } {Xβ : π₯β Μ } {Xβ : π₯β Μ } {Xβ : π₯β Μ } {Xβ : π₯β Μ } β is-prop Xβ β is-prop Xβ β is-prop Xβ β is-prop Xβ β is-prop Xβ β is-prop Xβ β is-prop (Xβ Γ Xβ Γ Xβ Γ Xβ Γ Xβ Γ Xβ ) Γβ-is-prop iβ iβ iβ iβ iβ iβ = Γ-is-prop iβ (Γβ -is-prop iβ iβ iβ iβ iβ ) Γβ-is-prop : {π₯β π₯β π₯β π₯β π₯β π₯β π₯β : Universe} {Xβ : π₯β Μ } {Xβ : π₯β Μ } {Xβ : π₯β Μ } {Xβ : π₯β Μ } {Xβ : π₯β Μ } {Xβ : π₯β Μ } {Xβ : π₯β Μ } β is-prop Xβ β is-prop Xβ β is-prop Xβ β is-prop Xβ β is-prop Xβ β is-prop Xβ β is-prop Xβ β is-prop (Xβ Γ Xβ Γ Xβ Γ Xβ Γ Xβ Γ Xβ Γ Xβ) Γβ-is-prop iβ iβ iβ iβ iβ iβ iβ = Γ-is-prop iβ (Γβ-is-prop iβ iβ iβ iβ iβ iβ) Γβ-is-prop : {π₯β π₯β π₯β π₯β π₯β π₯β π₯β π₯β : Universe} {Xβ : π₯β Μ } {Xβ : π₯β Μ } {Xβ : π₯β Μ } {Xβ : π₯β Μ } {Xβ : π₯β Μ } {Xβ : π₯β Μ } {Xβ : π₯β Μ } {Xβ : π₯β Μ } β is-prop Xβ β is-prop Xβ β is-prop Xβ β is-prop Xβ β is-prop Xβ β is-prop Xβ β is-prop Xβ β is-prop Xβ β is-prop (Xβ Γ Xβ Γ Xβ Γ Xβ Γ Xβ Γ Xβ Γ Xβ Γ Xβ) Γβ-is-prop iβ iβ iβ iβ iβ iβ iβ iβ = Γ-is-prop iβ (Γβ-is-prop iβ iβ iβ iβ iβ iβ iβ) \end{code}