LEMMA: Bootstrapping High-Level Mathematical Reasoning with Learned Symbolic Abstractions

Zhening Li, Gabriel Poesia, Omar Costilla-Reyes, Noah D. Goodman, Armando Solar-Lezama

TL;DR

LEMMA (Learning Mathematical Abstractions) is a reinforcement learning framework that enables agents to solve complex math problems by automatically discovering high-level "macro-actions." By mining common patterns from successful solutions and adding them to its toolkit, the agent reduces search depth and generalizes far better to harder, unseen problems than standard step-by-step solvers.

What Problem Does This Paper Address?

Mathematical reasoning is notoriously difficult for AI because the search space of possible steps grows exponentially with the length of the solution. While humans manage this complexity by creating hierarchies of abstractions—like "simplifying an expression" or "moving a term to the other side"—most reinforcement learning (RL) agents are forced to operate at the level of basic axioms (e.g., $x + 0 = x$).

The challenge is that these low-level steps make even simple linear equations require dozens of operations to solve formally. If an agent only learns to navigate these tiny steps, it struggles to solve longer, more complex problems. The authors aim to bridge this gap by creating an agent that can "bootstrap" its own high-level library of tactics, effectively shortening the path to a solution.

Methods

LEMMA builds upon Expert Iteration (ExIt), a standard loop where an agent alternates between searching for solutions and training a policy to guide that search. The authors introduce a novel Abstraction Step into this loop:

  1. Mining: The agent looks at a dataset of successful solutions it has found so far.
  2. Projection: Because exact action sequences are rare, LEMMA uses "projection functions" to find similarities.
  3. SeqAbs ignores specific numbers and only looks at the sequence of axioms used.
  4. RelAbs (Relative Abstractions) also tracks the relative position in the mathematical expression tree where the axioms were applied.
  5. Selection: Using a Bayesian criterion, the algorithm selects a subset of these patterns that best "compress" the solution data. These become new, high-level abstract actions.
  6. Integration: These new actions are added to the agent's action space. The agent then performs a brief session of imitation learning to understand how to use these new "shortcuts" before resuming its search for even harder problems.
Figure 1: Example of an axiomatic formal solution to a simple linear equation. We would like to automatically discover abstractions, or high-level actions, such as “simplify an expression” or “move a term to the other side”, which can be expressed in terms of the base axioms.

Datasets

The researchers evaluated LEMMA on two symbolic domains from the Common Core mathematical environments:

  • Equation Solving: Solving linear equations.
  • Fraction Simplification: Reducing complex fractional expressions.

To test the limits of the system, they also introduced "hard" versions of these benchmarks (equations-hard and fractions-hard). These versions feature longer equation templates and more complex prime factorizations, significantly increasing the solution length compared to the standard sets.

Key Insights and Ideas

  • Hierarchical Bootstrapping: LEMMA can learn abstractions that are themselves composed of previously learned abstractions. This mimics how human mathematics builds from basic arithmetic to algebra and beyond.
  • Search Depth Reduction: By turning a 5- or 7-step axiomatic sequence into a single abstract action, the agent effectively "shrinks" the problem. A problem that previously required 30 steps might now only require 5, making it much more likely that the agent's search will succeed.
  • Interpretable Tactics: The discovered abstractions are not "black boxes." When expanded, they often correspond to recognizable human strategies, such as "dividing both sides by a constant" or "canceling terms in a fraction."
  • Generalization via Abstraction: The most significant insight is that abstractions provide a form of structural regularization. Because the agent learns the logic of a multi-step move rather than just memorizing a sequence, it can apply that logic to much harder problems than it saw during training.

Key Results

The results demonstrate that adding abstraction learning consistently outperforms the baseline agent (ConPoLe).

As shown in Figure 2, the success rate of LEMMA-augmented agents jumps significantly after each abstraction round (indicated by the vertical dashed lines).

Figure 2: Success rate of agents on held-out problems on the four domains we test on, with standard errors across 3 random seeds. Vertical lines separate the 4 rounds of reinforcement learning.
  • Zero-Shot Generalization: When trained on simple equations and tested on equations-hard, the vanilla agent's success rate plummeted from 92% to 45.5%. In contrast, the LEMMA agent (using RelAbs) maintained a much higher success rate, dropping from 99.5% to 60%.
  • Efficiency: In the fractions domain, LEMMA discovered abstractions that performed integer division and addition/subtraction—operations that were not even explicitly provided in the original set of 8 axioms.

Limitations and Future Work

While successful, LEMMA currently relies on pre-defined projection functions to help it find patterns. The authors suggest that future work could involve learning these projections automatically. Additionally, the current abstractions are linear sequences of actions; extending this to more complex "tactics" with branching logic (if-then-else) would be a major step forward. Finally, the authors hope to apply these techniques to more formal, industrial-strength theorem-proving languages like Lean or Isabelle/HOL.

Summary updated

BibTeX
@misc{li2022lemma,
  author = {Zhening Li and Gabriel Poesia and Omar Costilla-Reyes and Noah D. Goodman and Armando Solar-Lezama},
  title = {{LEMMA: Bootstrapping High-Level Mathematical Reasoning with Learned Symbolic Abstractions}},
  year = {2022},
  eprint = {2211.08671},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2211.08671},
}
Figure