paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Embedding by Unembedding

通过去嵌入实现嵌入
ICFP 7(ICFP)2023匹配度 2/10 · 论文属于程序语言领域的嵌入语言与HOAS/去嵌入技术,关注语义域、增量计算和双向变换的形式化实现;与用户画像中的LLM/Agentic程序分析、静态分析、浮点程序分析、贝叶斯程序分析均无直接交集,仅可作为PL形式化与工程实现层面的泛化背景。引用 10 inbox
Kazutaka Matsuda, Samantha Frohlich, Meng Wang, Nicolas Wu
crossref: 2026-09-10

AI 速览

一句话:提出“去嵌入”通用策略,将 HOAS 风格嵌入表示转为 de Bruijn 索引项,以支持增量计算与双向变换等语义域。

嵌入是一种以宿主语言库形式实现对象语言的技术,轻量且能继承宿主语言特性;HOAS 利用高阶函数表示带绑定器的抽象语法树,但难以处理无法自然表达为函数的语义域,尤其是涉及开放表达式的情况,如增量计算与可逆/双向语言。本文指出 HOAS 的困难源于宿主语言与对象语言函数语义域之间的不匹配,并提出基于去嵌入(unembedding)的解决方案:将 finally-tagless 表示转换为带强正确性保证的 de Bruijn 索引项。作者给出通用的“Embedding by Unembedding”策略,并在增量计算和双向变换两个实质性案例中验证其有效性,所得嵌入式实现的功能可与各自领域最先进的实现相媲美,同时保持 HOAS 的简洁性。

问题
HOAS 难以嵌入语义域无法自然表达为函数(尤其涉及开放表达式)的对象语言,如增量计算与可逆/双向语言。
方法
识别 HOAS 中宿主语言与对象语言函数语义域的不匹配,提出基于 unembedding 的通用策略,将 finally-tagless 表示转换为带正确性保证的 de Bruijn 索引项。
评估
通过增量计算与双向变换两个实质性案例研究进行验证,所得嵌入式实现的功能与各自领域的最先进语言实现相当。
原文摘要(Abstract)

Embedding is a language development technique that implements the object language as a library in a host language. There are many advantages of the approach, including being lightweight and the ability to inherit features of the host language. A notable example is the technique of HOAS, which makes crucial use of higher-order functions to represent abstract syntax trees with binders. Despite its popularity, HOAS has its limitations. We observe that HOAS struggles with semantic domains that cannot be naturally expressed as functions, particularly when open expressions are involved. Prominent examples of this include incremental computation and reversible/bidirectional languages. In this paper, we pin-point the challenge faced by HOAS as a mismatch between the semantic domain of host and object language functions, and propose a solution. The solution is based on the technique of unembedding , which converts from the finally-tagless representation to de Bruijn-indexed terms with strong correctness guarantees. We show that this approach is able to extend the applicability of HOAS while preserving its elegance. We provide a generic strategy for Embedding by Unembedding, and then demonstrate its effectiveness with two substantial case studies in the domains of incremental computation and bidirectional transformations. The resulting embedded implementations are comparable in features to the state-of-the-art language implementations in the respective areas.

链接与引用

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

BibTeX
@article{paperbot1931,
  title = {Embedding by Unembedding},
  author = {Kazutaka Matsuda and Samantha Frohlich and Meng Wang and Nicolas Wu},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {7},
  number = {ICFP},
  year = {2023},
  doi = {10.1145/3607830}
}