Functional Program Synthesis with Higher-Order Functions and Recursion Schemes

📅 2025-11-28
📈 Citations: 0
✨ Influential: 0
📄 PDF
🤖 AI Summary
This work addresses the challenges of modeling higher-order functions and recursive patterns—and the resulting large search space—in program synthesis. We propose two novel algorithms: HOTGP (Higher-Order Type-guided Genetic Programming) and Origami (structured search guided by parametric recursive pattern templates). To our knowledge, this is the first approach to integrate parametric recursive pattern templates into a type-driven synthesis framework, augmented with the AC/DC adaptive search optimization mechanism. On the PSB2 benchmark, our method achieves 100% task success rate—the first to solve all tasks in this benchmark. By synergistically combining type constraints, λ-calculus semantics, parametric polymorphism, and syntax-guided search, our approach uniquely attains 100% success on 18% of tasks and significantly outperforms state-of-the-art genetic programming methods and large language models (e.g., GitHub Copilot) in both overall solution rate and win rate.

Technology Category

Natural Language Processing: Code Generation / Program Synthesis from Natural LanguageSearch and Optimization: Sampling/Simulation-based SearchCognitive Modeling & Cognitive Systems: Computational Creativity

Application Category

Search and Retrieval-Augmented AI: Agentic searchGraph Algorithms and Modeling for the Web: Algorithms and analysis for heterogeneous, signed, attributed, multi-relational, temporal, higher-order, and annotated Web-related graphsSemantics and Knowledge: Methods to enhance, augment, integrate or synergize semantic models such as knowledge graphs and LLMs
📝 Abstract
Program synthesis is the process of generating a computer program following a set of specifications, such as a set of input-output examples. It can be modeled as a search problem in which the search space is the set of all valid programs. As the search space is vast, brute force is usually not feasible, and search heuristics, such as genetic programming, also have difficulty navigating it without guidance. This text presents 2 novel GP algorithms that synthesize pure, typed, and functional programs: HOTGP and Origami. HOTGP uses strong types and a functional grammar, synthesizing Haskell code, with support for higher-order functions, $λ$-functions, and parametric polymorphism. Experimental results show that HOTGP is competitive with the state of the art. Additionally, Origami is an algorithm that tackles the challenge of effectively handling loops and recursion by exploring Recursion Schemes, in which the programs are composed of well-defined templates with only a few parts that need to be synthesized. The first implementation of Origami can synthesize solutions in several Recursion Schemes and data structures, being competitive with other GP methods in the literature, as well as LLMs. The latest version of Origami employs a novel procedure, called AC/DC, designed to improve the search-space exploration. It achieves considerable improvement over its previous version by raising success rates on every problem. Compared to similar methods in the literature, it has the highest count of problems solved with success rates of $100%$, $geq 75%$, and $geq 25%$ across all benchmarks. In $18%$ of all benchmark problems, it stands as the only method to reach $100%$ success rate, being the first known approach to achieve it on any problem in PSB2. It also demonstrates competitive performance to LLMs, achieving the highest overall win-rate against Copilot among all GP methods.
Problem

Research questions and friction points this paper is trying to address.

Synthesizing pure typed functional programs using genetic programming
Effectively handling loops and recursion in program synthesis
Navigating vast search spaces in automated program generation
Innovation

Methods, ideas, or system contributions that make the work stand out.

HOTGP uses strong types and functional grammar for synthesis
Origami explores Recursion Schemes with well-defined program templates
AC/DC procedure improves search-space exploration in Origami
🔎 Similar Papers
2024-08-22arXiv.orgCitations: 2