This paper from researchers at UNC Chapel Hill introduces a framework for turning static, one-off math problems into dynamic, generative programs. By moving beyond simple arithmetic to advanced competition-level mathematics, the authors demonstrate how Large Language Models (LLMs) can learn to "abstract" the underlying logic of a problem to create infinite, verifiable variations.
TL;DR
The authors present EFAGen, a method that automatically transforms advanced math problems into Executable Functional Abstractions (EFAs)—Python programs that can sample new problem parameters, render them into natural language, and solve them programmatically. This approach enables high-quality data augmentation and "adversarial" stress-testing, helping LLMs improve their reasoning on complex mathematical tasks.
What Problem Does This Paper Address?
While LLMs have become surprisingly good at solving math problems, they are often brittle. A model might solve a specific calculus problem but fail if the numbers are slightly tweaked or if the phrasing changes. This is because most math datasets are static; they provide a "surface form" (the specific numbers and words) rather than the "deep structure" (the underlying mathematical principles).
Previously, creating "problem generators" that could produce valid variations required intense human engineering or was limited to simple grade-school arithmetic. For advanced math—like tridiagonal matrix eigenvalues or complex number theory—automatically inferring the constraints needed to keep a problem solvable and non-trivial is extremely difficult.
Methods
The researchers developed EFAGen, which treats the inference of these abstractions as a program synthesis task. Given a "seed" problem and its solution, EFAGen uses an LLM to generate a Python class that inherits from a base EFABase structure.
An EFA consists of three core methods:
sample(): Randomly selects valid parameters (e.g., choosing a GCD and LCM that actually allow for a valid integer solution).render(): Plugs those parameters into a natural language template.solve(): Uses symbolic libraries (likesympy) or algorithmic logic to compute the correct answer for any sampled parameters.
To ensure these generated programs are actually correct, the authors use an overgenerate-and-filter pipeline. They sample many candidate programs and put them through a battery of automated unit tests:
- Executability: Does the code run without errors?
- Degrees of Freedom: Does it actually generate different problems, or just the same one over and over?
- Soundness: When given the original problem's parameters, does the program produce the original answer?
- Consistency: Do identical parameters always yield the same solution?
Finally, they use these successful EFAs to perform rejection-finetuning, training the LLM to become a better writer of EFAs by using the unit tests as a reward signal.
Datasets
The study utilizes several prominent mathematical benchmarks:
- MATH: A dataset of 12,500 competition-level problems across five difficulty levels.
- MATH-Hard: A subset of the most difficult (Level 5) problems.
- NuminaMath: A massive collection of 860k problems ranging from grade school (GSM8K) to international Olympiads (IMO, AIME).
- MATH-500 & FnEval: Used for evaluating the effectiveness of data augmentation.
Key Insights and Ideas
- Math as Code: The most powerful insight is that the "logic" of a math problem is best captured as an executable program rather than just text. This allows for verification that is impossible with pure natural language generation.
- Faithfulness and Learnability: The authors prove that EFAs are "faithful"—meaning that variants generated by an EFA actually help a model solve the original seed problem. They also show these variants are "learnable," providing a consistent structure that models can pick up on.
- Adversarial Discovery: EFAs can be used to find "hard" variants of "easy" problems. By sampling 50 variants of a problem a model can solve, they often find at least one variant that causes the model to fail, exposing specific reasoning gaps.
- Natural Filtering: Low-quality or "bad" EFAs (e.g., those that hard-code answers or produce trivial problems) naturally fail the unit tests, meaning the training data for the next generation of models is self-purifying.
Key Results
- Self-Improvement: Through iterative self-training, the EFA success rate for difficult "Intermediate Algebra" problems jumped from 52.9% to 81.4%.
- Effective Augmentation: Adding EFA-generated data to training sets consistently improved performance. On the MATH-500 benchmark, augmentation led to a +1.9 to +2.2 point absolute increase in Pass@1 accuracy.
- Generality: EFAGen successfully inferred EFAs across diverse domains, including Algebra, Number Theory, and Probability, even for high-level competition problems where functionalization was previously thought to require human experts.
Limitations and Future Work
- Complexity Ceiling: While EFAGen handles much harder math than previous work, extremely abstract or proof-based problems that lack clear numerical parameters remain a challenge.
- Seed Dependency: The quality of the EFA is highly dependent on the quality of the initial "seed" solution provided to the LLM.
- Future Directions: The authors suggest integrating EFAs into active learning loops, where a model identifies its own weaknesses and uses EFAGen to "hallucinate" a curriculum of practice problems to overcome them.
Summary updated