Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
research-article
Open access

Algebro-geometric Algorithms for Template-Based Synthesis of Polynomial Programs

Published: 06 April 2023 Publication History

Abstract

Template-based synthesis, also known as sketching, is a localized approach to program synthesis in which the programmer provides not only a specification, but also a high-level "sketch" of the program. The sketch is basically a partial program that models the general intuition of the programmer, while leaving the low-level details as unimplemented "holes". The role of the synthesis engine is then to fill in these holes such that the completed program satisfies the desired specification. In this work, we focus on template-based synthesis of polynomial imperative programs with real variables, i.e. imperative programs in which all expressions appearing in assignments, conditions and guards are polynomials over program variables. While this problem can be solved in a sound and complete manner by a reduction to the first-order theory of the reals, the resulting formulas will contain a quantifier alternation and are extremely hard for modern SMT solvers, even when considering toy programs with a handful of lines. Moreover, the classical algorithms for quantifier elimination are notoriously unscalable and not at all applicable to this use-case.
In contrast, our main contribution is an algorithm, based on several well-known theorems in polyhedral and real algebraic geometry, namely Putinar's Positivstellensatz, the Real Nullstellensatz, Handelman's Theorem and Farkas' Lemma, which sidesteps the quantifier elimination difficulty and reduces the problem directly to Quadratic Programming (QP). Alternatively, one can view our algorithm as an efficient way of eliminating quantifiers in the particular formulas that appear in the synthesis problem. The resulting QP instances can then be handled quite easily by SMT solvers. Notably, our reduction to QP is sound and semi-complete, i.e. it is complete if polynomials of a sufficiently high degree are used in the templates. Thus, we provide the first method for sketching-based synthesis of polynomial programs that does not sacrifice completeness, while being scalable enough to handle meaningful programs. Finally, we provide experimental results over a variety of examples from the literature.

References

