Reference. Type Universes as Kripke Worlds
What are mutable references; what do they mean? The answers to these questions have spawned lots of important theoretical work and form the foundation of many impactful tools. However, existing semantics collapse a key distinction: which allocations does a reference depend on? In this paper, we deconstruct the space of mutable higher-order references. We formalize a novel distinction–splitting the design space of references not only into higher-order vs (full-)ground references, but also dependency of an allocation on past vs future allocations. This distinction is fundamental to a thorny issue that arises in constructing semantic models of mutable references–the type-world circularity. The issue disappears for what we call predicative references, those that only quantify over past, not future, allocations, and for non-higher-order impredicative references. We design a syntax and semantics for each point in our newly described space. The syntax relies on a type universe hierarchy, à la dependent type theory, to kind the types of allocated terms, and stratify allocations. Each type universe corresponds to a semantic Kripke world, giving a lightweight syntactic mechanism to design and restrict heap shapes. The semantics bear a resemblance to work on regions, and suggest some connection between universe systems and regions, which we describe in some detail.
Cite
Cites 42 works (2 here)
With notes (2)
Stratified Type Theory chan-2025-stratified
A hierarchy of type universes is a rudimentary ingredient in the type theories of many proof assistants to prevent the logical inconsistency resulting from combining dependent functions and the type-in-type axiom. In this work, we argue that a universe hierarchy is not the only option for universes in type theory. Taking inspiration from Leivant’s Stratified System F, we introduce Stratified Type Theory (), where rather than stratifying universes by levels, we stratify typing judgements and restrict the domain of dependent functions to strictly lower levels. Even with type-in-type, this restriction suffices to enforce consistency. In , we consider a number of extensions beyond just stratified dependent functions. First, the subsystem employs McBride’s crude-but-effective stratification (also known as displacement) as a simple form of level polymorphism where global definitions with concrete levels can be displaced uniformly to any higher level. Second, to recover some expressivity lost due to the restriction on dependent function domains, the full includes a separate nondependent function type with a floating domain whose level matches that of the overall function type. Finally, we have implemented a prototype type checker for extended with datatypes and inference for level and displacement annotations, along with a small core library. We have proven to be consistent and to be type safe, but consistency of the full remains an open problem, largely due to the interaction between floating functions and cumulativity of judgements. Nevertheless, we believe to be consistent, and as evidence have verified the ill-typedness of some well-known type-theoretic paradoxes using our implementation.
An Order-Theoretic Analysis of Universe Polymorphism houfavonia-2023-an
We present a novel formulation of universe polymorphism in dependent type theory in terms of monads on the category of strict partial orders, and a novel algebraic structure, displacement algebras, on top of which one can implement a generalized form of McBride’s “crude but effective stratification” scheme for lightweight universe polymorphism. We give some examples of exotic but consistent universe hierarchies, and prove that every universe hierarchy in our sense can be embedded in a displacement algebra and hence implemented via our generalization of McBride’s scheme. Many of our technical results are mechanized in Agda, and we have an OCaml library for universe levels based on displacement algebras, for use in proof assistant implementations.
External (40)
- Oxidizing OCaml with Modal Memory Management (2024)
- Reference Capabilities for Flexible Memory Management (2023)
- Capturing Types (2023)
- Polymorphic Reachability Types: Tracking Freshness, Aliasing, and Separation in Higher-Order Generic Programs (2023)
- A flexible type system for fearless concurrency (2022)
- Reachability types: tracking aliasing and separation in higher-order functional programs (2021)
- The fire triangle: how to mix substitution, dependent elimination, and effects (2019)
- A monad for full ground reference cells (2017)
- Dijkstra monads for free (2016)
- Strong Normalisation in λ-Calculi with References (2012)
- Algorithmic Games for Full Ground References (2012)
- Secure distributed programming with value-dependent types (2011)
- Termination of Threads with Shared Memory via Infinitary Choice (2011)
- Termination in Impure Concurrent Languages (2010)
- State-dependent representation independence (2009)
- On Stratified Regions (2009)
- Universe Types for Topology and Encapsulation (2008)
- Global State Considered Helpful (2008)
- A very modal model of a modern, major, general type system (2007)
- Fair Cooperative Multithreading (2007)
- Typing termination in a higher-order concurrent imperative language (2007)
- L3: A Linear Language with Locations (2005)
- Relational Reasoning in a Nominal Semantics for Storage (2005)
- Advanced Topics in Types and Programming Languages (2005)
- Universes: Lightweight Ownership for JML (2005)
- Semantics of Types for Mutable State (PhD dissertation) (2004)
- Possible World Semantics for General Storage in Call-By-Value (2002)
- Types and Programming Languages (2002)
- An indexed model of recursive types for foundational proof-carrying code (2001)
- Call-by-push-value (2001)
- Operational reasoning for functions with local state (1999)
- A fully abstract game semantics for general references (1998)
- Region-based Memory Management (1997)
- An Intuitionistic Theory of Types: Predicative Part (1975)
- Interprétation fonctionelle et élimination des coupures de l’arithmétique d’ordre supérieur (1972)
- The Mechanical Evaluation of Expressions (1964)
- The Sun Also Rises (1926)
- 10.48550/arxiv.2309.05885
- Crude but Effective Stratification (Epilogue blog)
- Swift Language Documentation: Strong Reference Cycles for Closures