paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Imperative Compositional Programming: Type Sound Distributive Intersection Subtyping with References via Bidirectional Typing

命令式组合式编程:经双向类型化实现带可变引用的类型安全分配性交集子类型
OOPSLA 8(OOPSLA2)2024匹配度 3/10 · 该论文属于纯编程语言理论中的类型系统与语言设计,核心是分配性交集子类型、可变引用、双向类型化与 Coq 形式化,与用户关注的 PL→AI/AI→PL、LLM/Agent、浮点或贝叶斯程序分析没有直接关系。虽然文中提到用 CP 建模 live-variable analysis,但这只是示例,并非静态分析或 AI 交叉研究。引用 1 inbox
Wenjia Ye, Yaozhu Sun, Bruno C. d. S. Oliveira
dblp: 2026-09-10crossref: 2026-09-10

AI 速览

一句话:用双向类型化仅限制引用规则,在保留分配性交集子类型的同时为组合式编程加入可变引用,并机器化验证类型安全。

组合式编程(CP)以模块化为核心,其理论基础是带交集类型的纯函数式 System F 变体 F_i+,子类型的分配律是模块化能力的关键。然而 Davies 与 Pfenning 曾指出,分配性子类型规则与可变引用结合会导致类型不安全,他们提出的补救办法是删除分配律;但 CP 从根本上依赖分配律,无法照搬。本文重新审视该问题,提出采用双向类型化(bidirectional typing),只需对引用的类型规则施加较轻量的限制,即可同时保留分配律与不受限的交集引入规则,从而恢复类型安全。作者先给出一个基于 Davies–Pfenning 工作的通用演算以说明该方案的普适性,再给出带引用的 F_i+ 扩展,支持命令式组合式编程风格;同时实现了 CP 的引用扩展,并用它建模模块化的活跃变量分析。两个演算及其证明均已在 Coq 证明助手中机器化验证。

问题
分配性交集子类型与可变引用结合会导致类型不安全,而删除分配律的既有补救方案会破坏组合式编程赖以存在的模块化能力。
方法
采用双向类型化,仅限制引用的类型规则,同时保留子类型分配律与无限制的交集引入规则;先给出通用演算,再给出带引用的 F_i+ 扩展,并在 Coq 中机器化证明。
评估
在 Coq 证明助手中机器化验证两个演算的类型安全性,并实现 CP 的引用扩展,以模块化活跃变量分析为例展示其表达力。
原文摘要(Abstract)

Compositional programming is a programming paradigm that emphasizes modularity and is implemented in the CP programming language. The foundations for compositional programming are based on a purely functional variant of System F with intersection types, called F i + , which includes distributivity rules for subtyping. This paper shows how to extend compositional programming and CP with mutable references, enabling a modular, imperative compositional programming style. A technical obstacle solved in our work is the interaction between distributive intersection subtyping and mutable references. Davies and Pfenning [2000] studied this problem in standard formulations of intersection type systems and argued that, when combined with references, distributive subtyping rules lead to type unsoundness. To recover type soundness, they proposed dropping distributivity rules in subtyping. CP cannot adopt this solution, since it fundamentally relies on distributivity for modularity. Therefore, we revisit the problem and show that, by adopting bidirectional typing , a more lightweight and type sound restriction is possible: we can simply restrict the typing rule for references. This solution retains distributivity and an unrestricted intersection introduction rule. We present a first calculus, based on Davies and Pfenning ’s work, which illustrates the generality of our solution. Then we present an extension of F i + with references, which adopts our restriction and enables imperative compositional programming. We implement an extension of CP with references and show how to model a modular live-variable analysis in CP. Both calculi and their proofs are formalized in the Coq proof assistant.

链接与引用

DOI 原文 · PDF(开放获取) · DBLP

BibTeX
@article{YeSO24,
  title = {Imperative Compositional Programming: Type Sound Distributive Intersection Subtyping with References via Bidirectional Typing},
  author = {Wenjia Ye and Yaozhu Sun and Bruno C. d. S. Oliveira},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {8},
  number = {OOPSLA2},
  year = {2024},
  doi = {10.1145/3689782}
}