[论文解读] Applied Type System: An Approach to Practical Programming with Theorem-Proving
本文提出了应用类型系统(ATS),一种形式化框架,将静态类型推理与动态程序执行分离,从而实现依赖类型的实际编程。通过将静态部分(类型构造)与动态部分(程序求值)解耦,ATS 支持通过显式构造证明来实现定理证明,确保类型安全,并通过证明擦除实现约束求解,其正确性通过翻译到核心类型系统的形式化证明得以确立。
The framework Pure Type System (PTS) offers a simple and general approach to designing and formalizing type systems. However, in the presence of dependent types, there often exist certain acute problems that make it difficult for PTS to directly accommodate many common realistic programming features such as general recursion, recursive types, effects (e.g., exceptions, references, input/output), etc. In this paper, Applied Type System (ATS) is presented as a framework for designing and formalizing type systems in support of practical programming with advanced types (including dependent types). In particular, it is demonstrated that ATS can readily accommodate a paradigm referred to as programming with theorem-proving (PwTP) in which programs and proofs are constructed in a syntactically intertwined manner, yielding a practical approach to internalizing constraint-solving needed during type-checking. The key salient feature of ATS lies in a complete separation between statics, where types are formed and reasoned about, and dynamics, where programs are constructed and evaluated. With this separation, it is no longer possible for a program to occur in a type as is otherwise allowed in PTS. The paper contains not only a formal development of ATS but also some examples taken from ats-lang.org, a programming language with a type system rooted in ATS, in support of employing ATS as a framework to formulate advanced type systems for practical programming.
研究动机与目标
- 为解决纯类型系统(PTS)在支持依赖类型下的通用递归、副作用和递归类型等实际编程特性时的局限性。
- 形式化一个支持高级类型(尤其是依赖类型和有界类型)实用编程的框架。
- 为编程中的定理证明(PwTP)建立类型理论基础,其中证明被显式构造,以简化类型约束。
- 证明证明擦除在保留动态语义的同时,确保在存在副作用时的类型安全。
- 将先前关于依赖型 ML 和有界递归数据类型的成果统一并扩展为一个单一、表达性强且形式化坚实类型系统框架。
提出的方法
- 引入静态部分(类型构造与推理)与动态部分(程序构造与求值)之间的完整分离,禁止在类型中出现程序。
- 定义两种核心类型形式:有界类型用于编码不变量(如前置与后置条件),断言类型用于证明级别的约束。
- 形式化一个最小核心系统 $\mbox{ATS}_{0}$,并证明其类型安全性。
- 将 $\mbox{ATS}_{0}$ 扩展为 $\mbox{ATS}_{\it pf}$,以支持编程中的定理证明(PwTP),其中证明被显式构造。
- 使用证明擦除转换,将类型正确的 $\mbox{ATS}_{\it pf}$ 程序映射为具有相同动态语义的 $\mbox{ATS}_{0}$ 程序。
- 通过形式化证明建立 PwTP 的正确性:即 $\mbox{ATS}_{\it pf}$ 中的类型正确性在证明擦除后,可推出 $\mbox{ATS}_{0}$ 中的类型正确性。
实验结果
研究问题
- RQ1类型系统如何在支持引用和异常等副作用的同时,支持依赖类型的实用编程?
- RQ2何种形式化机制能够实现程序与证明的语法交织,而不损害类型安全?
- RQ3如何形式化证明擦除,以确保其保留动态语义并保证类型安全性?
- RQ4为何将静态部分与动态部分分离,可消除依赖类型系统中对程序纯性推理的需求?
- RQ5如何在类型系统中使用有界类型与断言类型来表达和强制程序不变量?
主要发现
- ATS 中静态与动态的分离消除了对程序纯性推理的需求,使得依赖类型系统能够实用地支持副作用和通用递归。
- 框架 $\mbox{ATS}_{0}$ 经形式化证明为类型安全,为高级类型系统奠定了坚实基础。
- $\mbox{ATS}_{\it pf}$ 的扩展支持编程中的定理证明(PwTP),其中证明被用于在类型检查期间内化约束求解。
- 证明擦除得到形式化证明:每个在 $\mbox{ATS}_{\it pf}$ 中类型正确的程序,均可转换为在 $\mbox{ATS}_{0}$ 中类型正确且具有相同动态行为的程序。
- 使用有界类型与断言类型可精确表达程序不变量,类似于霍尔逻辑中的前置与后置条件。
- ATS 将先前关于依赖型 ML 和有界递归数据类型的成果统一并扩展为一个单一、表达性强且形式化坚实类型系统框架。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。