FAILURE MAP
← Case archive

FA-15341 / Numerics / Open access

Bareiss determinant: elimination pivot count · case 01

The exact bareiss determinant result violates the stated contract at elimination pivot count.

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

ROOT CAUSE

The elimination pivot count step uses range(n-2) instead of range(n-1).

VERIFIED REPAIR

Use range(n-1) at the elimination pivot count step.

Unsuccessful approach: The partial repair range(1,n-1) still violates the elimination pivot count 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-2):
     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, 1], [3, 0]], -3), ([[-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), ([[-1]], -1)], [([[2, 2], [2, -2]], -8), ([[-2, 3], [-3, 2]], 5), ([[-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, -3], [-3, -2]], -11), ([[0, -3], [1, -2]], 3), ([[-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, 3], [-3, 2]], 5), ([[-1, 1], [0, 2]], -2), ([[-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)], [([[3, -1], [2, 3]], 11), ([[0, 3], [0, -3]], 0), ([[-1]], -1), ([[-1, -1, 0, 3], [-3, 1, -2, 2], [0, -1, 1, 2], [-3, 2, -3, -2]], 4), ([[-1, 0], [-3, -2]], 2), ([[-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 fixtureActualExpectedOutcome
explicit oracle 00-3Failed
explicit oracle 1-1-1Passed
explicit oracle 294Failed
explicit oracle 322Passed
explicit oracle 422Passed
explicit oracle 511Passed
explicit oracle 633Passed
explicit oracle 7-1-1Passed

SHA-256 / 6598d7ee45a1dc6d80d0373d35e00f2a71cc25e98849d59138279e339283db87

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(1,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, 1], [3, 0]], -3), ([[-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), ([[-1]], -1)], [([[2, 2], [2, -2]], -8), ([[-2, 3], [-3, 2]], 5), ([[-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, -3], [-3, -2]], -11), ([[0, -3], [1, -2]], 3), ([[-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, 3], [-3, 2]], 5), ([[-1, 1], [0, 2]], -2), ([[-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)], [([[3, -1], [2, 3]], 11), ([[0, 3], [0, -3]], 0), ([[-1]], -1), ([[-1, -1, 0, 3], [-3, 1, -2, 2], [0, -1, 1, 2], [-3, 2, -3, -2]], 4), ([[-1, 0], [-3, -2]], 2), ([[-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 fixtureActualExpectedOutcome
explicit oracle 00-3Failed
explicit oracle 1-1-1Passed
explicit oracle 224Failed
explicit oracle 322Passed
explicit oracle 422Passed
explicit oracle 511Passed
explicit oracle 633Passed
explicit oracle 7-1-1Passed

SHA-256 / 24d069a73870a39b5f56e82f43a6b37603e9840ea3fbc580e9582394764835ee

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, 1], [3, 0]], -3), ([[-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), ([[-1]], -1)], [([[2, 2], [2, -2]], -8), ([[-2, 3], [-3, 2]], 5), ([[-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, -3], [-3, -2]], -11), ([[0, -3], [1, -2]], 3), ([[-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, 3], [-3, 2]], 5), ([[-1, 1], [0, 2]], -2), ([[-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)], [([[3, -1], [2, 3]], 11), ([[0, 3], [0, -3]], 0), ([[-1]], -1), ([[-1, -1, 0, 3], [-3, 1, -2, 2], [0, -1, 1, 2], [-3, 2, -3, -2]], 4), ([[-1, 0], [-3, -2]], 2), ([[-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 fixtureActualExpectedOutcome
explicit oracle 0-3-3Passed
explicit oracle 1-1-1Passed
explicit oracle 244Passed
explicit oracle 322Passed
explicit oracle 422Passed
explicit oracle 511Passed
explicit oracle 633Passed
explicit oracle 7-1-1Passed

SHA-256 / 236746470c4fa319284aa3e1a2b3be5671bd823bd258ba20d5db6e91369bfb2e

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

Case digest / 7fefe2b1f9931a89834b798eb9bfcab1daa5c0cb74ca075e4204d7b05e27750b