| name | math-logic-reasoning |
| description | Activate this skill for any problem requiring rigorous mathematical reasoning, formal logical deduction, or structured constraint solving. This includes competition math (algebra, number theory, combinatorics, geometry, AIME/AMC-style), olympiad problems, proof-based questions, multi-step word problems, logic grid puzzles, constraint satisfaction problems (who-owns-the-zebra style), syllogistic reasoning, and any problem where systematic step-by-step deduction is required to reach a provably correct answer. Trigger this skill whenever the user presents a math problem, asks the agent to solve a puzzle, poses a logic riddle, or requests formal reasoning — even if framed casually. When in doubt, use this skill. Precision and correctness matter more than speed. |
Math and Logic Reasoning Skill
This skill governs how the agent approaches problems that demand exact, verifiable answers through structured reasoning. It applies to two broad problem families — mathematical reasoning and logical deduction — with shared principles and specialized techniques for each.
Core Principles (Apply to Everything)
1. Never Skip Steps in Your Head
The most common source of error is "obvious" steps that aren't verified. Write out every nontrivial manipulation. A step that takes 2 seconds to write saves minutes of backtracking.
2. State What You're Solving Before You Solve It
Before any computation, articulate:
- What is the unknown? What form should the answer take?
- What are the constraints or given conditions?
- What counts as a valid solution?
This prevents solving the wrong problem.
3. Maintain a Clean Separation Between Work and Conclusion
Your scratch work can be messy. Your final answer should be clearly stated, with the key logical chain summarized. Never bury the answer in the middle of working.
4. Verify Before Finalizing
Every answer should pass at least one check:
- For math: substitute back, check edge cases, sanity-check the magnitude
- For logic: verify your assignment satisfies all constraints, not just the ones you used
5. If Stuck, Change Representation
Stuckness usually means the current representation is wrong. Try: different variable naming, a diagram, a small concrete case, the contrapositive, casework, symmetry arguments, or modular arithmetic.
Part I: Mathematical Reasoning
Problem Intake
Before computing anything, ask:
- What type is this? (algebra, number theory, combinatorics, geometry, calculus, probability)
- What is the answer format? (integer, fraction, expression, "find all X such that...")
- Are there hidden constraints? (integer solutions only? positive reals? non-degenerate triangles?)
Read the problem twice. Misreading is the #1 cause of wasted effort.
Execution Framework
Phase 1 — Setup
- Define variables clearly. Use conventional notation for the domain.
- Write out all given conditions as equations/inequalities.
- Note what you need to find.
Phase 2 — Strategy Selection
Choose your approach before executing. Common strategies:
| Situation | Strategy |
|---|
| System of equations | Substitution, elimination, or matrix methods |
| Divisibility / modular | Factor, use mod arithmetic, check small cases |
| Counting | Bijection, complementary counting, inclusion-exclusion |
| Geometric | Coordinate geometry, similarity, area ratios, trigonometry |
| Optimization | AM-GM, Cauchy-Schwarz, calculus (if allowed), Lagrange multipliers |
| Recursion / sequences | Find closed form, characteristic equation, generating functions |
| Existence / construction | Explicit construction OR pigeonhole / probabilistic |
Phase 3 — Execution
- Work symbolically as long as possible before substituting numbers.
- At each step, ask: does this simplify? does a factor cancel?
- Flag any step where you divide (check divisor ≠ 0) or square (check sign).
Phase 4 — Verification
- Substitute your answer back into the original equations.
- Check boundary/edge cases.
- Sanity check: is the magnitude reasonable? Does it have the right sign/parity?
- For competition problems with integer answers: double-check arithmetic on the final computation.
Number Theory Heuristics
- Try small cases first — patterns often emerge for n=1,2,3,4.
- Mod 2, mod 3, mod 9, mod 10 are your first tools for divisibility.
- For Diophantine equations: parametrize solutions, check if infinite families exist.
- GCD/LCM: remember gcd(a,b)·lcm(a,b) = a·b for positive integers.
Combinatorics Heuristics
- Always ask: are objects distinguishable? Is order relevant?
- Complementary counting is often cleaner than direct counting.
- If a formula seems off by a factor of 2 or k!, you probably over/under-counted permutations.
- Recursion: define f(n) clearly, find base cases, verify your recurrence on small n.
Algebra / Polynomials
- Factor before expanding whenever possible.
- Vieta's formulas: if you know roots, you know symmetric functions of roots.
- For inequalities: identify equality conditions first — they often suggest substitutions.
Geometry
- Draw a labeled diagram. Geometry done without a diagram is almost always wrong.
- Mark what's given, what's equal, what's perpendicular.
- Coordinates work well for "find length/area" problems; synthetic is cleaner for "prove."
- Similar triangles: identify them by angle-angle, then set up ratios carefully.
Part II: Logical Deduction
This covers constraint satisfaction, logic grid puzzles, syllogistic chains, and any problem where you must derive what must be true given a set of rules.
The Golden Rule of Logic Puzzles
Never guess. Never assume. Only record what is forced by the constraints.
If you can't prove something is true, it isn't known yet.
Constraint Setup
-
Inventory: List all entities, attributes, and possible values.
- e.g., People: {Alice, Bob, Carol}; Pets: {cat, dog, fish}; Houses: {red, blue, green}
-
Build an elimination grid for each (attribute × entity) pair. Start with all values possible.
-
Translate each clue into one or more constraint statements:
- "A is to the left of B" → pos(A) < pos(B)
- "A and B are neighbors" → |pos(A) - pos(B)| = 1
- "A has the cat" → pet(A) = cat, which implies pet(B) ≠ cat, pet(C) ≠ cat
- "The cat owner drinks milk" → pet(X) = cat ↔ drink(X) = milk
Deduction Loop
Repeat until no new inferences can be drawn:
-
Direct assignment: If only one value remains possible for a cell, assign it and propagate (eliminate that value from all other cells in the same row/column).
-
Forced by elimination: If a value can only go in one cell in a group, assign it there.
-
Linked constraints: Combine two clues to produce a new one.
- "A is left of B" + "B is left of C" → A is left of C
-
Positional arithmetic: For ordered arrangements, use inequalities and count remaining slots.
-
Case analysis (last resort): If stuck, branch on the most constrained unknown. Mark it clearly, follow to contradiction or resolution, then try the other branch.
Common Errors to Avoid
| Error | Prevention |
|---|
| Assuming a clue implies its converse | Only conclude what the clue directly states |
| Forgetting a constraint exists | After each deduction, re-check all clues for new implications |
| Conflating "neighbor" with "immediately left/right" | Re-read the problem's definition |
| Assigning before confirming uniqueness | Count remaining options before assigning |
Verification
Once a complete assignment is found:
- Go through every single clue and verify the assignment satisfies it.
- Note which clue each verification covers — if any clue is never checked, you might have missed it.
Part III: Presenting Solutions
For Math Problems
[Brief restatement of what's being solved]
**Setup:**
[Define variables, state given conditions]
**Solution:**
[Step-by-step work with clear transitions]
**Answer: [X]**
**Verification:**
[Substitute back or check the answer]
For Logic Puzzles
[List of entities and attributes]
**Deduction trace:**
[Numbered steps, each citing the clue used]
Step 1: From clue 3, ...
Step 2: Since step 1 forces ..., combined with clue 7, ...
**Solution:**
[Final assignment table]
**Verification:**
[Every clue checked: ✓ Clue 1: ..., ✓ Clue 2: ...]
When to Use the Reference Files
- See
references/competition-techniques.md for deeper treatment of specific math techniques (generating functions, modular inverses, projective geometry, etc.)
- See
references/logic-patterns.md for a catalog of common constraint types and their propagation rules
Meta-Note on Difficulty
Hard problems (AIME #13-15, multi-constraint logic grids) often require:
- Insight, not just procedure: a clever substitution, a symmetry argument, or a reframe of the problem
- Patience: the solution may require 5+ deduction steps before progress becomes visible
- Willingness to restart: if you've been solving for a while and the answer looks messy, consider whether you chose the right approach at the outset
Elegance is a signal of correctness. If the answer is ugly, look for a cleaner path.