FAILURE MAP
← Case archive

FA-15481 / Numerics / Open access

Integer matrix binary power: base power squaring · case 01

The exact integer matrix binary power result violates the stated contract at base power squaring.

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

ROOT CAUSE

The base power squaring step uses a instead of mul(a,a).

VERIFIED REPAIR

Use mul(a,a) at the base power squaring step.

Unsuccessful approach: The partial repair mul(a,r) still violates the base power squaring invariant.

Case contract

Input [square integer matrix,nonnegative exponent<=12]; return exact matrix power.

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,e=x;n=len(a)
    def mul(a,b):return [[sum(a[i][k]*b[k][j] for k in range(n)) for j in range(n)] for i in range(n)]
    r=[[int(i==j) for j in range(n)] for i in range(n)]
    for _ in range(12):
     if e==0:break
     if e%2==1:r=mul(r,a)
     a=a
     e=e//2
    return r
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([[[-1]], 2], [[1]]), ([[[-1]], 0], [[1]]), ([[[-1, 3], [-1, -3]], 8], [[1168, 2688], [-896, -624]]), ([[[-1]], 1], [[-1]]), ([[[-1]], 3], [[-1]]), ([[[-1]], 4], [[1]]), ([[[-1]], 5], [[-1]]), ([[[-1]], 6], [[1]])], [([[[-1]], 3], [[-1]]), ([[[-1]], 6], [[1]]), ([[[-1]], 0], [[1]]), ([[[-1, 3], [-1, -3]], 8], [[1168, 2688], [-896, -624]]), ([[[2]], 8], [[256]]), ([[[2]], 0], [[1]]), ([[[2]], 1], [[2]]), ([[[2]], 2], [[4]])], [([[[-1]], 4], [[1]]), ([[[2]], 2], [[4]]), ([[[-1]], 0], [[1]]), ([[[-1, 3], [-1, -3]], 8], [[1168, 2688], [-896, -624]]), ([[[1]], 7], [[1]]), ([[[1]], 8], [[1]]), ([[[3]], 0], [[1]]), ([[[3]], 1], [[3]])], [([[[-1]], 5], [[-1]]), ([[[2]], 6], [[64]]), ([[[-1]], 0], [[1]]), ([[[-1, 3], [-1, -3]], 8], [[1168, 2688], [-896, -624]]), ([[[-1]], 6], [[1]]), ([[[-1]], 7], [[-1]]), ([[[-1]], 8], [[1]]), ([[[3]], 0], [[1]])], [([[[-1]], 8], [[1]]), ([[[2]], 2], [[4]]), ([[[-1]], 0], [[1]]), ([[[-1, 3], [-1, -3]], 8], [[1168, 2688], [-896, -624]]), ([[[-3]], 5], [[-243]]), ([[[-3]], 6], [[729]]), ([[[-3]], 7], [[-2187]]), ([[[-3]], 8], [[6561]])]]
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]][[1]]Failed
explicit oracle 1[[1]][[1]]Passed
explicit oracle 2[[-1, 3], [-1, -3]][[1168, 2688], [-896, -624]]Failed
explicit oracle 3[[-1]][[-1]]Passed
explicit oracle 4[[1]][[-1]]Failed
explicit oracle 5[[-1]][[1]]Failed
explicit oracle 6[[1]][[-1]]Failed
explicit oracle 7[[1]][[1]]Passed

