FA-14346 / Numerics / Open access
Generalized crt: reduced congruence multiplier · case 01
The exact generalized crt result violates the stated contract at reduced congruence multiplier.
ROOT CAUSE
The reduced congruence multiplier step uses ((b-a)*pow(m//g,-1,q))%q if q>1 else 0 instead of ((b-a)//g*pow(m//g,-1,q))%q if q>1 else 0.
VERIFIED REPAIR
Use ((b-a)//g*pow(m//g,-1,q))%q if q>1 else 0 at the reduced congruence multiplier step.
Unsuccessful approach: The partial repair ((b-a)//g)%q if q>1 else 0 still violates the reduced congruence multiplier invariant.
Case contract
Input [a,m,b,n], positive moduli; return least nonnegative common residue and lcm modulus or None.
Why this case matters
Exact discrete arithmetic with observable algorithmic state; no floating point approximation is used.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
import itertools
from fractions import Fraction
N = 1
observations = []
def solve(x):
a,m,b,n=x
g=math.gcd(m,n)
if (b-a)%g != 0: return None
q=n//g
k=((b-a)*pow(m//g,-1,q))%q if q>1 else 0
period=m*(n//g)
r=a+m*k
return [r%period,period]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([-3, 2, -1, 4], [3, 4]), ([-3, 2, -2, 3], [1, 6]), ([-3, 1, -3, 1], [0, 1]), ([3, 8, 3, 8], [3, 8]), ([-3, 1, -2, 1], [0, 1]), ([-3, 1, -1, 1], [0, 1]), ([-3, 1, 0, 1], [0, 1]), ([-3, 1, 1, 1], [0, 1])], [([-3, 2, 3, 4], [3, 4]), ([-3, 2, 2, 3], [5, 6]), ([-3, 1, -3, 1], [0, 1]), ([3, 8, 3, 8], [3, 8]), ([-1, 1, 0, 1], [0, 1]), ([-1, 1, 1, 1], [0, 1]), ([-1, 1, 2, 1], [0, 1]), ([-1, 1, 3, 1], [0, 1])], [([-2, 2, 0, 4], [0, 4]), ([-2, 2, 0, 3], [0, 6]), ([-3, 1, -3, 1], [0, 1]), ([3, 8, 3, 8], [3, 8]), ([1, 1, 3, 1], [0, 1]), ([2, 1, -3, 1], [0, 1]), ([2, 1, -2, 1], [0, 1]), ([2, 1, -1, 1], [0, 1])], [([-1, 2, -3, 4], [1, 4]), ([-1, 2, -3, 3], [3, 6]), ([-3, 1, -3, 1], [0, 1]), ([3, 8, 3, 8], [3, 8]), ([-3, 1, -1, 2], [1, 2]), ([-3, 1, 0, 2], [0, 2]), ([-3, 1, 1, 2], [1, 2]), ([-3, 1, 2, 2], [0, 2])], [([-1, 2, 1, 4], [1, 4]), ([-1, 2, 1, 3], [1, 6]), ([-3, 1, -3, 1], [0, 1]), ([3, 8, 3, 8], [3, 8]), ([-1, 1, 2, 2], [0, 2]), ([-1, 1, 3, 2], [1, 2]), ([0, 1, -3, 2], [1, 2]), ([0, 1, -2, 2], [0, 2])]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("explicit oracle %d" % i, solve(args), expected)
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 |
|---|---|---|---|
| explicit oracle 0 | [1, 4] | [3, 4] | Failed |
| explicit oracle 1 | [1, 6] | [1, 6] | Passed |
| explicit oracle 2 | [0, 1] | [0, 1] | Passed |
| explicit oracle 3 | [3, 8] | [3, 8] | Passed |
| explicit oracle 4 | [0, 1] | [0, 1] | Passed |
| explicit oracle 5 | [0, 1] | [0, 1] | Passed |
| explicit oracle 6 | [0, 1] | [0, 1] | Passed |
| explicit oracle 7 | [0, 1] | [0, 1] | Passed |
SHA-256 / 80b29ecabbcc33d7fb7e6fd76f6f9e7532c10fd8913a3ad172db42829986b622
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
import itertools
from fractions import Fraction
N = 1
observations = []
def solve(x):
a,m,b,n=x
g=math.gcd(m,n)
if (b-a)%g != 0: return None
q=n//g
k=((b-a)//g)%q if q>1 else 0
period=m*(n//g)
r=a+m*k
return [r%period,period]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([-3, 2, -1, 4], [3, 4]), ([-3, 2, -2, 3], [1, 6]), ([-3, 1, -3, 1], [0, 1]), ([3, 8, 3, 8], [3, 8]), ([-3, 1, -2, 1], [0, 1]), ([-3, 1, -1, 1], [0, 1]), ([-3, 1, 0, 1], [0, 1]), ([-3, 1, 1, 1], [0, 1])], [([-3, 2, 3, 4], [3, 4]), ([-3, 2, 2, 3], [5, 6]), ([-3, 1, -3, 1], [0, 1]), ([3, 8, 3, 8], [3, 8]), ([-1, 1, 0, 1], [0, 1]), ([-1, 1, 1, 1], [0, 1]), ([-1, 1, 2, 1], [0, 1]), ([-1, 1, 3, 1], [0, 1])], [([-2, 2, 0, 4], [0, 4]), ([-2, 2, 0, 3], [0, 6]), ([-3, 1, -3, 1], [0, 1]), ([3, 8, 3, 8], [3, 8]), ([1, 1, 3, 1], [0, 1]), ([2, 1, -3, 1], [0, 1]), ([2, 1, -2, 1], [0, 1]), ([2, 1, -1, 1], [0, 1])], [([-1, 2, -3, 4], [1, 4]), ([-1, 2, -3, 3], [3, 6]), ([-3, 1, -3, 1], [0, 1]), ([3, 8, 3, 8], [3, 8]), ([-3, 1, -1, 2], [1, 2]), ([-3, 1, 0, 2], [0, 2]), ([-3, 1, 1, 2], [1, 2]), ([-3, 1, 2, 2], [0, 2])], [([-1, 2, 1, 4], [1, 4]), ([-1, 2, 1, 3], [1, 6]), ([-3, 1, -3, 1], [0, 1]), ([3, 8, 3, 8], [3, 8]), ([-1, 1, 2, 2], [0, 2]), ([-1, 1, 3, 2], [1, 2]), ([0, 1, -3, 2], [1, 2]), ([0, 1, -2, 2], [0, 2])]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("explicit oracle %d" % i, solve(args), expected)
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 |
|---|---|---|---|
| explicit oracle 0 | [3, 4] | [3, 4] | Passed |
| explicit oracle 1 | [5, 6] | [1, 6] | Failed |
| explicit oracle 2 | [0, 1] | [0, 1] | Passed |
| explicit oracle 3 | [3, 8] | [3, 8] | Passed |
| explicit oracle 4 | [0, 1] | [0, 1] | Passed |
| explicit oracle 5 | [0, 1] | [0, 1] | Passed |
| explicit oracle 6 | [0, 1] | [0, 1] | Passed |
| explicit oracle 7 | [0, 1] | [0, 1] | Passed |
SHA-256 / ca17202ef4362c4f6bedef5cf0294fac605bcb84fb79566a237b578a0450c93d
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
import itertools
from fractions import Fraction
N = 1
observations = []
def solve(x):
a,m,b,n=x
g=math.gcd(m,n)
if (b-a)%g != 0: return None
q=n//g
k=((b-a)//g*pow(m//g,-1,q))%q if q>1 else 0
period=m*(n//g)
r=a+m*k
return [r%period,period]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([-3, 2, -1, 4], [3, 4]), ([-3, 2, -2, 3], [1, 6]), ([-3, 1, -3, 1], [0, 1]), ([3, 8, 3, 8], [3, 8]), ([-3, 1, -2, 1], [0, 1]), ([-3, 1, -1, 1], [0, 1]), ([-3, 1, 0, 1], [0, 1]), ([-3, 1, 1, 1], [0, 1])], [([-3, 2, 3, 4], [3, 4]), ([-3, 2, 2, 3], [5, 6]), ([-3, 1, -3, 1], [0, 1]), ([3, 8, 3, 8], [3, 8]), ([-1, 1, 0, 1], [0, 1]), ([-1, 1, 1, 1], [0, 1]), ([-1, 1, 2, 1], [0, 1]), ([-1, 1, 3, 1], [0, 1])], [([-2, 2, 0, 4], [0, 4]), ([-2, 2, 0, 3], [0, 6]), ([-3, 1, -3, 1], [0, 1]), ([3, 8, 3, 8], [3, 8]), ([1, 1, 3, 1], [0, 1]), ([2, 1, -3, 1], [0, 1]), ([2, 1, -2, 1], [0, 1]), ([2, 1, -1, 1], [0, 1])], [([-1, 2, -3, 4], [1, 4]), ([-1, 2, -3, 3], [3, 6]), ([-3, 1, -3, 1], [0, 1]), ([3, 8, 3, 8], [3, 8]), ([-3, 1, -1, 2], [1, 2]), ([-3, 1, 0, 2], [0, 2]), ([-3, 1, 1, 2], [1, 2]), ([-3, 1, 2, 2], [0, 2])], [([-1, 2, 1, 4], [1, 4]), ([-1, 2, 1, 3], [1, 6]), ([-3, 1, -3, 1], [0, 1]), ([3, 8, 3, 8], [3, 8]), ([-1, 1, 2, 2], [0, 2]), ([-1, 1, 3, 2], [1, 2]), ([0, 1, -3, 2], [1, 2]), ([0, 1, -2, 2], [0, 2])]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("explicit oracle %d" % i, solve(args), expected)
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 |
|---|---|---|---|
| explicit oracle 0 | [3, 4] | [3, 4] | Passed |
| explicit oracle 1 | [1, 6] | [1, 6] | Passed |
| explicit oracle 2 | [0, 1] | [0, 1] | Passed |
| explicit oracle 3 | [3, 8] | [3, 8] | Passed |
| explicit oracle 4 | [0, 1] | [0, 1] | Passed |
| explicit oracle 5 | [0, 1] | [0, 1] | Passed |
| explicit oracle 6 | [0, 1] | [0, 1] | Passed |
| explicit oracle 7 | [0, 1] | [0, 1] | Passed |
SHA-256 / c54e04acf6519dd612e726b9496cfb1702f7b1703e43611dd66e8972f12330a7
Verification & scope
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.
Observations recorded using Python 3.12.14 at 2026-09-29T14:39:15.908107+00:00.
Case digest / 9a475dc2c2f5887c9512dc0b4fdcc79dc22c7aae9c9dcb25ac2d2bc18b8c0763