Constraint-First Reasoning: A Training-Free Protocol for Exploiting Answer-Space Constraints in Mathematical Problem Solving
TL;DR Highlight
Extracting answer constraints before solving lifted DeepSeek-V4-Pro AIME/CMIMC average by 8.5 points over direct CoT.
Who Should Read
Developers whose LLM keeps missing answer-format details like modular reduction or integer form in math and calculation tasks.
Core Mechanics
- Most fixes were format slips
- 80% of fixed errors were cases where the model reached the right value but broke the answer format.
- Forgotten mod reduction was 30%, non-integer answers 20%, wrong p+q encoding 17%.
- Two stages: constraints first, then solve
- Stage 1 extracts constraints (integrality, remainder, range, answer format) as JSON without solving.
- Stage 2 solves while checking each major step against that JSON.
- A regex router limits it to relevant problems
- Cues like 'remainder', 'how many', 'relatively prime' trigger Stage 2.
- The router uses zero model tokens; without cues the problem goes to plain CoT.
- Weak models can be hurt
- JustRL-1.5B had only 73.9% constraint validity and gained just +2.9 points.
- It also had 6 AIME problems where CFR turned a right answer wrong.
- Not free: token cost rises
Evidence
- Average AIME/CMIMC gains
- DeepSeek-V4-Pro went from 70.8% to 79.2%, +8.5 points over direct CoT.
- Qwen3.5-9B went from 56.1% to 63.3%, +7.2 points.
- Qwen3.5-35B-A3B gained +3.0 and JustRL-1.5B +2.9 points.
- Matched prompting baselines
- On DeepSeek-V4-Pro AIME24: Routed-CFR 95.8%, Plan-and-Solve 90.0%, Self-Refine 89.2%, direct CoT 90.8%.
- On AIME25: Routed-CFR 91.7% vs direct CoT 80.8%.
- Routing effect and cost
- BRUMO25 token multiplier was 1.58x routed vs 1.71x always-on.
- CMIMC25 accuracy: routed 36.9%, always-on 34.2%, direct CoT 28.1%.
- OlympiadBench and paired stats
- OlympiadBench: Routed-CFR 91.14% vs direct CoT 90.66% (+0.48 points), routing rate 61.87%.
- Pooled AIME24-26 gain on DeepSeek-V4-Pro was +8.3 points, Holm-corrected p=0.00034.
How to Apply
- Add a constraints-first step to a math or calculation prompt
- Pick one calculation prompt you use today and split it into the two stages in the code below.
- Compare answer-format error counts against solving directly.
- Use a regex router to pick targets
- Run Stage 2 only on questions with cues like 'remainder', 'how many', 'divisible by', 'coprime'.
- Let everything else go single-pass to save tokens.
- Handle Stage 1 JSON parse failures
- On a JSON parse failure, recover fields with regex.
- If fewer than 2 fields are recovered, fall back to plain CoT without constraints.
- Check constraint validity before using a small model
- Before using a small model, read 20-30 extracted constraints and count the wrong ones.
- Skip CFR if the validity is low.
Try It
# Paste into Claude or ChatGPT (simplified version of the paper's CFR Stage 1 prompt, run in two turns)
[Stage 1] You are a mathematical constraint analyst. Do not solve the problem. Extract only constraints the final answer must satisfy, ones that can catch wrong answers or wrong answer formats. Cross-check constraints against each other to narrow the feasible range. Types: domain (integer, positive, range), modular (remainder, divisibility), parity, bound, structure, format (encodings like p+q). Return JSON: {problem_summary, raw_constraints[], propagated_constraints[], likely_answer_range, answer_format, critical_constraints[]}
Problem: {{problem}}
[Stage 2] (continue after getting the Stage 1 JSON) Solve the problem below. The final answer must satisfy the constraints. After each major step, check consistency against the constraints; if violated, stop and re-examine. Before the final answer, confirm all constraints pass.
Problem: {{problem}}
Constraints: {{Stage 1 JSON}}
# Next: solve the same problem in one shot without constraints and compare the answer-format errors.Terminology
Related Papers
AI is a tool and using it well takes skill
A rebuttal to Hickey: LLMs are tools, and skill in directing and checking them decides the outcome
Reflective Prompt Optimization of a Deep-Research Agent: A Topic-Disjoint, Multi-Seed Protocol for Measuring Transferable Gains and Prompt-Level Overfitting
Reflective prompt optimization raised held-out citation reward from 0.702 to 0.781 on a deep-research agent.
GPT‑6 and Intelligent UI for everyone
GPT-6 reportedly adds generated UI to chat; with no article text, only comment reactions are available.
Base Models Can Reason By Taking a Cue From Training Data
Prefilling just two opening tokens lifted Olmo-3-7B's MATH-500 accuracy from 42% to 78%.
Labels Override Definitions in Jev-Style Typed Decision Models
Renaming options to A/B raised routing accuracy by +0.1511 over meaningful labels.
How Much Prompt Is Enough? A Blackbox Minimization of Few-Shots in LLMs
Delta debugging trimmed few-shot prompts by 65.3% on average with unchanged propositional output
Original Abstract (Expand)
Large language models can derive a plausible mathematical object yet still violate explicit requirements--for example, by omitting a modular reduction, returning a non-integer, or using the wrong encoded answer form. We introduce Constraint-First Reasoning (CFR), a training-free two-stage prompting protocol: Stage 1 extracts and summarizes constraints entailed by the problem, and Stage 2 solves while checking intermediate and final results against that summary. Routed-CFR activates the two-stage protocol only when a text-only regex router detects restrictive cues; otherwise it uses direct chain-of-thought (CoT). Across AIME, CMIMC, BRUMO, and AIMO_AMC, the method improves direct CoT on multiple backbones. We further report convention-controlled routing experiments, matched prompting baselines, problem-level paired tests, decoding robustness, constraint-quality audits, total-token accounting, and an OlympiadBench evaluation. These analyses position CFR as a targeted test-time intervention whose benefit depends on recoverable constraints and reliable Stage 1 extraction, rather than as a general-purpose replacement for mathematical reasoning.