paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Automated Ambiguity Detection in Layout-Sensitive Grammars

布局敏感文法中的自动歧义检测
OOPSLA 7(OOPSLA2)2023匹配度 2/10 · 论文研究布局敏感文法的有界歧义检测,结合SMT编码与Coq机械化证明,属于语言设计与形式化方法;但未涉及LLM/Agent、浮点程序分析或贝叶斯程序分析,与用户画像的核心交叉方向几乎无交集。引用 2 inbox
Jiangyi Liu, Fengmin Zhu, Fei He
crossref: 2026-09-10

AI 速览

一句话:提出布局敏感文法的有界歧义检测方法,以SMT编码局部歧义并机器化验证,可找出最短歧义句。

布局敏感文法广泛用于现代语言,语言设计阶段需保证文法无歧义;但该类文法的歧义判定不可判定,自动检测可暴露设计缺陷。本文将基于SAT的有界歧义检测扩展到布局敏感文法,改用SMT编码行号/列号上的排序与定量关系。关键创新是考虑布局约束影响的可达性条件,并据此提出等价的局部歧义概念,实现有界检查器以寻找最短非空歧义句。编码的可靠性与完备性在Coq中机器化验证。评估覆盖YAML等领域特定语言和Python等通用语言的文法片段与完整文法,验证了有效性。

问题
布局敏感文法在现代编程语言中常见,语言设计需要无歧义文法,但歧义判定不可判定,因此需自动检测潜在歧义。
方法
将CFG的有界歧义SAT检测推广到布局敏感文法,通过SMT表达行/列约束,引入考虑布局影响的可达性条件和局部歧义概念,并实现有界歧义检查器。
评估
在从YAML和Python等语言手册提取的文法片段与完整文法上评估,并利用Coq机器化验证SMT编码的可靠性与完备性。
原文摘要(Abstract)

Layout-sensitive grammars have been adopted in many modern programming languages. In a serious language design phase, the specified syntax—typically a grammar—must be unambiguous. Although checking ambiguity is undecidable for context-free grammars and (trivially also) layout-sensitive grammars, ambiguity detection , on the other hand, is possible and can benefit language designers from exposing potential design flaws . In this paper, we tackle the ambiguity detection problem in layout-sensitive grammars. Inspired by a previous work on checking the bounded ambiguity of context-free grammars via SAT solving , we intensively extend their approach to support layout-sensitive grammars but via SMT solving to express the ordering and quantitative relations over line/column numbers. Our key novelty lies in a reachability condition, which takes the impact of layout constraints on ambiguity into careful account. With this condition in hand, we propose an equivalent ambiguity notion called local ambiguity for the convenience of SMT encoding. We translate local ambiguity into an SMT formula and developed a bounded ambiguity checker that automatically finds a shortest nonempty ambiguous sentence (if exists) for a user-input grammar. The soundness and completeness of our SMT encoding are mechanized in the Coq proof assistant. We conducted an evaluation on both grammar fragments and full grammars extracted from the language manuals of domain-specific languages like YAML as well as general-purpose languages like Python, which reveals the effectiveness of our approach.

链接与引用

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

BibTeX
@article{paperbot1823,
  title = {Automated Ambiguity Detection in Layout-Sensitive Grammars},
  author = {Jiangyi Liu and Fengmin Zhu and Fei He},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {7},
  number = {OOPSLA2},
  year = {2023},
  doi = {10.1145/3622838}
}