FA-15346 / Numerics / Open access
Bareiss determinant: nonzero pivot selection · case 01
The exact bareiss determinant result violates the stated contract at nonzero pivot selection.
ROOT CAUSE
The nonzero pivot selection step uses a[i][k]>0 instead of a[i][k]!=0.
VERIFIED REPAIR
Use a[i][k]!=0 at the nonzero pivot selection step.
Unsuccessful approach: The partial repair a[k][i]!=0 still violates the nonzero pivot selection invariant.
Case contract
Input nonempty square integer matrix; return exact determinant using pivoted fraction-free elimination.
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=[r[:] for r in x];n=len(a);prev=1;sign=1
for k in range(n-1):
pivot=next((i for i in range(k,n) if a[i][k]>0),None)
if pivot is None:return 0
if pivot!=k:
a[k],a[pivot]=a[pivot],a[k]
sign=-sign
for i in range(k+1,n):
for j in range(k+1,n):a[i][j]=(a[i][j]*a[k][k]-a[i][k]*a[k][j])//prev
prev=a[k][k]
if not prev:return None
for i in range(k+1,n):a[i][k]=0
return sign*a[-1][-1]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([[-2, 3], [-3, 2]], 5), ([[0, 3], [0, -3]], 0), ([[-1]], -1), ([[-1, -1, 0, 3], [-3, 1, -2, 2], [0, -1, 1, 2], [-3, 2, -3, -2]], 4), ([[2]], 2), ([[2]], 2), ([[1]], 1), ([[3]], 3)], [([[-2, 2], [-3, -1]], 8), ([[3, 3, 1], [1, 1, -3], [2, 2, -3]], 0), ([[-1]], -1), ([[-1, -1, 0, 3], [-3, 1, -2, 2], [0, -1, 1, 2], [-3, 2, -3, -2]], 4), ([[-3]], -3), ([[1]], 1), ([[3]], 3), ([[2]], 2)], [([[-1, 1], [0, 2]], -2), ([[0, -2, 0, -1], [0, 3, 2, 3], [-1, -1, 3, 1], [0, 0, 0, -3]], -12), ([[-1]], -1), ([[-1, -1, 0, 3], [-3, 1, -2, 2], [0, -1, 1, 2], [-3, 2, -3, -2]], 4), ([[3]], 3), ([[-2]], -2), ([[-1]], -1), ([[-3]], -3)], [([[-2, 2], [-3, 1]], 4), ([[0, 0, 3], [2, -2, -1], [-2, 2, -2]], 0), ([[-1]], -1), ([[-1, -1, 0, 3], [-3, 1, -2, 2], [0, -1, 1, 2], [-3, 2, -3, -2]], 4), ([[2]], 2), ([[-2]], -2), ([[2]], 2), ([[2]], 2)], [([[-1, 0], [-3, -2]], 2), ([[2, 0, 2, 0], [0, -1, -1, 1], [-3, 1, -2, 3], [0, 0, 0, -3]], 0), ([[-1]], -1), ([[-1, -1, 0, 3], [-3, 1, -2, 2], [0, -1, 1, 2], [-3, 2, -3, -2]], 4), ([[0, 3], [0, -3]], 0), ([[-1, 0], [1, 2]], -2), ([[-2, 0], [-2, 0]], 0), ([[2, 1], [1, 3]], 5)]]
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 | 5 | Failed |
| explicit oracle 1 | 0 | 0 | Passed |
| explicit oracle 2 | -1 | -1 | Passed |
| explicit oracle 3 | 0 | 4 | Failed |
| explicit oracle 4 | 2 | 2 | Passed |
| explicit oracle 5 | 2 | 2 | Passed |
| explicit oracle 6 | 1 | 1 | Passed |
| explicit oracle 7 | 3 | 3 | Passed |
SHA-256 / 50cef7fd84bbd3fe8ec5b0ed15c8139b14b62f0bfe5adc18f8095dbf4fa83d08
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=[r[:] for r in x];n=len(a);prev=1;sign=1
for k in range(n-1):
pivot=next((i for i in range(k,n) if a[k][i]!=0),None)
if pivot is None:return 0
if pivot!=k:
a[k],a[pivot]=a[pivot],a[k]
sign=-sign
for i in range(k+1,n):
for j in range(k+1,n):a[i][j]=(a[i][j]*a[k][k]-a[i][k]*a[k][j])//prev
prev=a[k][k]
if not prev:return None
for i in range(k+1,n):a[i][k]=0
return sign*a[-1][-1]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([[-2, 3], [-3, 2]], 5), ([[0, 3], [0, -3]], 0), ([[-1]], -1), ([[-1, -1, 0, 3], [-3, 1, -2, 2], [0, -1, 1, 2], [-3, 2, -3, -2]], 4), ([[2]], 2), ([[2]], 2), ([[1]], 1), ([[3]], 3)], [([[-2, 2], [-3, -1]], 8), ([[3, 3, 1], [1, 1, -3], [2, 2, -3]], 0), ([[-1]], -1), ([[-1, -1, 0, 3], [-3, 1, -2, 2], [0, -1, 1, 2], [-3, 2, -3, -2]], 4), ([[-3]], -3), ([[1]], 1), ([[3]], 3), ([[2]], 2)], [([[-1, 1], [0, 2]], -2), ([[0, -2, 0, -1], [0, 3, 2, 3], [-1, -1, 3, 1], [0, 0, 0, -3]], -12), ([[-1]], -1), ([[-1, -1, 0, 3], [-3, 1, -2, 2], [0, -1, 1, 2], [-3, 2, -3, -2]], 4), ([[3]], 3), ([[-2]], -2), ([[-1]], -1), ([[-3]], -3)], [([[-2, 2], [-3, 1]], 4), ([[0, 0, 3], [2, -2, -1], [-2, 2, -2]], 0), ([[-1]], -1), ([[-1, -1, 0, 3], [-3, 1, -2, 2], [0, -1, 1, 2], [-3, 2, -3, -2]], 4), ([[2]], 2), ([[-2]], -2), ([[2]], 2), ([[2]], 2)], [([[-1, 0], [-3, -2]], 2), ([[2, 0, 2, 0], [0, -1, -1, 1], [-3, 1, -2, 3], [0, 0, 0, -3]], 0), ([[-1]], -1), ([[-1, -1, 0, 3], [-3, 1, -2, 2], [0, -1, 1, 2], [-3, 2, -3, -2]], 4), ([[0, 3], [0, -3]], 0), ([[-1, 0], [1, 2]], -2), ([[-2, 0], [-2, 0]], 0), ([[2, 1], [1, 3]], 5)]]
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 | 5 | 5 | Passed |
| explicit oracle 1 | None | 0 | Failed |
| explicit oracle 2 | -1 | -1 | Passed |
| explicit oracle 3 | 4 | 4 | Passed |
| explicit oracle 4 | 2 | 2 | Passed |
| explicit oracle 5 | 2 | 2 | Passed |
| explicit oracle 6 | 1 | 1 | Passed |
| explicit oracle 7 | 3 | 3 | Passed |
SHA-256 / 921be477503169c3dec83951be2a14c6936ec12f9af7424efdb00aace29f4707
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=[r[:] for r in x];n=len(a);prev=1;sign=1
for k in range(n-1):
pivot=next((i for i in range(k,n) if a[i][k]!=0),None)
if pivot is None:return 0
if pivot!=k:
a[k],a[pivot]=a[pivot],a[k]
sign=-sign
for i in range(k+1,n):
for j in range(k+1,n):a[i][j]=(a[i][j]*a[k][k]-a[i][k]*a[k][j])//prev
prev=a[k][k]
if not prev:return None
for i in range(k+1,n):a[i][k]=0
return sign*a[-1][-1]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([[-2, 3], [-3, 2]], 5), ([[0, 3], [0, -3]], 0), ([[-1]], -1), ([[-1, -1, 0, 3], [-3, 1, -2, 2], [0, -1, 1, 2], [-3, 2, -3, -2]], 4), ([[2]], 2), ([[2]], 2), ([[1]], 1), ([[3]], 3)], [([[-2, 2], [-3, -1]], 8), ([[3, 3, 1], [1, 1, -3], [2, 2, -3]], 0), ([[-1]], -1), ([[-1, -1, 0, 3], [-3, 1, -2, 2], [0, -1, 1, 2], [-3, 2, -3, -2]], 4), ([[-3]], -3), ([[1]], 1), ([[3]], 3), ([[2]], 2)], [([[-1, 1], [0, 2]], -2), ([[0, -2, 0, -1], [0, 3, 2, 3], [-1, -1, 3, 1], [0, 0, 0, -3]], -12), ([[-1]], -1), ([[-1, -1, 0, 3], [-3, 1, -2, 2], [0, -1, 1, 2], [-3, 2, -3, -2]], 4), ([[3]], 3), ([[-2]], -2), ([[-1]], -1), ([[-3]], -3)], [([[-2, 2], [-3, 1]], 4), ([[0, 0, 3], [2, -2, -1], [-2, 2, -2]], 0), ([[-1]], -1), ([[-1, -1, 0, 3], [-3, 1, -2, 2], [0, -1, 1, 2], [-3, 2, -3, -2]], 4), ([[2]], 2), ([[-2]], -2), ([[2]], 2), ([[2]], 2)], [([[-1, 0], [-3, -2]], 2), ([[2, 0, 2, 0], [0, -1, -1, 1], [-3, 1, -2, 3], [0, 0, 0, -3]], 0), ([[-1]], -1), ([[-1, -1, 0, 3], [-3, 1, -2, 2], [0, -1, 1, 2], [-3, 2, -3, -2]], 4), ([[0, 3], [0, -3]], 0), ([[-1, 0], [1, 2]], -2), ([[-2, 0], [-2, 0]], 0), ([[2, 1], [1, 3]], 5)]]
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 | 5 | 5 | Passed |
| explicit oracle 1 | 0 | 0 | Passed |
| explicit oracle 2 | -1 | -1 | Passed |
| explicit oracle 3 | 4 | 4 | Passed |
| explicit oracle 4 | 2 | 2 | Passed |
| explicit oracle 5 | 2 | 2 | Passed |
| explicit oracle 6 | 1 | 1 | Passed |
| explicit oracle 7 | 3 | 3 | Passed |
SHA-256 / a2351b765876260915c28aa7b5af0e7039793699ba0e21c634781a67706ccc1f
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:25.979270+00:00.
Case digest / 6fd44e9d14029e3bdfb37826c69e6356aea2371f0c445f4c5cdbe561da647bce