一句话:提出区分读者与写者的操作语义,使有状态语言可纳入抽象 GSOS 并获得余归纳等价推理。
命令式语言的程序等价推理因变量存储等状态而困难:状态增强观察能力,而等价关系必须组合,才能安全替换子程序。作者希望借助 Turi–Plotkin 的数学操作语义(抽象 GSOS)及其高阶扩展获得组合性,但以往将有状态语言纳入抽象 GSOS 的尝试均未成功。本文提出新的有状态语言操作语义,形式区分 reader(执行前期待初始存储的项)与 writer(已获得存储、正在运行的项)。该语义与抽象 GSOS 完全兼容,从而可利用既有理论开展余归纳推理。作者证明,该方法对一阶和高阶存储均能产生非平凡组合性结果,并适用于 trace、cost 和自然等价等不同粒度的程序等价。
Reasoning about program equivalence in imperative languages is notoriously challenging, as the presence of states (in the form of variable stores) fundamentally increases the observational power of program terms. The key desideratum for any notion of equivalence is compositionality , guaranteeing that subprograms can be safely replaced by equivalent subprograms regardless of the context. To facilitate compositionality proofs and avoid boilerplate work, one would hope to employ the abstract bialgebraic methods provided by Turi and Plotkin's powerful theory of mathematical operational semantics (a.k.a. abstract GSOS ) or its recent extension by Goncharov et al. to higher-order languages. However, multiple attempts to apply abstract GSOS to stateful languages have thus failed. We propose a novel approach to the operational semantics of stateful languages based on the formal distinction between readers (terms that expect an initial input store before being executed), and writers (running terms that have already been provided with a store). In contrast to earlier work, this style of semantics is fully compatible with abstract GSOS, and we can thus leverage the existing theory to obtain coinductive reasoning techniques. We demonstrate that our approach generates non-trivial compositionality results for stateful languages with first-order and higher-order store and that it flexibly applies to program equivalences at different levels of granularity, such as trace, cost, and natural equivalence.
@article{paperbot3036,
title = {Bialgebraic Reasoning on Stateful Languages},
author = {Sergey Goncharov and Stefan Milius and Lutz Schröder and Stelios Tsampas and Henning Urbat},
journal = {Proceedings of the ACM on Programming Languages},
volume = {9},
number = {ICFP},
year = {2025},
doi = {10.1145/3747513}
}