The goal of this skill is to fully automatically synthesize new mathematical contest problems at the IMO difficulty level, with quality sufficient for training LLMs or even human contestants. This project integrates ideas from several papers and incorporates some novel elements.
The underlying idea is to let an LLM iterate repeatedly over the problems, crafting problems that exceed its own ability to solve.
Please note: Although the final generated problems are checked by the LLM, errors are still possible. In addition, genuinely high-quality problems must be selected from the generated ones. (gacha / card-pulling)
Combining ideas from multiple sources may be better than applying a single one. This skill and the existing literature in this field are essentially prompt engineering.
More suited to semi-automatic, purpose-driven problem generation, or to assisting problem generation.
Copy the agents subfolder and the SKILL.md file from this folder to ~/.dsh/skills/imo-problem-generator. Type /imo-problem-generator in the chat bar to start working.
-
For fully automatic problem generation, provide two original problems and their solutions when you start using the skill, beginning from step 1.
-
You may also provide only ideas and let the orchestrating main agent generate the problems first, then start from step 2.
-
You may also tell the main agent to use only the functionality of a single sub-agent or multiple sub-agents to optimize existing problems.
Additional requirements can be, for example: no web search, no code tools, ...
First, place a CSV file containing the original problems of your choice, with the following columns: 序号,编号,题面,解法一,解法二,解法三,英文题面,备注.
Open config.json with a text editor and replace its contents with your own AI API information, referring to config.example.json. Also fill in: "sample_pairs": { "N": number of rows in the CSV file, "K": target number of problems to generate }.
Open a command line in the project folder (Git Bash on Windows, "Terminal" on Mac / Linux) and type:
bash run.shchmod 777 archive_outputs.sh
./archive_outputs.shYou can use the typesetting tool to typeset any CSV file. The CSV file should contain a column named "problem" and a column named "answer" or "solution".
Generate a Markdown file:
python csv_to_md.py rephrase_output/rephrase_summary.csv result.mdGenerate a PDF:
python render_pdf.py rephrase_output/rephrase_summary.csv paper.pdfThe following dependencies are required:
xelatex(TeX Live / MacTeX full suite), ortectonic(self-contained single file, recommended)- Detection order:
xelatexin PATH →tectonicin PATH →~/.local/bin/tectonic ⚠️ tectonic requires internet: on the first compile of a macro package it downloads the TeX Live packages on demand from its CDN (cached in~/.cache/tectonic; subsequent compiles are fast and mostly offline)
The following fonts are required, corresponding to the two \setmainfont / \setCJKmainfont lines in the tex template:
| Purpose | Files | Corresponding entry in tex |
|---|---|---|
| Latin text (Times New Roman, 4 weights) | times.ttf (Regular), timesbd.ttf (Bold), timesbi.ttf (Bold Italic), timesi.ttf (Italic) |
\setmainfont{Times New Roman} + mathptmx math font |
| Chinese Song typeface | simsun.ttc (SimSun/宋体), or NotoSerifCJKsc-Regular/Bold.otf (Source Han Serif) as fallback |
\setCJKmainfont[AutoFakeBold=3]{SimSun} |
The CJK font selection logic (_resolve_cjk_font()):
- If the environment variable
CJK_FONTis set → force it (can be temporarily overridden, e.g.,CJK_FONT="Noto Serif CJK SC"); - If
SimSun/宋体/NSimSunappears infc-list→ use SimSun; - Otherwise → fall back to
Noto Serif CJK SC.
AutoFakeBold=3 is for fonts like SimSun that have no bold weight, so that a fake bold can be synthesized (problem-number bolding relies on this).
-
Reverse Combine (MathFusion, CogAtom)
-
Fix Redundancy
-
Enhance (SAND-Math, ReverseMath)
-
Strengthen
-
Rephrase (Idea similar to Towards Robust Mathematical Reasoning)
-
Self-grade and refine
Note: Steps such as Enhance, Strengthen, and Rephrase are optional — "as much or as little as you prefer" (丰俭由人). The intermediate results of each step are also saved in the folders; it is possible that the intermediate results yield higher-quality problems.
Modifying prompts: You can add specific constraint (e.g."Output a yes/no problem". "Output a problem that queries the minimum") by changing files in the prompts folder. prompts_en is the English translation of prompts.
Choosing a model: it is recommended to use gemini-3.5-flash in the first step and deepseek-v4-flash-0731 afterwards. Enable thinking mode for both. You can refer to config.example.json.
Placing the CSV file (the method without the skill): collect some existing mathematical contest problems and first divide them into four categories: algebra, geometry, number theory, combinatorics. The algebra category is divided into 3 subcategories: inequalities, functional equations, others. The combinatorics category is divided into 5 subcategories: grids/tables, graph theory, sets, combinatorial geometry, others. Geometry and number theory each count as 1 subcategory. To make the generated problems more meaningful, it is recommended that all problems in the CSV file come from a single subcategory. This step can be done with the help of an LLM for filtering.
This work combines ideas from the following literature (mainly borrowing their problem-generation approaches):
| # | Problem-generation approach (borrowed idea) | Reference | Venue |
|---|---|---|---|
| 1 | Generation from scratch + filtering funnel + Difficulty Hiking | SAND-Math(arXiv 2507.20527) | NeurIPS 2025 |
| 2 | Concept-explanation pairs to generate from scratch + RL to increase difficulty | MathSmith(arXiv 2508.05592) | AAAI 2026 |
| 3 | Concept + proposition rationale generation | PromptCoT(arXiv 2503.02324) | ACL 2025 Findings |
| 4 | Weakness-driven: concept extraction and recombination | SwS(OpenReview 0jQUNQsZra) | NeurIPS 2025 |
| 5 | Hypothesis-driven error analysis generation | arXiv 2604.04386 | ICLR 2026 |
| 6 | Fusing two problem statements into a new problem | MathFusion(arXiv 2503.16212) | ACL 2025 |
| 7 | Cognitive atom extraction → random-walk recombination | CogAtom(arXiv 2509.17318) | EMNLP 2025 Findings |
| 8 | Solution back-translation | MathGenie(arXiv 2402.16352) | ACL 2024 |
| 9 | Answer inversion | ReverseMath(arXiv 2605.27709) | arXiv preprint |
| 10 | Reverse chain-of-thought generation for geometry problems | TR-CoT(arXiv 2410.17885) | arXiv preprint |
| 11 | Code agent exploration to evolve hard problems | Code2Math(arXiv 2603.03202) | arXiv preprint |
| 12 | Setter-solver-verifier three-party self-play | VHG(arXiv 2605.06660) | arXiv preprint |
| 13 | Multi-agent collaborative iterative refinement | arXiv 2511.03958 | EDM 2025 |
| 14 | Multi-agent verification and refinement of personalized problems | arXiv 2604.05160 | AIED 2026 |
| 15 | Guided tree search for discovering geometry theorems | Tong Geometry(通几何, Nature s42256-025-01164-x) | Nature Machine Intelligence |
| 16 | Multi-dimensional enhancement of seed problems | UniCode(arXiv 2510.17868) | ICLR 2026 (rejected submission) |
| 17 | Benchmark synthesis from proofs | Proof2Hybrid(arXiv 2508.02208) | arXiv preprint |
| 18 | Two-stage validity generation | SV2MPG(OpenReview fDhY9Cf8NI) | OpenReview submission |
| 19 | Template generation / rewriting | MetaMath(arXiv 2309.12284) | ICLR 2024 Spotlight |
The code and the prompts, except for the file listed below, are licensed under the MIT License (see LICENSE). The problem data is sourced from public mathematical contest materials and is provided for learning and research purposes only.
Exception (RAIL-MSD): The 候选知识点清单.md of the enhance_agent is copied from SAND-Math(arXiv:2507.20527,AMD) and is used under the Open RAIL-MSD license (including the usage restrictions of the AMD Responsible AI Use Policy). Its redistribution must retain the license notice at the top of the file and comply with the RAIL-MSD terms. All other prompts are original.