SHA-256 / 396bbe5dacc7be07ab90caa073111aebb032cbe29fb29efcd148959593822bdc

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,e=x;n=len(a)
    def mul(a,b):return [[sum(a[i][k]*b[k][j] for k in range(n)) for j in range(n)] for i in range(n)]
    r=[[int(i==j) for j in range(n)] for i in range(n)]
    for _ in range(12):
     if e==0:break
     if e%2==1:r=mul(r,a)
     a=mul(a,r)
     e=e//2
    return r
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([[[-1]], 2], [[1]]), ([[[-1]], 0], [[1]]), ([[[-1, 3], [-1, -3]], 8], [[1168, 2688], [-896, -624]]), ([[[-1]], 1], [[-1]]), ([[[-1]], 3], [[-1]]), ([[[-1]], 4], [[1]]), ([[[-1]], 5], [[-1]]), ([[[-1]], 6], [[1]])], [([[[-1]], 3], [[-1]]), ([[[-1]], 6], [[1]]), ([[[-1]], 0], [[1]]), ([[[-1, 3], [-1, -3]], 8], [[1168, 2688], [-896, -624]]), ([[[2]], 8], [[256]]), ([[[2]], 0], [[1]]), ([[[2]], 1], [[2]]), ([[[2]], 2], [[4]])], [([[[-1]], 4], [[1]]), ([[[2]], 2], [[4]]), ([[[-1]], 0], [[1]]), ([[[-1, 3], [-1, -3]], 8], [[1168, 2688], [-896, -624]]), ([[[1]], 7], [[1]]), ([[[1]], 8], [[1]]), ([[[3]], 0], [[1]]), ([[[3]], 1], [[3]])], [([[[-1]], 5], [[-1]]), ([[[2]], 6], [[64]]), ([[[-1]], 0], [[1]]), ([[[-1, 3], [-1, -3]], 8], [[1168, 2688], [-896, -624]]), ([[[-1]], 6], [[1]]), ([[[-1]], 7], [[-1]]), ([[[-1]], 8], [[1]]), ([[[3]], 0], [[1]])], [([[[-1]], 8], [[1]]), ([[[2]], 2], [[4]]), ([[[-1]], 0], [[1]]), ([[[-1, 3], [-1, -3]], 8], [[1168, 2688], [-896, -624]]), ([[[-3]], 5], [[-243]]), ([[[-3]], 6], [[729]]), ([[[-3]], 7], [[-2187]]), ([[[-3]], 8], [[6561]])]]
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]][[1]]Failed
explicit oracle 1[[1]][[1]]Passed
explicit oracle 2[[-1, 3], [-1, -3]][[1168, 2688], [-896, -624]]Failed
explicit oracle 3[[-1]][[-1]]Passed
explicit oracle 4[[-1]][[-1]]Passed
explicit oracle 5[[-1]][[1]]Failed
explicit oracle 6[[1]][[-1]]Failed
explicit oracle 7[[-1]][[1]]Failed

SHA-256 / 7484706bffe6489d433e0f3d903311f8aa69ac0200cb0e5fec1d88e8538b580b

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,e=x;n=len(a)
    def mul(a,b):return [[sum(a[i][k]*b[k][j] for k in range(n)) for j in range(n)] for i in range(n)]
    r=[[int(i==j) for j in range(n)] for i in range(n)]
    for _ in range(12):
     if e==0:break
     if e%2==1:r=mul(r,a)
     a=mul(a,a)
     e=e//2
    return r
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([[[-1]], 2], [[1]]), ([[[-1]], 0], [[1]]), ([[[-1, 3], [-1, -3]], 8], [[1168, 2688], [-896, -624]]), ([[[-1]], 1], [[-1]]), ([[[-1]], 3], [[-1]]), ([[[-1]], 4], [[1]]), ([[[-1]], 5], [[-1]]), ([[[-1]], 6], [[1]])], [([[[-1]], 3], [[-1]]), ([[[-1]], 6], [[1]]), ([[[-1]], 0], [[1]]), ([[[-1, 3], [-1, -3]], 8], [[1168, 2688], [-896, -624]]), ([[[2]], 8], [[256]]), ([[[2]], 0], [[1]]), ([[[2]], 1], [[2]]), ([[[2]], 2], [[4]])], [([[[-1]], 4], [[1]]), ([[[2]], 2], [[4]]), ([[[-1]], 0], [[1]]), ([[[-1, 3], [-1, -3]], 8], [[1168, 2688], [-896, -624]]), ([[[1]], 7], [[1]]), ([[[1]], 8], [[1]]), ([[[3]], 0], [[1]]), ([[[3]], 1], [[3]])], [([[[-1]], 5], [[-1]]), ([[[2]], 6], [[64]]), ([[[-1]], 0], [[1]]), ([[[-1, 3], [-1, -3]], 8], [[1168, 2688], [-896, -624]]), ([[[-1]], 6], [[1]]), ([[[-1]], 7], [[-1]]), ([[[-1]], 8], [[1]]), ([[[3]], 0], [[1]])], [([[[-1]], 8], [[1]]), ([[[2]], 2], [[4]]), ([[[-1]], 0], [[1]]), ([[[-1, 3], [-1, -3]], 8], [[1168, 2688], [-896, -624]]), ([[[-3]], 5], [[-243]]), ([[[-3]], 6], [[729]]), ([[[-3]], 7], [[-2187]]), ([[[-3]], 8], [[6561]])]]
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]][[1]]Passed
explicit oracle 1[[1]][[1]]Passed
explicit oracle 2[[1168, 2688], [-896, -624]][[1168, 2688], [-896, -624]]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 / 760aba23d25b55fbbb576cc7b95196e086c2496a34cdf917e7efb00ae9f360be

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

Case digest / 777d1b593cfc586873d8dcdbc183a4d52c1fbace48cacb258661b9819ee7b5ee