FA-14841 / Numerics / Open access
Jacobi symbol: initial residue · case 01
The exact jacobi symbol result violates the stated contract at initial residue.
ROOT CAUSE
The initial residue step uses abs(a)%n instead of a%n.
VERIFIED REPAIR
Use a%n at the initial residue step.
Unsuccessful approach: The partial repair a if a>0 else 0 still violates the initial residue invariant.
Case contract
Input [a,n], positive odd n; return Jacobi symbol in {-1,0,1}. Bounds: |a|<=100 and odd n<=99.
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,n=x
a=abs(a)%n;sign=1
for _ in range(100):
if a==0:break
while a%2==0:
a//=2
if n%8 in (3,5):sign=-sign
if a%4==3 and n%4==3:sign=-sign
a,n=n%a,a
return sign if n==1 else 0
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([-29, 3], 1), ([-30, 1], 1), ([50, 69], -1), ([-29, 1], 1), ([-28, 1], 1), ([-27, 1], 1), ([-26, 1], 1), ([-25, 1], 1)], [([-28, 3], -1), ([-25, 3], -1), ([-30, 1], 1), ([50, 69], -1), ([-13, 1], 1), ([-12, 1], 1), ([-11, 1], 1), ([-10, 1], 1)], [([-26, 3], 1), ([-20, 3], 1), ([-30, 1], 1), ([50, 69], -1), ([4, 1], 1), ([5, 1], 1), ([6, 1], 1), ([7, 1], 1)], [([-25, 3], -1), ([-16, 3], -1), ([-30, 1], 1), ([50, 69], -1), ([21, 1], 1), ([22, 1], 1), ([23, 1], 1), ([24, 1], 1)], [([-23, 3], 1), ([-11, 3], 1), ([-30, 1], 1), ([50, 69], -1), ([38, 1], 1), ([39, 1], 1), ([40, 1], 1), ([41, 1], 1)]]
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 | 1 | Failed |
| explicit oracle 1 | 1 | 1 | Passed |
| explicit oracle 2 | -1 | -1 | Passed |
| explicit oracle 3 | 1 | 1 | Passed |
| explicit oracle 4 | 1 | 1 | Passed |
| explicit oracle 5 | 1 | 1 | Passed |
| explicit oracle 6 | 1 | 1 | Passed |
| explicit oracle 7 | 1 | 1 | Passed |
SHA-256 / 9ff727fd2f75cc70882ba7c6f62e88c44307268e27e4133a404133c5804c840c
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,n=x
a=a if a>0 else 0;sign=1
for _ in range(100):
if a==0:break
while a%2==0:
a//=2
if n%8 in (3,5):sign=-sign
if a%4==3 and n%4==3:sign=-sign
a,n=n%a,a
return sign if n==1 else 0
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([-29, 3], 1), ([-30, 1], 1), ([50, 69], -1), ([-29, 1], 1), ([-28, 1], 1), ([-27, 1], 1), ([-26, 1], 1), ([-25, 1], 1)], [([-28, 3], -1), ([-25, 3], -1), ([-30, 1], 1), ([50, 69], -1), ([-13, 1], 1), ([-12, 1], 1), ([-11, 1], 1), ([-10, 1], 1)], [([-26, 3], 1), ([-20, 3], 1), ([-30, 1], 1), ([50, 69], -1), ([4, 1], 1), ([5, 1], 1), ([6, 1], 1), ([7, 1], 1)], [([-25, 3], -1), ([-16, 3], -1), ([-30, 1], 1), ([50, 69], -1), ([21, 1], 1), ([22, 1], 1), ([23, 1], 1), ([24, 1], 1)], [([-23, 3], 1), ([-11, 3], 1), ([-30, 1], 1), ([50, 69], -1), ([38, 1], 1), ([39, 1], 1), ([40, 1], 1), ([41, 1], 1)]]
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 | 0 | 1 | Failed |
| explicit oracle 1 | 1 | 1 | Passed |
| explicit oracle 2 | -1 | -1 | Passed |
| explicit oracle 3 | 1 | 1 | Passed |
| explicit oracle 4 | 1 | 1 | Passed |
| explicit oracle 5 | 1 | 1 | Passed |
| explicit oracle 6 | 1 | 1 | Passed |
| explicit oracle 7 | 1 | 1 | Passed |
SHA-256 / e10c19fd24c46fb71b4877f672aaba45f5c9ccd4b0193401424a900a06934f75
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,n=x
a=a%n;sign=1
for _ in range(100):
if a==0:break
while a%2==0:
a//=2
if n%8 in (3,5):sign=-sign
if a%4==3 and n%4==3:sign=-sign
a,n=n%a,a
return sign if n==1 else 0
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([-29, 3], 1), ([-30, 1], 1), ([50, 69], -1), ([-29, 1], 1), ([-28, 1], 1), ([-27, 1], 1), ([-26, 1], 1), ([-25, 1], 1)], [([-28, 3], -1), ([-25, 3], -1), ([-30, 1], 1), ([50, 69], -1), ([-13, 1], 1), ([-12, 1], 1), ([-11, 1], 1), ([-10, 1], 1)], [([-26, 3], 1), ([-20, 3], 1), ([-30, 1], 1), ([50, 69], -1), ([4, 1], 1), ([5, 1], 1), ([6, 1], 1), ([7, 1], 1)], [([-25, 3], -1), ([-16, 3], -1), ([-30, 1], 1), ([50, 69], -1), ([21, 1], 1), ([22, 1], 1), ([23, 1], 1), ([24, 1], 1)], [([-23, 3], 1), ([-11, 3], 1), ([-30, 1], 1), ([50, 69], -1), ([38, 1], 1), ([39, 1], 1), ([40, 1], 1), ([41, 1], 1)]]
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 | 1 | Passed |
| explicit oracle 1 | 1 | 1 | Passed |
| explicit oracle 2 | -1 | -1 | Passed |
| explicit oracle 3 | 1 | 1 | Passed |
| explicit oracle 4 | 1 | 1 | Passed |
| explicit oracle 5 | 1 | 1 | Passed |
| explicit oracle 6 | 1 | 1 | Passed |
| explicit oracle 7 | 1 | 1 | Passed |
SHA-256 / 795bc6dfd9085061d21559862a7e1cfe0a14acedff2bb0185621040c823120ef
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:20.926783+00:00.
Case digest / f712493649dc26841f31b4203baf38633913e0e34432052559bddba001ec26d3