[1]
Alessandro Abate, Cristina David, Pascal Kesseli, Daniel Kroening, and Elizabeth Polgreen. 2018. Counterexample guided inductive synthesis modulo theories. In CAV. 270–288.
[2]
Sheshansh Agrawal, Krishnendu Chatterjee, and Petr Novotnỳ. 2017. Lexicographic ranking supermartingales: an efficient approach to termination of probabilistic programs. In POPL.
[3]
Rajeev Alur, Rastislav Bodik, Garvit Juniwal, Milo MK Martin, Mukund Raghothaman, Sanjit A Seshia, Rishabh Singh, Armando Solar-Lezama, Emina Torlak, and Abhishek Udupa. 2013. Syntax-Guided Synthesis. FMCAD.
[4]
Rajeev Alur, Dana Fisman, Saswat Padhi, Andrew Reynolds, Rishabh Singh, and Abhishek Udupa. 2019. SyGuS-Comp: Syntax-guided Synthesis Competition. https://sygus.org/
[5]
Rajeev Alur, Rishabh Singh, Dana Fisman, and Armando Solar-Lezama. 2018. Search-based program synthesis. Commun. ACM, 61, 12 (2018), 84–93.
[6]
Ali Asadi, Krishnendu Chatterjee, Hongfei Fu, Amir Kafshdar Goharshady, and Mohammad Mahdavi. 2021. Polynomial reachability witnesses via Stellensätze. In PLDI. 772–787.
[7]
Haniel Barbosa, Clark W. 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 TACAS, Dana Fisman and Grigore Rosu (Eds.). 415–442.
[8]
Grigoriy Blekherman, Pablo A Parrilo, and Rekha R Thomas. 2012. Semidefinite optimization and convex algebraic geometry. SIAM.
[9]
Jacek Bochnak, Michel Coste, and Marie-Françoise Roy. 2013. Real algebraic geometry. 36, Springer Science & Business Media.
[10]
James Bornholt and Emina Torlak. 2018. Finding code that explodes under symbolic evaluation. In OOPSLA. 1–26.
[11]
Krishnendu Chatterjee, Hongfei Fu, and Amir Kafshdar Goharshady. 2016. Termination analysis of probabilistic programs through Positivstellensatz’s. In CAV. 3–22.
[12]
Krishnendu Chatterjee, Hongfei Fu, and Amir Kafshdar Goharshady. 2017. Non-polynomial Worst-Case Analysis of Recursive Programs. In CAV. 10427, 41–63.
[13]
Krishnendu Chatterjee, Hongfei Fu, and Amir Kafshdar Goharshady. 2019. Non-polynomial Worst-Case Analysis of Recursive Programs. ACM Trans. Program. Lang. Syst., 41, 4 (2019), 20:1–20:52.
[14]
Krishnendu Chatterjee, Hongfei Fu, Amir Kafshdar Goharshady, and Ehsan Kafshdar Goharshady. 2020. Polynomial invariant generation for non-deterministic recursive programs. In PLDI. 672–687.
[15]
Krishnendu Chatterjee, Hongfei Fu, Amir Kafshdar Goharshady, and Nastaran Okati. 2018. Computational Approaches for Stochastic Shortest Path on Succinct MDPs. In IJCAI. 4700–4707.
[16]
Krishnendu Chatterjee, Hongfei Fu, and Petr Novotnỳ. 2020. Termination analysis of probabilistic programs with martingales. Foundations of Probabilistic Programming, 221–258.
[17]
Krishnendu Chatterjee, Amir Kafshdar Goharshady, Tobias Meggendorfer, and Dorde Zikelic. 2022. Sound and Complete Certificates for Quantitative Termination Analysis of Probabilistic Programs. In CAV. 55–78.
[18]
Alonzo Church. 1963. Application of recursive arithmetic to the problem of circuit synthesis. Journal of Symbolic Logic, 28, 4 (1963).
[19]
Alessandro Cimatti, Alberto Griggio, Bastiaan Schaafsma, and Roberto Sebastiani. 2013. The MathSAT5 SMT Solver. In TACAS, Nir Piterman and Scott Smolka (Eds.).
[20]
Michael A Colón, Sriram Sankaranarayanan, and Henny B Sipma. 2003. Linear invariant generation using non-linear constraint solving. In CAV. 420–432.
[21]
Julius Farkas. 1902. Theory of simple inequalities. Journal for pure and applied mathematics (Crelles Journal), 1902, 124 (1902), 1–27.
[22]
Grigory Fedyukovich, Sumanth Prabhu, Kumar Madhukar, and Aarti Gupta. 2019. Quantified invariants via syntax-guided synthesis. In CAV. 259–277.
[23]
Yijun Feng, Lijun Zhang, David N Jansen, Naijun Zhan, and Bican Xia. 2017. Finding polynomial loop invariants for probabilistic programs. In ATVA. 400–416.
[24]
Amir Goharshady. 2020. Parameterized and algebro-geometric advances in static program analysis. Ph.D. Dissertation. Institute of Science and Technology Austria.
[25]
Amir Goharshady, S. Hitarth, Fatemeh Mohammadi, and Harshit Motwani. 2023. Algebro-geometric Algorithms for Template-based Synthesis of Polynomial Programs (Full Version including Appendices). https://hal.science/hal-04012686
[26]
Amir Kafshdar Goharshady, S. Hitarth, Fatemeh Mohammadi, and Harshit Jitendra Motwani. 2023. Algebro-geometric Algorithms for Template-based Synthesis of Polynomial Programs (Artifact). https://doi.org/10.5281/zenodo.7697453
[27]
Cordell Green. 1981. Application of theorem proving to problem solving. In Readings in Artificial Intelligence. 202–222.
[28]
Sumit Gulwani. 2011. Automating string processing in spreadsheets using input-output examples. In POPL. 317–330.
[29]
Sumit Gulwani, William R Harris, and Rishabh Singh. 2012. Spreadsheet data manipulation using examples. Commun. ACM, 55, 8 (2012), 97–105.
[30]
Sumit Gulwani, Susmit Jha, Ashish Tiwari, and Ramarathnam Venkatesan. 2011. Synthesis of loop-free programs. In PLDI. 62–73.
[31]
Sumit Gulwani, Oleksandr Polozov, and Rishabh Singh. 2017. Program synthesis. Foundations and Trends in Programming Languages, 4, 1-2 (2017), 1–119.
[32]
Zheng Guo, Michael James, David Justo, Jiaxiao Zhou, Ziteng Wang, Ranjit Jhala, and Nadia Polikarpova. 2019. Program synthesis by type-guided abstraction refinement. In POPL. 1–28.
[33]
David Handelman. 1988. Representing polynomials by positive linear functions on compact convex polyhedra. Pacific J. Math., 132, 1 (1988), 35–62.
[34]
Robin Hartshorne. 2013. Algebraic geometry. 52, Springer Science & Business Media.
[35]
Qinheping Hu, Rishabh Singh, and Loris D’Antoni. 2022. Solving Program Sketches with Large Integer Values. TOPLAS, 44, 2 (2022), 9:1–9:28.
[36]
Mingzhang Huang, Hongfei Fu, Krishnendu Chatterjee, and Amir Kafshdar Goharshady. 2019. Modular verification for almost-sure termination of probabilistic programs. In OOPSLA. 129:1–129:29.
[37]
Andreas Humenberger, Maximilian Jaroschek, and Laura Kovács. 2018. Invariant Generation for Multi-Path Loops with Polynomial Assignments. In VMCAI. 10747, 226–246.
[38]
Tristan Knoth, Di Wang, Nadia Polikarpova, and Jan Hoffmann. 2019. Resource-guided program synthesis. In PLDI. 253–268.
[39]
Andrej Kolmogoroff. 1932. Zur deutung der intuitionistischen logik. Mathematische Zeitschrift, 35, 1 (1932), 58–65.
[40]
John R Koza. 1994. Genetic programming as a means for programming computers by natural selection. Statistics and computing, 4, 2 (1994), 87–112.
[41]
Krzysztof Krawiec. 2016. Behavioral program synthesis with genetic programming. 618.
[42]
Hongming Liu, Hongfei Fu, Zhiyong Yu, Jiaxin Song, and Guoqiang Li. 2022. Location-by-Location Linear Invariant Generation with Farkas’ Lemma. In OOPSLA.
[43]
Ngoc Hoang Anh Mai and Victor Magron. 2022. On the complexity of Putinar–Vasilescu’s Positivstellensatz. Journal of Complexity, 101663.
[44]
Zohar Manna and Richard J Waldinger. 1971. Toward automatic program synthesis. Commun. ACM, 14, 3 (1971), 151–165.
[45]
Aaron Meurer, Christopher P Smith, Mateusz Paprocki, Ondřej Čertík, Sergey B Kirpichev, Matthew Rocklin, AMiT Kumar, Sergiu Ivanov, Jason K Moore, and Sartaj Singh. 2017. SymPy: symbolic computing in Python. PeerJ Computer Science, 3 (2017), e103.
[46]
Leonardo de Moura and Nikolaj Bjørner. 2008. Z3: An efficient SMT solver. In TACAS. 337–340.
[47]
Eike Neumann, Joël Ouaknine, and James Worrell. 2020. On ranking function synthesis and termination for polynomial programs. In CONCUR.
[48]
Rong Pan, Qinheping Hu, Rishabh Singh, and Loris D’Antoni. 2020. Solving Program Sketches with Large Integer Values. In ESOP. 572–598.
[49]
Amir Pnueli and Roni Rosner. 1989. On the synthesis of a reactive module. In POPL. 179–190.
[50]
Nadia Polikarpova, Ivan Kuraj, and Armando Solar-Lezama. 2016. Program synthesis from polymorphic refinement types. In PLDI. 522–538.
[51]
Mathias Preiner, Aina Niemetz, and Armin Biere. 2017. Counterexample-guided model synthesis. In TACAS. 264–280.
[52]
Mihai Putinar. 1993. Positive polynomials on compact semi-algebraic sets. Indiana University Mathematics Journal, 42, 3 (1993), 969–984.
[53]
Andrew Reynolds, Morgan Deters, Viktor Kuncak, Cesare Tinelli, and Clark Barrett. 2015. Counterexample-guided quantifier instantiation for synthesis in SMT. In CAV. 198–216.
[54]
Henry Gordon Rice. 1953. Classes of recursively enumerable sets and their decision problems. Transactions of the American Mathematical society, 74, 2 (1953), 358–366.
[55]
Enric Rodríguez-Carbonell. 2018. Some programs that need polynomial invariants in order to be verified. https://www.cs.upc.edu/ erodri/webpage/polynomial_invariants/list.html
[56]
Sriram Sankaranarayanan, Henny B Sipma, and Zohar Manna. 2004. Constraint-based linear-relations analysis. In SAS. 53–68.
[57]
Sriram Sankaranarayanan, Henny B Sipma, and Zohar Manna. 2004. Non-linear loop invariant generation using Gröbner bases. In POPL. 318–329.
[58]
David E Shaw, William R Swartout, and C Cordell Green. 1975. Inferring LISP Programs From Examples. In IJCAI. 260–267.
[59]
Xujie Si, Woosuk Lee, Richard Zhang, Aws Albarghouthi, Paraschos Koutris, and Mayur Naik. 2018. Syntax-guided synthesis of datalog programs. In ESEC/FSE. 515–527.
[60]
David Canfield Smith. 1975. Pygmalion: a creative programming environment. Stanford University.
[61]
Dominik Sobania, Dirk Schweim, and Franz Rothlauf. 2022. A Comprehensive Survey on Program Synthesis with Evolutionary Algorithms. IEEE Transactions on Evolutionary Computation.
[62]
Armando Solar-Lezama. 2008. Program synthesis by sketching. University of California, Berkeley.
[63]
Armando Solar-Lezama. 2009. The sketching approach to program synthesis. In APLAS. 4–13.
[64]
Saurabh Srivastava, Sumit Gulwani, and Jeffrey S Foster. 2010. From program verification to program synthesis. In POPL. 313–326.
[65]
Saurabh Srivastava, Sumit Gulwani, and Jeffrey S Foster. 2013. Template-based program verification and program synthesis. International Journal on Software Tools for Technology Transfer, 15, 5 (2013), 497–518.
[66]
Toru Takisaka, Yuichiro Oyabu, Natsuki Urabe, and Ichiro Hasuo. 2018. Ranking and repulsing supermartingales for reachability in probabilistic programs. In ATVA. 476–493.
[67]
Emina Torlak and Rastislav Bodík. 2014. A lightweight symbolic virtual machine for solver-aided host languages. In PLDI. 530–541.
[68]
Anne S Troelstra. 1977. Aspects of constructive mathematics. In Studies in Logic and the Foundations of Mathematics. 90, 973–1052.
[69]
Jinyi Wang, Yican Sun, Hongfei Fu, Krishnendu Chatterjee, and Amir Kafshdar Goharshady. 2021. Quantitative analysis of assertion violations in probabilistic programs. In PLDI. 1171–1186.
[70]
Peixin Wang, Hongfei Fu, Amir Kafshdar Goharshady, Krishnendu Chatterjee, Xudong Qin, and Wenjun Shi. 2019. Cost analysis of nondeterministic probabilistic programs. In PLDI. 204–220.
[71]
David S Watkins. 2004. Fundamentals of matrix computations. 64, John Wiley & Sons.

