FAILURE MAP
← Case archive

FA-14861 / Numerics / Open access

Jacobi symbol: common factor terminal · case 01

The exact jacobi symbol result violates the stated contract at common factor terminal.

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

ROOT CAUSE

The common factor terminal step uses sign instead of sign if n==1 else 0.

VERIFIED REPAIR

Use sign if n==1 else 0 at the common factor terminal step.

Unsuccessful approach: The partial repair sign if n>1 else 0 still violates the common factor terminal 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=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
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([-30, 3], 0), ([-30, 1], 1), ([50, 69], -1), ([-29, 1], 1), ([-28, 1], 1), ([-27, 1], 1), ([-26, 1], 1), ([-25, 1], 1)], [([-27, 3], 0), ([-27, 1], 1), ([-30, 1], 1), ([50, 69], -1), ([-13, 1], 1), ([-12, 1], 1), ([-11, 1], 1), ([-10, 1], 1)], [([-24, 3], 0), ([-24, 1], 1), ([-30, 1], 1), ([50, 69], -1), ([4, 1], 1), ([5, 1], 1), ([6, 1], 1), ([7, 1], 1)], [([-21, 3], 0), ([-21, 1], 1), ([-30, 1], 1), ([50, 69], -1), ([21, 1], 1), ([22, 1], 1), ([23, 1], 1), ([24, 1], 1)], [([-18, 3], 0), ([-18, 1], 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 fixtureActualExpectedOutcome
explicit oracle 010Failed
explicit oracle 111Passed
explicit oracle 2-1-1Passed
explicit oracle 311Passed
explicit oracle 411Passed
explicit oracle 511Passed
explicit oracle 611Passed
explicit oracle 711Passed

SHA-256 / 43cac1b119754c438b4c76f8a02aa45e5c90935caee3f9eccd1d441a66a6bb17

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%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 = [[([-30, 3], 0), ([-30, 1], 1), ([50, 69], -1), ([-29, 1], 1), ([-28, 1], 1), ([-27, 1], 1), ([-26, 1], 1), ([-25, 1], 1)], [([-27, 3], 0), ([-27, 1], 1), ([-30, 1], 1), ([50, 69], -1), ([-13, 1], 1), ([-12, 1], 1), ([-11, 1], 1), ([-10, 1], 1)], [([-24, 3], 0), ([-24, 1], 1), ([-30, 1], 1), ([50, 69], -1), ([4, 1], 1), ([5, 1], 1), ([6, 1], 1), ([7, 1], 1)], [([-21, 3], 0), ([-21, 1], 1), ([-30, 1], 1), ([50, 69], -1), ([21, 1], 1), ([22, 1], 1), ([23, 1], 1), ([24, 1], 1)], [([-18, 3], 0), ([-18, 1], 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 fixtureActualExpectedOutcome
explicit oracle 010Failed
explicit oracle 101Failed
explicit oracle 20-1Failed
explicit oracle 301Failed
explicit oracle 401Failed
explicit oracle 501Failed
explicit oracle 601Failed
explicit oracle 701Failed

SHA-256 / b49c5852ed383fe09cf74ec2c49edfe81cbf3d023e3748f09fb35e4e47f88f8e

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 = [[([-30, 3], 0), ([-30, 1], 1), ([50, 69], -1), ([-29, 1], 1), ([-28, 1], 1), ([-27, 1], 1), ([-26, 1], 1), ([-25, 1], 1)], [([-27, 3], 0), ([-27, 1], 1), ([-30, 1], 1), ([50, 69], -1), ([-13, 1], 1), ([-12, 1], 1), ([-11, 1], 1), ([-10, 1], 1)], [([-24, 3], 0), ([-24, 1], 1), ([-30, 1], 1), ([50, 69], -1), ([4, 1], 1), ([5, 1], 1), ([6, 1], 1), ([7, 1], 1)], [([-21, 3], 0), ([-21, 1], 1), ([-30, 1], 1), ([50, 69], -1), ([21, 1], 1), ([22, 1], 1), ([23, 1], 1), ([24, 1], 1)], [([-18, 3], 0), ([-18, 1], 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 fixtureActualExpectedOutcome
explicit oracle 000Passed
explicit oracle 111Passed
explicit oracle 2-1-1Passed
explicit oracle 311Passed
explicit oracle 411Passed
explicit oracle 511Passed
explicit oracle 611Passed
explicit oracle 711Passed

SHA-256 / ed1bde85bcddc4290797150393bd719e9b7c8c71d9376d0f97ddc2e8d8327a7d

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

Case digest / 9cf0269d1ba0edd9c5f8160b33bbaaf37ae6d35a30d485916b461870ea202cce