{"abstract":"The exact montgomery residue product result violates the stated contract at final conditional subtraction.","category":"Numerics","checks":8,"contract":"Input [a,b,m,R], odd modulus m<R and R power of2, 0<=a,b<m; return a*b*R^-1 modulo m using Montgomery reduction.","contract_signature":"x","evaluation_group":"s3-numerics-montgomery-residue-product","failed_approach":"The partial repair v>0 still violates the final conditional subtraction invariant.","family":"s3-numerics-montgomery-residue-product-final-conditional-subtraction","id":"FA-15786","implementations":{"attempt":{"sha256":"a48f5b396b0db57b36a35b92b36fe05b03f0999ce37e941810dc048f496122d9","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nimport itertools\nfrom fractions import Fraction\nN = 1\nobservations = []\ndef solve(x):\n    a,b,m,R=x\n    nprime=(-pow(m,-1,R))%R\n    t=a*b\n    u=(t*nprime)%R\n    v=(t+u*m)//R\n    if v>0:v-=m\n    return v\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[([3, 3, 9, 16], 0), ([1, 1, 3, 8], 2), ([0, 0, 3, 8], 0), ([30, 30, 31, 32], 1), ([0, 1, 3, 8], 0), ([0, 2, 3, 8], 0), ([1, 0, 3, 8], 0), ([1, 2, 3, 8], 1)], [([3, 6, 9, 16], 0), ([2, 2, 3, 8], 2), ([0, 0, 3, 8], 0), ([30, 30, 31, 32], 1), ([1, 3, 5, 8], 1), ([1, 4, 5, 8], 3), ([2, 0, 5, 8], 0), ([2, 1, 5, 8], 4)], [([6, 3, 9, 16], 0), ([1, 3, 5, 8], 1), ([0, 0, 3, 8], 0), ([30, 30, 31, 32], 1), ([0, 0, 7, 8], 0), ([0, 1, 7, 8], 0), ([0, 2, 7, 8], 0), ([0, 3, 7, 8], 0)], [([6, 6, 9, 16], 0), ([2, 2, 5, 8], 3), ([0, 0, 3, 8], 0), ([30, 30, 31, 32], 1), ([2, 3, 7, 8], 6), ([2, 4, 7, 8], 1), ([2, 5, 7, 8], 3), ([2, 6, 7, 8], 5)], [([3, 5, 15, 16], 0), ([3, 1, 5, 8], 1), ([0, 0, 3, 8], 0), ([30, 30, 31, 32], 1), ([4, 6, 7, 8], 3), ([5, 0, 7, 8], 0), ([5, 1, 7, 8], 5), ([5, 2, 7, 8], 3)]]\nfor i, (args, expected) in enumerate(fixtures[N-1]):\n    check(\"explicit oracle %d\" % i, solve(args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"6a5d9226c44056ef8079b0365a60bde9888a6a16f4f784f66d9bb09437a00dc4","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nimport itertools\nfrom fractions import Fraction\nN = 1\nobservations = []\ndef solve(x):\n    a,b,m,R=x\n    nprime=(-pow(m,-1,R))%R\n    t=a*b\n    u=(t*nprime)%R\n    v=(t+u*m)//R\n    if v>m:v-=m\n    return v\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[([3, 3, 9, 16], 0), ([1, 1, 3, 8], 2), ([0, 0, 3, 8], 0), ([30, 30, 31, 32], 1), ([0, 1, 3, 8], 0), ([0, 2, 3, 8], 0), ([1, 0, 3, 8], 0), ([1, 2, 3, 8], 1)], [([3, 6, 9, 16], 0), ([2, 2, 3, 8], 2), ([0, 0, 3, 8], 0), ([30, 30, 31, 32], 1), ([1, 3, 5, 8], 1), ([1, 4, 5, 8], 3), ([2, 0, 5, 8], 0), ([2, 1, 5, 8], 4)], [([6, 3, 9, 16], 0), ([1, 3, 5, 8], 1), ([0, 0, 3, 8], 0), ([30, 30, 31, 32], 1), ([0, 0, 7, 8], 0), ([0, 1, 7, 8], 0), ([0, 2, 7, 8], 0), ([0, 3, 7, 8], 0)], [([6, 6, 9, 16], 0), ([2, 2, 5, 8], 3), ([0, 0, 3, 8], 0), ([30, 30, 31, 32], 1), ([2, 3, 7, 8], 6), ([2, 4, 7, 8], 1), ([2, 5, 7, 8], 3), ([2, 6, 7, 8], 5)], [([3, 5, 15, 16], 0), ([3, 1, 5, 8], 1), ([0, 0, 3, 8], 0), ([30, 30, 31, 32], 1), ([4, 6, 7, 8], 3), ([5, 0, 7, 8], 0), ([5, 1, 7, 8], 5), ([5, 2, 7, 8], 3)]]\nfor i, (args, expected) in enumerate(fixtures[N-1]):\n    check(\"explicit oracle %d\" % i, solve(args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"A deterministic bounded teaching model. Inputs are restricted to the explicit contract; this is not a production algebra library. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"s3-numerics-montgomery-residue-product-final-conditional-subtraction","generated_at":"2026-09-29T14:39:30.157059+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Exact discrete arithmetic with observable algorithmic state; no floating point approximation is used.","root_cause":"The final conditional subtraction step uses v>m instead of v>=m.","sha256":"f9df1342ea84db29a7f5249a67493a09dd572f5d80f5ad19578e0fbcdcff6ee1","title":"Montgomery residue product: final conditional subtraction · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verified":true,"visibility":"public","verification":{"attempt":{"elapsed_ms":42.27,"exit_code":1,"observations":[{"actual":0,"check":"explicit oracle 0","expected":0,"passed":true},{"actual":-1,"check":"explicit oracle 1","expected":2,"passed":false},{"actual":0,"check":"explicit oracle 2","expected":0,"passed":true},{"actual":1,"check":"explicit oracle 3","expected":1,"passed":true},{"actual":0,"check":"explicit oracle 4","expected":0,"passed":true},{"actual":0,"check":"explicit oracle 5","expected":0,"passed":true},{"actual":0,"check":"explicit oracle 6","expected":0,"passed":true},{"actual":-2,"check":"explicit oracle 7","expected":1,"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"explicit oracle 0\", \"actual\": 0, \"expected\": 0, \"passed\": true}, {\"check\": \"explicit oracle 1\", \"actual\": -1, \"expected\": 2, \"passed\": false}, {\"check\": \"explicit oracle 2\", \"actual\": 0, \"expected\": 0, \"passed\": true}, {\"check\": \"explicit oracle 3\", \"actual\": 1, \"expected\": 1, \"passed\": true}, {\"check\": \"explicit oracle 4\", \"actual\": 0, \"expected\": 0, \"passed\": true}, {\"check\": \"explicit oracle 5\", \"actual\": 0, \"expected\": 0, \"passed\": true}, {\"check\": \"explicit oracle 6\", \"actual\": 0, \"expected\": 0, \"passed\": true}, {\"check\": \"explicit oracle 7\", \"actual\": -2, \"expected\": 1, \"passed\": false}], \"passed\": false}\n"},"broken":{"elapsed_ms":41.913,"exit_code":1,"observations":[{"actual":9,"check":"explicit oracle 0","expected":0,"passed":false},{"actual":2,"check":"explicit oracle 1","expected":2,"passed":true},{"actual":0,"check":"explicit oracle 2","expected":0,"passed":true},{"actual":1,"check":"explicit oracle 3","expected":1,"passed":true},{"actual":0,"check":"explicit oracle 4","expected":0,"passed":true},{"actual":0,"check":"explicit oracle 5","expected":0,"passed":true},{"actual":0,"check":"explicit oracle 6","expected":0,"passed":true},{"actual":1,"check":"explicit oracle 7","expected":1,"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"explicit oracle 0\", \"actual\": 9, \"expected\": 0, \"passed\": false}, {\"check\": \"explicit oracle 1\", \"actual\": 2, \"expected\": 2, \"passed\": true}, {\"check\": \"explicit oracle 2\", \"actual\": 0, \"expected\": 0, \"passed\": true}, {\"check\": \"explicit oracle 3\", \"actual\": 1, \"expected\": 1, \"passed\": true}, {\"check\": \"explicit oracle 4\", \"actual\": 0, \"expected\": 0, \"passed\": true}, {\"check\": \"explicit oracle 5\", \"actual\": 0, \"expected\": 0, \"passed\": true}, {\"check\": \"explicit oracle 6\", \"actual\": 0, \"expected\": 0, \"passed\": true}, {\"check\": \"explicit oracle 7\", \"actual\": 1, \"expected\": 1, \"passed\": true}], \"passed\": false}\n"}},"member_only":{"stages":["fixed"],"fields":["implementations.fixed","verification.fixed","harness","repair"],"note":"The verified repair, its recorded checks, the repair description, and the scoring harness are available to members."}}