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.
- Alessandro Abate, Cristina David, Pascal Kesseli, Daniel Kroening, and Elizabeth Polgreen. 2018. Counterexample guided inductive synthesis modulo theories. In CAV. 270–288.
Google Scholar
- Sheshansh Agrawal, Krishnendu Chatterjee, and Petr Novotnỳ. 2017. Lexicographic ranking supermartingales: an efficient approach to termination of probabilistic programs. In POPL.
Google Scholar
- 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.
Google Scholar
- Rajeev Alur, Dana Fisman, Saswat Padhi, Andrew Reynolds, Rishabh Singh, and Abhishek Udupa. 2019. SyGuS-Comp: Syntax-guided Synthesis Competition. https://sygus.org/
Google Scholar
- Rajeev Alur, Rishabh Singh, Dana Fisman, and Armando Solar-Lezama. 2018. Search-based program synthesis. Commun. ACM, 61, 12 (2018), 84–93.
Google Scholar
Digital Library
- Ali Asadi, Krishnendu Chatterjee, Hongfei Fu, Amir Kafshdar Goharshady, and Mohammad Mahdavi. 2021. Polynomial reachability witnesses via Stellensätze. In PLDI. 772–787.
Google Scholar
- 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.
Google Scholar
- Grigoriy Blekherman, Pablo A Parrilo, and Rekha R Thomas. 2012. Semidefinite optimization and convex algebraic geometry. SIAM.
Google Scholar
- Jacek Bochnak, Michel Coste, and Marie-Françoise Roy. 2013. Real algebraic geometry. 36, Springer Science & Business Media.
Google Scholar
- James Bornholt and Emina Torlak. 2018. Finding code that explodes under symbolic evaluation. In OOPSLA. 1–26.
Google Scholar
- Krishnendu Chatterjee, Hongfei Fu, and Amir Kafshdar Goharshady. 2016. Termination analysis of probabilistic programs through Positivstellensatz’s. In CAV. 3–22.
Google Scholar
- Krishnendu Chatterjee, Hongfei Fu, and Amir Kafshdar Goharshady. 2017. Non-polynomial Worst-Case Analysis of Recursive Programs. In CAV. 10427, 41–63.
Google Scholar
- 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.
Google Scholar
Digital Library
- Krishnendu Chatterjee, Hongfei Fu, Amir Kafshdar Goharshady, and Ehsan Kafshdar Goharshady. 2020. Polynomial invariant generation for non-deterministic recursive programs. In PLDI. 672–687.
Google Scholar
- Krishnendu Chatterjee, Hongfei Fu, Amir Kafshdar Goharshady, and Nastaran Okati. 2018. Computational Approaches for Stochastic Shortest Path on Succinct MDPs. In IJCAI. 4700–4707.
Google Scholar
- Krishnendu Chatterjee, Hongfei Fu, and Petr Novotnỳ. 2020. Termination analysis of probabilistic programs with martingales. Foundations of Probabilistic Programming, 221–258.
Google Scholar
- 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.
Google Scholar
- Alonzo Church. 1963. Application of recursive arithmetic to the problem of circuit synthesis. Journal of Symbolic Logic, 28, 4 (1963).
Google Scholar
- Alessandro Cimatti, Alberto Griggio, Bastiaan Schaafsma, and Roberto Sebastiani. 2013. The MathSAT5 SMT Solver. In TACAS, Nir Piterman and Scott Smolka (Eds.).
Google Scholar
- Michael A Colón, Sriram Sankaranarayanan, and Henny B Sipma. 2003. Linear invariant generation using non-linear constraint solving. In CAV. 420–432.
Google Scholar
- Julius Farkas. 1902. Theory of simple inequalities.. Journal for pure and applied mathematics (Crelles Journal), 1902, 124 (1902), 1–27.
Google Scholar
- Grigory Fedyukovich, Sumanth Prabhu, Kumar Madhukar, and Aarti Gupta. 2019. Quantified invariants via syntax-guided synthesis. In CAV. 259–277.
Google Scholar
- Yijun Feng, Lijun Zhang, David N Jansen, Naijun Zhan, and Bican Xia. 2017. Finding polynomial loop invariants for probabilistic programs. In ATVA. 400–416.
Google Scholar
- Amir Goharshady. 2020. Parameterized and algebro-geometric advances in static program analysis. Ph.D. Dissertation. Institute of Science and Technology Austria.
Google Scholar
- 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
Google Scholar
- 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
Google Scholar
Digital Library
- Cordell Green. 1981. Application of theorem proving to problem solving. In Readings in Artificial Intelligence. 202–222.
Google Scholar
- Sumit Gulwani. 2011. Automating string processing in spreadsheets using input-output examples. In POPL. 317–330.
Google Scholar
- Sumit Gulwani, William R Harris, and Rishabh Singh. 2012. Spreadsheet data manipulation using examples. Commun. ACM, 55, 8 (2012), 97–105.
Google Scholar
Digital Library
- Sumit Gulwani, Susmit Jha, Ashish Tiwari, and Ramarathnam Venkatesan. 2011. Synthesis of loop-free programs. In PLDI. 62–73.
Google Scholar
- Sumit Gulwani, Oleksandr Polozov, and Rishabh Singh. 2017. Program synthesis. Foundations and Trends in Programming Languages, 4, 1-2 (2017), 1–119.
Google Scholar
Cross Ref
- 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.
Google Scholar
- David Handelman. 1988. Representing polynomials by positive linear functions on compact convex polyhedra. Pacific J. Math., 132, 1 (1988), 35–62.
Google Scholar
Cross Ref
- Robin Hartshorne. 2013. Algebraic geometry. 52, Springer Science & Business Media.
Google Scholar
- Qinheping Hu, Rishabh Singh, and Loris D’Antoni. 2022. Solving Program Sketches with Large Integer Values. TOPLAS, 44, 2 (2022), 9:1–9:28.
Google Scholar
- 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.
Google Scholar
- Andreas Humenberger, Maximilian Jaroschek, and Laura Kovács. 2018. Invariant Generation for Multi-Path Loops with Polynomial Assignments. In VMCAI. 10747, 226–246.
Google Scholar
- Tristan Knoth, Di Wang, Nadia Polikarpova, and Jan Hoffmann. 2019. Resource-guided program synthesis. In PLDI. 253–268.
Google Scholar
- Andrej Kolmogoroff. 1932. Zur deutung der intuitionistischen logik. Mathematische Zeitschrift, 35, 1 (1932), 58–65.
Google Scholar
Cross Ref
- John R Koza. 1994. Genetic programming as a means for programming computers by natural selection. Statistics and computing, 4, 2 (1994), 87–112.
Google Scholar
- Krzysztof Krawiec. 2016. Behavioral program synthesis with genetic programming. 618.
Google Scholar
- Hongming Liu, Hongfei Fu, Zhiyong Yu, Jiaxin Song, and Guoqiang Li. 2022. Location-by-Location Linear Invariant Generation with Farkas’ Lemma. In OOPSLA.
Google Scholar
- Ngoc Hoang Anh Mai and Victor Magron. 2022. On the complexity of Putinar–Vasilescu’s Positivstellensatz. Journal of Complexity, 101663.
Google Scholar
- Zohar Manna and Richard J Waldinger. 1971. Toward automatic program synthesis. Commun. ACM, 14, 3 (1971), 151–165.
Google Scholar
Digital Library
- 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.
Google Scholar
Cross Ref
- Leonardo de Moura and Nikolaj Bjørner. 2008. Z3: An efficient SMT solver. In TACAS. 337–340.
Google Scholar
- Eike Neumann, Joël Ouaknine, and James Worrell. 2020. On ranking function synthesis and termination for polynomial programs. In CONCUR.
Google Scholar
- Rong Pan, Qinheping Hu, Rishabh Singh, and Loris D’Antoni. 2020. Solving Program Sketches with Large Integer Values. In ESOP. 572–598.
Google Scholar
- Amir Pnueli and Roni Rosner. 1989. On the synthesis of a reactive module. In POPL. 179–190.
Google Scholar
- Nadia Polikarpova, Ivan Kuraj, and Armando Solar-Lezama. 2016. Program synthesis from polymorphic refinement types. In PLDI. 522–538.
Google Scholar
- Mathias Preiner, Aina Niemetz, and Armin Biere. 2017. Counterexample-guided model synthesis. In TACAS. 264–280.
Google Scholar
- Mihai Putinar. 1993. Positive polynomials on compact semi-algebraic sets. Indiana University Mathematics Journal, 42, 3 (1993), 969–984.
Google Scholar
Cross Ref
- Andrew Reynolds, Morgan Deters, Viktor Kuncak, Cesare Tinelli, and Clark Barrett. 2015. Counterexample-guided quantifier instantiation for synthesis in SMT. In CAV. 198–216.
Google Scholar
- Henry Gordon Rice. 1953. Classes of recursively enumerable sets and their decision problems. Transactions of the American Mathematical society, 74, 2 (1953), 358–366.
Google Scholar
Cross Ref
- 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
Google Scholar
- Sriram Sankaranarayanan, Henny B Sipma, and Zohar Manna. 2004. Constraint-based linear-relations analysis. In SAS. 53–68.
Google Scholar
- Sriram Sankaranarayanan, Henny B Sipma, and Zohar Manna. 2004. Non-linear loop invariant generation using Gröbner bases. In POPL. 318–329.
Google Scholar
- David E Shaw, William R Swartout, and C Cordell Green. 1975. Inferring LISP Programs From Examples. In IJCAI. 260–267.
Google Scholar
- 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.
Google Scholar
- David Canfield Smith. 1975. Pygmalion: a creative programming environment. Stanford University.
Google Scholar
- Dominik Sobania, Dirk Schweim, and Franz Rothlauf. 2022. A Comprehensive Survey on Program Synthesis with Evolutionary Algorithms. IEEE Transactions on Evolutionary Computation.
Google Scholar
- Armando Solar-Lezama. 2008. Program synthesis by sketching. University of California, Berkeley.
Google Scholar
Digital Library
- Armando Solar-Lezama. 2009. The sketching approach to program synthesis. In APLAS. 4–13.
Google Scholar
- Saurabh Srivastava, Sumit Gulwani, and Jeffrey S Foster. 2010. From program verification to program synthesis. In POPL. 313–326.
Google Scholar
- 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.
Google Scholar
Digital Library
- Toru Takisaka, Yuichiro Oyabu, Natsuki Urabe, and Ichiro Hasuo. 2018. Ranking and repulsing supermartingales for reachability in probabilistic programs. In ATVA. 476–493.
Google Scholar
- Emina Torlak and Rastislav Bodík. 2014. A lightweight symbolic virtual machine for solver-aided host languages. In PLDI. 530–541.
Google Scholar
- Anne S Troelstra. 1977. Aspects of constructive mathematics. In Studies in Logic and the Foundations of Mathematics. 90, 973–1052.
Google Scholar
Cross Ref
- 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.
Google Scholar
- 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.
Google Scholar
- David S Watkins. 2004. Fundamentals of matrix computations. 64, John Wiley & Sons.
Google Scholar
Index Terms
Algebro-geometric Algorithms for Template-Based Synthesis of Polynomial Programs
Recommendations
Can reactive synthesis and syntax-guided synthesis be friends?
PLDI 2022: Proceedings of the 43rd ACM SIGPLAN International Conference on Programming Language Design and ImplementationWhile reactive synthesis and syntax-guided synthesis (SyGuS) have seen enormous progress in recent years, combining the two approaches has remained a challenge. In this work, we present the synthesis of reactive programs from Temporal Stream Logic ...
Algorithmic program synthesis: introduction
Program synthesis is a process of producing an executable program from a specification. Algorithmic synthesis produces the program automatically, without an intervention from an expert. While classical compilation falls under the definition of ...






Comments