Martin Escardo & Tom de Jong, June 2023. Iterative sets. We define the type of iterative sets as a subtype of that of multisets. * H. R. Gylterud, "From multisets to sets in homotopy type theory". The Journal of Symbolic Logic, vol. 83, no. 3, pp. 1132โ1146, 2018. https://doi.org/10.1017/jsl.2017.84 See the module Iterative.index for further bibliographic references. The previous module Iterative.Multisets doesn't make significant use of univalence, and so we assumed it only for specific constructions. But here the use of univalence is more pervasive, and so we assume it globally. \begin{code} {-# OPTIONS --safe --without-K --lossy-unification #-} open import MLTT.Spartan open import UF.Univalence module Iterative.Sets (ua : Univalence) (๐ค : Universe) where open import UF.FunExt open import UF.UA-FunExt private ๐คโบ : Universe ๐คโบ = ๐ค โบ fe : Fun-Ext fe = Univalence-gives-Fun-Ext ua fe' : FunExt fe' ๐ค ๐ฅ = fe {๐ค} {๐ฅ} open import Iterative.Multisets ๐ค open import Ordinals.Notions open import UF.Base open import UF.DiscreteAndSeparated open import UF.Embeddings open import UF.Equiv open import UF.EquivalenceExamples open import UF.PairFun open import UF.Retracts open import UF.Sets open import UF.Size open import UF.Subsingletons open import UF.Subsingletons-FunExt open import W.Type \end{code} An iterative set is a multiset whose subforests are all embeddings. The effect of that is that the membership relation on iterative sets is proposition-valued, rather than just type-valued, as is the case for general multisets. \begin{code} is-iterative-set : ๐ โ ๐คโบ ฬ is-iterative-set (ssup X ฯ) = is-embedding ฯ ร ((x : X) โ is-iterative-set (ฯ x)) \end{code} It is convenient to name the projections for the sake of clarity: \begin{code} ๐-forest-is-embedding : (M : ๐) โ is-iterative-set M โ is-embedding (๐-forest M) ๐-forest-is-embedding (ssup _ _) = prโ ๐-subtrees-are-iterative : (M : ๐) โ is-iterative-set M โ (x : ๐-root M) โ is-iterative-set (๐-forest M x) ๐-subtrees-are-iterative (ssup _ _) = prโ \end{code} It is crucial that the notion of iterative set is property rather than data: \begin{code} being-iset-is-prop : (M : ๐) โ is-prop (is-iterative-set M) being-iset-is-prop (ssup X ฯ) = ร-is-prop (being-embedding-is-prop fe ฯ) (ฮ -is-prop fe (ฮป x โ being-iset-is-prop (ฯ x))) \end{code} The type of iterative sets as a subtype of that of iterative multisets: \begin{code} ๐ : ๐คโบ ฬ ๐ = ฮฃ M ๊ ๐ , is-iterative-set M ๐-is-locally-small : is-locally-small ๐ ๐-is-locally-small = subtype-is-locally-small being-iset-is-prop (๐-is-locally-small ua) \end{code} We again name the projections for the sake of clarity: \begin{code} underlying-mset : ๐ โ ๐ underlying-mset = prโ isets-are-iterative : (A : ๐) โ is-iterative-set (underlying-mset A) isets-are-iterative = prโ \end{code} Because the notion of iterative set is property, we get that ๐ is indeed a subtype of ๐. \begin{code} underlying-mset-is-embedding : is-embedding underlying-mset underlying-mset-is-embedding = prโ-is-embedding being-iset-is-prop \end{code} We define the root and the forest of an iterative set in terms of those for multisets, but we need to add a "proof obligation" in the case of the forest. \begin{code} ๐-root : ๐ โ ๐ค ฬ ๐-root A = ๐-root (underlying-mset A) ๐-forest : (A : ๐) โ ๐-root A โ ๐ ๐-forest A x = ๐-forest (underlying-mset A) x , ๐-subtrees-are-iterative (underlying-mset A) (isets-are-iterative A) x \end{code} A criterion for equality in ๐: \begin{code} to-๐-๏ผ : {X Y : ๐ค ฬ } {ฯ : X โ ๐} {ฮณ : Y โ ๐} โ (ฮฃ p ๊ X ๏ผ Y , ฯ ๏ผ ฮณ โ Idtofun p) โ (i : is-iterative-set (ssup X ฯ)) (j : is-iterative-set (ssup Y ฮณ)) โ (ssup X ฯ , i) ๏ผ[ ๐ ] (ssup Y ฮณ , j) to-๐-๏ผ ฯ i j = to-subtype-๏ผ being-iset-is-prop (to-๐-๏ผ ฯ) \end{code} We define membership of iterative sets in terms of that for multisets: \begin{code} _โ_ : ๐ โ ๐ โ ๐คโบ ฬ A โ B = underlying-mset A โ underlying-mset B \end{code} As is the case for iterative multisets, there is a resized down, equivalent definition of membership. \begin{code} _โโป_ : ๐ โ ๐ โ ๐ค ฬ A โโป B = underlying-mset A โ โป underlying-mset B โโปโโ : (A B : ๐) โ (A โ B) โ (A โโป B) โโปโโ A B = โ โปโโ ua (underlying-mset A) (underlying-mset B) \end{code} As discussed above, the membership relation becomes a proposition precisely because we required forests to be embeddings to define the subtype of iterative sets. \begin{code} โ-is-prop-valued : (A B : ๐) โ is-prop (A โ B) โ-is-prop-valued (M , _) (ssup X ฯ , ฯ-emb , _) = ฯ-emb M ๐-forest-โ : (A : ๐) (x : ๐-root A) โ ๐-forest A x โ A ๐-forest-โ A x = ๐-forest-โ (underlying-mset A) x \end{code} The subset relation is defined in the usual way and is proposition-valued: \begin{code} _โ_ : ๐ โ ๐ โ ๐คโบ ฬ A โ B = (C : ๐) โ C โ A โ C โ B โ-is-prop-valued : (A B : ๐) โ is-prop (A โ B) โ-is-prop-valued A B = ฮ โ-is-prop fe (ฮป C _ โ โ-is-prop-valued C B) \end{code} It is in the following that the univalence axiom is used for the first time, to establish the extensionality axiom for iterative sets: \begin{code} โ-is-extensional : (A B : ๐) โ A โ B โ B โ A โ A ๏ผ B โ-is-extensional A@(M@(ssup X ฯ) , ฯ-emb , g) B@(N@(ssup Y ฮณ) , ฮณ-emb , h) u v = V where have-uv : (A โ B) ร (B โ A) have-uv = u , v I : (x : X) โ ฮฃ y ๊ Y , ฮณ y ๏ผ ฯ x I x = u (ฯ x , g x) (๐-forest-โ M x) II : (y : Y) โ ฮฃ x ๊ X , ฯ x ๏ผ ฮณ y II y = v (ฮณ y , h y) (๐-forest-โ N y) f : X โ Y f x = prโ (I x) fโปยน : Y โ X fโปยน y = prโ (II y) ฮท : fโปยน โ f โผ id ฮท x = embeddings-are-lc ฯ ฯ-emb (ฯ (fโปยน (f x)) ๏ผโจ prโ (II (f x)) โฉ ฮณ (f x) ๏ผโจ prโ (I x) โฉ ฯ x โ) ฮต : f โ fโปยน โผ id ฮต y = embeddings-are-lc ฮณ ฮณ-emb (ฮณ (f (fโปยน y)) ๏ผโจ prโ (I (fโปยน y)) โฉ ฯ (fโปยน y) ๏ผโจ prโ (II y) โฉ ฮณ y โ) ๐ : X โ Y ๐ = qinveq f (fโปยน , ฮท , ฮต) p : X ๏ผ Y p = eqtoid (ua ๐ค) X Y ๐ III : Idtofun p ๏ผ f III = Idtofun-eqtoid (ua ๐ค) ๐ IV = ฮป x โ ฯ x ๏ผโจ (prโ (I x))โปยน โฉ ฮณ (f x) ๏ผโจ ap (ฮป - โ ฮณ (- x)) (III โปยน) โฉ ฮณ (Idtofun p x) โ V : A ๏ผ B V = to-๐-๏ผ (p , dfunext fe IV) (ฯ-emb , g) (ฮณ-emb , h) \end{code} It follows that ๐ is 0-type, or set, in the sense of the HoTT book. But notice that we now have two notions of set in this discussion: the "material" (iterative set) one and the "structural" one (0-type or set). The reader should keep this distinction in mind for the comments and code below. The following uses the fact that any type with an extensional order is automatically a set. \begin{code} ๐-is-set : is-set ๐ ๐-is-set = extensionally-ordered-types-are-sets _โ_ fe' โ-is-prop-valued โ-is-extensional \end{code} Here is a second, more direct, proof of this fact. The following says that ssup ฯ ๏ผ M is a proposition for every M : ๐ if ฯ is an embedding. The following doesn't seem to have been observed before in the literature. \begin{code} ๐-ssup-is-h-isolated : (X : ๐ค ฬ ) (ฯ : X โ ๐) โ is-embedding ฯ โ is-h-isolated (ssup X ฯ) ๐-ssup-is-h-isolated X ฯ ฯ-emb {M} = III where I = (ssup X ฯ ๏ผ M) โโจ ๏ผ-flip โฉ (M ๏ผ ssup X ฯ) โโจ ๐-๏ผ' M (ssup X ฯ) โฉ fiber ((ฯ โ_) โ Idtofun) (๐-forest M) โ II : is-embedding ((ฯ โ_) โ Idtofun) II = โ-is-embedding (Idtofun-is-embedding (ua ๐ค) fe) (postcomp-is-embedding fe' ฯ ฯ-emb) III : is-prop (ssup X ฯ ๏ผ M) III = equiv-to-prop I (II (๐-forest M)) \end{code} And a particular case of this is that if M is an iterative set then M ๏ผ N is a proposition for every *multiset* N. \begin{code} isets-are-h-isolated : (M : ๐) โ is-iterative-set M โ is-h-isolated M isets-are-h-isolated (ssup X ฯ) (ฯ-emb , _) = ๐-ssup-is-h-isolated X ฯ ฯ-emb \end{code} Because a subtype of any type whatsoever consisting of h-isolated elements is a 0-type, we get a second proof that the type of iterative sets is a 0-type. \begin{code} ๐-is-set' : is-set ๐ ๐-is-set' {M , M-is-is-set} = equiv-to-prop (โ-sym (to-subtype-๏ผ-โ being-iset-is-prop)) (isets-are-h-isolated M M-is-is-set) \end{code} By definition, an iterative multiset is an iterative set if its ๐-forests are all embeddings. The ๐-forests are also embeddings: \begin{code} ๐-forest-is-embedding : (A : ๐) โ is-embedding (๐-forest A) ๐-forest-is-embedding A@(ssup X ฯ , ฯ-emb , ฯ-iter) = pair-fun-is-embedding-special ฯ ฯ-iter ฯ-emb being-iset-is-prop \end{code} We construct elements of ๐ using the constructor ssup. We now introduce a corresponding constructor ๐-ssup to construct elements of the type ๐. \begin{code} ๐-ssup : (X : ๐ค ฬ ) (ฯ : X โ ๐) โ is-embedding ฯ โ ๐ ๐-ssup X ฯ ฯ-emb = ssup X ฯ , ฯ-emb , ฯ-iset where ฯ : X โ ๐ ฯ = underlying-mset โ ฯ ฯ-iset : (x : X) โ is-iterative-set (ฯ x) ฯ-iset = isets-are-iterative โ ฯ ฯ-emb : is-embedding ฯ ฯ-emb = โ-is-embedding ฯ-emb underlying-mset-is-embedding \end{code} It behaves as expected with respect to the corresponding destructors: \begin{code} ๐-ssup-root : (X : ๐ค ฬ ) (ฯ : X โ ๐) (e : is-embedding ฯ) โ ๐-root (๐-ssup X ฯ e) ๏ผ X ๐-ssup-root X ฯ e = refl ๐-ssup-forest : (X : ๐ค ฬ ) (ฯ : X โ ๐) (e : is-embedding ฯ) โ ๐-forest (๐-ssup X ฯ e) ๏ผ ฯ ๐-ssup-forest X ฯ e = refl \end{code} Notice that the identifications are definitional. We have the following ฮท rules for ๐, where the first is more general and the second is more natural. In both cases the identifications are not definitional. \begin{code} ๐-ฮท' : (A : ๐) (e : is-embedding (๐-forest A)) โ ๐-ssup (๐-root A) (๐-forest A) e ๏ผ A ๐-ฮท' (ssup _ _ , _) _ = to-subtype-๏ผ being-iset-is-prop refl ๐-ฮท : (A : ๐) โ ๐-ssup (๐-root A) (๐-forest A) (๐-forest-is-embedding A) ๏ผ A ๐-ฮท A = ๐-ฮท' A (๐-forest-is-embedding A) \end{code} Here are two characterizations of the membership relation: \begin{code} โ-behaviour : (A : ๐) (X : ๐ค ฬ ) (ฯ : X โ ๐) (e : is-embedding ฯ) โ A โ ๐-ssup X ฯ e โ (ฮฃ x ๊ X , ฯ x ๏ผ A) โ-behaviour A X ฯ e = (A โ ๐-ssup X ฯ e) โโจ โ-refl _ โฉ (ฮฃ x ๊ X , underlying-mset (ฯ x) ๏ผ underlying-mset A) โโจ ฮฃ-cong I โฉ (ฮฃ x ๊ X , ฯ x ๏ผ A) โ where I : (x : X) โ (underlying-mset (ฯ x) ๏ผ underlying-mset A) โ (ฯ x ๏ผ A) I x = embedding-criterion-converse underlying-mset underlying-mset-is-embedding (ฯ x) A โ-behaviour' : (A B : ๐) โ A โ B โ (ฮฃ x ๊ ๐-root B , ๐-forest B x ๏ผ A) โ-behaviour' A B = transport (ฮป - โ A โ - โ (ฮฃ x ๊ ๐-root - , ๐-forest - x ๏ผ A)) (๐-ฮท B) (โ-behaviour A (๐-root B) (๐-forest B) (๐-forest-is-embedding B)) private โ-remark : (A B : ๐) โ A โ B โ fiber (๐-forest B) A โ-remark = โ-behaviour' \end{code} It also follows from the facts that ๐ is a set and that ๐-forest is an embedding that the root of any iterative set is a 0-type: \begin{code} ๐-root-is-set : (A : ๐) โ is-set (๐-root A) ๐-root-is-set A = subtypes-of-sets-are-sets (๐-forest A) (๐-forest-is-embedding A) ๐-is-set \end{code} It would be nice if we could define ๐ inductively as follows: data ๐ : ๐คโบ ฬ where ๐-ssup : (X : ๐ค ฬ ) (ฯ : X โ ๐) โ is-embedding ฯ โ ๐ However, this is not a strictly positive definition, for the criterion of strict positivity adopted by Agda, and so it is not accepted. Nevertheless, all iterative sets *are* generated by the "constructor" ๐-ssup, in the following sense, so that we can view ๐ as really inductively defined by the above data declaration. The following result, implementing the above idea, seems to be new. \begin{code} ๐-Induction' : (P : ๐ โ ๐ฅ ฬ ) (f : (A : ๐) โ ((x : ๐-root A) โ P (๐-forest A x)) โ P A) โ ฮฃ h ๊ ((A : ๐) โ P A) , ((A : ๐) โ h A ๏ผ f A (ฮป x โ h (๐-forest A x))) ๐-Induction' P f = (ฮป (M , i) โ H M i) , p where H : (M : ๐) (i : is-iterative-set M) โ P (M , i) H M@(ssup X ฯ) i@(_ , ฯ-iter) = f (M , i) (ฮป x โ H (ฯ x) (ฯ-iter x)) p : (A : ๐) โ _ ๏ผ _ p (M@(ssup X ฯ) , i@(_ , ฯ-iter)) = refl ๐-Induction : (P : ๐ โ ๐ฅ ฬ ) โ (f : (X : ๐ค ฬ ) (ฯ : X โ ๐) (e : is-embedding ฯ) โ ((x : X) โ P (ฯ x)) โ P (๐-ssup X ฯ e)) โ ฮฃ h ๊ ((A : ๐) โ P A) , ((X : ๐ค ฬ ) (ฯ : X โ ๐) (e : is-embedding ฯ) โ h (๐-ssup X ฯ e) ๏ผ f X ฯ e (ฮป x โ h (ฯ x))) ๐-Induction {๐ฅ} P f = h , IV where f' : (A : ๐) โ ((x : ๐-root A) โ P (๐-forest A x)) โ P A f' A@(M@(ssup X ฯ) , i@(ฯ-emb , ฯ-iter)) g = II where I : P (๐-ssup X (๐-forest A) (๐-forest-is-embedding A)) I = f X (๐-forest A) (๐-forest-is-embedding A) g II : P A II = transport P (๐-ฮท A) I h : (A : ๐) โ P A h = prโ (๐-Induction' P f') III : (A : ๐) โ h A ๏ผ f' A (ฮป x โ h (๐-forest A x)) III = prโ (๐-Induction' P f') IV : (X : ๐ค ฬ ) (ฯ : X โ ๐) (e : is-embedding ฯ) โ h (๐-ssup X ฯ e) ๏ผ f X ฯ e (ฮป x โ h (ฯ x)) IV X ฯ e = h A ๏ผโจ III A โฉ f' A (ฮป x โ h (ฯ x)) ๏ผโจ refl โฉ t P (๐-ฮท A) (f X ฯ e' (ฮป x โ h (ฯ x))) ๏ผโจ i โฉ t P (ap (๐-ssup X ฯ) p) (f X ฯ e' (ฮป x โ h (ฯ x))) ๏ผโจ ii โฉ t (P โ ๐-ssup X ฯ) p (f X ฯ e' (ฮป x โ h (ฯ x))) ๏ผโจ iii โฉ f X ฯ e (ฮป x โ h (ฯ x)) โ where t = transport A = ๐-ssup X ฯ e e' = ๐-forest-is-embedding A p : e' ๏ผ e p = being-embedding-is-prop fe ฯ e' e q : ๐-ฮท A ๏ผ ap (๐-ssup X ฯ) p q = ๐-is-set _ _ i = ap (ฮป - โ t P - (f X ฯ e' (ฮป x โ h (ฯ x)))) q ii = (transport-ap P (๐-ssup X ฯ) p)โปยน iii = apd (ฮป - โ f X ฯ - (ฮป x โ h (ฯ x))) p ๐-induction : (P : ๐ โ ๐ฅ ฬ ) โ ((X : ๐ค ฬ ) (ฯ : X โ ๐) (e : is-embedding ฯ) โ ((x : X) โ P (ฯ x)) โ P (๐-ssup X ฯ e)) โ (A : ๐) โ P A ๐-induction P f = prโ (๐-Induction P f) ๐-induction-behaviour : (P : ๐ โ ๐ฅ ฬ ) โ (f : (X : ๐ค ฬ ) (ฯ : X โ ๐) (e : is-embedding ฯ) โ ((x : X) โ P (ฯ x)) โ P (๐-ssup X ฯ e)) โ (X : ๐ค ฬ ) (ฯ : X โ ๐) (e : is-embedding ฯ) โ ๐-induction P f (๐-ssup X ฯ e) ๏ผ f X ฯ e (ฮป x โ ๐-induction P f (ฯ x)) ๐-induction-behaviour P f = prโ (๐-Induction P f) ๐-recursion : (P : ๐ฅ ฬ ) โ ((X : ๐ค ฬ ) (ฯ : X โ ๐) โ is-embedding ฯ โ (X โ P) โ P) โ ๐ โ P ๐-recursion P = ๐-induction (ฮป _ โ P) ๐-recursion-behaviour : (P : ๐ฅ ฬ ) โ (f : (X : ๐ค ฬ ) (ฯ : X โ ๐) (e : is-embedding ฯ) โ (X โ P) โ P) โ (X : ๐ค ฬ ) (ฯ : X โ ๐) (e : is-embedding ฯ) โ ๐-recursion P f (๐-ssup X ฯ e) ๏ผ f X ฯ e (ฮป x โ ๐-recursion P f (ฯ x)) ๐-recursion-behaviour P = ๐-induction-behaviour (ฮป _ โ P) ๐-iteration : (P : ๐ฅ ฬ ) โ ((X : ๐ค ฬ ) โ (X โ P) โ P) โ ๐ โ P ๐-iteration P f = ๐-recursion P (ฮป X ฯ e โ f X) ๐-iteration-behaviour : (P : ๐ฅ ฬ ) โ (f : (X : ๐ค ฬ ) โ (X โ P) โ P) โ (X : ๐ค ฬ ) (ฯ : X โ ๐) (e : is-embedding ฯ) โ ๐-iteration P f (๐-ssup X ฯ e) ๏ผ f X (ฮป x โ ๐-iteration P f (ฯ x)) ๐-iteration-behaviour P f = ๐-recursion-behaviour P (ฮป X ฯ e โ f X) \end{code} So we are essentially working with (an encoding) of the above non-strictly positive data type. The usual induction principle for iterative sets follows directly from the above form of induction. This consequence is already in Gylterud [4]. \begin{code} โ-induction : (P : ๐ โ ๐ฅ ฬ ) โ ((A : ๐) โ ((B : ๐) โ B โ A โ P B) โ P A) โ (A : ๐) โ P A โ-induction P IH = ๐-induction P f where f : (X : ๐ค ฬ ) (ฯ : X โ ๐) (e : is-embedding ฯ) โ ((x : X) โ P (ฯ x)) โ P (๐-ssup X ฯ e) f X ฯ e IH' = IH A s where A : ๐ A = ๐-ssup X ฯ e s : (B : ๐) โ B โ A โ P B s B@(.(underlying-mset (ฯ x)) , j) (x , refl) = II where I : P (ฯ x) I = IH' x II : P (underlying-mset (ฯ x) , j) II = transport P (to-subtype-๏ผ being-iset-is-prop refl) I \end{code} And then it follows immediately that the membership relation is accessible: \begin{code} โ-is-accessible : (A : ๐) โ is-accessible _โ_ A โ-is-accessible = โ-induction (is-accessible _โ_) (ฮป _ โ acc) \end{code} Singleton sets can be constructed as follows. \begin{code} โด_โต : (A : ๐) โ ๐ โด A โต = ๐-ssup ๐ (ฮป _ โ A) (global-point-is-embedding (ฮป _ โ A) ๐-is-set) โดโต-behaviour : (A : ๐) (B : ๐) โ B โ โด A โต โ (B ๏ผ A) โดโต-behaviour A B = B โ โด A โต โโจ โ-behaviour' B โด A โต โฉ ๐ ร (A ๏ผ B) โโจ ๐-lneutral โฉ (A ๏ผ B) โโจ ๏ผ-flip โฉ (B ๏ผ A) โ \end{code} Given a family of iterative sets indexed by a small type, we construct its union as in [4]. We make use of propositional truncations (to define the image of a map) and of set replacement (which follows from having set quotients). \begin{code} open import UF.PropTrunc module _ (pt : propositional-truncations-exist) where open PropositionalTruncation pt open import UF.ImageAndSurjection pt module unions-of-iterative-sets (sr : Set-Replacement pt) where private module union-construction {I : ๐ค ฬ } (๐ : I โ ๐) where im : ๐คโบ ฬ im = image ๐ im-is-small : image ๐ is ๐ค small im-is-small = sr ๐ (I , โ-refl I) ๐-is-locally-small ๐-is-set imโป : ๐ค ฬ imโป = resized im im-is-small imโป-โ-im : imโป โ im imโป-โ-im = resizing-condition im-is-small ฯ : im โ ๐ ฯ = restriction ๐ ฯโป : imโป โ ๐ ฯโป = ฯ โ โ imโป-โ-im โ ฯ-is-embedding : is-embedding ฯ ฯ-is-embedding = restrictions-are-embeddings ๐ ฯโป-is-embedding : is-embedding ฯโป ฯโป-is-embedding = โ-is-embedding (equivs-are-embeddings โ imโป-โ-im โ (โโ-is-equiv imโป-โ-im)) ฯ-is-embedding โ : {I : ๐ค ฬ } (๐ : I โ ๐) โ ๐ โ {I} ๐ = ๐-ssup imโป ฯโป ฯโป-is-embedding where open union-construction ๐ โ-behaviour : {I : ๐ค ฬ } (๐ : I โ ๐) (B : ๐) โ B โ โ ๐ โ (โ i ๊ I , B ๏ผ ๐ i) โ-behaviour {I} ๐ B = B โ โ ๐ โโจ โ-behaviour' B (โ ๐) โฉ (ฮฃ j ๊ imโป , ฯโป j ๏ผ B) โโจ eโ โฉ (ฮฃ j ๊ im , ฯ j ๏ผ B) โโจ ฮฃ-assoc โฉ (ฮฃ C ๊ ๐ , C โimage ๐ ร (C ๏ผ B)) โโจ ฮฃ-cong (ฮป C โ ร-comm) โฉ (ฮฃ C ๊ ๐ , (C ๏ผ B) ร (C โimage ๐)) โโจ โ-sym ฮฃ-assoc โฉ (ฮฃ s ๊ singleton-type' B , prโ s โimage ๐) โโจ โ-sym eโ โฉ ๐ {๐ค} ร B โimage ๐ โโจ ๐-lneutral โฉ (โ i ๊ I , ๐ i ๏ผ B) โโจ โ-cong pt (ฮป i โ ๏ผ-flip) โฉ (โ i ๊ I , B ๏ผ ๐ i) โ where open union-construction ๐ eโ = ฮฃ-change-of-variable-โ _ imโป-โ-im eโ = ฮฃ-change-of-variable-โ _ (singleton-โ-๐' (singleton-types'-are-singletons B)) \end{code} Any iterative set is the union of its ๐-forest. \begin{code} โ-ฮท : (A : ๐) โ โ (๐-forest A) ๏ผ A โ-ฮท A = โ-is-extensional (โ (๐-forest A)) A i j where i : โ (๐-forest A) โ A i B m = โฅโฅ-rec (โ-is-prop-valued B A) f (โ โ-behaviour (๐-forest A) B โ m) where f : (ฮฃ a ๊ ๐-root A , B ๏ผ ๐-forest A a) โ B โ A f (a , refl) = ๐-forest-โ A a j : A โ โ (๐-forest A) j B m = โ โ-behaviour (๐-forest A) B โโปยน โฃ a , e โฃ where abstract m' : ฮฃ a ๊ ๐-root A , ๐-forest A a ๏ผ B m' = โ โ-behaviour' B A โ m a : ๐-root A a = prโ m' e : B ๏ผ ๐-forest A a e = (prโ m') โปยน \end{code} Unions allow us to construct a retraction of the inclusion ๐ โช ๐, and this seems to be a new result. \begin{code} ๐-to-๐ : ๐ โ ๐ ๐-to-๐ (ssup X ฯ) = โ (๐-to-๐ โ ฯ) ๐-to-๐-is-retraction-of-inclusion : ๐-to-๐ โ underlying-mset ๏ผ id ๐-to-๐-is-retraction-of-inclusion = dfunext fe (โ-induction _ f) where f : (A : ๐) โ ((B : ๐) โ B โ A โ (๐-to-๐ โ underlying-mset) B ๏ผ B) โ (๐-to-๐ โ underlying-mset) A ๏ผ A f A IH = ๐-to-๐ Aโ ๏ผโจ I โฉ ๐-to-๐ (ssup (๐-root A) (๐-forest Aโ)) ๏ผโจ refl โฉ โ (๐-to-๐ โ ๐-forest Aโ) ๏ผโจ refl โฉ โ (๐-to-๐ โ underlying-mset โ ๐-forest A) ๏ผโจ II โฉ โ (๐-forest A) ๏ผโจ โ-ฮท A โฉ A โ where Aโ : ๐ Aโ = underlying-mset A I = ap (๐-to-๐ โ underlying-mset) (๐-ฮท A โปยน) II = ap โ (dfunext fe (ฮป a โ IH (๐-forest A a) (๐-forest-โ A a))) ๐-is-retract-of-๐ : retract ๐ of ๐ ๐-is-retract-of-๐ = ๐-to-๐ , underlying-mset , happly ๐-to-๐-is-retraction-of-inclusion \end{code}