Going Bananas! - Unfolding Program Synthesis with Origami
Matheus Campos Fernandes, Fabrício Olivetti de França, Emilio Francesquini
TL;DR
This work addresses the challenge of automatically synthesizing recursive functional programs from input-output specifications by embedding Recursion Schemes into a Koza-style Genetic Programming framework (Origami). Origami represents solutions as pattern-driven, typed trees where recursion can only occur through designated patterns, enabling controlled use of folds, unfolds, and their combinations. Empirical evaluation on the PSB1 benchmark shows Origami frequently outperforms HOTGP and other GP-based approaches, solving more problems and achieving higher success rates, while highlighting remaining challenges with Accumulation and Hylo patterns. The findings suggest that guiding search with recursion schemes is a promising direction for scalable, correct-by-construction program synthesis, with future work needed on unbound types and broader pattern exploration.
Abstract
Automatically creating a computer program using input-output examples can be a challenging task, especially when trying to synthesize computer programs that require loops or recursion. Even though the use of recursion can make the algorithmic description more succinct and declarative, this concept creates additional barriers to program synthesis algorithms such as the creation and the (tentative) evaluation of non-terminating programs. One reason is that the recursive function must define how to traverse (or generate) the data structure and, at the same time, how to process it. In functional programming, the concept of recursion schemes decouples these two tasks by putting a major focus on the latter. This can also help to avoid some of the pitfalls of recursive functions during program synthesis, as argued in a previous work where we introduced the Origami technique. In our previous paper, we showed how this technique was effective in finding solutions for programs that require folding lists. In this work, we incorporate other recursion schemes into Origami, such as accumulated folding, unfolding, and the combination of unfolding and folding. We evaluated Origami on the 29 problems of the standard General Program Synthesis Benchmark Suite 1, obtaining favorable results against other well-known algorithms. Overall, Origami achieves the best result in 25% more problems than its predecessor (HOTGP) and an even higher increase when compared to other approaches. Not only that, but it can also consistently find a solution to problems that many algorithms report a low success rate.
