Partiality, Revisited The Partiality Monad as a Quotient Inductive-Inductive Type Thorsten Altenkirch1 Nils Anders Danielsson2 Nicolai Kraus1 1 University of Nottingham 2 University of Gothenburg FoSSaCS, 26 April 2017 Partiality Task: Given f ∶ N → N, find n ∶ N such that f (n) = 0. In many languages (e.g. Haskell): easy to write such a function (N → N) → N Our setting: intensional Martin-Löf type theory (e.g. Agda) ● formal system with Σ-, Π-, identity types, . . . ● can be used for programming ● potential foundation of mathematics All functions are total! Partiality Our goal: A monad M ∶ Type → Type such that M(A) is a “type of partial elements” in MLTT. Attempt: Maybe monad, M(A) ∶≡ 1 + A. Not good, “too decidable”: cannot construct suitable function (N → N) → 1 + N. Attempt: M(A) ∶≡ ΣQ∶Prop (Q → A). (Cf. Escardó-Knapp 2017) Here not good, “too undecidable”. Our goal: something “semidecidable”. Delay monad Better attempt: Delay Monad (Capretta 2005). D(A) is the coinductive type generated by ● now ∶ A → D(A) ● later ∶ D(A) → D(A). Equivalent representation: functions N → (1 + A) which become constant once they are inr(a). Back to the problem “find a zero”: Yes, we can define a function (N → N) → D(N). But D(A) is very intensional: later(now(a)) =/ later(later(now(a)). Our goal: more extensionality. Delay monad, quotiented Weak bisimilarity: binary relation ≈ on D(A). Intuition: x ≈ y iff x and y become equal after removing some “laters”, thus: later(now(a)) ≈ later(later(now(a))). Chapman, Uustalu, Veltri: Quotienting the delay monad by weak bisimilarity (2015). Use D(A)/ ≈ (quotient as introduced by Hofmann). D(_)/≈ is a monad on Type assuming countable choice. Countable choice: Πn∶N ∥A(n)∥ → ∥Πn∶N A(n)∥, “for every n, there exists A(n)” → “there exists a function giving A(n) for every n”. Our goal: avoiding choice. Quotient inductive-inductive types We use a combination of two concepts: ● higher inductive types from homotopy type theory: inductive types can have constructors for equalities ● induction-induction This combination is also used in the HoTT book to define the Cauchy reals. ● Caveat: computational interpretation conjectured, but still experimental ● Only need special case (quotient inductive-inductive types), examined by Dijkstra (2016). Partiality monad, the construction Define type (set) A and ⊑∶ A → A → Prop simultaneously: Inductive type (set) A with constructors: η ∶ A → A ∶ A ⊔ ∶ (Σs∶N→A Πn∶N sn ⊑ sn+1 ) → A α ∶ Πx,y ∶A x ⊑ y → y ⊑ x → x = y Inductive relation ⊑ given by the rules: x ⊑y x ⊑x y ⊑z x ⊑z ⊑x Πn∶N sn ⊑ x Πn∶N sn ⊑ ⊔(s, p) ⊔(s, p) ⊑ x Further characterisations We get an adjunction: our construction SET ωCPO forgetting structure Note: categories can be defined internally: ● SET – types (actually sets) ● ωCPO – types (sets) with structure making them ω-complete partial orders Connection between the constructions Assuming countable choice, our construction is equivalent to Chapman-Uustalu-Veltri’s: A ≃ D(A)/≈ Why do we need countable choice? ! w ∶ D(A) → A ! w preserves weak bisimilarity (≈) ! (w (d) = w (e)) → (d ≈ e) ! surjectivity: Πx∶A ∥Σd∶D(A) w (d) = x∥ Induction on x; case x ≡ ⊔s needs countable choice Final words Some applications: ● non-terminating functions as fixed points, e.g. (N → N) → N ● functions from the Cauchy reals, developed further by Gilbert (2017) ● topology with 1 , . . . We have formalised this in Agda. Take home message: Constructing an inductive type simultaneously with its equalities is also useful “outside homotopy type theory”. Thank you for your attention!
© Copyright 2026 Paperzz