FAILURE MAP
← Case archive

FA-15056 / Numerics / Open access

Negative radix encoding: negative base digit order · case 01

The exact negative radix encoding result violates the stated contract at negative base digit order.

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

ROOT CAUSE

The negative base digit order step uses out instead of out[::-1].

VERIFIED REPAIR

Use out[::-1] at the negative base digit order step.

Unsuccessful approach: The partial repair sorted(out) still violates the negative base digit order invariant.

Case contract

Input [integer, magnitude base>=2]; return most-significant-first digits 0..base-1 representing integer in radix -base. Bounds: |integer|<=100 and base<=8.

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):
    n,b=x
    if n==0:return [0]
    out=[]
    for _ in range(60):
     if n==0:break
     r=n%b
     out.append(r)
     n=(n-r)//(-b)
    return out if bool(out) else []
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([-100, 2], [1, 1, 1, 0, 1, 1, 0, 0]), ([100, 8], [2, 4, 4]), ([-100, 3], [1, 2, 1, 1, 1, 2]), ([-100, 4], [2, 2, 1, 0]), ([-100, 5], [1, 1, 0, 0]), ([-100, 6], [1, 4, 5, 2]), ([-100, 7], [1, 5, 1, 5]), ([-100, 8], [1, 7, 5, 4])], [([-100, 3], [1, 2, 1, 1, 1, 2]), ([-100, 5], [1, 1, 0, 0]), ([-100, 2], [1, 1, 1, 0, 1, 1, 0, 0]), ([100, 8], [2, 4, 4]), ([-98, 5], [1, 1, 0, 2]), ([-98, 6], [1, 4, 5, 4]), ([-98, 7], [1, 5, 0, 0]), ([-98, 8], [1, 7, 5, 6])], [([-100, 4], [2, 2, 1, 0]), ([-100, 8], [1, 7, 5, 4]), ([-100, 2], [1, 1, 1, 0, 1, 1, 0, 0]), ([100, 8], [2, 4, 4]), ([-96, 8], [1, 7, 4, 0]), ([-95, 2], [1, 1, 1, 0, 0, 0, 0, 1]), ([-95, 3], [1, 2, 1, 2, 2, 1]), ([-95, 4], [2, 2, 0, 1])], [([-100, 5], [1, 1, 0, 0]), ([-99, 4], [2, 2, 1, 1]), ([-100, 2], [1, 1, 1, 0, 1, 1, 0, 0]), ([100, 8], [2, 4, 4]), ([-93, 4], [2, 2, 0, 3]), ([-93, 5], [1, 2, 4, 2]), ([-93, 6], [1, 4, 4, 3]), ([-93, 7], [1, 5, 0, 5])], [([-100, 6], [1, 4, 5, 2]), ([-99, 7], [1, 5, 1, 6]), ([-100, 2], [1, 1, 1, 0, 1, 1, 0, 0]), ([100, 8], [2, 4, 4]), ([-91, 7], [1, 6, 6, 0]), ([-91, 8], [1, 7, 4, 5]), ([-90, 2], [1, 1, 1, 1, 1, 0, 1, 0]), ([-90, 3], [1, 2, 1, 2, 0, 0])]]
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[0, 0, 1, 1, 0, 1, 1, 1][1, 1, 1, 0, 1, 1, 0, 0]Failed
explicit oracle 1[4, 4, 2][2, 4, 4]Failed
explicit oracle 2[2, 1, 1, 1, 2, 1][1, 2, 1, 1, 1, 2]Failed
explicit oracle 3[0, 1, 2, 2][2, 2, 1, 0]Failed
explicit oracle 4[0, 0, 1, 1][1, 1, 0, 0]Failed
explicit oracle 5[2, 5, 4, 1][1, 4, 5, 2]Failed
explicit oracle 6[5, 1, 5, 1][1, 5, 1, 5]Failed
explicit oracle 7[4, 5, 7, 1][1, 7, 5, 4]Failed

