paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Contextual Typing

上下文类型化(Contextual Typing)
ICFP 8(ICFP)2024匹配度 2/10 · 论文属于类型系统与双向类型检查的理论工作,虽与静态分析和形式化验证(Agda)相关,但未涉及用户核心关注的 LLM/Agent、浮点程序分析或贝叶斯程序分析,也未体现 AI 与 PL 的交叉。引用 4 inbox
Xu Xue, Bruno C. d. S. Oliveira
dblp: 2026-09-10crossref: 2026-09-10

AI 速览

一句话:将双向类型检查推广为上下文类型化,传播更丰富的上下文信息以减少标注,并用 QTAS 定量刻画可标注性。

双向类型检查通过在检查过程中传播已知类型信息,以轻量方式支持多种类型系统并减少明显标注,但其推断能力有限,且遇到子类型、交集类型、记录、重载等复杂特性时会出现困难。本文提出上下文类型化(contextual typing),将传播的信息从已知类型推广为关于项周围上下文的已知信息,例如其他项或记录标签,从而在保持轻量与可扩展的同时进一步减少标注;在带子类型的系统中,上下文包含关系也比双向子类型包含更具表达力,因为部分已知的上下文信息可被利用。为便于规约这类系统,作者引入定量类型赋值系统(QTAS),用计数器量化项通过类型检查所需的类型信息量,泛化了传统双向类型中只能表示检查/推断两种模式的 mode,并将可标注性准则形式化为定理。论文先在简单类型 lambda 演算上展示该方法,随后扩展到含子类型、交集类型、记录与重载的演算,全部元理论均在 Agda 证明助手中形式化。

问题
双向类型检查虽轻量且可扩展,但推断能力有限,在子类型、交集类型、记录与重载等复杂特性下需要的标注仍然偏多。
方法
将类型检查中传播的已知信息从类型推广为项周围的上下文信息(如其他项、记录标签),并提出用计数器量化所需类型信息量的 QTAS 来规约系统、泛化双向 mode 并给出可标注性定理。
评估
在简单类型 lambda 演算以及含子类型、交集类型、记录和重载的演算上演示上下文类型化,并将全部元理论在 Agda 中形式化验证。
原文摘要(Abstract)

Bidirectional typing is a simple, lightweight approach to type inference that propagates known type information during typing, and can scale up to many different type systems and features. It typically only requires a reasonable amount of annotations and eliminates the need for many obvious annotations. Nonetheless the power of inference is still limited, and complications arise in the presence of more complex features. In this paper we present a generalization of bidirectional typing called contextual typing . In contextual typing not only known type information is propagated during typing, but also other known information about the surrounding context of a term. This information can be of various forms, such as other terms or record labels. Due to this richer notion of contextual information, less annotations are needed, while the approach remains lightweight and scalable. For type systems with subtyping, contextual typing subsumption is also more expressive than subsumption with bidirectional typing, since partially known contextual information can be exploited. To aid specifying type systems with contextual typing, we introduce Q uantitative T ype A ssignment S ystems (QTASs). A QTAS quantifies the amount of type information that a term needs in order to type check using counters. Thus, a counter in a QTAS generalizes modes in traditional bidirectional typing, which can only model an all (checking mode) or nothing (inference mode) approach. QTASs enable precise guidelines for annotatability of contextual type systems formalized as a theorem. We illustrate contextual typing first on a simply typed lambda calculus, and then on a richer calculus with subtyping, intersection types, records and overloading. All the metatheory is formalized in the Agda theorem prover.

链接与引用

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

BibTeX
@article{XueO24,
  title = {Contextual Typing},
  author = {Xu Xue and Bruno C. d. S. Oliveira},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {8},
  number = {ICFP},
  year = {2024},
  doi = {10.1145/3674655}
}