Cited By

View all
  • (2024)Algebraic Tools for Computing Polynomial Loop InvariantsProceedings of the 2024 International Symposium on Symbolic and Algebraic Computation10.1145/3666000.3669710(371-381)Online publication date: 16-Jul-2024
  • (2024)From Batch to Stream: Automatic Generation of Online AlgorithmsProceedings of the ACM on Programming Languages10.1145/36564188:PLDI(1014-1039)Online publication date: 20-Jun-2024
  • (2024)Solvable Polynomial Ideals: The Ideal Reflection for Program AnalysisProceedings of the ACM on Programming Languages10.1145/36328678:POPL(724-752)Online publication date: 5-Jan-2024

Recommendations

Comments

Information & Contributors

Information

Published In

cover image Proceedings of the ACM on Programming Languages
Proceedings of the ACM on Programming Languages  Volume 7, Issue OOPSLA1
April 2023
901 pages
EISSN:2475-1421
DOI:10.1145/3554309
Issue’s Table of Contents
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 06 April 2023
Published in PACMPL Volume 7, Issue OOPSLA1

Permissions

Request permissions for this article.

Check for updates

Badges

Author Tags

  1. program synthesis
  2. sketching
  3. syntax-guided synthesis

Qualifiers

  • Research-article

Funding Sources

  • Hong Kong Research Grants Council
  • HKUST
  • FWO
  • Arctic University of Norway
  • KU Leuven
  • University of Ghent
  • Sofina-Boël Fellowship Program

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)589
  • Downloads (Last 6 weeks)35
Reflects downloads up to 18 Aug 2024

Other Metrics

Citations

Cited By

View all
  • (2024)Algebraic Tools for Computing Polynomial Loop InvariantsProceedings of the 2024 International Symposium on Symbolic and Algebraic Computation10.1145/3666000.3669710(371-381)Online publication date: 16-Jul-2024
  • (2024)From Batch to Stream: Automatic Generation of Online AlgorithmsProceedings of the ACM on Programming Languages10.1145/36564188:PLDI(1014-1039)Online publication date: 20-Jun-2024
  • (2024)Solvable Polynomial Ideals: The Ideal Reflection for Program AnalysisProceedings of the ACM on Programming Languages10.1145/36328678:POPL(724-752)Online publication date: 5-Jan-2024

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Get Access

Login options

Full Access

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media