FAILURE MAP
← Case archive

FA-14791 / Numerics / Open access

Integer polynomial pseudodivision: pseudo quotient displacement · case 01

The exact integer polynomial pseudodivision result violates the stated contract at pseudo quotient displacement.

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

ROOT CAUSE

The pseudo quotient displacement step uses 0 instead of len(r)-len(B).

VERIFIED REPAIR

Use len(r)-len(B) at the pseudo quotient displacement step.

Unsuccessful approach: The partial repair max(0,len(r)-len(B)-1) still violates the pseudo quotient displacement invariant.

Case contract

Input [A,B] integer ascending canonical nonzero polynomials degA>=degB; returns [scale, quotient, remainder] with scale*A=B*quotient+remainder, scale=lc(B)^(degA-degB+1).

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,B=x
    r=A[:];q=[0]*(len(A)-len(B)+1);b=B[-1];steps=len(A)-len(B)+1
    for _ in range(steps):
     if len(r)<len(B):
      q=[b*v for v in q];r=[b*v for v in r];continue
     k=0
     c=r[-1]
     q=[b*v for v in q]
     q[k]=q[k]+c
     r=[b*v for v in r]
     for j in range(len(B)):r[j+k]=r[j+k]-c*B[j]
     while r and r[-1]==0:r.pop()
    while q and q[-1]==0:q.pop()
    return [b**steps,q,r]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([[-2, -2, -2], [-2, -2]], [4, [0, 4], [-8]]), ([[2, 2], [2, 2]], [2, [2], []]), ([[-2, -2, -2], [-2, -1]], [1, [-2, 2], [-6]]), ([[-2, -2, -2], [-2, 1]], [1, [-6, -2], [-14]]), ([[-2, -2, -2], [-2, 2]], [4, [-8, -4], [-24]]), ([[-2, -2, -2], [-1, -2]], [4, [2, 4], [-6]]), ([[-2, -2, -2], [-1, -1]], [1, [0, 2], [-2]]), ([[-2, -2, -2], [-1, 1]], [1, [-4, -2], [-6]])], [([[-2, -2, -2], [-2, -1]], [1, [-2, 2], [-6]]), ([[-2, -2, -2], [-2, 2]], [4, [-8, -4], [-24]]), ([[-2, -2, -2], [-2, -2]], [4, [0, 4], [-8]]), ([[2, 2], [2, 2]], [2, [2], []]), ([[-2, -2, -2], [2, -1]], [1, [6, 2], [-14]]), ([[-2, -2, -2], [2, 1]], [1, [2, -2], [-6]]), ([[-2, -2, -2], [2, 2]], [4, [0, -4], [-8]]), ([[-2, -2, -1], [-2, -2]], [4, [2, 2], [-4]])], [([[-2, -2, -2], [-2, 1]], [1, [-6, -2], [-14]]), ([[-2, -2, -2], [-1, 1]], [1, [-4, -2], [-6]]), ([[-2, -2, -2], [-2, -2]], [4, [0, 4], [-8]]), ([[2, 2], [2, 2]], [2, [2], []]), ([[-2, -2, -1], [1, 1]], [1, [-1, -1], [-1]]), ([[-2, -2, -1], [1, 2]], [4, [-3, -2], [-5]]), ([[-2, -2, -1], [2, -2]], [4, [6, 2], [-20]]), ([[-2, -2, -1], [2, -1]], [1, [4, 1], [-10]])], [([[-2, -2, -2], [-2, 2]], [4, [-8, -4], [-24]]), ([[-2, -2, -2], [0, -1]], [1, [2, 2], [-2]]), ([[-2, -2, -2], [-2, -2]], [4, [0, 4], [-8]]), ([[2, 2], [2, 2]], [2, [2], []]), ([[-2, -2, 1], [0, 2]], [4, [-4, 2], [-8]]), ([[-2, -2, 1], [1, -2]], [4, [3, -2], [-11]]), ([[-2, -2, 1], [1, -1]], [1, [1, -1], [-3]]), ([[-2, -2, 1], [1, 1]], [1, [-3, 1], [1]])], [([[-2, -2, -2], [-1, -2]], [4, [2, 4], [-6]]), ([[-2, -2, -2], [1, -2]], [4, [6, 4], [-14]]), ([[-2, -2, -2], [-2, -2]], [4, [0, 4], [-8]]), ([[2, 2], [2, 2]], [2, [2], []]), ([[-2, -2, 2], [0, -2]], [4, [4, -4], [-8]]), ([[-2, -2, 2], [0, -1]], [1, [2, -2], [-2]]), ([[-2, -2, 2], [0, 1]], [1, [-2, 2], [-2]]), ([[-2, -2, 2], [0, 2]], [4, [-4, 4], [-8]])]]
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[4, [8], [8, 8, -8]][4, [0, 4], [-8]]Failed
explicit oracle 1[2, [2], []][2, [2], []]Passed
explicit oracle 2[1, [4], [6, 2, -2]][1, [-2, 2], [-6]]Failed
explicit oracle 3[1, [-4], [-10, 2, -2]][1, [-6, -2], [-14]]Failed
explicit oracle 4[4, [-8], [-24, 8, -8]][4, [-8, -4], [-24]]Failed
explicit oracle 5[4, [8], [0, 8, -8]][4, [2, 4], [-6]]Failed
explicit oracle 6[1, [4], [2, 2, -2]][1, [0, 2], [-2]]Failed
explicit oracle 7[1, [-4], [-6, 2, -2]][1, [-4, -2], [-6]]Failed

