FAILURE MAP
← Case archive

FA-15661 / Numerics / Open access

Binary field inversion: constant polynomial termination · case 01

The exact binary field inversion result violates the stated contract at constant polynomial termination.

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

ROOT CAUSE

The constant polynomial termination step uses u&1 instead of u==1.

VERIFIED REPAIR

Use u==1 at the constant polynomial termination step.

Unsuccessful approach: The partial repair u.bit_length()<=2 still violates the constant polynomial termination invariant.

Case contract

Input [a,irreducible bitmask], a nonzero with degree below modulus; return multiplicative inverse in binary field. Bounds: modulus degree is between two and six.

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,p=x;u=a;v=p;g1=1;g2=0
    for _ in range(60):
     if u&1:break
     if u==0:return None
     j=u.bit_length()-v.bit_length()
     if j<0:
      u,v=v,u;g1,g2=g2,g1;j=-j
     u=u^(v<<j)
     g1=g1^(g2<<j)
    for _ in range(60):
     if g1.bit_length()<p.bit_length():break
     g1=g1^(p<<(g1.bit_length()-p.bit_length()))
    return g1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([2, 7], 3), ([1, 7], 1), ([63, 67], 32), ([3, 7], 2), ([1, 11], 1), ([2, 11], 5), ([3, 11], 6), ([4, 11], 7)], [([3, 7], 2), ([3, 11], 6), ([1, 7], 1), ([63, 67], 32), ([8, 19], 15), ([9, 19], 2), ([10, 19], 12), ([11, 19], 5)], [([2, 11], 5), ([2, 19], 9), ([1, 7], 1), ([63, 67], 32), ([10, 25], 11), ([11, 25], 10), ([12, 25], 2), ([13, 25], 9)], [([3, 11], 6), ([5, 19], 11), ([1, 7], 1), ([63, 67], 32), ([12, 31], 13), ([13, 31], 12), ([14, 31], 11), ([15, 31], 2)], [([4, 11], 7), ([12, 19], 10), ([1, 7], 1), ([63, 67], 32), ([14, 37], 6), ([15, 37], 13), ([16, 37], 11), ([17, 37], 24)]]
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 023Failed
explicit oracle 111Passed
explicit oracle 2132Failed
explicit oracle 312Failed
explicit oracle 411Passed
explicit oracle 545Failed
explicit oracle 616Failed
explicit oracle 727Failed

SHA-256 / f4f1907ba0b844ff2c10198c41d39f8d64e0cacefbef8fa2710dee0a1acb7270

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,p=x;u=a;v=p;g1=1;g2=0
    for _ in range(60):
     if u.bit_length()<=2:break
     if u==0:return None
     j=u.bit_length()-v.bit_length()
     if j<0:
      u,v=v,u;g1,g2=g2,g1;j=-j
     u=u^(v<<j)
     g1=g1^(g2<<j)
    for _ in range(60):
     if g1.bit_length()<p.bit_length():break
     g1=g1^(p<<(g1.bit_length()-p.bit_length()))
    return g1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([2, 7], 3), ([1, 7], 1), ([63, 67], 32), ([3, 7], 2), ([1, 11], 1), ([2, 11], 5), ([3, 11], 6), ([4, 11], 7)], [([3, 7], 2), ([3, 11], 6), ([1, 7], 1), ([63, 67], 32), ([8, 19], 15), ([9, 19], 2), ([10, 19], 12), ([11, 19], 5)], [([2, 11], 5), ([2, 19], 9), ([1, 7], 1), ([63, 67], 32), ([10, 25], 11), ([11, 25], 10), ([12, 25], 2), ([13, 25], 9)], [([3, 11], 6), ([5, 19], 11), ([1, 7], 1), ([63, 67], 32), ([12, 31], 13), ([13, 31], 12), ([14, 31], 11), ([15, 31], 2)], [([4, 11], 7), ([12, 19], 10), ([1, 7], 1), ([63, 67], 32), ([14, 37], 6), ([15, 37], 13), ([16, 37], 11), ([17, 37], 24)]]
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 013Failed
explicit oracle 111Passed
explicit oracle 2332Failed
explicit oracle 312Failed
explicit oracle 411Passed
explicit oracle 515Failed
explicit oracle 616Failed
explicit oracle 727Failed

SHA-256 / 992c723b0c225713c3d945318c53436c5cf1a704d33874c401cd3e40807dbe66

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,p=x;u=a;v=p;g1=1;g2=0
    for _ in range(60):
     if u==1:break
     if u==0:return None
     j=u.bit_length()-v.bit_length()
     if j<0:
      u,v=v,u;g1,g2=g2,g1;j=-j
     u=u^(v<<j)
     g1=g1^(g2<<j)
    for _ in range(60):
     if g1.bit_length()<p.bit_length():break
     g1=g1^(p<<(g1.bit_length()-p.bit_length()))
    return g1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([2, 7], 3), ([1, 7], 1), ([63, 67], 32), ([3, 7], 2), ([1, 11], 1), ([2, 11], 5), ([3, 11], 6), ([4, 11], 7)], [([3, 7], 2), ([3, 11], 6), ([1, 7], 1), ([63, 67], 32), ([8, 19], 15), ([9, 19], 2), ([10, 19], 12), ([11, 19], 5)], [([2, 11], 5), ([2, 19], 9), ([1, 7], 1), ([63, 67], 32), ([10, 25], 11), ([11, 25], 10), ([12, 25], 2), ([13, 25], 9)], [([3, 11], 6), ([5, 19], 11), ([1, 7], 1), ([63, 67], 32), ([12, 31], 13), ([13, 31], 12), ([14, 31], 11), ([15, 31], 2)], [([4, 11], 7), ([12, 19], 10), ([1, 7], 1), ([63, 67], 32), ([14, 37], 6), ([15, 37], 13), ([16, 37], 11), ([17, 37], 24)]]
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 033Passed
explicit oracle 111Passed
explicit oracle 23232Passed
explicit oracle 322Passed
explicit oracle 411Passed
explicit oracle 555Passed
explicit oracle 666Passed
explicit oracle 777Passed

SHA-256 / 0b575732c5243d3ae61d214515632f01650eec1da7109da113166a37788abeb2

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

Case digest / 5a62787bbd5b451f39d2fce68f7e8443a10383cbe54d75bcbb0476b17a21d1f0