Martin Escardo & Tom de Jong, June 2023. Iterative multisets. See the module Iterative.index for bibliographic references regarding this file. All the results of this file are in HΓ₯kon Gylterud [3]. \begin{code} {-# OPTIONS --safe --without-K #-} open import MLTT.Spartan module Iterative.Multisets (π€ : Universe) where open import UF.Base open import UF.Equiv open import UF.EquivalenceExamples open import UF.FunExt open import UF.Size open import UF.Subsingletons open import UF.UA-FunExt open import UF.Univalence open import W.Type open import W.Properties (π€ Μ ) id private π€βΊ : Universe π€βΊ = π€ βΊ \end{code} The type of iterative multisets: \begin{code} π : π€βΊ Μ π = W (π€ Μ ) id \end{code} This is equivalent to the following alternative definition. \begin{code} private data π' : π€βΊ Μ where ssup : (X : π€ Μ ) (Ο : X β π') β π' π-to-π' : π β π' π-to-π' (ssup X Ο) = ssup X (Ξ» x β π-to-π' (Ο x)) π'-to-π : π' β π π'-to-π (ssup X Ο) = ssup X (Ξ» x β π'-to-π (Ο x)) \end{code} Maybe add the proof that the above two functions are mutually inverse. But the only point of adding them is to make sure that the above comment remains valid if any change is made in the code, and the above two definitions seem to be enough for that purpose. Aside. Every W-type can be mapped to π as follows: \begin{code} W-to-π : {X : π€ Μ } {A : X β π€ Μ } β W X A β π W-to-π {X} {A} (ssup x f) = ssup (A x) (Ξ» a β W-to-π (f a)) \end{code} TODO. Is the above remark relevant in any way? In the case of ordinals, "ssup" stands for "strong supremum", "strict supremum" or "supremum of successors". See the module Iterative.Ordinals. The two destructors: \begin{code} π-root : π β π€ Μ π-root = W-root π-forest : (M : π) β π-root M β π π-forest = W-forest \end{code} The following properties of the above two destructors hold definitionally; \begin{code} π-ssup-root : (X : π€ Μ ) (Ο : X β π) β π-root (ssup X Ο) οΌ X π-ssup-root = W-ssup-root π-ssup-forest : (X : π€ Μ ) (Ο : X β π) β π-forest (ssup X Ο) οΌ Ο π-ssup-forest = W-ssup-forest \end{code} But the Ξ·-law holds only up to an identification: \begin{code} π-Ξ· : (M : π) β ssup (π-root M) (π-forest M) οΌ M π-Ξ· = W-Ξ· \end{code} The membership relation for multisets: \begin{code} _β _ : π β π β π€βΊ Μ M β N = Ξ£ x κ π-root N , π-forest N x οΌ M \end{code} The relation M β N can hold in multiple ways in general. We can think of M β N as measuring how many times M occurs as an element on N. Notice the following: \begin{code} private β -remark : (M N : π) β (M β N) οΌ fiber (π-forest N) M β -remark M N = refl \end{code} In particular, if π-forest N is an embedding, then M β N holds in at most one way. This situation is investigated in the module Iterative.Sets. The following fact is trivial, but it is good to have a name for it for the sake of clarity. \begin{code} π-forest-β : (M : π) (x : π-root M) β π-forest M x β M π-forest-β _ x = x , refl \end{code} The induction principle for π, and particular cases: \begin{code} π-induction : (P : π β π₯ Μ ) β ((X : π€ Μ ) (Ο : X β π) β ((x : X) β P (Ο x)) β P (ssup X Ο)) β (M : π) β P M π-induction = W-induction π-recursion : (P : π₯ Μ ) β ((X : π€ Μ ) β (X β π) β (X β P) β P) β π β P π-recursion = W-recursion π-iteration : (P : π₯ Μ ) β ((X : π€ Μ ) β (X β P) β P) β π β P π-iteration = W-iteration \end{code} A criterion for equality in π: \begin{code} to-π-οΌ : {X Y : π€ Μ } {Ο : X β π} {Ξ³ : Y β π} β (Ξ£ p κ X οΌ Y , Ο οΌ Ξ³ β Idtofun p) β ssup X Ο οΌ[ π ] ssup Y Ξ³ to-π-οΌ = to-W-οΌ from-π-οΌ : {X Y : π€ Μ } {Ο : X β π} {Ξ³ : Y β π} β ssup X Ο οΌ[ π ] ssup Y Ξ³ β Ξ£ p κ X οΌ Y , Ο οΌ Ξ³ β Idtofun p from-π-οΌ = from-W-οΌ from-to-π-οΌ : {X Y : π€ Μ } {Ο : X β π} {Ξ³ : Y β π} (Ο : Ξ£ p κ X οΌ Y , Ο οΌ Ξ³ β Idtofun p) β from-π-οΌ {X} {Y} {Ο} {Ξ³} (to-π-οΌ Ο) οΌ Ο from-to-π-οΌ = from-to-W-οΌ to-from-π-οΌ : {X Y : π€ Μ } {Ο : X β π} {Ξ³ : Y β π} (p : ssup X Ο οΌ ssup Y Ξ³) β to-π-οΌ (from-π-οΌ p) οΌ p to-from-π-οΌ = to-from-W-οΌ π-οΌ : {X Y : π€ Μ } {Ο : X β π} {Ξ³ : Y β π} β (ssup X Ο οΌ[ π ] ssup Y Ξ³) β (Ξ£ p κ X οΌ Y , Ο οΌ Ξ³ β Idtofun p) π-οΌ = W-οΌ π-οΌ' : (M N : π) β (M οΌ N) β (fiber ((π-forest N β_) β Idtofun) (π-forest M)) π-οΌ' M@(ssup X Ο) N@(ssup Y Ξ³) = (ssup X Ο οΌ ssup Y Ξ³) ββ¨ π-οΌ β© (Ξ£ p κ X οΌ Y , Ο οΌ Ξ³ β Idtofun p) ββ¨ Ξ£-cong (Ξ» p β οΌ-flip) β© (Ξ£ p κ X οΌ Y , Ξ³ β Idtofun p οΌ Ο) ββ¨ β-refl _ β© fiber ((Ξ³ β_) β Idtofun) Ο β \end{code} The above works in pure MLTT without any HoTT/UF assumptions. We now show that π is locally small assuming univalence. For this purpose, we characterize identification of multisets as follows. TODO. Notice that there is some ammount of repetition compared with Iterative.W-Properties. Can we avoid it by proving something more general that subsumes both cases? \begin{code} _βα΄Ή_ : π β π β π€ Μ ssup X Ο βα΄Ή ssup X' Ο' = Ξ£ π κ X β X' , ((x : X) β Ο x βα΄Ή Ο' (β π β x)) βα΄Ή-refl : (M : π) β M βα΄Ή M βα΄Ή-refl (ssup X Ο) = β-refl X , (Ξ» x β βα΄Ή-refl (Ο x)) singleton-typeα΄Ή : π β π€βΊ Μ singleton-typeα΄Ή M = Ξ£ t κ π , M βα΄Ή t M-center : (M : π) β singleton-typeα΄Ή M M-center M = M , βα΄Ή-refl M M-centrality : Univalence β (M : π) (Ο : singleton-typeα΄Ή M) β M-center M οΌ Ο M-centrality ua (ssup X Ο) (ssup Y Ξ³ , π , u) = V (eqtoid (ua π€) X Y π) (idtoeq-eqtoid (ua π€) X Y π β»ΒΉ) where V : (p : X οΌ Y) β π οΌ idtoeq X Y p β M-center (ssup X Ο) οΌ ssup Y Ξ³ , π , u V refl refl = IV where IH : (x : X) β M-center (Ο x) οΌ Ξ³ (β π β x) , u x IH x = M-centrality ua (Ο x) (Ξ³ (β π β x) , u x) I : (Ξ» x β M-center (Ο x)) οΌ (Ξ» x β Ξ³ (β π β x) , u x) I = dfunext (Univalence-gives-Fun-Ext ua) IH Ο : (Ξ£ Ξ΄ κ (X β π) , ((x : X) β Ο x βα΄Ή Ξ΄ x)) β singleton-typeα΄Ή (ssup X Ο) Ο (Ξ΄ , v) = ssup X Ξ΄ , β-refl X , v II : (Ο , Ξ» x β βα΄Ή-refl (Ο x)) οΌ (Ξ³ β β π β , u) II = ap Ξ Ξ£-distr I III : (ssup X Ο , β-refl X , Ξ» x β βα΄Ή-refl (Ο x)) οΌ (ssup X (Ξ³ β β π β) , β-refl X , u) III = ap Ο II IV = M-center (ssup X Ο) οΌβ¨ refl β© ssup X Ο , β-refl X , (Ξ» x β βα΄Ή-refl (Ο x)) οΌβ¨ III β© ssup X (Ξ³ β β π β) , β-refl X , u οΌβ¨ refl β© ssup Y Ξ³ , π , u β singleton-typesα΄Ή-are-singletons : Univalence β (M : π) β is-singleton (singleton-typeα΄Ή M) singleton-typesα΄Ή-are-singletons ua M = M-center M , M-centrality ua M idtoeqα΄Ή : (M N : π) β M οΌ N β M βα΄Ή N idtoeqα΄Ή M M refl = βα΄Ή-refl M idtoeqα΄Ή-is-equiv : Univalence β (M t : π) β is-equiv (idtoeqα΄Ή M t) idtoeqα΄Ή-is-equiv ua M = I where f : singleton-type M β singleton-typeα΄Ή M f = NatΞ£ (idtoeqα΄Ή M) f-is-equiv : is-equiv f f-is-equiv = maps-of-singletons-are-equivs f (singleton-types-are-singletons M) (singleton-typesα΄Ή-are-singletons ua M) I : (t : π) β is-equiv (idtoeqα΄Ή M t) I = NatΞ£-equiv-gives-fiberwise-equiv (idtoeqα΄Ή M) f-is-equiv π-οΌ-β : Univalence β (M N : π) β (M οΌ N) β (M βα΄Ή N) π-οΌ-β ua M N = idtoeqα΄Ή M N , idtoeqα΄Ή-is-equiv ua M N \end{code} And here is the desired conclusion: \begin{code} π-is-locally-small : Univalence β is-locally-small π π-is-locally-small ua M N = M βα΄Ή N , β-sym (π-οΌ-β ua M N) \end{code} Not only the type of identifications of elements of π has a small copy, but also so does the (multi-valued) membership relation: \begin{code} _β β»_ : π β π β π€ Μ M β β» N = Ξ£ x κ π-root N , π-forest N x βα΄Ή M β β»ββ : Univalence β (M N : π) β (M β N) β (M β β» N) β β»ββ ua M N = Ξ£-cong (Ξ» x β π-οΌ-β ua (π-forest N x) M) \end{code}