Jiangyi Liu, Charlie Murphy, Anvay Grover, Keith J. C. Johnson, Thomas Reps, Loris D'Antoni
{"title":"Synthesizing Formal Semantics from Executable Interpreters","authors":"Jiangyi Liu, Charlie Murphy, Anvay Grover, Keith J. C. Johnson, Thomas Reps, Loris D'Antoni","doi":"arxiv-2408.14668","DOIUrl":null,"url":null,"abstract":"Program verification and synthesis frameworks that allow one to customize the\nlanguage in which one is interested typically require the user to provide a\nformally defined semantics for the language. Because writing a formal semantics can be a daunting and error-prone task,\nthis requirement stands in the way of such frameworks being adopted by\nnon-expert users. We present an algorithm that can automatically synthesize inductively defined\nsyntax-directed semantics when given (i) a grammar describing the syntax of a\nlanguage and (ii) an executable (closed-box) interpreter for computing the\nsemantics of programs in the language of the grammar. Our algorithm synthesizes the semantics in the form of Constrained-Horn\nClauses (CHCs), a natural, extensible, and formal logical framework for\nspecifying inductively defined relations that has recently received widespread\nadoption in program verification and synthesis. The key innovation of our synthesis algorithm is a Counterexample-Guided\nSynthesis (CEGIS) approach that breaks the hard problem of synthesizing a set\nof constrained Horn clauses into small, tractable expression-synthesis problems\nthat can be dispatched to existing SyGuS synthesizers. Our tool Synantic synthesized inductively-defined formal semantics from 14\ninterpreters for languages used in program-synthesis applications. When synthesizing formal semantics for one of our benchmarks, Synantic\nunveiled an inconsistency in the semantics computed by the interpreter for a\nlanguage of regular expressions; fixing the inconsistency resulted in a more\nefficient semantics and, for some cases, in a 1.2x speedup for a synthesizer\nsolving synthesis problems over such a language.","PeriodicalId":501197,"journal":{"name":"arXiv - CS - Programming Languages","volume":null,"pages":null},"PeriodicalIF":0.0000,"publicationDate":"2024-08-26","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"arXiv - CS - Programming Languages","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/arxiv-2408.14668","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 0
Abstract
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.