一句话:基于聚焦(focalization)给出支持高阶多态、存在类型与索引类型(GADT)的双向类型检查声明式规范与算法规则,并证明其可靠完备。
双向类型检查因适用范围广、错误报告友好、易于实现而流行,但其在索引类型(广义代数数据类型,GADT)上的原则尚不清晰。本文基于等式的证明论处理,用聚焦(focalization)给出声明式类型规范:既给出模式匹配覆盖的声明式规则,也通过聚焦的子类型判定支持一阶存在类型;并用精化类型避免在项语法中显式传递等式证明,使演算接近 Haskell 与 OCaml。作者进一步加入判定类型是否为主类型(principal)的规则,使带大量类型推断的丰富类型系统获得完备的声明式规范。最后给出算法类型规则,并证明其相对声明式系统可靠且完备,证明需要若干技术创新,包括以互相递归的方式证明可靠性与完备性。
Bidirectional typechecking, in which terms either synthesize a type or are checked against a known type, has become popular for its applicability to a variety of type systems, its error reporting, and its ease of implementation. Following principles from proof theory, bidirectional typing can be applied to many type constructs. The principles underlying a bidirectional approach to indexed types (generalized algebraic datatypes) are less clear. Building on proof-theoretic treatments of equality, we give a declarative specification of typing based on focalization. This approach permits declarative rules for coverage of pattern matching, as well as support for first-class existential types using a focalized subtyping judgment. We use refinement types to avoid explicitly passing equality proofs in our term syntax, making our calculus similar to languages such as Haskell and OCaml. We also extend the declarative specification with an explicit rules for deducing when a type is principal, permitting us to give a complete declarative specification for a rich type system with significant type inference. We also give a set of algorithmic typing rules, and prove that it is sound and complete with respect to the declarative system. The proof requires a number of technical innovations, including proving soundness and completeness in a mutually recursive fashion.
@article{paperbot667,
title = {Sound and complete bidirectional typechecking for higher-rank polymorphism with existentials and indexed types},
author = {Jana Dunfield and Neelakantan R. Krishnaswami},
journal = {Proceedings of the ACM on Programming Languages},
volume = {3},
number = {POPL},
year = {2019},
doi = {10.1145/3290322}
}