FAILURE MAP
← Case archive

FA-14386 / Numerics / Open access

Linear congruence solutions: coset cardinality · case 01

The exact linear congruence solutions result violates the stated contract at coset cardinality.

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

ROOT CAUSE

The coset cardinality step uses range(g+1) instead of range(g).

THE FAILURE

The coset cardinality step uses range(g+1) instead of range(g).

Unsuccessful approach: The partial repair range(1,g) still violates the coset cardinality invariant.

Case contract

Input [a,b,m], m>0; sorted all x in [0,m) with a*x congruent b modulo m.

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,b,m=x
    g=math.gcd(a,m)
    if b%g != 0: return []
    q=m//g
    r=((b//g)*pow(a//g,-1,q))%q if q>1 else 0
    return sorted(r+k*q for k in range(g+1))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([1, -6, 1], [0]), ([11, 6, 12], [6]), ([1, -6, 2], [0]), ([1, -6, 3], [0]), ([1, -6, 4], [2]), ([1, -6, 5], [4]), ([1, -6, 6], [0]), ([1, -6, 7], [1])], [([1, -6, 2], [0]), ([1, -6, 4], [2]), ([1, -6, 1], [0]), ([11, 6, 12], [6]), ([1, -5, 6], [1]), ([1, -5, 7], [2]), ([1, -5, 8], [3]), ([1, -5, 9], [4])], [([1, -6, 3], [0]), ([1, -6, 7], [1]), ([1, -6, 1], [0]), ([11, 6, 12], [6]), ([1, -4, 11], [7]), ([1, -4, 12], [8]), ([1, -3, 1], [0]), ([1, -3, 2], [1])], [([1, -6, 4], [2]), ([1, -6, 10], [4]), ([1, -6, 1], [0]), ([11, 6, 12], [6]), ([1, -2, 4], [2]), ([1, -2, 5], [3]), ([1, -2, 6], [4]), ([1, -2, 7], [5])], [([1, -6, 5], [4]), ([1, -5, 1], [0]), ([1, -6, 1], [0]), ([11, 6, 12], [6]), ([1, -1, 9], [8]), ([1, -1, 10], [9]), ([1, -1, 11], [10]), ([1, -1, 12], [11])]]
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]Failed
explicit oracle 1[6, 18][6]Failed
explicit oracle 2[0, 2][0]Failed
explicit oracle 3[0, 3][0]Failed
explicit oracle 4[2, 6][2]Failed
explicit oracle 5[4, 9][4]Failed
explicit oracle 6[0, 6][0]Failed
explicit oracle 7[1, 8][1]Failed

SHA-256 / e8386910e3e44d5294c263ab9109c607df1a48a11b8984e43f825b2109db7cfe

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,b,m=x
    g=math.gcd(a,m)
    if b%g != 0: return []
    q=m//g
    r=((b//g)*pow(a//g,-1,q))%q if q>1 else 0
    return sorted(r+k*q for k in range(1,g))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([1, -6, 1], [0]), ([11, 6, 12], [6]), ([1, -6, 2], [0]), ([1, -6, 3], [0]), ([1, -6, 4], [2]), ([1, -6, 5], [4]), ([1, -6, 6], [0]), ([1, -6, 7], [1])], [([1, -6, 2], [0]), ([1, -6, 4], [2]), ([1, -6, 1], [0]), ([11, 6, 12], [6]), ([1, -5, 6], [1]), ([1, -5, 7], [2]), ([1, -5, 8], [3]), ([1, -5, 9], [4])], [([1, -6, 3], [0]), ([1, -6, 7], [1]), ([1, -6, 1], [0]), ([11, 6, 12], [6]), ([1, -4, 11], [7]), ([1, -4, 12], [8]), ([1, -3, 1], [0]), ([1, -3, 2], [1])], [([1, -6, 4], [2]), ([1, -6, 10], [4]), ([1, -6, 1], [0]), ([11, 6, 12], [6]), ([1, -2, 4], [2]), ([1, -2, 5], [3]), ([1, -2, 6], [4]), ([1, -2, 7], [5])], [([1, -6, 5], [4]), ([1, -5, 1], [0]), ([1, -6, 1], [0]), ([11, 6, 12], [6]), ([1, -1, 9], [8]), ([1, -1, 10], [9]), ([1, -1, 11], [10]), ([1, -1, 12], [11])]]
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]Failed
explicit oracle 1[][6]Failed
explicit oracle 2[][0]Failed
explicit oracle 3[][0]Failed
explicit oracle 4[][2]Failed
explicit oracle 5[][4]Failed
explicit oracle 6[][0]Failed
explicit oracle 7[][1]Failed

SHA-256 / 0af69cd81aca27d6e2851869df4d515ac88d98af8b3d0beb85228dc924c96e61

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

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

Case digest / 8b1346c2af813d711feca4ff0a43d8c46dd475caa02d8824ab70dcbb2c985f09