Martin Escardo, June 2023. Paths in W-types. \begin{code} {-# OPTIONS --safe --without-K #-} open import MLTT.Spartan module W.Paths where open import UF.Logic open import UF.PropTrunc open import UF.Subsingletons open import W.Type open import W.Numbers module _ (X : π€ Μ ) (A : X β π₯ Μ ) where private π = W X A \end{code} Paths whose lengths can be measured with natural numbers. \begin{code} Pathβ : π β π€ β π₯ Μ Pathβ (ssup x Ο) = is-empty (A x) + (Ξ£ a κ A x , Pathβ (Ο a)) Pathβ-length : (w : π) β Pathβ w β β Pathβ-length (ssup x Ο) (inl _) = 0 Pathβ-length (ssup x Ο) (inr (a , as)) = succ (Pathβ-length (Ο a) as) \end{code} To construct such paths, we need to be able to decide pointedness. A weaker notion that doesn't require this is the following. \begin{code} module weaker-notion-of-path (pt : propositional-truncations-exist) where open PropositionalTruncation pt open Truncation pt renaming (β₯_β₯Ξ© to β¦_β§) Path : π β π€ β π₯ Μ Path (ssup x Ο) = β₯ A x β₯ β Ξ£ a κ A x , Path (Ο a) head : {w : π} β β₯ A (W-root w) β₯ β Path w β A (W-root w) head {ssup x Ο} s as = prβ (as s) tail : {w : π} (s : β₯ A (W-root w) β₯) (as : Path w) β Path (W-forest w (head s as)) tail {ssup x Ο} s as = prβ (as s) Pathβ-gives-Path : (w : π) β Pathβ w β Path w Pathβ-gives-Path (ssup x Ο) (inl e) aβ = π-elim (β₯β₯-rec π-is-prop e aβ) Pathβ-gives-Path (ssup x Ο) (inr (a , as)) aβ = a , Pathβ-gives-Path (Ο a) as \end{code} To measure the length of a path in the weaker sense, we need generalized natural numbers. \begin{code} Path-length : (w : π) β Path w β π Path-length (ssup x Ο) as = Suc β¦ A x β§ (Ξ» (s : β₯ A x β₯) β Path-length (Ο (head s as)) (tail s as)) \end{code} For example, descending chains in ordinals can be seen as paths in a W-type of ordinals. See Iterative.index.