{"id":"unit-conversion-trace-check","version":"1.0.0","description":"Check a multi-step unit conversion trace with exact arithmetic; reports the first wrong step and its exact value","supported_operations":["check unit conversion steps","verify multi step unit conversion","find wrong step in unit conversion","check dimensional analysis trace","validate chained unit conversions","verify worked unit conversion","check show your work unit conversion"],"unsupported_operations":["a built-in unit catalog (every unit is defined by the caller)","steps that multiply by other quantities (only unit changes of one quantity)","floating-point tolerances (rounding must be declared per step)","logarithmic or irrational conversions"],"semantics":["units: caller-defined catalog {symbol, dimension (7 integers L, M, T, I, Theta, N, J), factor > 0, offset}, value_SI = value x factor + offset; numbers are exact strings (integer, decimal or p/q, at most 60 characters).","Order: start_unit terms known, then its affine rule; then each step in order: to_unit terms known (unknown_unit), affine rule (invalid_affine_composition), same dimension as the current unit (dimension_mismatch), value (value_mismatch with expected = the exact or rounded value, actual = the claim, both canonical).","Step value: v_B = (v x F(A) + O(A) - O(B)) / F(B) for quantity_kind \"absolute\" (O = offset of a sole affine term, which must have power 1), offsets ignored for \"interval\"; when round_places is not null the value is rounded to that many decimal places, half to even. The claim must equal it exactly; the next step starts from the claimed value, so a trace may round intermediates exactly as written.","steps_checked counts the steps that passed; final_value is the last claimed value in canonical exact form when every step passes, otherwise null.","Structural problems throw invalid_input; more than 200 units, 50 steps, 8 terms, |power| 6, 30 round places, 60-character numbers or a 4000-digit exact intermediate throws limit_exceeded.","Reference: JCGM 200:2012 (VIM) 1.24 and SI Brochure 9th ed. (2019) 2.3.4, 5.4; reference_version \"jcgm-200-2012-vim3-si-brochure-9e-2019\"."],"limits":{"max_units":200,"max_symbol_bytes":32,"max_terms":8,"max_abs_power":6,"max_number_chars":60,"max_exact_digits":4000,"max_steps":50,"max_round_places":30},"pricing":{"status":"unpriced","charge_usd":null},"input_schema":{"type":"object","additionalProperties":false,"required":["units","quantity_kind","start_value","start_unit","steps"],"properties":{"units":{"type":"array","minItems":1,"maxItems":200,"items":{"type":"object","additionalProperties":false,"required":["symbol","dimension","factor","offset"],"properties":{"symbol":{"type":"string","minLength":1,"maxLength":32},"dimension":{"type":"array","minItems":7,"maxItems":7,"items":{"type":"integer","minimum":-12,"maximum":12}},"factor":{"type":"string","minLength":1,"maxLength":60,"pattern":"^-?(0|[1-9][0-9]*)(\\.[0-9]+|/[1-9][0-9]*)?$"},"offset":{"type":"string","minLength":1,"maxLength":60,"pattern":"^-?(0|[1-9][0-9]*)(\\.[0-9]+|/[1-9][0-9]*)?$"}}}},"quantity_kind":{"type":"string","enum":["absolute","interval"]},"start_value":{"type":"string","minLength":1,"maxLength":60,"pattern":"^-?(0|[1-9][0-9]*)(\\.[0-9]+|/[1-9][0-9]*)?$"},"start_unit":{"type":"array","maxItems":8,"items":{"type":"object","additionalProperties":false,"required":["unit","power"],"properties":{"unit":{"type":"string","minLength":1,"maxLength":32},"power":{"type":"integer","enum":[-6,-5,-4,-3,-2,-1,1,2,3,4,5,6]}}}},"steps":{"type":"array","minItems":1,"maxItems":50,"items":{"type":"object","additionalProperties":false,"required":["to_unit","claimed_value","round_places"],"properties":{"to_unit":{"type":"array","maxItems":8,"items":{"type":"object","additionalProperties":false,"required":["unit","power"],"properties":{"unit":{"type":"string","minLength":1,"maxLength":32},"power":{"type":"integer","enum":[-6,-5,-4,-3,-2,-1,1,2,3,4,5,6]}}}},"claimed_value":{"type":"string","minLength":1,"maxLength":60,"pattern":"^-?(0|[1-9][0-9]*)(\\.[0-9]+|/[1-9][0-9]*)?$"},"round_places":{"type":["integer","null"],"minimum":0,"maximum":30}}}}}},"output_schema":{"type":"object","additionalProperties":false,"required":["valid","reason","first_discrepancy","steps_checked","final_value","reference_version"],"properties":{"valid":{"type":"boolean"},"reason":{"type":["string","null"],"enum":[null,"unknown_unit","invalid_affine_composition","dimension_mismatch","value_mismatch"]},"first_discrepancy":{"type":["object","null"],"additionalProperties":false,"required":["field","index","term_index","unit","expected","actual"],"properties":{"field":{"type":"string","enum":["start_unit","steps"]},"index":{"type":["integer","null"],"minimum":0},"term_index":{"type":["integer","null"],"minimum":0},"unit":{"type":["string","null"]},"expected":{"type":["string","null"]},"actual":{"type":["string","null"]}}},"steps_checked":{"type":"integer","minimum":0,"maximum":50},"final_value":{"type":["string","null"]},"reference_version":{"type":"string","const":"jcgm-200-2012-vim3-si-brochure-9e-2019"}}},"examples":[{"input":{"units":[{"symbol":"m","dimension":[1,0,0,0,0,0,0],"factor":"1","offset":"0"},{"symbol":"mi","dimension":[1,0,0,0,0,0,0],"factor":"1609.344","offset":"0"},{"symbol":"s","dimension":[0,0,1,0,0,0,0],"factor":"1","offset":"0"},{"symbol":"h","dimension":[0,0,1,0,0,0,0],"factor":"3600","offset":"0"}],"quantity_kind":"absolute","start_value":"60","start_unit":[{"unit":"mi","power":1},{"unit":"h","power":-1}],"steps":[{"to_unit":[{"unit":"m","power":1},{"unit":"h","power":-1}],"claimed_value":"96560.64","round_places":null},{"to_unit":[{"unit":"m","power":1},{"unit":"s","power":-1}],"claimed_value":"26.82","round_places":2}]},"output":{"valid":true,"reason":null,"first_discrepancy":null,"steps_checked":2,"final_value":"26.82","reference_version":"jcgm-200-2012-vim3-si-brochure-9e-2019"}},{"input":{"units":[{"symbol":"m","dimension":[1,0,0,0,0,0,0],"factor":"1","offset":"0"},{"symbol":"mi","dimension":[1,0,0,0,0,0,0],"factor":"1609.344","offset":"0"},{"symbol":"s","dimension":[0,0,1,0,0,0,0],"factor":"1","offset":"0"},{"symbol":"h","dimension":[0,0,1,0,0,0,0],"factor":"3600","offset":"0"}],"quantity_kind":"absolute","start_value":"60","start_unit":[{"unit":"mi","power":1},{"unit":"h","power":-1}],"steps":[{"to_unit":[{"unit":"m","power":1},{"unit":"h","power":-1}],"claimed_value":"96560.64","round_places":null},{"to_unit":[{"unit":"m","power":1},{"unit":"s","power":-1}],"claimed_value":"26.8","round_places":null}]},"output":{"valid":false,"reason":"value_mismatch","first_discrepancy":{"field":"steps","index":1,"term_index":null,"unit":null,"expected":"26.8224","actual":"26.8"},"steps_checked":1,"final_value":null,"reference_version":"jcgm-200-2012-vim3-si-brochure-9e-2019"}}],"execute_url":"/v1/tools/unit-conversion-trace-check/versions/1.0.0/execute"}