paperbot · PL 论文追踪

全部论文 待读 收藏

P2 A HAT Trick: Automatically Verifying Representation Invariants using Symbolic Finite Automata

一个 HAT 技巧:使用符号有限自动机自动验证表示不变式
PLDI 8(PLDI)2024匹配度 3/10 · 论文属于精化类型与符号自动机相结合的形式化验证工作,虽与静态分析/程序验证相关,但未涉及 LLM、Agent、浮点程序分析或贝叶斯程序分析,因此与用户当前核心研究方向的交叉点不直接匹配。引用 8 inbox
Zhe Zhou, Qianchuan Ye, Benjamin Delaware, Suresh Jagannathan
dblp: 2026-09-10crossref: 2026-09-10arxiv: 2026-09-10

AI 速览

一句话:提出 Hoare 自动机类型,将符号有限自动机融入精化类型,以自动验证依赖有状态库的数据结构表示不变式。

函数式程序常通过有状态库的抽象接口维护隐藏状态,数据结构的表示不变式往往依赖库状态的历史,而库规格过于通用,难以直接表达和验证这些不变量。本文提出用符号有限自动机(SFA)精确刻画客户端与有状态库交互中的时序与数据相关历史;并将 SFA 集成进精化类型系统,形成 Hoare 自动机类型(HAT),用于限定有状态计算并模块化地描述表示不变式。作者还设计双向类型检查算法,实现 HAT 上高效的子类型包含检查,并将其翻译为可由 SMT 自动求解的形式。实验在 OCaml 数据结构实现上验证了该方法的可行性,能自动检查分层于有状态库 API 之上的复杂表示不变式。

问题
如何对函数式客户端在调用有状态库时所需的应用级表示不变式进行模块化规格与自动验证,尤其是当库状态对客户端不可见且库规格通用时。
方法
用符号有限自动机(SFA)捕捉交互的时序与数据历史,并将其作为精化类型中的限定,形成 Hoare 自动机类型(HAT);同时给出支持 HAT 子类型包含检查的双向类型检查算法,并翻译到 SMT 验证。
评估
实现该算法并在 OCaml 中类型检查基于有状态库 API 的复杂数据结构实现,实验结果表明能自动验证其表示不变式。
原文摘要(Abstract)

Functional programs typically interact with stateful libraries that hide state behind typed abstractions. One particularly important class of applications are data structure implementations that rely on such libraries to provide a level of efficiency and scalability that may be otherwise difficult to achieve. However, because the specifications of the methods provided by these libraries are necessarily general and rarely specialized to the needs of any specific client, any required application-level invariants must often be expressed in terms of additional constraints on the (often) opaque state maintained by the library. In this paper, we consider the specification and verification of such representation invariants using symbolic finite automata (SFA). We show that SFAs can be used to succinctly and precisely capture fine-grained temporal and data-dependent histories of interactions between functional clients and stateful libraries. To facilitate modular and compositional reasoning, we integrate SFAs into a refinement type system to qualify stateful computations resulting from such interactions. The particular instantiation we consider, Hoare Automata Types (HATs), allows us to both specify and automatically type-check the representation invariants of a datatype, even when its implementation depends on stateful library methods that operate over hidden state. We also develop a new bidirectional type checking algorithm that implements an efficient subtyping inclusion check over HATs, enabling their translation into a form amenable for SMT-based automated verification. We present extensive experimental results on an implementation of this algorithm that demonstrates the feasibility of type-checking complex and sophisticated HAT-specified OCaml data structure implementations layered on top of stateful library APIs.

链接与引用

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

BibTeX
@article{abs-2404-01484,
  title = {A HAT Trick: Automatically Verifying Representation Invariants using Symbolic Finite Automata},
  author = {Zhe Zhou and Qianchuan Ye and Benjamin Delaware and Suresh Jagannathan},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {8},
  number = {PLDI},
  year = {2024},
  doi = {10.1145/3656433}
}