FAILURE MAP
← Case archive

FA-14846 / Numerics / Open access

Jacobi symbol: supplementary two law · case 01

The exact jacobi symbol result violates the stated contract at supplementary two law.

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

ROOT CAUSE

The supplementary two law step uses n%4==3 instead of n%8 in (3,5).

VERIFIED REPAIR

Use n%8 in (3,5) at the supplementary two law step.

Unsuccessful approach: The partial repair n%8==3 still violates the supplementary two law 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%4==3: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 = [[([-28, 5], -1), ([-30, 1], 1), ([50, 69], -1), ([-29, 1], 1), ([-28, 1], 1), ([-27, 1], 1), ([-26, 1], 1), ([-25, 1], 1)], [([-23, 5], -1), ([-13, 5], -1), ([-30, 1], 1), ([50, 69], -1), ([-13, 1], 1), ([-12, 1], 1), ([-11, 1], 1), ([-10, 1], 1)], [([-18, 5], -1), ([2, 5], -1), ([-30, 1], 1), ([50, 69], -1), ([4, 1], 1), ([5, 1], 1), ([6, 1], 1), ([7, 1], 1)], [([-13, 5], -1), ([17, 5], -1), ([-30, 1], 1), ([50, 69], -1), ([21, 1], 1), ([22, 1], 1), ([23, 1], 1), ([24, 1], 1)], [([-8, 5], -1), ([32, 5], -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 01-1Failed
explicit oracle 111Passed
explicit oracle 21-1Failed
explicit oracle 311Passed
explicit oracle 411Passed
explicit oracle 511Passed
explicit oracle 611Passed
explicit oracle 711Passed

SHA-256 / 3c00c04bd2ddd8f1ae329f8cc11e501365c9176116bfb3a2fa5a9beb1ab98126

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

SHA-256 / f4e3a5a6645d93d97ddf6f7877c4d4e0ec4bb5b3234ddcb54fbc79802d156c2f

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 = [[([-28, 5], -1), ([-30, 1], 1), ([50, 69], -1), ([-29, 1], 1), ([-28, 1], 1), ([-27, 1], 1), ([-26, 1], 1), ([-25, 1], 1)], [([-23, 5], -1), ([-13, 5], -1), ([-30, 1], 1), ([50, 69], -1), ([-13, 1], 1), ([-12, 1], 1), ([-11, 1], 1), ([-10, 1], 1)], [([-18, 5], -1), ([2, 5], -1), ([-30, 1], 1), ([50, 69], -1), ([4, 1], 1), ([5, 1], 1), ([6, 1], 1), ([7, 1], 1)], [([-13, 5], -1), ([17, 5], -1), ([-30, 1], 1), ([50, 69], -1), ([21, 1], 1), ([22, 1], 1), ([23, 1], 1), ([24, 1], 1)], [([-8, 5], -1), ([32, 5], -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 0-1-1Passed
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 / 1660099889884dc62ce335526561435291abda740b206ed794e9bcf3898142ff

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

Case digest / 0ce74b60bc3bf92d9dc04d9f7b03c8d455252168bfd105c59fb004137b53d54f