FAILURE MAP
← Case archive

FA-14341 / Numerics / Open access

Generalized crt: compatibility divisibility · case 01

The exact generalized crt result violates the stated contract at compatibility divisibility.

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The compatibility divisibility step uses a != b instead of (b-a)%g != 0.

VERIFIED REPAIR

Use (b-a)%g != 0 at the compatibility divisibility step.

Unsuccessful approach: The partial repair (b-a)%m != 0 still violates the compatibility divisibility 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 a != b: 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, 1, -2, 1], [0, 1]), ([-3, 2, -2, 1], [1, 2]), ([-3, 1, -3, 1], [0, 1]), ([3, 8, 3, 8], [3, 8]), ([-3, 1, -1, 1], [0, 1]), ([-3, 1, 0, 1], [0, 1]), ([-3, 1, 1, 1], [0, 1]), ([-3, 1, 2, 1], [0, 1])], [([-3, 1, -1, 1], [0, 1]), ([-2, 2, -3, 1], [0, 2]), ([-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])], [([-3, 1, 0, 1], [0, 1]), ([-2, 2, 3, 1], [0, 2]), ([-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])], [([-3, 1, 1, 1], [0, 1]), ([-1, 2, 2, 1], [1, 2]), ([-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])], [([-3, 1, 2, 1], [0, 1]), ([0, 2, 1, 1], [0, 2]), ([-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 fixtureActualExpectedOutcome
explicit oracle 0None[0, 1]Failed
explicit oracle 1None[1, 2]Failed
explicit oracle 2[0, 1][0, 1]Passed
explicit oracle 3[3, 8][3, 8]Passed
explicit oracle 4None[0, 1]Failed
explicit oracle 5None[0, 1]Failed
explicit oracle 6None[0, 1]Failed
explicit oracle 7None[0, 1]Failed

SHA-256 / 4447aab0e6c59275296b15c476d70f47484226d6d03a1c2a3150c8fb7a841501

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)%m != 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, 1, -2, 1], [0, 1]), ([-3, 2, -2, 1], [1, 2]), ([-3, 1, -3, 1], [0, 1]), ([3, 8, 3, 8], [3, 8]), ([-3, 1, -1, 1], [0, 1]), ([-3, 1, 0, 1], [0, 1]), ([-3, 1, 1, 1], [0, 1]), ([-3, 1, 2, 1], [0, 1])], [([-3, 1, -1, 1], [0, 1]), ([-2, 2, -3, 1], [0, 2]), ([-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])], [([-3, 1, 0, 1], [0, 1]), ([-2, 2, 3, 1], [0, 2]), ([-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])], [([-3, 1, 1, 1], [0, 1]), ([-1, 2, 2, 1], [1, 2]), ([-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])], [([-3, 1, 2, 1], [0, 1]), ([0, 2, 1, 1], [0, 2]), ([-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 fixtureActualExpectedOutcome
explicit oracle 0[0, 1][0, 1]Passed
explicit oracle 1None[1, 2]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 / 14bef38cac93ce338c4a19276094588f186684fc2ffa94882149d02e624be047

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, 1, -2, 1], [0, 1]), ([-3, 2, -2, 1], [1, 2]), ([-3, 1, -3, 1], [0, 1]), ([3, 8, 3, 8], [3, 8]), ([-3, 1, -1, 1], [0, 1]), ([-3, 1, 0, 1], [0, 1]), ([-3, 1, 1, 1], [0, 1]), ([-3, 1, 2, 1], [0, 1])], [([-3, 1, -1, 1], [0, 1]), ([-2, 2, -3, 1], [0, 2]), ([-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])], [([-3, 1, 0, 1], [0, 1]), ([-2, 2, 3, 1], [0, 2]), ([-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])], [([-3, 1, 1, 1], [0, 1]), ([-1, 2, 2, 1], [1, 2]), ([-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])], [([-3, 1, 2, 1], [0, 1]), ([0, 2, 1, 1], [0, 2]), ([-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 fixtureActualExpectedOutcome
explicit oracle 0[0, 1][0, 1]Passed
explicit oracle 1[1, 2][1, 2]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 / a5ce8ba0af04d3cc64842e68157e9c3abebe379dadc5eb9db6eed2423b973fdd

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.815443+00:00.

Case digest / 151ce05d114effd3f22a2ea3b893c365f913a934a6f7c1a6ad2757e9671e5e8f