Software Design Specification (SDS)
Defines the concrete instantiation of the Ciphered Reasoning Loop (CRL) pattern for algebraic simplification and mathematical reasoning, including schema definitions, invariant policies, and agent roles.
This specification implements ADR-014 (Ciphered Reasoning Loop) for the domain of algebraic simplification. The key insight is that most “LLM math errors” are really missing side-conditions (illegal cancellation, domain slips, extraneous roots) — not reasoning failures per se.
CRL-Math turns math agent correctness into invariant compliance, not model cleverness.
The CRL-Math system operates across four representation types:
| Rep | Name | Description |
|---|---|---|
| F | Formal AST | Typed expression AST + step list |
| G | Knowledge Graph | Nodes = expressions/steps/obligations, edges = “rewrites_to / requires” |
| N | Natural Language | Proof-carrying explanation (citations to StepIDs) |
| A | Agent Trace | Tool checks + hashes attached to steps |
1
2
3
4
5
6
7
{
"expr_id": "string",
"surface": "string",
"rep": "F | G | N | A",
"type": "string",
"assumptions": ["string"]
}
Example:
1
2
3
4
5
6
7
{
"expr_id": "E0",
"surface": "(sqrt(x^2 - 2x + 1)) / (x - 1)",
"rep": "F",
"type": "Real -> Real",
"assumptions": []
}
1
2
3
4
5
6
7
8
{
"step_id": "string",
"rule": "string",
"input_expr_ids": ["string"],
"output_expr_id": "string",
"obligations_added": ["string"],
"witness_ids": ["string"]
}
Rules Catalog (Algebra):
FACTOR_DIFF_SQUARESREWRITE_QUADRATIC_TO_SQUARESQRT_OF_SQUARE_REALABS_OVER_SELF_TO_SIGNCANCEL_FACTORDISTRIBUTECOMBINE_LIKE_TERMS1
2
3
4
5
6
{
"obl_id": "string",
"predicate": "string",
"origin_step_id": "string",
"status": "required | discharged | contradicted"
}
Obligation Generators (Unsafe Rules):
| Operation | Obligation Generated |
|---|---|
Cancel factor f(x) |
f(x) ≠ 0 |
Divide by f(x) |
f(x) ≠ 0 |
sqrt(f(x)) in reals |
f(x) ≥ 0 |
| Even power root | Handle ± or emit branch obligation |
log(f(x)) |
f(x) > 0 |
1
2
3
4
5
6
{
"wit_id": "string",
"kind": "CAS | AlgebraRule | RandomTest | ProofChecker",
"payload_hash": "string",
"note": "string"
}
These policies are the “cipher key” — enforceable rules the loop must satisfy.
Variables keep identity across steps. α-renaming allowed, capture not.
1
2
3
4
5
Policy "I2_DomainObligationsPreserved"
statement: >
If a Step applies a rule that may change definedness (divide/cancel/log/sqrt),
then it must emit an Obligation capturing the required side condition, and that
Obligation must be present in the final output conditions unless discharged.
1
2
3
4
Policy "I3_EquivalenceModeDeclared"
statement: >
Every simplification result must declare its EquivalenceMode. If Conditional,
the final output must include the accumulated Obligations as explicit conditions.
Equivalence Modes:
1
2
3
4
Policy "I3b_SqrtSquareRealIsAbs"
statement: >
Over real numbers, sqrt(u^2) rewrites to |u| (not u) unless an explicit condition
u >= 0 is added and preserved.
1
2
3
4
Policy "I4_WitnessedRewrites"
statement: >
Every Step must have at least one Witness, and rules that are commonly unsafe
(cancel/divide/branch) must have tool-backed Witness (CAS or randomized tests).
1
2
3
Policy "I5_NoOrphanNarrativeClaims"
statement: >
Every natural language claim must reference one or more Step IDs that justify it.
ExprAST/Step objectsFor each Step:
1
Goal: simplify (x^2 - 1)/(x - 1)
Create nodes for expressions, goal, current assumptions.
Planner suggests: “factor numerator, cancel (x-1)”.
Formalizer proposes:
x^2 - 1 = (x-1)(x+1) (rule: FACTOR_DIFF_SQUARES)(x-1)(x+1)/(x-1) = x+1 obligation: x-1 ≠ 0Verifier checks:
x≠1Explainer produces:
“Factor the numerator as (x−1)(x+1). For x≠1, cancel (x−1) to get x+1.” with citations:
[S1][S2]and explicit domain note.
Store steps, obligations, tool outputs, and hashes.
Problem: \(f(x) = \frac{\sqrt{x^2 - 2x + 1}}{x - 1}\)
This combines:
sqrt((·)^2))x-1)Correct CRL Steps:
| Step | Rule | Result | Obligation |
|---|---|---|---|
| S1 | REWRITE_QUADRATIC_TO_SQUARE | sqrt((x-1)^2) / (x-1) |
None |
| S2 | SQRT_OF_SQUARE_REAL | |x-1| / (x-1) |
None |
| S3 | ABS_OVER_SELF_TO_SIGN | piecewise(1 if x>1, -1 if x<1) |
O1: x ≠ 1 |
Final Result: \(f(x) = \begin{cases} 1 & x > 1 \\ -1 & x < 1 \end{cases} \quad \text{undefined at } x = 1\)
| Failure Mode | How CRL Prevents It |
|---|---|
| Hidden side-conditions | Every cancel/divide/sqrt generates tracked obligations |
| Narrative/proof mismatch | N must be generated from StepIDs; rhetoric can’t drift |
| Multi-agent contradiction | Agents disagree over proposed Steps, not conflicting text |
| Tool hallucination | Tool outputs are hashed and referenced; claims without witnesses rejected |
| Branch loss | I₃b forces sqrt(u²) → |u| |
To prevent agents chasing nonsense rewrites, define simplicity:
Important: Simplicity must not override invariants. A “simpler” form with obligations is acceptable — but obligations must be surfaced.
| SEA™ Component | Role in CRL-Math |
|---|---|
| Semantic Core | SBVR rules for obligation generation |
| Knowledge Graph | Step/Expression/Obligation nodes; provenance edges |
| CALM Validation | Policy enforcement (I₁–I₅) |
| Agent Config Service | Define Planner/Formalizer/Verifier/Explainer/Auditor roles |
| Artifact Engine | Generate proof-carrying explanations |
⏳ Post-MVP (specialized reasoning domain)