NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Code2Math: Can Your Code Agent Effectively Evolve Math Problems Through Exploration?

Dadi Guo, Yuejin Xie, Qingyu Liu, Weixian Huang, Jiayu Liu, Zhiyuan Fan, Qihan Ren, Shuai Shao, Tianyi Zhou, Jianjie Feng, Wenze Su, Yujiu Yang, Dongrui Liu, Yi R. FungarXiv 2026

TL;DR

As large language models (LLMs) approach Olympiad-level mathematical proficiency, finding novel, high-quality problems to train and evaluate them has become a major bottleneck. This paper introduces Code2Math, a multi-agent framework that leverages code execution to autonomously evolve simple math problems into highly complex, structurally distinct variations. Crucially, the study reveals a "capability asymmetry"—models can successfully generate valid mathematical challenges that surpass their own ability to solve.

What Problem Does This Paper Address?

State-of-the-art reasoning models (like DeepSeek-R1) are achieving incredible performance on standard math benchmarks, nearing International Mathematical Olympiad (IMO) levels. However, this rapid progress has triggered a data scarcity crisis: we are running out of sufficiently challenging, high-quality math problems to continue training and evaluating these models.

Manually curating Olympiad-level math problems requires deep domain expertise and immense human effort. Meanwhile, existing automated generation methods often rely on superficial text paraphrasing or simple rule-based edits (like changing numbers or adding tedious algebra). The authors address this gap by asking: Can code-driven agents autonomously explore mathematical spaces to synthesize genuinely difficult problems that require deep conceptual insights ("Aha!" moments)?

Methods

The authors propose a multi-agent framework that treats problem generation as an iterative, exploratory process backed by a Python execution sandbox. The system operates under a test-time scaling paradigm, running multiple rollouts until a generated problem satisfies two strict verification agents.

The pipeline consists of three specialized agents:

  1. Evolution Agent: Analyzes the original "seed" problem to identify its cognitive bottleneck. It then enters an exploration phase, writing Python code using specialized libraries (SymPy for symbolic math, Z3 for constraint satisfaction, NetworkX for graph theory, and itertools for combinatorics) to search for tighter mathematical bounds, hidden periodicities, or complex combinatorial structures. It outputs a new problem statement and a proposed solution.
  2. Solvability Verification Agent: Acts as a strict firewall against "bad math." It checks the problem text for contradictions and rigorously audits the proposed solution steps to ensure logical consistency, filtering out flawed generations.
  3. Difficulty Verification Agent: Evaluates the relative difficulty using a 5-point rubric designed to distinguish Cognitive Depth (requiring a non-trivial leap in insight) from Artificial Complexity (merely adding tedious calculations or repetitive steps).
Figure 2: Overview of our multi-agent system. Our pipeline consists of three components: the Evolution Agent, the Solvability Verification Agent, and the Difficulty Verification Agent. It is equipped with code tools related to mathematics. The framework takes an original problem and its solution as input and outputs a validated new problem along with a solution for reference.

Datasets

The framework was evaluated using a dataset of 100 seed problems collected from diverse, high-level mathematical sources. These include standard mathematics problem books, recent regional exams, the IMO, and mainstream benchmarks like AIME-2024 and AIME-2025. This diverse mix ensures a wide coverage of fields, including algebra, combinatorics, calculus, sequences, and graph theory.

Key Insights and Ideas

  • Capability Asymmetry: The most striking insight is that LLMs exhibit an asymmetry in creation versus solution. An evolution agent can synthesize a "Burden of Discovery"—deliberately concealing insights to create a harder problem—that reduces the solve rate of models otherwise stronger than itself.
  • Code as an Exploration Engine: Code execution shifts the model's behavior from superficial text editing to grounded structural exploration. By anchoring problems around concrete computational targets (like fixed constants or enumerable configurations), code-enabled evolution produces cleaner, more rigorous, and better-specified mathematical challenges.
  • Solvability is the Real Bottleneck: Maintaining mathematical validity while increasing difficulty is incredibly hard. The failure analysis revealed that the vast majority of rejected problem candidates failed at the solvability verification stage rather than the difficulty check.

Key Results

  • Substantial Difficulty Escalation: Evolved problems systematically degraded the performance of top-tier solver models. For example, the solve rate of GPT-5.2-High dropped from 70% on the seed problems to 64% on DeepSeek-Reasoner evolutions, and down to 61% on Gemini-3-Pro-Thinking and Seed-2.0-Pro evolutions.
  • Longer Reasoning Chains: Solvers required significantly more cognitive effort to tackle the evolved problems. The Average Token Consumption (ATC) shifted heavily to the right, showing a substantial increase in high-token counts and timeout cases.
Figure 3: Distribution of Average Token Consump- tion (ATC) across original and agent-evolved problems. For each problem, we compute the average output to- kens across all solver models. Timeout samples (where solvers failed to produce output) are assigned the maxi- mum token limit to reflect their high difficulty.
  • High Solvability Precision: Problems that passed the internal multi-agent filters were highly reliable. An external judge (GPT-5.2-High) certified up to 96% of DeepSeek-Reasoner's accepted problems as valid, a finding strongly supported by a blind human expert audit which yielded a 99.2% validity precision rate.
  • The Power of Code: In ablation studies comparing code-enabled agents to no-code agents, code-driven evolution consistently produced harder problems, lowering average solver accuracy from 25.7% (no-code) to 23.1% (with code).

Limitations and Future Work

  • High Computational Cost: The dual-verification pipeline is computationally expensive. Generating a single qualified problem requires multiple iterations, averaging between 1.56 and 6.55 failures per success, with some difficult cases exceeding 10 iterations.
  • Small Scale: Due to these computational constraints, the evaluation was limited to a relatively small sample of 100 seed problems.
  • Downstream Training Value Unverified: While the framework successfully generates harder problems, the authors have not yet fine-tuned an LLM on this synthesized data to verify if it directly translates to an increase in a model's baseline mathematical capability. Testing this downstream training value remains a key direction for future work.

Summary updated

BibTeX
@misc{guo2026code,
  author = {Dadi Guo and Yuejin Xie and Qingyu Liu and Weixian Huang and Jiayu Liu and Zhiyuan Fan and Qihan Ren and Shuai Shao and Tianyi Zhou and Jianjie Feng and Wenze Su and Yujiu Yang and Dongrui Liu and Yi R. Fung},
  title = {{Code2Math: Can Your Code Agent Effectively Evolve Math Problems Through Exploration?}},
  year = {2026},
  eprint = {2603.03202},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2603.03202},
}
Figure