Martin Escardo and Tom de Jong, 9th December 2023. We discuss "hereditarily finitely linearly ordered iterative multisets". Notice that this is data, rather then property. \begin{code} {-# OPTIONS --safe --without-K #-} open import MLTT.Spartan hiding (_^_) open import UF.Univalence module Iterative.Multisets-HFLO (ua : Univalence) (π€ : Universe) where open import Iterative.Multisets π€ open import Iterative.Multisets-Addendum ua π€ open import UF.Base open import UF.Equiv open import UF.EquivalenceExamples open import UF.FunExt open import UF.Subsingletons open import UF.UA-FunExt open import W.Type private π€βΊ : Universe π€βΊ = π€ βΊ fe : Fun-Ext fe = Univalence-gives-Fun-Ext ua fe' : FunExt fe' π€ π₯ = fe {π€} {π₯} open import Fin.Bishop open import Fin.Type hflo-data : π β π€ Μ hflo-data (ssup X Ο) = finite-linear-order X Γ ((x : X) β hflo-data (Ο x)) hflo-data-gives-finite-linear-order : (M : π) β hflo-data M β finite-linear-order (π-root M) hflo-data-gives-finite-linear-order (ssup x Ο) = prβ π-subtrees-have-hflo-data : (M : π) β hflo-data M β (x : π-root M) β hflo-data (π-forest M x) π-subtrees-have-hflo-data (ssup x Ο) = prβ β : π€βΊ Μ β = Ξ£ M κ π , hflo-data M β-underlying-mset : β β π β-underlying-mset = prβ hflo-structure : (H : β) β hflo-data (β-underlying-mset H) hflo-structure = prβ \end{code} Examples. We will use the superscript H to indicate elements of the type β. \begin{code} πα΄Ή-hflo-data : hflo-data πα΄Ή πα΄Ή-hflo-data = (0 , f) , (Ξ» (x : π) β π-elim x) where f : π {π€} β π {π€β} f = one-π-only πα΄΄ : β πα΄΄ = πα΄Ή , πα΄Ή-hflo-data open import UF.Equiv-FunExt πα΄΄-equality : (H : β) β is-empty (π-root (β-underlying-mset H)) β πα΄΄ οΌ H πα΄΄-equality (ssup X Ο , (0 , f) , Ξ΄) e = to-Ξ£-οΌ ((to-π-οΌ (eqtoid (ua π€) π X (β-sym (f β one-π-only)) , dfunext fe (Ξ» (x : π) β π-elim x))) , I) where I : {d : hflo-data (ssup X Ο)} β d οΌ (zero , f) , Ξ΄ I {(zero , f') , Ξ΄'} = to-Ξ£-οΌ (to-Ξ£-οΌ (refl , to-subtype-οΌ (being-equiv-is-prop fe') (dfunext fe (Ξ» x β π-elim (β f β x)))) , dfunext fe (Ξ» x β π-elim (β f β x))) I {(succ n' , f') , Ξ΄'} = π-elim (e (β f' ββ»ΒΉ π)) πα΄΄-equality (ssup X Ο , (succ n , f) , Ξ΄) e = π-elim (e (β f ββ»ΒΉ π)) πα΄Ή-hflo-data : hflo-data πα΄Ή πα΄Ή-hflo-data = (1 , f) , (Ξ» β β πα΄Ή-hflo-data) where f : π {π€} β π {π€β} + π {π€β} f = π-lneutral'' πα΄΄ : β πα΄΄ = πα΄Ή , πα΄Ή-hflo-data πα΄Ή-hflo-data : hflo-data πα΄Ή πα΄Ή-hflo-data = π+π-natural-finite-linear-order , dep-cases (Ξ» _ β πα΄Ή-hflo-data) (Ξ» _ β πα΄Ή-hflo-data) πα΄΄ : β πα΄΄ = πα΄Ή , πα΄Ή-hflo-data open import Fin.ArithmeticViaEquivalence Ξ£α΄Ή-hflo-data : {X : π€ Μ } (A : X β π) β finite-linear-order X β ((x : X) β hflo-data (A x)) β hflo-data (Ξ£α΄Ή A) Ξ£α΄Ή-hflo-data {X} A (n , f) A-hflo = (β a , h) , Ξ΄ where u : (x : X) β Ξ£ m κ β , π-root (A x) β Fin m u x = hflo-data-gives-finite-linear-order (A x) (A-hflo x) a : Fin n β β a i = prβ (u (β f ββ»ΒΉ i)) b : (i : Fin n) β π-root (A (β f ββ»ΒΉ i)) β Fin (a i) b i = prβ (u (β f ββ»ΒΉ i)) h = (Ξ£ x κ X , π-root (A x)) ββ¨ hβ β© (Ξ£ i κ Fin n , π-root (A (β f ββ»ΒΉ i))) ββ¨ hβ β© (Ξ£ i κ Fin n , Fin (a i)) ββ¨ hβ β© Fin (β a) β where hβ = β-sym (Ξ£-change-of-variable-β (Ξ» x β π-root (A x)) (β-sym f)) hβ = Ξ£-cong b hβ = β-sym (β-property a) Ξ΄ : ((x , y) : Ξ£ x κ X , π-root (A x)) β hflo-data (π-forest (A x) y) Ξ΄ (x , y) = π-subtrees-have-hflo-data (A x) (A-hflo x) y Ξ α΄Ή-hflo-data : {X : π€ Μ } (A : X β π) β finite-linear-order X β ((x : X) β hflo-data (A x)) β hflo-data (Ξ α΄Ή A) Ξ α΄Ή-hflo-data {X} A (n , f) A-hflo = (β fe a , h) , Ξ΄ where u : (x : X) β Ξ£ m κ β , π-root (A x) β Fin m u x = hflo-data-gives-finite-linear-order (A x) (A-hflo x) a : Fin n β β a i = prβ (u (β f ββ»ΒΉ i)) b : (i : Fin n) β π-root (A (β f ββ»ΒΉ i)) β Fin (a i) b i = prβ (u (β f ββ»ΒΉ i)) h = (Ξ x κ X , π-root (A x)) ββ¨ hβ β© (Ξ i κ Fin n , π-root (A (β f ββ»ΒΉ i))) ββ¨ hβ β© (Ξ i κ Fin n , Fin (a i)) ββ¨ hβ β© Fin (β fe a) β where hβ = β-sym (Ξ -change-of-variable-β fe' (Ξ» x β π-root (A x)) (β-sym f)) hβ = Ξ -cong fe fe b hβ = β-sym (β-property fe a) v : (x : X) (y : π-root (A x)) β hflo-data (π-forest (A x) y) v x = π-subtrees-have-hflo-data (A x) (A-hflo x) Ξ΄ : (g : Ξ x κ X , π-root (A x)) β hflo-data (Ξ£α΄Ή (Ξ» x β π-forest (A x) (g x))) Ξ΄ g = Ξ£α΄Ή-hflo-data (Ξ» x β π-forest (A x) (g x)) (n , f) (Ξ» x β v x (g x)) +α΄Ή-hflo-data : (M N : π) β hflo-data M β hflo-data N β hflo-data (M +α΄Ή N) +α΄Ή-hflo-data M N h k = Ξ£α΄Ή-hflo-data (cases (Ξ» _ β M) (Ξ» _ β N)) π+π-natural-finite-linear-order (dep-cases (Ξ» _ β h) (Ξ» _ β k)) Γα΄Ή-hflo-data : (M N : π) β hflo-data M β hflo-data N β hflo-data (M Γα΄Ή N) Γα΄Ή-hflo-data M N h k = Ξ α΄Ή-hflo-data (cases (Ξ» _ β M) (Ξ» _ β N)) π+π-natural-finite-linear-order (dep-cases (Ξ» _ β h) (Ξ» _ β k)) Γα΄Ή'-hflo-data : (M N : π) β hflo-data M β hflo-data N β hflo-data (M Γα΄Ή' N) Γα΄Ή'-hflo-data (ssup X Ο) (ssup Y Ξ³) ((n , f) , u) ((m , g) , v) = (n Γ' m , (X Γ Y ββ¨ Γ-cong f g β© Fin n Γ Fin m ββ¨ β-sym (FinΓhomo n m) β© Fin (n Γ' m) β )) , (Ξ» (x , y) β Γα΄Ή'-hflo-data (Ο x) (Ξ³ y) (u x) (v y)) _+α΄΄_ _Γα΄΄_ _Γα΄΄'_ : β β β β β (M , h) +α΄΄ (N , k) = M +α΄Ή N , +α΄Ή-hflo-data M N h k (M , h) Γα΄΄ (N , k) = M Γα΄Ή N , Γα΄Ή-hflo-data M N h k (M , h) Γα΄΄' (N , k) = M Γα΄Ή' N , Γα΄Ή'-hflo-data M N h k \end{code} TODO. Define Ξ£α΄΄ and Ξ α΄΄. (Boilerplate.) We now develop a representation of elements of β for the sake of being able to exhibit examples explicitly and visually. \begin{code} data _^_ (X : π₯ Μ ) : β β π₯ Μ where Β· : X ^ 0 _,_ : {n : β} β X β X ^ n β X ^ (succ n) data π : π€ Μ where [_] : {n : β} β π ^ n β π to-vector : (n : β) β (Fin n β π) β π ^ n to-vector 0 f = Β· to-vector (succ n) f = f π , to-vector n (f β suc) to-π-curried : (M : π) β hflo-data M β π to-π-curried (ssup X Ο) ((n , f) , Ξ΄) = [ to-vector n (Ξ» (i : Fin n) β to-π-curried (Ο (β f ββ»ΒΉ i)) (Ξ΄ (β f ββ»ΒΉ i))) ] to-π : β β π to-π = uncurry to-π-curried \end{code} Examples. \begin{code} private s = to-π πα΄΄ πα΄΄' : β πα΄΄ = πα΄΄ +α΄΄ πα΄΄ πα΄΄' = πα΄΄ +α΄΄ πα΄΄ πΛ’ πΛ’ πΛ’ πΛ’ πΛ’' : π πΛ’ = s πα΄΄ πΛ’ = s πα΄΄ πΛ’ = s πα΄΄ πΛ’ = s πα΄΄ πΛ’' = s πα΄΄' examplesΛ’ : ( πΛ’ οΌ [ Β· ] ) Γ ( πΛ’ οΌ [ πΛ’ , Β· ] ) Γ ( πΛ’ οΌ [ πΛ’ , πΛ’ , Β· ] ) Γ ( πΛ’ οΌ [ πΛ’ , πΛ’ , πΛ’ , Β· ] ) Γ ( πΛ’' οΌ [ πΛ’ , πΛ’ , πΛ’ , Β· ] ) Γ ( s (πα΄΄ Γα΄΄ πα΄΄) οΌ [ πΛ’ , πΛ’ , πΛ’ , [ πΛ’ , πΛ’ , Β· ] , Β· ] ) Γ ( s (πα΄΄ Γα΄΄' πα΄΄) οΌ [ πΛ’ , πΛ’ , πΛ’ , πΛ’ , Β· ] ) Γ ( s (πα΄΄ +α΄΄ πα΄΄) οΌ πΛ’ ) Γ ( s (πα΄΄ +α΄΄ πα΄΄) οΌ πΛ’ ) Γ ( s (πα΄΄ +α΄΄ πα΄΄) οΌ [ πΛ’ , πΛ’ , Β· ] ) Γ ( s (πα΄΄ +α΄΄ πα΄΄) οΌ [ πΛ’ , πΛ’ , πΛ’ , πΛ’ , πΛ’ , πΛ’ , Β· ] ) Γ ( s (πα΄΄ Γα΄΄ πα΄΄) οΌ [ πΛ’ , πΛ’ , πΛ’ , πΛ’ , [ πΛ’ , πΛ’ , Β· ] , πΛ’ , πΛ’ , πΛ’ , πΛ’ , Β· ] ) Γ ( s (πα΄΄ Γα΄΄' πα΄΄) οΌ [ πΛ’ , πΛ’ , πΛ’ , πΛ’ , πΛ’ , πΛ’ , πΛ’ , πΛ’ , πΛ’ , Β· ] ) Γ ( s (πα΄΄' Γα΄΄ πα΄΄') οΌ [ πΛ’ , πΛ’ , πΛ’ , πΛ’ , πΛ’ , πΛ’ , πΛ’ , πΛ’ , [ πΛ’ , πΛ’ , Β· ] , Β· ] ) examplesΛ’ = refl , refl , refl , refl , refl , refl , refl , refl , refl , refl , refl , refl , refl , refl \end{code}