MathGAP: Out-of-Distribution Evaluation on Problems with Arbitrarily Complex Proofs

Andreas Opedal, Haruki Shirakami, Bernhard Schölkopf, Abulhair Saparov, Mrinmaya Sachan · DOI

Introduction

While Large Language Models (LLMs) frequently achieve high scores on mathematical benchmarks like GSM8k, questions remain regarding whether these models are truly reasoning or simply retrieving patterns from their training data. Current benchmarks suffer from two primary limitations: data contamination and static complexity. If a model can solve a three-step problem, its ability to solve a ten-step problem often remains untested. Furthermore, the structural complexity of proofs—whether they are linear or branch into multiple sub-problems—is rarely evaluated systematically.

To address these gaps, researchers introduced MathGAP, a framework designed to stress-test LLM reasoning through the generation of synthetic math word problems with controllable proof trees. By moving beyond "in-distribution" testing, MathGAP enables "out-of-distribution" (OOD) evaluation, challenging models with logic far more complex than typical training examples.

The MathGAP Framework

MathGAP utilizes a formal "world-model" approach to problem generation. Unlike traditional methods that wrap stories around mathematical operations, MathGAP reverses the process by starting with a logical foundation.

The MathGAP generation process: from logical proof tree to natural language word problem and solution.

The generation process follows three distinct steps:

  1. Sample a Proof Tree: The system begins with a "root" logical statement (the final answer) and works backward. It iteratively applies inference rules—such as addition, comparison, or part-whole relations—to construct a tree of premises.
  2. Define Complexity: The framework programmatically controls four key variables: depth (number of steps), width (number of initial facts), shape (linear vs. nonlinear), and ordering (sequence of presentation).
  3. Automated Generation: Because the problems are derived from logic trees, the system automatically generates both the natural language problem and the corresponding ground-truth Chain-of-Thought (CoT) reasoning trace.

The "Nonlinear Wall" and Logical Memory

The study revealed several critical insights into the nature of LLM reasoning. One of the most significant findings is the "Nonlinear Wall." Nonlinear problems prove substantially harder for models than linear ones, even when the total number of facts remains constant. In a linear proof, a model can "consume" facts sequentially. In a nonlinear proof, the model must store intermediate results in its "mental" workspace while processing other branches of the logic tree. LLMs currently struggle with this form of logical "memory management."

Additionally, the research found that Width is harder than Depth. Models generally exhibit more difficulty tracking a large number of initial facts (width) than following a long sequence of steps (depth). The models also showed extreme sensitivity to "sentence shuffling." Moving a single sentence from its logical position to the beginning or middle of a problem caused a noticeable drop in accuracy, highlighting a "lost in the middle" effect for logical premises.

Results and Model Performance

The researchers evaluated a range of models, including Mixtral-8x7B, Llama-3, GPT-4o, and the reasoning-focused OpenAI o1 and DeepSeek-R1. Across the board, performance decayed as proof depth and width increased.

Accuracy of Mixtral-8x7B decreases significantly as problem width increases, illustrating the difficulty models face with high-axiom problems.

Key performance highlights include:

  • GPT-4o's Limits: While highly capable on standard tasks, GPT-4o's accuracy plummeted toward zero on the most complex nonlinear problems.
  • The "Thinking" Advantage: Reasoning models like o1 and DeepSeek-R1 performed significantly better on nonlinear tasks, but this success was tied to their output token limits. When restricted to 4,096 tokens, o1 failed on depth-7 nonlinear problems. However, when allowed up to 25,000 tokens for internal "thinking," its accuracy rose to 76.5%.
  • Future-Proofing: Even the most advanced models struggled with a "future-proof" test set featuring depth-7 problems and randomized sentence ordering, with o1 and R1 solving only 5% and 11% respectively.

Conclusion and Future Directions

The MathGAP framework demonstrates that current LLM reasoning is fragile and highly dependent on problem structure. While "thinking" models show promise, they are not yet robust against high-complexity, out-of-distribution logical structures.

Future work aims to increase the linguistic diversity of the generated problems, which currently rely on templates. Expanding the framework to include more advanced mathematical concepts like rates or probabilities and supporting multiple languages will further enhance its utility as a rigorous benchmark for the next generation of reasoning models.

Summary updated

BibTeX
@inproceedings{opedal2025mathgap,
  author = {Andreas Opedal and Haruki Shirakami and Bernhard Schölkopf and Abulhair Saparov and Mrinmaya Sachan},
  title = {{MathGAP: Out-of-Distribution Evaluation on Problems with Arbitrarily Complex Proofs}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=5ck9PIrTpH},
}
Figure