SHA-256 / fa2f1390421f3eaddb82da03780ba8d7888ca137306cf89cfea80e4cb74ab3c3

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):
    n,b=x
    if n==0:return [0]
    out=[]
    for _ in range(60):
     if n==0:break
     r=n%b
     out.append(r)
     n=(n-r)//(-b)
    return sorted(out) if bool(out) else []
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([-100, 2], [1, 1, 1, 0, 1, 1, 0, 0]), ([100, 8], [2, 4, 4]), ([-100, 3], [1, 2, 1, 1, 1, 2]), ([-100, 4], [2, 2, 1, 0]), ([-100, 5], [1, 1, 0, 0]), ([-100, 6], [1, 4, 5, 2]), ([-100, 7], [1, 5, 1, 5]), ([-100, 8], [1, 7, 5, 4])], [([-100, 3], [1, 2, 1, 1, 1, 2]), ([-100, 5], [1, 1, 0, 0]), ([-100, 2], [1, 1, 1, 0, 1, 1, 0, 0]), ([100, 8], [2, 4, 4]), ([-98, 5], [1, 1, 0, 2]), ([-98, 6], [1, 4, 5, 4]), ([-98, 7], [1, 5, 0, 0]), ([-98, 8], [1, 7, 5, 6])], [([-100, 4], [2, 2, 1, 0]), ([-100, 8], [1, 7, 5, 4]), ([-100, 2], [1, 1, 1, 0, 1, 1, 0, 0]), ([100, 8], [2, 4, 4]), ([-96, 8], [1, 7, 4, 0]), ([-95, 2], [1, 1, 1, 0, 0, 0, 0, 1]), ([-95, 3], [1, 2, 1, 2, 2, 1]), ([-95, 4], [2, 2, 0, 1])], [([-100, 5], [1, 1, 0, 0]), ([-99, 4], [2, 2, 1, 1]), ([-100, 2], [1, 1, 1, 0, 1, 1, 0, 0]), ([100, 8], [2, 4, 4]), ([-93, 4], [2, 2, 0, 3]), ([-93, 5], [1, 2, 4, 2]), ([-93, 6], [1, 4, 4, 3]), ([-93, 7], [1, 5, 0, 5])], [([-100, 6], [1, 4, 5, 2]), ([-99, 7], [1, 5, 1, 6]), ([-100, 2], [1, 1, 1, 0, 1, 1, 0, 0]), ([100, 8], [2, 4, 4]), ([-91, 7], [1, 6, 6, 0]), ([-91, 8], [1, 7, 4, 5]), ([-90, 2], [1, 1, 1, 1, 1, 0, 1, 0]), ([-90, 3], [1, 2, 1, 2, 0, 0])]]
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[0, 0, 0, 1, 1, 1, 1, 1][1, 1, 1, 0, 1, 1, 0, 0]Failed
explicit oracle 1[2, 4, 4][2, 4, 4]Passed
explicit oracle 2[1, 1, 1, 1, 2, 2][1, 2, 1, 1, 1, 2]Failed
explicit oracle 3[0, 1, 2, 2][2, 2, 1, 0]Failed
explicit oracle 4[0, 0, 1, 1][1, 1, 0, 0]Failed
explicit oracle 5[1, 2, 4, 5][1, 4, 5, 2]Failed
explicit oracle 6[1, 1, 5, 5][1, 5, 1, 5]Failed
explicit oracle 7[1, 4, 5, 7][1, 7, 5, 4]Failed

SHA-256 / a60d039d28f5d3851e8f524c3763de9e35762ebda802551c1a5cfdf505b3b859

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):
    n,b=x
    if n==0:return [0]
    out=[]
    for _ in range(60):
     if n==0:break
     r=n%b
     out.append(r)
     n=(n-r)//(-b)
    return out[::-1] if bool(out) else []
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([-100, 2], [1, 1, 1, 0, 1, 1, 0, 0]), ([100, 8], [2, 4, 4]), ([-100, 3], [1, 2, 1, 1, 1, 2]), ([-100, 4], [2, 2, 1, 0]), ([-100, 5], [1, 1, 0, 0]), ([-100, 6], [1, 4, 5, 2]), ([-100, 7], [1, 5, 1, 5]), ([-100, 8], [1, 7, 5, 4])], [([-100, 3], [1, 2, 1, 1, 1, 2]), ([-100, 5], [1, 1, 0, 0]), ([-100, 2], [1, 1, 1, 0, 1, 1, 0, 0]), ([100, 8], [2, 4, 4]), ([-98, 5], [1, 1, 0, 2]), ([-98, 6], [1, 4, 5, 4]), ([-98, 7], [1, 5, 0, 0]), ([-98, 8], [1, 7, 5, 6])], [([-100, 4], [2, 2, 1, 0]), ([-100, 8], [1, 7, 5, 4]), ([-100, 2], [1, 1, 1, 0, 1, 1, 0, 0]), ([100, 8], [2, 4, 4]), ([-96, 8], [1, 7, 4, 0]), ([-95, 2], [1, 1, 1, 0, 0, 0, 0, 1]), ([-95, 3], [1, 2, 1, 2, 2, 1]), ([-95, 4], [2, 2, 0, 1])], [([-100, 5], [1, 1, 0, 0]), ([-99, 4], [2, 2, 1, 1]), ([-100, 2], [1, 1, 1, 0, 1, 1, 0, 0]), ([100, 8], [2, 4, 4]), ([-93, 4], [2, 2, 0, 3]), ([-93, 5], [1, 2, 4, 2]), ([-93, 6], [1, 4, 4, 3]), ([-93, 7], [1, 5, 0, 5])], [([-100, 6], [1, 4, 5, 2]), ([-99, 7], [1, 5, 1, 6]), ([-100, 2], [1, 1, 1, 0, 1, 1, 0, 0]), ([100, 8], [2, 4, 4]), ([-91, 7], [1, 6, 6, 0]), ([-91, 8], [1, 7, 4, 5]), ([-90, 2], [1, 1, 1, 1, 1, 0, 1, 0]), ([-90, 3], [1, 2, 1, 2, 0, 0])]]
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, 1, 0, 1, 1, 0, 0][1, 1, 1, 0, 1, 1, 0, 0]Passed
explicit oracle 1[2, 4, 4][2, 4, 4]Passed
explicit oracle 2[1, 2, 1, 1, 1, 2][1, 2, 1, 1, 1, 2]Passed
explicit oracle 3[2, 2, 1, 0][2, 2, 1, 0]Passed
explicit oracle 4[1, 1, 0, 0][1, 1, 0, 0]Passed
explicit oracle 5[1, 4, 5, 2][1, 4, 5, 2]Passed
explicit oracle 6[1, 5, 1, 5][1, 5, 1, 5]Passed
explicit oracle 7[1, 7, 5, 4][1, 7, 5, 4]Passed

SHA-256 / 5aa53f613ba800365d32da22737268ee353c9f9084ce402de97b5ff88652a7af

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

Case digest / 0bb2b27649371ad80cd0e64ec9c297b671eeee12fd295c0f38c89a19e0f29b2f