Skip to main content
Log in

Partial bounding for recursive function synthesis

  • Published:
Formal Methods in System Design Aims and scope Submit manuscript

Abstract

Quantifier bounding is a standard approach in inductive program synthesis to deal with unbounded domains. In this paper, we propose one such bounding method for the synthesis of recursive functions over recursive input data types. The synthesis problem is specified by an input reference (recursive) function and a recursion skeleton. The goal is to synthesize a recursive function equivalent to the input function whose recursion strategy is specified by the recursion skeleton. In this context, we illustrate that it is possible to selectively bound a subset of the recursively typed parameters, each by a suitable bound. The choices are guided by counterexamples. The evaluation of our strategy on a broad set of benchmarks shows that it succeeds in efficiently synthesizing non-trivial recursive functions where standard across-the-board bounding would fail.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6
Fig. 7
Fig. 8

Similar content being viewed by others

Notes

  1. The tool is available publicly at https://github.com/synduce/Synduce/releases/tag/fmsd22.

  2. This example is from [25], which calls this data type zipper.

  3. The full evaluation data is available at https://github.com/synduce/Synduce/tree/fmsd22/benchmarks/data/table3.txt.

References

  1. Abrahamsson O, Myreen MO (2018) Automatically introducing tail recursion in CakeML. In: Trends in functional programming, lecture notes in computer science. Springer International Publishing, pp 118–134

  2. Ahmad MBS, Cheung A (2018) Automatically leveraging mapreduce frameworks for data-intensive applications. In: Proceedings of the 2018 international conference on management of data, SIGMOD ’18. ACM

  3. Albarghouthi A, Gulwani S, Kincaid Z (2013) Recursive program synthesis. In: Computer aided verification, lecture notes in computer science. Springer, pp 934–950

  4. Alur R, Bodik R, Juniwal G, et al (2013) Syntax-guided synthesis. In: 2013 Formal methods in computer-aided design. IEEE, pp 1–8

  5. Barrett C, Conway CL, Deters M et al (2011) CVC4. Computer aided verification. In: Lecture notes in computer science. Springer, pp 171–177

  6. Burstall RM, Darlington J (1977) A transformation system for developing recursive programs. J ACM 24(1):44–67

    Article  MathSciNet  MATH  Google Scholar 

  7. de Moura L, Bjørner N (2008) Z3: an efficient SMT solver. In: Tools and algorithms for the construction and analysis of systems, Lecture Notes in Computer Science. Springer, pp 337–340

  8. Farzan A, Nicolet V (2017) Synthesis of divide and conquer parallelism for loops. In: Proceedings of the 38th ACM conference on programming language design and implementation, PLDI ’17

  9. Fedyukovich G, Ahmad MBS, Bodik R (2017) Gradual synthesis for static parallelization of single-pass array-processing programs. In: Proceedings of the 38th ACM conference on programming language design and implementation, PLDI 2017

  10. Feldman YMY, Padon O, Immerman N, et al (2017) Bounded quantifier instantiation for checking inductive invariants. In: Tools and algorithms for the construction and analysis of systems, lecture notes in computer science, pp 76–95

  11. Feser JK, Chaudhuri S, Dillig I (2015) Synthesizing data structure transformations from input–output examples. In: Proceedings of the 36th ACM conference on programming language design and implementation, PLDI ’15

  12. Frankle J, Osera PM, Walker D, et al (2016) Example-directed synthesis: a type-theoretic interpretation. In: Proceedings of the 43rd ACM symposium on principles of programming languages, POPL’16

  13. Hamilton GW, Jones ND (2012) Distillation with labelled transition systems. In: Proceedings of the ACM 2012 workshop on partial evaluation and program manipulation, PEPM ’12. ACM, pp 15–24

  14. Huet G (1997) The zipper. J Funct Program 7(5)

  15. Inala JP, Polikarpova N, Qiu X, et al (2017) Synthesis of recursive ADT transformations from reusable templates. In: Tools and algorithms for the construction and analysis of systems, lecture notes in computer science

  16. Itzhaky S, Singh R, Solar-Lezama A, et al (2016) Deriving divide-and-conquer dynamic programming algorithms using solver-aided transformations. In: Proceedings of the 2016 ACM conference on object-oriented programming, systems, languages, and applications. ACM, pp 145–164

  17. Katayama S (2012) An analytical inductive functional programming system that avoids unintended programs. In: Proceedings of the 2012 workshop on partial evaluation and program manipulation, PEPM’12

  18. Kitzelmann E, Schmid U (2006) Inductive synthesis of functional programs: an explanation based generalization approach. J Mach Learn Res 7(15):429–454

    MathSciNet  MATH  Google Scholar 

  19. Kneuss E, Kuraj I, Kuncak V, et al (2013) Synthesis modulo recursive functions. In: Proceedings of the 2013 international conference on object oriented programming systems languages and applications, OOPSLA’13

  20. Kobayashi N (2009) Types and higher-order recursion schemes for verification of higher-order programs. In: Proceedings of the 36th ACM symposium on principles of programming languages, POPL’09

  21. Kobayashi N, Tabuchi N, Unno H (2010) Higher-order multi-parameter tree transducers and recursion schemes for program verification. In: Proceedings of the 37th ACM symposium on principles of programming languages, POPL’10

  22. Kobayashi N, Sato R, Unno H (2011) Predicate abstraction and CEGAR for higher-order model checking. In: Proceedings of the 32nd ACM conference on programming language design and implementation, PLDI’11, pp 222–233

  23. Leroy X, Doligez D, Frisch A, et al (2019) The OCaml system release 4.11: documentation and user’s manual. p 823

  24. Morihata A, Matsuzaki K (2010) Automatic parallelization of recursive functions using quantifier elimination. In: Proceedings of the 10th international conference on functional and logic programming, FLOPS’10

  25. Morihata A, Matsuzaki K, Hu Z, et al (2009) The third homomorphism theorem on trees: downward and upward lead to divide-and-conquer. In: Proceedings of the 36th ACM symposium on principles of programming languages, POPL’09

  26. Nicolet V (2022) Synduce. https://github.com/synduce/Synduce/releases/tag/fmsd22

  27. Ong CHL, Ramsay SJ (2011) Verifying higher-order functional programs with pattern-matching algebraic data types. In: Proceedings of the 38th ACM symposium on principles of programming languages, POPL’11

  28. Osera PM, Zdancewic S (2015) Type-and-example-directed program synthesis. In: Proceedings of the 36th ACM conference on programming language design and implementation, PLDI’15

  29. Padhi S, Polgreen E, Raghothaman M, et al (2019) The SyGuS language standard version 2.1

  30. Polikarpova N, Kuraj I, Solar-Lezama A (2016) Program synthesis from polymorphic refinement types. In: Proceedings of the 37th ACM conference on programming language design and implementation, PLDI’16

  31. Ramsay SJ, Neatherway RP, Ong CHL (2014) A type-directed abstraction refinement approach to higher-order model checking. In: Proceedings of the 41st ACM symposium on principles of programming languages, POPL’14

  32. Reynolds A, Deters M, Kuncak V, et al (2015) Counterexample-guided quantifier instantiation for synthesis in SMT. In: Computer aided verification, lecture notes in computer science, pp 198–216

  33. Solar-Lezama A (2008) Program synthesis by sketching. University of California, Berkeley

    Google Scholar 

  34. Solar-Lezama A, Tancau L, Bodik R, et al (2006) Combinatorial sketching for finite programs. In: Proceedings of the 12th international conference on architectural support for programming languages and operating systems, ASPLOS XII. pp 404–415

  35. Solar-Lezama A, Arnold G, Tancau L, et al (2007) Sketching stencils. In: Proceedings of the 28th ACM conference on programming language design and implementation, PLDI’07

  36. Solar-Lezama A, Jones CG, Bodik R (2008) Sketching concurrent data structures. In: Proceedings of the 29th ACM conference on programming language design and implementation, PLDI’08

  37. Summers PD (1977) A methodology for LISP program construction from examples. J ACM 24(1):161–175

    Article  MathSciNet  MATH  Google Scholar 

  38. Yang W, Fedyukovich G, Gupta A (2019) Lemma synthesis for automating induction over algebraic data types. In: Principles and practice of constraint programming, lecture notes in computer science, pp 600–617

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Azadeh Farzan.

Additional information

Publisher's Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Rights and permissions

Springer Nature or its licensor (e.g. a society or other partner) holds exclusive rights to this article under a publishing agreement with the author(s) or other rightsholder(s); author self-archiving of the accepted manuscript version of this article is solely governed by the terms of such publishing agreement and applicable law.

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Farzan, A., Nicolet, V. Partial bounding for recursive function synthesis. Form Methods Syst Des (2023). https://doi.org/10.1007/s10703-023-00417-y

Download citation

  • Received:

  • Accepted:

  • Published:

  • DOI: https://doi.org/10.1007/s10703-023-00417-y

Keywords

Navigation