Presentation. Towards univalent reference types [00OI]
Slide Side effects in programming languages
- February 10, 2024
- Jon Sterling, Daniel Gratzer, Lars Birkedal
Most practical programming languages have side effects: state, input-output, errors, etc.
Monads capture the structure of side effects (Moggi, Wadler).
Slide State as a side effect
- February 10, 2024
- Jon Sterling, Daniel Gratzer, Lars Birkedal
State means being able to interact with the computer’s memory; references or pointers govern access to a location in memory.
The syntax of state varies along three axes:
What kind of things can be stored in memory cells?
(numbers? pointers?? procedures???)
(first-order \Rightarrow ground \Rightarrow higher-order)
When can these memory cells be allocated?
(statically? dynamically??)
What equations hold of stateful computations?
(garbage collection??, representation independence??)
Slide First-order dynamic allocation
- February 10, 2024
- Jon Sterling, Daniel Gratzer, Lars Birkedal
Storing only integers or other first-order data.
Models of very extensional equational theory including “garbage collection” found by Plotkin, Power; Staton. Adapted to “full ground store” (storage of pointers) by Kammar, Levy, Moss, and Staton.
Extensionality of models lost when moving to higher-order storage.
Slide Higher-order dynamic allocation
- February 10, 2024
- Jon Sterling, Daniel Gratzer, Lars Birkedal
An extreme point in the design space...
Deeply impredicative: heap contains elements of arbitrary types.
\Longrightarrow guarded recursion (step-indexing) used to break the circularity.
Slide Guarded higher-order dynamic allocation
- February 10, 2024
- Jon Sterling, Daniel Gratzer, Lars Birkedal
An equational theory of higher-order store in which reads to the heap leave behind “breadcrumbs”.
Slide Representation independence in the heap
- February 10, 2024
- Jon Sterling, Daniel Gratzer, Lars Birkedal
Consider two implementations of an “counter” object:
Slide Representation independence in the heap (II)
- February 10, 2024
- Jon Sterling, Daniel Gratzer, Lars Birkedal
What is the relationship between \mathsf {posCounter} and \mathsf {negCounter}?
They appear to be indistinguishable. Indeed, they are “observationally equivalent”!
\forall \mathcal {C}{\mathopen {}\left [-\right ]\mathclose {}}\colon \mathsf {Counter}\to \mathsf {T}\,{\mathopen {}\left (\right )\mathclose {}}\mathpunct {.} \mathcal {C}{\mathopen {}\left [\mathsf {posCounter}\right ]\mathclose {}} \mathord {\downarrow } \Leftrightarrow \mathcal {C}{\mathopen {}\left [\mathsf {negCounter}\right ]\mathclose {}} \mathord {\downarrow }Observational equivalence is an extremely weak property: indistinguishability under observations of ground type only.
Slide Univalent reference types
- February 10, 2024
- Jon Sterling, Daniel Gratzer, Lars Birkedal
We add two additional rules to the equational theory of guarded higher-order dynamic allocation.
LAYOUT UNIVALENCE.
CELL UNIVALENCE. For f^+\colon A\to B and f^-\colon B\to A with x:B\vdash f^+{\mathopen {}\left (f^-{\mathopen {}\left (x\right )\mathclose {}}\right )\mathclose {}}\equiv x and x\colon A\vdash f^-{\mathopen {}\left (f^+{\mathopen {}\left (x\right )\mathclose {}}\right )\mathclose {}} \equiv x we have:
Slide Representation independence in the heap (III)
- February 10, 2024
- Jon Sterling, Daniel Gratzer, Lars Birkedal
The theory of univalent reference types derives \vdash \mathsf {posCounter} \equiv \mathsf {negCounter}.
Proof.
- February 10, 2024
- Jon Sterling, Daniel Gratzer, Lars Birkedal
The function \mathsf {neg} \colon \mathsf {Integer}\to \mathsf {Integer} is inverse to itself; therefore, apply CELL UNIVALENCE with f^+ \equiv f^- \equiv \mathsf {neg} and simplify.
Slide Can we find a reasonable model of this theory???
- February 10, 2024
- Jon Sterling, Daniel Gratzer, Lars Birkedal
Let’s start with the non-univalent fragment (“guarded higher-order dynamic allocation”).
Slide Models of guarded higher order dynamic allocation
- February 10, 2024
- Jon Sterling, Daniel Gratzer, Lars Birkedal
S., Gratzer, and Birkedal (2022) found synthetic denotational semantics for guarded higher-order dynamic allocation in an impredicative version of guarded dependent type theory (iGDTT).
Guarded recursion needed to solve the domain equation; impredicativity needed to define the monad (b/c \mathsf {Heap} is large).
Slide Models of univalent reference types
- February 10, 2024
- Jon Sterling, Daniel Gratzer, Lars Birkedal
Our main observation is that a slight variation on SGB’22 suffices to model univalent reference types, so long as both \mathbf {FinSet} and \mathbf {Set} are both univalent universes in the sense of Voevodsky.
- Univalence of \mathbf {FinSet} implies the LAYOUT UNIVALENCE rule.
- Univalence of \mathbf {Set} implies the CELL UNIVALENCE rule.
We therefore need an impredicative version of guarded homotopy type theory.
Slide Impredicative Guarded Homotopy Type Theory
- February 10, 2024
- Jon Sterling, Daniel Gratzer, Lars Birkedal
We define iGHoTT to be the extension of Martin-Löf’s intensional type theory by the following additional features:
- homotopy type theory: the univalence axiom
- guarded recursion: later modality \mathord {\blacktriangleright } and solutions to guarded fixed points
- a univalent impredicative universe, i.e. a universe \mathcal {S}\in \mathcal {U} closed under families of \mathcal {S}-small types indexed in a \mathcal {U}-small type.
In iGHoTT, we can define a model of univalent reference types. The real question is whether we can find a model of iGHoTT.
Slide Models of iGDTT
- February 10, 2024
- Jon Sterling, Daniel Gratzer, Lars Birkedal
Palombi and S. (2023) have contributed a modular method for building models of (non-univalent) guarded dependent type theory over an arbitrary base topos. As applied by SGB’22:
- Any realisability topos \mathcal {E} contains an impredicative universe \mathbb {M}_{\mathcal {E}}.
- Pick any internal well-founded order \mathbb {O}\in \mathbb {M}_{\mathcal {E}}.
- Then the relative presheaf topos \mathcal {F} :\equiv {\mathopen {}\left [\mathbb {O}^{\mathsf {op}},\mathcal {E}\right ]\mathclose {}} is a model of guarded recursion and contains an impredicative universe \mathbb {M}_{\mathcal {F}} defined from \mathbb {M}_{\mathcal {E}} by Hofmann—Streicher lifting.
Slide Towards models of iGHoTT
- February 10, 2024
- Jon Sterling, Daniel Gratzer, Lars Birkedal
We have not gotten around to adapting the SGB’22 model of iGDTT to obtain a model of iGHoTT, which is much more complicated.
- Let \mathbb {A} be a partial combinatory algebra.
- Let \square be a suitable internal cube category in \mathbf {PER}{\mathopen {}\left (\mathbb {A}\right )\mathclose {}}, and let \mathbb {O} be an internal well-founded order in the same.
- Then the category of internal presheaves of assemblies {\mathopen {}\left [{\mathopen {}\left (\square \times \mathbb {O}\right )\mathclose {}}^{\mathsf {op}},\mathbf {Asm}{\mathopen {}\left (\mathbb {A}\right )\mathclose {}}\right ]\mathclose {}} is expected to form a model of iGHoTT{}.
Impredicative HoTT via cubical assemblies due to Awodey et al. and studied by Uemura, Swan.
Guarded HoTT via \square \times \mathbb {O} due to Birkedal et al. (2019).
Slide A more canonical model of iGHoTT?
- February 10, 2024
- Jon Sterling, Daniel Gratzer, Lars Birkedal
Even if internal presheaves of assemblies on \square \times \mathbb {O} works, the resulting model will be uncanonical from the {\mathopen {}\left (\infty ,1\right )\mathclose {}}-categorical standpoint.
For example, if \mathbb {O}=\omega , we shall not have defined the “internal (pre)-{\mathopen {}\left (\infty ,1\right )\mathclose {}}-topos of trees” in cubical assemblies.
More canonical approach would be to take internal presheaves on any \mathcal {S}-small well-founded order \mathbb {O} internal to the {\mathopen {}\left (\infty ,1\right )\mathclose {}}-category \mathcal {E} presented by {\mathopen {}\left [\square ^{\mathsf {op}},\mathbf {Asm}{\mathopen {}\left (\mathbb {A}\right )\mathclose {}}\right ]\mathclose {}}. This may introduce coherence problems that we are currently unprepared for.
Slide Comparing with other realisability models of state
- February 10, 2024
- Jon Sterling, Daniel Gratzer, Lars Birkedal
SGB’22 were not the first to combine guarded recursion with realisability to model higher-order dynamic allocation; see Birkedal, Støvring, and Thamsborg (2010).
However, op.cit. relied on a specific realisability model based on an untyped domain model of a stateful language; in contrast, the model construction of SGB’22 applies uniformly for any pair {\mathopen {}\left (\mathcal {E},\mathbb {O}\right )\mathclose {}}.
Thus SGB’22 showed that realisability is inessential: if we find any other viable source of impredicative universes besides realisability, SGB’22 would apply there too.
Slide
- February 10, 2024
- Jon Sterling, Daniel Gratzer, Lars Birkedal
Thanks!