paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Generating Well-Typed Terms That Are Not “Useless”

生成非“无用”的良类型项
POPL 8(POPL)2024匹配度 3/10 · 论文属于 PL/类型系统与编译器随机测试,有形式化和 GHC 工业案例,但未涉及用户核心关注的 LLM/Agent、静态分析、浮点程序分析或贝叶斯程序分析,与画像交叉方向不匹配。引用 8 inbox
Justine Frank, Benjamin Quiring, Leonidas Lampropoulos
crossref: 2026-09-10

AI 速览

一句话:提出一种非局部生成算法,生成会使用参数的良类型函数,显著提升编译器随机测试效率。

良类型项随机生成是函数式编译器随机测试的核心。现有自顶向下、面向类型的局部生成常独立决定表达式类型,容易产生参数无法用于产生有意义结果、参数未被使用的“无用”函数,既引入死代码编译开销,也降低优化测试覆盖。本文提出非局部生成算法,更有效地生成会使用参数的函数。作者在带类型洞与参数洞的简单类型 lambda 演算扩展中,将局部和非局部算法形式化为步进关系,说明延迟子表达式类型生成如何产生“有用”函数。实现表明,该方法参数使用率更接近真实程序,并在 GHC 严格性分析器案例中比当前最优局部方法快四倍发现缺陷。

问题
现有良类型项随机生成方法在局部选择类型时,常生成参数未被使用的“无用”函数,降低编译器随机测试的覆盖与效率。
方法
提出非局部生成算法,并在带类型洞和参数洞的简单类型 lambda 演算扩展中,将局部与非局部算法形式化为步进关系,通过延迟子表达式类型生成来生成使用参数的函数。
评估
实现该算法,比较生成项与真实程序的参数使用率,并复现 GHC 严格性分析器缺陷发现案例,结果比当前最优局部方法快四倍发现缺陷。
原文摘要(Abstract)

Random generation of well-typed terms lies at the core of effective random testing of compilers for functional languages. Existing techniques have had success following a top-down type-oriented approach to generation that makes choices locally, which suffers from an inherent limitation: the type of an expression is often generated independently from the expression itself. Such generation frequently yields functions with argument types that cannot be used to produce a result in a meaningful way, leaving those arguments unused. Such “use-less” functions can hinder both performance, as the argument generation code is dead but still needs to be compiled, and effectiveness, as a lot of interesting optimizations are tested less frequently. In this paper, we introduce a novel algorithm that is significantly more effective at generating functions that use their arguments. We formalize both the “local” and the “nonlocal” algorithms as step-relations in an extension of the simply-typed lambda calculus with type and arguments holes, showing how delaying the generation of types for subexpressions by allowing nonlocal generation steps leads to “useful” functions. We implement our algorithm demonstrating that it’s much closer to real programs in terms of argument usage rate, and we replicate a case study from the literature that finds bugs in the strictness analyzer of GHC, with our approach finding bugs four times faster than the current state-of-the-art local approach.

链接与引用

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

BibTeX
@article{paperbot2625,
  title = {Generating Well-Typed Terms That Are Not “Useless”},
  author = {Justine Frank and Benjamin Quiring and Leonidas Lampropoulos},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {8},
  number = {POPL},
  year = {2024},
  doi = {10.1145/3632919}
}