FA-5541 / Number theory / Open access
Modular multiplicative inverse · case 01
Fermat inversion is used without a prime-modulus precondition.
ROOT CAUSE
Fermat inversion is used without a prime-modulus precondition.
VERIFIED REPAIR
Apply the specified mathematical contract directly, preserving all terms and boundary cases: return pow(a,-1,m) if math.gcd(a,m)==1 else None
Unsuccessful approach: Integer reciprocal is not a modular inverse.
Case contract
Integer inputs; n is positive unless a zero or negative fixture explicitly extends that operation. A modulus is greater than one; p is prime; exponent k may be signed when an inverse exists. a may be signed; return the least nonnegative inverse modulo m or None if gcd(a,m)!=1. Exact operational definition: pow(a,-1,m) if math.gcd(a,m)==1 else None
Why this case matters
Small exact fixtures expose this error without platform timing, external services, or probabilistic observations. Number theory results depend on the stated convention.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR
N = 1
observations = []
def solve(a, m):
return pow(a,m-2,m)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (3, 10)', solve(*(3, 10)), 7)
check('fixture 2: (2, 5)', solve(*(2, 5)), 3)
check('fixture 3: (2, 4)', solve(*(2, 4)), None)
check('fixture 4: (-3, 10)', solve(*(-3, 10)), 3)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| fixture 1: (3, 10) | 1 | 7 | Failed |
| fixture 2: (2, 5) | 3 | 3 | Passed |
| fixture 3: (2, 4) | 0 | None | Failed |
| fixture 4: (-3, 10) | 1 | 3 | Failed |
SHA-256 / 1a9f81ae2b0d496c6e76b5a3464887e38d877ea6b6073a5392e1dd0650b45d28
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR
N = 1
observations = []
def solve(a, m):
return 1//a if a else None
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (3, 10)', solve(*(3, 10)), 7)
check('fixture 2: (2, 5)', solve(*(2, 5)), 3)
check('fixture 3: (2, 4)', solve(*(2, 4)), None)
check('fixture 4: (-3, 10)', solve(*(-3, 10)), 3)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| fixture 1: (3, 10) | 0 | 7 | Failed |
| fixture 2: (2, 5) | 0 | 3 | Failed |
| fixture 3: (2, 4) | 0 | None | Failed |
| fixture 4: (-3, 10) | -1 | 3 | Failed |
SHA-256 / 502213d5a548cec5e71b2c6a904b8c767838a2487b19d05ae4536edfdf84e477
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR
N = 1
observations = []
def solve(a, m):
return pow(a,-1,m) if math.gcd(a,m)==1 else None
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (3, 10)', solve(*(3, 10)), 7)
check('fixture 2: (2, 5)', solve(*(2, 5)), 3)
check('fixture 3: (2, 4)', solve(*(2, 4)), None)
check('fixture 4: (-3, 10)', solve(*(-3, 10)), 3)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| fixture 1: (3, 10) | 7 | 7 | Passed |
| fixture 2: (2, 5) | 3 | 3 | Passed |
| fixture 3: (2, 4) | None | None | Passed |
| fixture 4: (-3, 10) | 3 | 3 | Passed |
SHA-256 / 0545f810d55a18dbdef437550dcfbc2abac917ef1d2d6476734f28abf2e1c479
Verification & scope
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.
Observations recorded using Python 3.12.14 at 2026-09-29T14:37:50.797141+00:00.
Case digest / c37a848bb38536d29cfbc6f15bd4c4e287935bb67cf75b9d398f47cb3e7b3f46