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

This paper introduces a multi-agent framework that leverages code execution to autonomously evolve existing mathematical problems into structurally distinct, more challenging, and solvable variations, offering a scalable solution to the scarcity of high-quality training data for advanced mathematical reasoning.

Dadi Guo, Yuejin Xie, Qingyu Liu, Jiayu Liu, Zhiyuan Fan, Qihan Ren, Shuai Shao, Tianyi Zhou, Dongrui Liu, Yi R. Fung

Published 2026-03-05
📖 5 min read🧠 Deep dive

Imagine you are a master chef trying to train a new generation of young cooks (the AI models) to become world-class culinary artists. You have a huge library of recipes (math problems), but most of them are simple: "How to boil an egg" or "How to make toast." To train a chef to win a Michelin star, you need recipes that are incredibly complex, requiring deep intuition, creativity, and years of practice.

The problem? Writing these super-hard recipes by hand is slow, expensive, and requires a genius chef to do it.

Enter "Code2Math": The AI Sous-Chef that invents its own challenges.

This paper introduces a system where an AI doesn't just solve math problems; it invents harder versions of them using a computer code "kitchen." Here's how it works, broken down into simple concepts:

1. The Three Chefs (The Multi-Agent System)

Instead of one AI trying to do everything, the researchers set up a team of three specialized "agents" (AI assistants) that work together like a high-end kitchen brigade:

  • The Innovator (Evolution Agent): This is the creative chef. It looks at a simple recipe (a "seed" problem) and says, "How can I make this harder?" It doesn't just add more ingredients; it changes the structure of the dish. It uses a computer (Python code) to test thousands of variations instantly. It asks, "If I change this number, does the dish still work? If I add this constraint, does it break the pattern?" It's like a chef trying to turn a simple soup into a complex, multi-layered soufflé that requires a secret technique to rise.
  • The Inspector (Solvability Agent): This is the strict health inspector. Before the new recipe goes to the students, the Inspector checks: "Is this dish actually edible? Did the chef make a mistake in the math? Is the solution logical?" If the recipe is broken or impossible, it gets thrown in the trash.
  • The Critic (Difficulty Agent): This is the food critic. They taste the new dish and ask, "Is this actually harder, or just annoying?" They make sure the new problem isn't just "boringly long" (like peeling 1,000 potatoes) but actually requires a brilliant "Aha!" moment to solve. They want the student to have to think deeply, not just grind through calculations.

2. The "Code Kitchen" (Exploration)

The secret sauce here is Code.
Usually, when an AI tries to invent a problem, it just guesses with words. But this system uses code execution as a playground.

  • Analogy: Imagine the Innovator Chef is trying to build a tower of blocks. Instead of just imagining it, they have a robot arm that can actually stack 1,000 different block configurations in a second to see which ones fall over and which ones stand tall.
  • The AI writes code to simulate millions of scenarios. It tests if a new math problem has a solution, finds the "hidden patterns," and ensures the difficulty is real. This turns the invention process from a "guessing game" into a "scientific experiment."

3. The Result: "Burden of Discovery"

The paper introduces a cool concept called the "Burden of Discovery."

  • Old Way: A hard problem might just have big numbers. (e.g., "Add these 500 numbers.")
  • New Way: A hard problem hides the key to the solution. It's like a treasure hunt where the map is torn up. The student has to find the hidden clue (the "Aha!" moment) before they can even start solving.
  • The AI agents are surprisingly good at this. They created problems that were so tricky that even the smartest AI solvers (like the current state-of-the-art models) got stuck. In fact, the AI could create problems that were harder than itself could solve! It's like a teacher creating a test that is harder than the teacher can take.

4. The Catch: It's Expensive

There is a trade-off. Because the AI has to try, fail, check, and retry so many times to make a perfect problem, it takes a lot of computing power.

  • Analogy: To find one perfect diamond, the AI has to dig through a mountain of dirt. For every one good problem it creates, it might "fail" or "reject" about 3 to 6 times. It's a slow, heavy process, but the result is high-quality gold.

Why Does This Matter?

Right now, AI models are getting really good at math, but they are hitting a wall because we run out of hard problems to train them on. We can't just ask humans to write more hard problems fast enough.

Code2Math shows that we can use AI to evolve its own curriculum. It's like giving the AI a gym where it can build its own weights. By letting the AI explore, fail, and refine its own challenges using code, we can generate an endless supply of high-quality, brain-teasing math problems to push the next generation of AI (and humans) to new heights.

In a nutshell: The paper proves that if you give an AI a computer to play with and a team of critics to keep it honest, it can invent its own "final boss" math problems, pushing the boundaries of what's possible in artificial intelligence.