arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2408.14668cs.PL
收藏

从可执行解释器综合形式语义

Synthesizing Formal Semantics from Executable Interpreters

Jiangyi Liu, Charlie Murphy, Anvay Grover, Keith J. C. Johnson, Thomas Reps, Loris D'Antoni

AI总结:

本文提出利用文法和黑盒解释器,通过 CEGIS 将 CHC 语义综合分解为 SyGuS 表达式问题,并在 14 个解释器上验证,还发现并修复了正则表达式语义不一致。

摘要:

允许用户定制所关注语言的程序验证与综合框架,通常要求用户为该语言提供形式化定义的语义。由于编写形式语义可能是一项令人生畏且容易出错的任务,这一要求阻碍了此类框架被非专业用户采用。我们提出一种算法,在给定(i)描述某语言语法的文法以及(ii)用于计算该文法语言中程序语义的可执行(黑盒)解释器时,能够自动综合归纳定义的、语法制导的语义。该算法以 Constrained-Horn Clauses(CHC,约束 Horn 子句)的形式综合语义;CHC 是一种自然、可扩展且形式化的逻辑框架,用于指定归纳定义的关系,近来已在程序验证与综合中得到广泛采用。我们综合算法的关键创新是一种 Counterexample-Guided Synthesis(CEGIS,反例引导综合)方法,它将综合一组约束 Horn 子句这一困难问题分解为若干小型、易处理的表达式综合问题,并可分派给现有的 SyGuS 综合器。我们的工具 Synantic 从用于程序综合应用的语言的 14 个解释器中综合出归纳定义的形式语义。在为其中一个基准综合形式语义时,Synantic 揭示了某个正则表达式语言的解释器所计算语义中的一处不一致;修复该不一致后得到了更高效的语义,并且在某些情况下,使针对该语言求解综合问题的综合器获得了 1.2 倍加速。

英文摘要:

Program verification and synthesis frameworks that allow one to customize the language in which one is interested typically require the user to provide a formally defined semantics for the language. Because writing a formal semantics can be a daunting and error-prone task, this requirement stands in the way of such frameworks being adopted by non-expert users. We present an algorithm that can automatically synthesize inductively defined syntax-directed semantics when given (i) a grammar describing the syntax of a language and (ii) an executable (closed-box) interpreter for computing the semantics of programs in the language of the grammar. Our algorithm synthesizes the semantics in the form of Constrained-Horn Clauses (CHCs), a natural, extensible, and formal logical framework for specifying inductively defined relations that has recently received widespread adoption in program verification and synthesis. The key innovation of our synthesis algorithm is a Counterexample-Guided Synthesis (CEGIS) approach that breaks the hard problem of synthesizing a set of constrained Horn clauses into small, tractable expression-synthesis problems that can be dispatched to existing SyGuS synthesizers. Our tool Synantic synthesized inductively-defined formal semantics from 14 interpreters for languages used in program-synthesis applications. When synthesizing formal semantics for one of our benchmarks, Synantic unveiled an inconsistency in the semantics computed by the interpreter for a language of regular expressions; fixing the inconsistency resulted in a more efficient semantics and, for some cases, in a 1.2x speedup for a synthesizer solving synthesis problems over such a language.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