Layer 1: SymPy (Symbolic Algebra)
When: Exact algebraic computation - solving, calculus, simplification, matrix algebra.
Key Commands:
```bash
# Solve equation
uv run python -m runtime.harness scripts/sympy_compute.py \
solve "x*2 - 5x + 6 = 0" --var x --domain real
# Integrate
uv run python -m runtime.harness scripts/sympy_compute.py \
integrate "sin(x)" --var x
# Definite integral
uv run python -m runtime.harness scripts/sympy_compute.py \
integrate "x**2" --var x --bounds 0 1
# Differentiate (2nd order)
uv run python -m runtime.harness scripts/sympy_compute.py \
diff "x**3" --var x --order 2
# Simplify (trig strategy)
uv run python -m runtime.harness scripts/sympy_compute.py \
simplify "sin(x)2 + cos(x)2" --strategy trig
# Limit
uv run python -m runtime.harness scripts/sympy_compute.py \
limit "sin(x)/x" --var x --to 0
# Matrix eigenvalues
uv run python -m runtime.harness scripts/sympy_compute.py \
eigenvalues "[[1,2],[3,4]]"
```
Best For: Closed-form solutions, calculus, exact algebra.
Layer 2: Z3 (Constraint Solving & Theorem Proving)
When: Proving theorems, checking satisfiability, constraint optimization.
Key Commands:
```bash
# Prove commutativity
uv run python -m runtime.harness scripts/cc_math/z3_solve.py \
prove "x + y == y + x" --vars x y --type int
# Check satisfiability
uv run python -m runtime.harness scripts/cc_math/z3_solve.py \
sat "x > 0, x < 10, x*x == 49" --type int
# Optimize
uv run python -m runtime.harness scripts/cc_math/z3_solve.py \
optimize "x + y" --constraints "x >= 0, y >= 0, x + y <= 100" \
--direction maximize --type real
```
Best For: Logical proofs, constraint satisfaction, optimization with constraints.
Layer 3: Math Scratchpad (Reasoning Verification)
When: Verifying step-by-step reasoning, checking derivation chains.
Key Commands:
```bash
# Verify single step
uv run python -m runtime.harness scripts/cc_math/math_scratchpad.py \
verify "x = 2 implies x^2 = 4"
# Verify with context
uv run python -m runtime.harness scripts/cc_math/math_scratchpad.py \
verify "x^2 = 4" --context '{"x": 2}'
# Verify chain of reasoning
uv run python -m runtime.harness scripts/cc_math/math_scratchpad.py \
chain --steps '["x^2 - 4 = 0", "(x-2)(x+2) = 0", "x = 2 or x = -2"]'
# Explain a step
uv run python -m runtime.harness scripts/cc_math/math_scratchpad.py \
explain "d/dx(x^3) = 3*x^2"
```
Best For: Checking your work, validating derivations, step-by-step verification.
Layer 4: Math Tutor (Educational)
When: Learning, getting hints, generating practice problems.
Key Commands:
```bash
# Step-by-step solution
uv run python scripts/cc_math/math_tutor.py steps "x*2 - 5x + 6 = 0" --operation solve
# Progressive hint (level 1-5)
uv run python scripts/cc_math/math_tutor.py hint "Solve x**2 - 4 = 0" --level 2
# Generate practice problem
uv run python scripts/cc_math/math_tutor.py generate --topic algebra --difficulty 2
```
Best For: Learning, tutoring, practice.
Layer 5: Lean 4 (Formal Proofs)
When: Rigorous machine-verified mathematical proofs, category theory, type theory.
Access: Use /lean4 skill for full documentation.
Best For: Publication-grade proofs, dependent types, category theory.