SHA-256 / de5821814c9f568333a060cf22b3c867b8f50467c5bcecbb5fdac5fa3847a1a9

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,B=x
    r=A[:];q=[0]*(len(A)-len(B)+1);b=B[-1];steps=len(A)-len(B)+1
    for _ in range(steps):
     if len(r)<len(B):
      q=[b*v for v in q];r=[b*v for v in r];continue
     k=max(0,len(r)-len(B)-1)
     c=r[-1]
     q=[b*v for v in q]
     q[k]=q[k]+c
     r=[b*v for v in r]
     for j in range(len(B)):r[j+k]=r[j+k]-c*B[j]
     while r and r[-1]==0:r.pop()
    while q and q[-1]==0:q.pop()
    return [b**steps,q,r]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([[-2, -2, -2], [-2, -2]], [4, [0, 4], [-8]]), ([[2, 2], [2, 2]], [2, [2], []]), ([[-2, -2, -2], [-2, -1]], [1, [-2, 2], [-6]]), ([[-2, -2, -2], [-2, 1]], [1, [-6, -2], [-14]]), ([[-2, -2, -2], [-2, 2]], [4, [-8, -4], [-24]]), ([[-2, -2, -2], [-1, -2]], [4, [2, 4], [-6]]), ([[-2, -2, -2], [-1, -1]], [1, [0, 2], [-2]]), ([[-2, -2, -2], [-1, 1]], [1, [-4, -2], [-6]])], [([[-2, -2, -2], [-2, -1]], [1, [-2, 2], [-6]]), ([[-2, -2, -2], [-2, 2]], [4, [-8, -4], [-24]]), ([[-2, -2, -2], [-2, -2]], [4, [0, 4], [-8]]), ([[2, 2], [2, 2]], [2, [2], []]), ([[-2, -2, -2], [2, -1]], [1, [6, 2], [-14]]), ([[-2, -2, -2], [2, 1]], [1, [2, -2], [-6]]), ([[-2, -2, -2], [2, 2]], [4, [0, -4], [-8]]), ([[-2, -2, -1], [-2, -2]], [4, [2, 2], [-4]])], [([[-2, -2, -2], [-2, 1]], [1, [-6, -2], [-14]]), ([[-2, -2, -2], [-1, 1]], [1, [-4, -2], [-6]]), ([[-2, -2, -2], [-2, -2]], [4, [0, 4], [-8]]), ([[2, 2], [2, 2]], [2, [2], []]), ([[-2, -2, -1], [1, 1]], [1, [-1, -1], [-1]]), ([[-2, -2, -1], [1, 2]], [4, [-3, -2], [-5]]), ([[-2, -2, -1], [2, -2]], [4, [6, 2], [-20]]), ([[-2, -2, -1], [2, -1]], [1, [4, 1], [-10]])], [([[-2, -2, -2], [-2, 2]], [4, [-8, -4], [-24]]), ([[-2, -2, -2], [0, -1]], [1, [2, 2], [-2]]), ([[-2, -2, -2], [-2, -2]], [4, [0, 4], [-8]]), ([[2, 2], [2, 2]], [2, [2], []]), ([[-2, -2, 1], [0, 2]], [4, [-4, 2], [-8]]), ([[-2, -2, 1], [1, -2]], [4, [3, -2], [-11]]), ([[-2, -2, 1], [1, -1]], [1, [1, -1], [-3]]), ([[-2, -2, 1], [1, 1]], [1, [-3, 1], [1]])], [([[-2, -2, -2], [-1, -2]], [4, [2, 4], [-6]]), ([[-2, -2, -2], [1, -2]], [4, [6, 4], [-14]]), ([[-2, -2, -2], [-2, -2]], [4, [0, 4], [-8]]), ([[2, 2], [2, 2]], [2, [2], []]), ([[-2, -2, 2], [0, -2]], [4, [4, -4], [-8]]), ([[-2, -2, 2], [0, -1]], [1, [2, -2], [-2]]), ([[-2, -2, 2], [0, 1]], [1, [-2, 2], [-2]]), ([[-2, -2, 2], [0, 2]], [4, [-4, 4], [-8]])]]
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[4, [8], [8, 8, -8]][4, [0, 4], [-8]]Failed
explicit oracle 1[2, [2], []][2, [2], []]Passed
explicit oracle 2[1, [4], [6, 2, -2]][1, [-2, 2], [-6]]Failed
explicit oracle 3[1, [-4], [-10, 2, -2]][1, [-6, -2], [-14]]Failed
explicit oracle 4[4, [-8], [-24, 8, -8]][4, [-8, -4], [-24]]Failed
explicit oracle 5[4, [8], [0, 8, -8]][4, [2, 4], [-6]]Failed
explicit oracle 6[1, [4], [2, 2, -2]][1, [0, 2], [-2]]Failed
explicit oracle 7[1, [-4], [-6, 2, -2]][1, [-4, -2], [-6]]Failed

