一句话:提出统一处理多种生命周期、粒度与共享方式的资源类型系统,用可达性类型追踪个体与成组资源,并在 Rocq 中证明类型与内存安全。
静态强制安全的资源管理面临灵活生命周期与表达性共享之间的张力:基于区域的系统提供词法作用域下的批量管理,但资源是二等值,无法逃逸作用域或自由地从函数返回;Rust 等所有权与线性类型系统提供一等、非词法生命周期,但其不变式限制了高阶模式与共享表达能力。本文提出一个统一的类型系统,在类型层面一致地表示所有堆分配资源,并支持三种分配模式:一等非词法资源的新鲜分配、具有词法受限生命周期的二等资源新鲜分配,以及通过影子 arena 对资源进行分组以批量追踪与释放的共分配(coallocation)。系统基于 reachability types 扩展,能够追踪个体资源与成组资源,表达循环存储结构,并选择性地施加栈式生命周期纪律。这些机制形式化为 A <: * 与 {A} <: * 两个类型系统,并在 Rocq 中证明了类型安全与内存安全。
Statically enforcing safe resource management is challenging due to tensions between flexible lifetime dis-ciplines and expressive sharing patterns. Region-based systems offer lexically scoped regions under a stack discipline, wherein resources are managed in bulk. In many such systems, however, resources are second-class and can neither escape their scope nor be freely returned from functions. Ownership and linear type systems, such as Rust, offer first-class, non-lexical lifetimes with robust static guarantees, but rely on invariants that limit higher-order patterns and expressive sharing. In this work, we propose a type system that uniformly treats all heap-allocated resources under diverse lifetime, granularity, and sharing settings. Our system provides programmers with three allocation modes: (1) fresh allocation for first-class, non-lexical resources; (2) fresh allocation for second-class resources with lexically bounded lifetimes; and (3) coallocation that groups resources by shadow arenas for bulk tracking and deallocation. Regardless of mode, resources are represented uniformly at the type level, supporting generic abstraction and preserving the higher-order parametric nature of the language. Obtaining static safety in higher-order languages with flexible sharing is nontrivial. To address this, our solution builds on reachability types, and our extension adds the capability to track both individual and grouped resources, enables the expression of cyclic store structures, and allows the selective enforcing of stack lifetime discipline. These mechanisms are formalized in the A < : ∗ and { A } < : ∗ type systems, which are proven type safe and memory safe in Rocq.
@article{paperbot3834,
title = {When Lifetimes Liberate: A Type System for Arenas with Higher-Order Reachability Tracking},
author = {Siyuan He and Songlin Jia and Yuyan Bao and Tiark Rompf},
journal = {Proceedings of the ACM on Programming Languages},
volume = {10},
number = {OOPSLA1},
year = {2026},
doi = {10.1145/3798254}
}