Rational trace check
rational-trace-check · version 1.0.0 · Numbers & math · free, no key needed
Check a step-by-step rational calculation trace; reports the first step whose operand, operator or result disagrees.
Use when you need to: verify a step by step fraction calculation · check a calculation trace with fractions · find the first wrong step in my arithmetic.
Decide before calling
Read the versioned contract and the supported scope below. Reuse rational-trace-check@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.
Explain the choice
"I can use rational-trace-check@1.0.0 for verify a step by step fraction calculation. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."
Supported
- verify a step by step fraction calculation
- check a calculation trace with fractions
- find the first wrong step in my arithmetic
- validate each step of an exact rational computation
- audit a multi-step fraction derivation
- check intermediate results of a rational calculation
- בדיקת שלבי חישוב עם שברים
Not supported
- exponentiation, roots or functions in a step
- steps with more than two operands
- floating-point or approximate results
- reordering or repairing the trace
Behavior
- Reference: ISO/IEC 10967-2:2001 (LIA-2) exact-result terminology; exact arithmetic over the rationals with canonical reduced form; RFC 8259 sec. 6 integer grammar and sec. 7 strings.
- inputs maps names to rational strings; steps are {id, operator (+ - * /), left, right, result}; an operand is {value, from} where from is null (literal) or the name of an input or an EARLIER step. Names match ^[A-Za-z_][A-Za-z0-9_]{0,63}$ and share one namespace (repeats are invalid_input); "__proto__" is an ordinary name.
- All values are rational strings -?(0|[1-9][0-9]*)(/[1-9][0-9]*)?, never JSON numbers, compared exactly by value. require_canonical (required): true also demands canonical form for every stated value.
- Per step, in order: left then right operand (unknown_reference, operand_mismatch, not_canonical), division_by_zero, result (operator_mismatch when another operator, tried as + - * /, yields the stated result; else result_mismatch), result not_canonical. After all steps: final_result_mismatch, then claimed_result not_canonical.
- The first discrepancy stops the check: step_index, step_id, field, stated, actual, reference and matching_operator describe it. steps_checked counts verified steps; final_value is the canonical last result when every step verified.
- Limits: 256 inputs, 1024 steps (counts checked before contents), 500 digits per stated value or exact step result; over a limit is limit_exceeded.
Input
inputs(object, required)steps(array of object, required): min items 1; max items 1024claimed_result(string, required): pattern^-?(0|[1-9][0-9]*)(/[1-9][0-9]*)?$require_canonical(boolean, required)
Output
valid(boolean, required)reason(one of null, "unknown_reference", "operand_mismatch", "division_by_zero", "operator_mismatch", "result_mismatch", "not_canonical", "final_result_mismatch", required)steps_checked(integer, required): min 0final_value(string or null, required)first_discrepancy(object or null, required)reference_version(constant "ISO/IEC 10967-2:2001 (LIA-2) exact-result terminology; exact arithmetic over the rationals with canonical reduced form; RFC 8259 sec. 6 integer grammar and sec. 7 strings", required)
Limits
- max steps: 1024
- max inputs: 256
- max value digits: 500
Example
Request input:
{
"inputs": {},
"steps": [
{
"id": "s1",
"operator": "+",
"left": {
"value": "1",
"from": null
},
"right": {
"value": "1/2",
"from": null
},
"result": "3/2"
},
{
"id": "s2",
"operator": "+",
"left": {
"value": "3/2",
"from": "s1"
},
"right": {
"value": "1/3",
"from": null
},
"result": "11/6"
}
],
"claimed_result": "11/6",
"require_canonical": true
}
Response:
{
"result": {
"valid": true,
"reason": null,
"steps_checked": 2,
"final_value": "11/6",
"first_discrepancy": null,
"reference_version": "ISO/IEC 10967-2:2001 (LIA-2) exact-result terminology; exact arithmetic over the rationals with canonical reduced form; RFC 8259 sec. 6 integer grammar and sec. 7 strings"
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "rational-trace-check",
"version": "1.0.0",
"input": {
"inputs": {},
"steps": [
{
"id": "s1",
"operator": "+",
"left": {
"value": "1",
"from": null
},
"right": {
"value": "1/2",
"from": null
},
"result": "3/2"
},
{
"id": "s2",
"operator": "+",
"left": {
"value": "3/2",
"from": "s1"
},
"right": {
"value": "1/3",
"from": null
},
"result": "11/6"
}
],
"claimed_result": "11/6",
"require_canonical": true
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/rational-trace-check/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"inputs":{},"steps":[{"id":"s1","operator":"+","left":{"value":"1","from":null},"right":{"value":"1/2","from":null},"result":"3/2"},{"id":"s2","operator":"+","left":{"value":"3/2","from":"s1"},"right":{"value":"1/3","from":null},"result":"11/6"}],"claimed_result":"11/6","require_canonical":true}'
The machine-readable contract is at /v1/tools/rational-trace-check/versions/1.0.0.
CLI
node cli.mjs run rational-trace-check 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Polynomial identity check: Check a polynomial identity over exact rationals by expanding both sides; report the lowest disagreeing coefficient.
- Rational expression check: Check a claimed exact rational value of an integer/fraction expression; reports the true value and the difference.
- Chi square decomposition check: Check a claimed Pearson chi-square, its per-cell (O-E)^2/E terms and df exactly; returns the first wrong term.
- Rational equation check: Check a chained claim like 1/2 + 1/3 = 5/6 < 1 exactly; returns the first false relation or division by zero.
- Contingency expected check: Check claimed expected counts (row total x column total / N) of a count table exactly; returns the first wrong cell.
- Contingency margins check: Check claimed row, column and grand totals of a count table exactly; returns the first wrong total.