{"id":"rational-trace-check","version":"1.0.0","description":"Check a step-by-step rational calculation trace; reports the first step whose operand, operator or result disagrees.","supported_operations":["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","בדיקת שלבי חישוב עם שברים"],"unsupported_operations":["exponentiation, roots or functions in a step","steps with more than two operands","floating-point or approximate results","reordering or repairing the trace"],"semantics":["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."],"limits":{"max_steps":1024,"max_inputs":256,"max_value_digits":500},"pricing":{"status":"unpriced","charge_usd":null},"input_schema":{"type":"object","additionalProperties":false,"required":["inputs","steps","claimed_result","require_canonical"],"properties":{"inputs":{"type":"object","maxProperties":256,"additionalProperties":{"type":"string","pattern":"^-?(0|[1-9][0-9]*)(/[1-9][0-9]*)?$"}},"steps":{"type":"array","minItems":1,"maxItems":1024,"items":{"type":"object","additionalProperties":false,"required":["id","operator","left","right","result"],"properties":{"id":{"type":"string","pattern":"^[A-Za-z_][A-Za-z0-9_]{0,63}$"},"operator":{"type":"string","enum":["+","-","*","/"]},"left":{"type":"object","additionalProperties":false,"required":["value","from"],"properties":{"value":{"type":"string","pattern":"^-?(0|[1-9][0-9]*)(/[1-9][0-9]*)?$"},"from":{"type":["string","null"],"pattern":"^[A-Za-z_][A-Za-z0-9_]{0,63}$"}}},"right":{"type":"object","additionalProperties":false,"required":["value","from"],"properties":{"value":{"type":"string","pattern":"^-?(0|[1-9][0-9]*)(/[1-9][0-9]*)?$"},"from":{"type":["string","null"],"pattern":"^[A-Za-z_][A-Za-z0-9_]{0,63}$"}}},"result":{"type":"string","pattern":"^-?(0|[1-9][0-9]*)(/[1-9][0-9]*)?$"}}}},"claimed_result":{"type":"string","pattern":"^-?(0|[1-9][0-9]*)(/[1-9][0-9]*)?$"},"require_canonical":{"type":"boolean"}}},"output_schema":{"type":"object","additionalProperties":false,"required":["valid","reason","steps_checked","final_value","first_discrepancy","reference_version"],"properties":{"valid":{"type":"boolean"},"reason":{"type":["string","null"],"enum":[null,"unknown_reference","operand_mismatch","division_by_zero","operator_mismatch","result_mismatch","not_canonical","final_result_mismatch"]},"steps_checked":{"type":"integer","minimum":0},"final_value":{"type":["string","null"]},"first_discrepancy":{"type":["object","null"],"additionalProperties":false,"required":["step_index","step_id","field","stated","actual","reference","matching_operator"],"properties":{"step_index":{"type":["integer","null"],"minimum":0},"step_id":{"type":["string","null"]},"field":{"type":"string","enum":["left","right","operator","result","claimed_result"]},"stated":{"type":["string","null"]},"actual":{"type":["string","null"]},"reference":{"type":["string","null"]},"matching_operator":{"type":["string","null"],"enum":[null,"+","-","*","/"]}}},"reference_version":{"type":"string","const":"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"}}},"examples":[{"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},"output":{"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"}},{"input":{"inputs":{"price":"7/2"},"steps":[{"id":"total","operator":"-","left":{"value":"7/2","from":"price"},"right":{"value":"1/2","from":null},"result":"4"}],"claimed_result":"4","require_canonical":true},"output":{"valid":false,"reason":"operator_mismatch","steps_checked":0,"final_value":null,"first_discrepancy":{"step_index":0,"step_id":"total","field":"operator","stated":"4","actual":"3","reference":null,"matching_operator":"+"},"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"}}],"execute_url":"/v1/tools/rational-trace-check/versions/1.0.0/execute"}