skip to main content
research-article
Open access

Synthesizing Formal Semantics from Executable Interpreters

Published: 08 October 2024 Publication History

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.

References

[1]
Aws Albarghouthi, Paraschos Koutris, Mayur Naik, and Calvin Smith. 2017. Constraint-based synthesis of datalog programs. In Principles and Practice of Constraint Programming: 23rd International Conference, CP 2017, Melbourne, VIC, Australia, August 28–September 1, 2017, Proceedings 23. 689–706.
[2]
Rajeev Alur, Rastislav Bodík, Garvit Juniwal, Milo M. K. Martin, Mukund Raghothaman, Sanjit A. Seshia, Rishabh Singh, Armando Solar-Lezama, Emina Torlak, and Abhishek Udupa. 2013. Syntax-guided synthesis. In Formal Methods in Computer-Aided Design, FMCAD 2013, Portland, OR, USA, October 20-23, 2013. IEEE, 1–8. https://ieeexplore.ieee.org/document/6679385/
[3]
Rajeev Alur, Arjun Radhakrishna, and Abhishek Udupa. 2017. Scaling enumerative program synthesis via divide and conquer. In International conference on tools and algorithms for the construction and analysis of systems. 319–336.
[4]
Haniel Barbosa, Clark Barrett, Martin Brain, Gereon Kremer, Hanna Lachnitt, Makai Mann, Abdalrhman Mohamed, Mudathir Mohamed, Aina Niemetz, Andres Nötzli, Alex Ozdemir, Mathias Preiner, Andrew Reynolds, Ying Sheng, Cesare Tinelli, and Yoni Zohar. 2022. cvc5: A Versatile and Industrial-Strength SMT Solver. In Tools and Algorithms for the Construction and Analysis of Systems, Dana Fisman and Grigore Rosu (Eds.). Springer International Publishing, Cham. 415–442. isbn:978-3-030-99524-9
[5]
Xiaohong Chen and Grigore Rosu. 2019. A Semantic Framework for Programming Languages and Formal Analysis. In Engineering Trustworthy Software Systems - 5th International School, SETSS 2019, Chongqing, China, April 21-27, 2019, Tutorial Lectures, Jonathan P. Bowen, Zhiming Liu, and Zili Zhang (Eds.) (Lecture Notes in Computer Science, Vol. 12154). Springer, 122–158. https://doi.org/10.1007/978-3-030-55089-9_4
[6]
Loris D’Antoni, Qinheping Hu, Jinwoo Kim, and Thomas Reps. 2021. Programmable program synthesis. In Computer Aided Verification: 33rd International Conference, CAV 2021, Virtual Event, July 20–23, 2021, Proceedings, Part I 33. 84–109.
[7]
Azadeh Farzan, Danya Lette, and Victor Nicolet. 2022. Recursion synthesis with unrealizability witnesses. In Proceedings of the 43rd ACM SIGPLAN International Conference on Programming Language Design and Implementation. 244–259.
[8]
Azadeh Farzan and Victor Nicolet. 2021. Counterexample-Guided Partial Bounding for Recursive Function Synthesis. In Computer Aided Verification: 33rd International Conference, CAV 2021, Virtual Event, July 20–23, 2021, Proceedings, Part I 33. 832–855.
[9]
Kangjing Huang and Xiaokang Qiu. 2022. Bootstrapping Library-Based Synthesis. In International Static Analysis Symposium. 272–298.
[10]
Keith J. C. Johnson, Andrew Reynolds, Thomas Reps, and Loris D’Antoni. 2024. The SemGuS Toolkit. In Computer Aided Verification, Arie Gurfinkel and Vijay Ganesh (Eds.). Springer Nature Switzerland, Cham. 27–40. isbn:978-3-031-65633-0
[11]
Larry G. Jones. 1990. Efficient Evaluation of Circular Attribute Grammars. ACM Trans. Program. Lang. Syst., 12, 3 (1990), 429–462. https://doi.org/10.1145/78969.78971
[12]
Pankaj Kumar Kalita, Miriyala Jeevan Kumar, and Subhajit Roy. 2022. Synthesis of semantic actions in attribute grammars. In 2022 Formal Methods in Computer-Aided Design (FMCAD). 304–314.
[13]
Jinwoo Kim, Qinheping Hu, Loris D’Antoni, and Thomas Reps. 2021. Semantics-guided synthesis. Proceedings of the ACM on Programming Languages, 5, POPL (2021), 1–32.
[14]
Woosuk Lee and Hangyeol Cho. 2023. Inductive synthesis of structurally recursive functional programs from non-recursive expressions. Proceedings of the ACM on Programming Languages, 7, POPL (2023), 2048–2078.
[15]
Junghee Lim and Thomas W. Reps. 2013. TSL: A System for Generating Abstract Interpreters and its Application to Machine-Code Analysis. ACM Trans. Program. Lang. Syst., 35, 1 (2013), 4:1–4:59. https://doi.org/10.1145/2450136.2450139
[16]
Jiangyi Liu, Charlie Murphy, Anvay Grover, Keith Johnson, Thomas Reps, and Loris D’Antoni. 2024. Artifact of paper "Synthesizing Formal Semantics from Executable Interpreters". https://doi.org/10.5281/zenodo.13368062
[17]
Jiangyi Liu, Charlie Murphy, Anvay Grover, Keith J. C. Johnson, Thomas Reps, and Loris D’Antoni. 2024. Synthesizing Formal Semantics from Executable Interpreters. arxiv:2408.14668. arxiv:2408.14668
[18]
Eva Magnusson and Görel Hedin. 2003. Circular Reference Attributed Grammars - Their Evaluation and Applications. In Workshop on Language Descriptions, Tools and Applications, LDTA@ETAPS 2003, Warsaw, Poland, April 12-13, 2003, Barrett R. Bryant and João Saraiva (Eds.) (Electronic Notes in Theoretical Computer Science, Vol. 82). Elsevier, 532–554. https://doi.org/10.1016/S1571-0661(05)82627-1
[19]
Anders Miltner, Adrian Trejo Nuñez, Ana Brendel, Swarat Chaudhuri, and Isil Dillig. 2022. Bottom-up synthesis of recursive functional programs using angelic execution. Proceedings of the ACM on Programming Languages, 6, POPL (2022), 1–29.
[20]
Charlie Murphy, Keith J. C. Johnson, Thomas Reps, and Loris D’Antoni. 2024. Verifying Solutions to Semantics-Guided Synthesis Problems. arxiv:2408.15475. arxiv:2408.15475
[21]
Xujie Si, Woosuk Lee, Richard Zhang, Aws Albarghouthi, Paraschos Koutris, and Mayur Naik. 2018. Syntax-guided synthesis of datalog programs. In Proceedings of the 2018 26th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering. 515–527.

Recommendations

Comments

Information & Contributors

Information

Published In

cover image Proceedings of the ACM on Programming Languages
Proceedings of the ACM on Programming Languages  Volume 8, Issue OOPSLA2
October 2024
2691 pages
EISSN:2475-1421
DOI:10.1145/3554319
Issue’s Table of Contents
This work is licensed under a Creative Commons Attribution-ShareAlike International 4.0 License.

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 08 October 2024
Published in PACMPL Volume 8, Issue OOPSLA2

Permissions

Request permissions for this article.

Check for updates

Badges

Author Tags

  1. Program Synthesis
  2. SMT
  3. SemGuS
  4. Semantics
  5. SyGuS

Qualifiers

  • Research-article

Funding Sources

  • NSF (National Science Foundation)

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • 0
    Total Citations
  • 169
    Total Downloads
  • Downloads (Last 12 months)169
  • Downloads (Last 6 weeks)70
Reflects downloads up to 06 Jan 2025

Other Metrics

Citations

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Login options

Full Access

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media