SHA-256 / 0206d61f0179e885c22a09ee942ff3e2175e4b8e3bea9bb8aee490ef21b0ddad

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,B=x
    r=A[:];q=[0]*(len(A)-len(B)+1);b=B[-1];steps=len(A)-len(B)+1
    for _ in range(steps):
     if len(r)<len(B):
      q=[b*v for v in q];r=[b*v for v in r];continue
     k=len(r)-len(B)
     c=r[-1]
     q=[b*v for v in q]
     q[k]=q[k]+c
     r=[b*v for v in r]
     for j in range(len(B)):r[j+k]=r[j+k]-c*B[j]
     while r and r[-1]==0:r.pop()
    while q and q[-1]==0:q.pop()
    return [b**steps,q,r]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([[-2, -2, -2], [-2, -2]], [4, [0, 4], [-8]]), ([[2, 2], [2, 2]], [2, [2], []]), ([[-2, -2, -2], [-2, -1]], [1, [-2, 2], [-6]]), ([[-2, -2, -2], [-2, 1]], [1, [-6, -2], [-14]]), ([[-2, -2, -2], [-2, 2]], [4, [-8, -4], [-24]]), ([[-2, -2, -2], [-1, -2]], [4, [2, 4], [-6]]), ([[-2, -2, -2], [-1, -1]], [1, [0, 2], [-2]]), ([[-2, -2, -2], [-1, 1]], [1, [-4, -2], [-6]])], [([[-2, -2, -2], [-2, -1]], [1, [-2, 2], [-6]]), ([[-2, -2, -2], [-2, 2]], [4, [-8, -4], [-24]]), ([[-2, -2, -2], [-2, -2]], [4, [0, 4], [-8]]), ([[2, 2], [2, 2]], [2, [2], []]), ([[-2, -2, -2], [2, -1]], [1, [6, 2], [-14]]), ([[-2, -2, -2], [2, 1]], [1, [2, -2], [-6]]), ([[-2, -2, -2], [2, 2]], [4, [0, -4], [-8]]), ([[-2, -2, -1], [-2, -2]], [4, [2, 2], [-4]])], [([[-2, -2, -2], [-2, 1]], [1, [-6, -2], [-14]]), ([[-2, -2, -2], [-1, 1]], [1, [-4, -2], [-6]]), ([[-2, -2, -2], [-2, -2]], [4, [0, 4], [-8]]), ([[2, 2], [2, 2]], [2, [2], []]), ([[-2, -2, -1], [1, 1]], [1, [-1, -1], [-1]]), ([[-2, -2, -1], [1, 2]], [4, [-3, -2], [-5]]), ([[-2, -2, -1], [2, -2]], [4, [6, 2], [-20]]), ([[-2, -2, -1], [2, -1]], [1, [4, 1], [-10]])], [([[-2, -2, -2], [-2, 2]], [4, [-8, -4], [-24]]), ([[-2, -2, -2], [0, -1]], [1, [2, 2], [-2]]), ([[-2, -2, -2], [-2, -2]], [4, [0, 4], [-8]]), ([[2, 2], [2, 2]], [2, [2], []]), ([[-2, -2, 1], [0, 2]], [4, [-4, 2], [-8]]), ([[-2, -2, 1], [1, -2]], [4, [3, -2], [-11]]), ([[-2, -2, 1], [1, -1]], [1, [1, -1], [-3]]), ([[-2, -2, 1], [1, 1]], [1, [-3, 1], [1]])], [([[-2, -2, -2], [-1, -2]], [4, [2, 4], [-6]]), ([[-2, -2, -2], [1, -2]], [4, [6, 4], [-14]]), ([[-2, -2, -2], [-2, -2]], [4, [0, 4], [-8]]), ([[2, 2], [2, 2]], [2, [2], []]), ([[-2, -2, 2], [0, -2]], [4, [4, -4], [-8]]), ([[-2, -2, 2], [0, -1]], [1, [2, -2], [-2]]), ([[-2, -2, 2], [0, 1]], [1, [-2, 2], [-2]]), ([[-2, -2, 2], [0, 2]], [4, [-4, 4], [-8]])]]
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[4, [0, 4], [-8]][4, [0, 4], [-8]]Passed
explicit oracle 1[2, [2], []][2, [2], []]Passed
explicit oracle 2[1, [-2, 2], [-6]][1, [-2, 2], [-6]]Passed
explicit oracle 3[1, [-6, -2], [-14]][1, [-6, -2], [-14]]Passed
explicit oracle 4[4, [-8, -4], [-24]][4, [-8, -4], [-24]]Passed
explicit oracle 5[4, [2, 4], [-6]][4, [2, 4], [-6]]Passed
explicit oracle 6[1, [0, 2], [-2]][1, [0, 2], [-2]]Passed
explicit oracle 7[1, [-4, -2], [-6]][1, [-4, -2], [-6]]Passed

SHA-256 / e148c589c513c8b1ec1438f3be0327ddc80d69ad68d83a93aef7c32049a4d03d

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

Case digest / 588edf859fe6d3c8bc995ce7fbcf68a2eb6eaf43301be7100ab64bc61fd37f20