Properties
Martin Escardo. 19th December 2020, June 2023. General properties of W-types. Notice that we don't assume any axioms from univalent foundations other than function extensionality, but that we formulate and prove properties in univalent style.{-# OPTIONS --safe --without-K #-} open import MLTT.Spartan module W.Properties (X : π€ Μ ) (A : X β π₯ Μ ) where open import UF.Base open import UF.Equiv open import UF.EquivalenceExamples open import UF.FunExt open import UF.Retracts open import UF.Sets open import UF.Subsingletons open import UF.Subsingletons-FunExt open import W.Type private π = W X AWe first show that the identity type of π is equivalent to _οΌΚ·_ defined as follows._οΌΚ·_ : π β π β π€ β π₯ Μ ssup x f οΌΚ· ssup x' f' = Ξ£ p κ x οΌ x' , ((a : A x) β f a οΌΚ· f' (transport A p a)) οΌΚ·-refl : (w : π) β w οΌΚ· w οΌΚ·-refl (ssup x f) = refl , (Ξ» a β οΌΚ·-refl (f a)) singleton-typeΚ· : π β π€ β π₯ Μ singleton-typeΚ· w = Ξ£ t κ π , w οΌΚ· t W-center : (w : π) β singleton-typeΚ· w W-center w = w , οΌΚ·-refl w W-centrality : Fun-Ext β (w : π) (Ο : singleton-typeΚ· w) β W-center w οΌ Ο W-centrality fe w@(ssup x f) Ο@(ssup x g , refl , u) = IV where have-u : (a : A x) β f a οΌΚ· g a have-u = u IH : (a : A x) β W-center (f a) οΌ (g a , u a) IH a = W-centrality fe (f a) (g a , u a) I : (Ξ» a β W-center (f a)) οΌ (Ξ» a β g a , u a) I = dfunext fe IH Ο : (Ξ£ h κ (A x β π) , ((a : A x) β f a οΌΚ· h a)) β singleton-typeΚ· (ssup x f) Ο (h , v) = ssup x h , refl , v II : (f , Ξ» a β οΌΚ·-refl (f a)) οΌ[ domain Ο ] (g , u) II = ap Ξ Ξ£-distr I III : (ssup x f , refl , (Ξ» a β οΌΚ·-refl (f a))) οΌ (ssup x g , refl , u) III = ap Ο II IV = W-center w οΌβ¨reflβ© ssup x f , refl , (Ξ» a β οΌΚ·-refl (f a)) οΌβ¨ III β© ssup x g , refl , u οΌβ¨reflβ© Ο β singleton-typesΚ·-are-singletons : Fun-Ext β (w : π) β is-singleton (singleton-typeΚ· w) singleton-typesΚ·-are-singletons fe w = W-center w , W-centrality fe wFrom this it follows that the canonical map from the native notion of π-identity to the alternative notion of π-identity defined above is an equivalence:idtoidΚ· : (w t : π) β w οΌ t β w οΌΚ· t idtoidΚ· w w refl = οΌΚ·-refl w idtoidΚ·-is-equiv : Fun-Ext β (w t : π) β is-equiv (idtoidΚ· w t) idtoidΚ·-is-equiv fe w = I where f : singleton-type w β singleton-typeΚ· w f = NatΞ£ (idtoidΚ· w) f-is-equiv : is-equiv f f-is-equiv = maps-of-singletons-are-equivs f (singleton-types-are-singletons w) (singleton-typesΚ·-are-singletons fe w) I : (t : π) β is-equiv (idtoidΚ· w t) I = NatΞ£-equiv-gives-fiberwise-equiv (idtoidΚ· w) f-is-equiv idtoidΚ·-β : Fun-Ext β (w t : π) β (w οΌ t) β (w οΌΚ· t) idtoidΚ·-β fe w t = idtoidΚ· w t , idtoidΚ·-is-equiv fe w tWe now describe ways to "construct" and "destruct" native π identifications, which are mutually inverse and hence induce an equivalence. We first do this for arbitrary elements of π, using the accessors W-root and W-forest, and then get the case of elements given by ssup as an instance.W-Code : π β π β π€ β π₯ Μ W-Code w t = Ξ£ p κ W-root w οΌ W-root t , (W-forest w οΌ W-forest t β transport A p) W-code : (w t : π) β w οΌ t β W-Code w t W-code w _ refl = refl , refl W-decode : (w t : π) β W-Code w t β w οΌ t W-decode (ssup x Ο) (ssup x' Ο') (refl , f) = ap (ssup x) f W-decode-code : (w t : π) (q : w οΌ t) β W-decode w t (W-code w t q) οΌ q W-decode-code (ssup x Ο) _ refl = refl to-W-οΌ : {x : X} {Ο : A x β π} {x' : X} {Ο' : A x' β π} β (Ξ£ p κ x οΌ x' , (Ο οΌ Ο' β transport A p)) β ssup x Ο οΌ[ π ] ssup x' Ο' to-W-οΌ {x} {Ο} {x'} {Ο'} = W-decode (ssup x Ο) (ssup x' Ο') from-W-οΌ : {x : X} {Ο : A x β π} {x' : X} {Ο' : A x' β π} β ssup x Ο οΌ[ π ] ssup x' Ο' β (Ξ£ p κ x οΌ x' , (Ο οΌ Ο' β transport A p)) from-W-οΌ {x} {Ο} {x'} {Ο'} = W-code (ssup x Ο) (ssup x' Ο') to-from-W-οΌ : {x : X} {Ο : A x β π} {x' : X} {Ο' : A x' β π} β (q : ssup x Ο οΌ[ π ] ssup x' Ο') β to-W-οΌ (from-W-οΌ q) οΌ q to-from-W-οΌ {x} {Ο} {x'} {Ο'} = W-decode-code (ssup x Ο) (ssup x' Ο') from-to-W-οΌ : {x : X} {Ο : A x β π} {x' : X} {Ο' : A x' β π} β (Ο : Ξ£ p κ x οΌ x' , (Ο οΌ Ο' β transport A p)) β from-W-οΌ (to-W-οΌ {x} {Ο} {x'} {Ο'} Ο) οΌ Ο from-to-W-οΌ (refl , refl) = refl W-οΌ : {x : X} {Ο : A x β π} {x' : X} {Ο' : A x' β π} β (ssup x Ο οΌ[ π ] ssup x' Ο') β (Ξ£ p κ x οΌ x' , (Ο οΌ Ο' β transport A p)) W-οΌ {x} {Ο} {x'} {Ο'} = qinveq from-W-οΌ (to-W-οΌ , to-from-W-οΌ , from-to-W-οΌ {x} {Ο} {x'} {Ο'})From this we conclude that if X is a proposition or a set, then π is a proposition or a set respectively:W-is-prop : funext π₯ (π€ β π₯) β is-prop X β is-prop π W-is-prop fe X-is-prop (ssup x Ο) (ssup x' Ο') = Ξ³ where p : x οΌ x' p = X-is-prop x x' IH : (a : A x) β Ο a οΌ Ο' (transport A p a) IH a = W-is-prop fe X-is-prop (Ο a) (Ο' (transport A p a)) Ξ³ : ssup x Ο οΌ ssup x' Ο' Ξ³ = to-W-οΌ (p , dfunext fe IH) W-is-set : funext π₯ (π€ β π₯) β is-set X β is-set π W-is-set fe X-is-set {ssup x Ο} {ssup x' Ο'} = Ξ³ where S = Ξ£ p κ x οΌ x' , (Ο βΌ Ο' β transport A p) IH : (p : x οΌ x') (a : A x) β is-prop (Ο a οΌ Ο' (transport A p a)) IH p a = W-is-set fe X-is-set {Ο a} {Ο' (transport A p a)} Ξ± : is-prop S Ξ± = Ξ£-is-prop X-is-set (Ξ» p β Ξ -is-prop fe (IH p)) Ξ² : retract (ssup x Ο οΌ ssup x' Ο') of S Ξ² = (Ξ» (p , h) β to-W-οΌ (p , dfunext fe h)) , (Ξ» p β prβ (from-W-οΌ p) , happly (prβ (from-W-οΌ p))) , h where h : (Ξ» (p : ssup x (Ξ» v β Ο v) οΌ ssup x' (Ξ» v β Ο' v)) β to-W-οΌ (prβ (from-W-οΌ p) , dfunext fe (happly (prβ (from-W-οΌ p))))) βΌ id h = k (ssup x' Ο') where k : (t : π) (p : ssup x Ο οΌ t) β W-decode (ssup x Ο) t (prβ (W-code (ssup x Ο) t p) , dfunext fe (happly (prβ (W-code (ssup x Ο) t p)))) οΌ p k _ refl = ap (ssup x) (dfunext fe (happly refl)) οΌβ¨ I β© ap (ssup x) refl οΌβ¨reflβ© refl β where I = ap (ap (ssup x)) (funext-happly fe Ο Ο refl) Ξ³ : is-prop (ssup x Ο οΌ ssup x' Ο') Ξ³ = retract-of-prop Ξ² Ξ±Notice that, in both cases, we didn't need to assume anything about the family A to deduce the truncation level of the type π = W X A. Only the truncation level of X matters. When the two roots are literally the same, and X is a set, the identification of the forests is a homotopy, the loop that from-W-οΌ produces being refl and its transport therefore the identity.forest-οΌ : is-set X β {x : X} {Ο Ο' : A x β π} β ssup x Ο οΌ ssup x Ο' β Ο βΌ Ο' forest-οΌ X-is-set {x} {Ο} {Ο'} p = happly III where I : x οΌ x I = prβ (from-W-οΌ p) II : Ο οΌ Ο' β transport A I II = prβ (from-W-οΌ p) III : Ο οΌ Ο' III = transport (Ξ» - β Ο οΌ Ο' β transport A -) (X-is-set I refl) II