paperbot · PL 论文追踪

全部论文 待读 收藏

P2 A Pretty Expressive Printer

一个极具表现力的美化打印器
OOPSLA 7(OOPSLA2)2023匹配度 2/10 · 论文属于程序语言与开发工具中的美化打印器,并用 Lean 形式化验证正确性与最优性,兼具理论、工程与工业落地;但它不涉及静态分析、ML/Agentic 程序、LLM 与程序分析的交叉、浮点程序分析或贝叶斯程序分析,与用户核心研究方向关联很弱。引用 0 inbox
Sorawee Porncharoenwase, Justin Pombrio, Emina Torlak
crossref: 2026-09-10

AI 速览

一句话:提出 Πe 美化打印器,表达力严格更强、可证明最优、复杂度更优,并用 Lean 验证正确性。

美化打印器需要在打印语言的表达力、布局最优性和算法性能之间权衡。本文提出新型美化打印器 Πe:它通过用户提供的 cost factory 定义最优性目标,在表达力上严格强于现有工作,并可证明地最小化该目标;算法时间复杂度也优于许多已有打印器。作者在 Lean 中验证了 Πe 的正确性(有效性与最优性),并实现了 PrettyExpressive。为进行评估,他们建立了分析美化打印语言表达力的形式化框架,调研文献中的打印器,比较表达力、最优性、最坏时间复杂度与实际运行时间。实验显示 PrettyExpressive 能高效生成最优布局,并已被用作 Racket 代码格式化器的基础。

问题
美化打印器在表达力、布局最优性和性能之间存在权衡,现有工作难以同时兼顾。
方法
提出 Πe,以用户提供的 cost factory 参数化最优性目标,并用 Lean 验证其有效性与最优性;同时建立表达力形式化框架并实现 PrettyExpressive。
评估
通过形式化框架和文献调研比较多个美化打印器的表达力、最优性、最坏时间复杂度与实际运行时间;PrettyExpressive 还被用于 Racket 代码格式化器。
原文摘要(Abstract)

Pretty printers make trade-offs between the expressiveness of their pretty printing language, the optimality objective that they minimize when choosing between different ways to lay out a document, and the performance of their algorithm. This paper presents a new pretty printer, Π e , that is strictly more expressive than all pretty printers in the literature and provably minimizes an optimality objective. Furthermore, the time complexity of Π e is better than many existing pretty printers. When choosing among different ways to lay out a document, Π e consults a user-supplied cost factory , which determines the optimality objective, giving Π e a unique degree of flexibility. We use the Lean theorem prover to verify the correctness (validity and optimality) of Π e , and implement Π e concretely as a pretty printer that we call PrettyExpressive. To evaluate our pretty printer against others, we develop a formal framework for reasoning about the expressiveness of pretty printing languages, and survey pretty printers in the literature, comparing their expressiveness, optimality, worst-case time complexity, and practical running time. Our evaluation shows that PrettyExpressive is efficient and effective at producing optimal layouts. PrettyExpressive has also seen real-world adoption: it serves as a foundation of a code formatter for Racket.

链接与引用

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

BibTeX
@article{paperbot1848,
  title = {A Pretty Expressive Printer},
  author = {Sorawee Porncharoenwase and Justin Pombrio and Emina Torlak},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {7},
  number = {OOPSLA2},
  year = {2023},
  doi = {10.1145/3622837}
}