FA-15031 / Numerics / Open access
Balanced odd radix encoding: carry quotient · case 01
The exact balanced odd radix encoding result violates the stated contract at carry quotient.
ROOT CAUSE
The carry quotient step uses n//b instead of (n-r)//b.
VERIFIED REPAIR
Use (n-r)//b at the carry quotient step.
Unsuccessful approach: The partial repair (n+r)//b still violates the carry quotient invariant.
Case contract
Input [integer, odd radix>=3]; return least-significant-first balanced digits between -(base//2) and base//2, zero=[0]. Bounds: |integer|<=100 and radix<=9.
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=[];half=b//2
for _ in range(60):
if n==0:break
r=n%b
if r>half:r-=b
out.append(r)
n=n//b
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([-100, 3], [-1, 0, 1, -1, -1]), ([100, 9], [1, 2, 1]), ([-100, 5], [0, 0, 1, -1]), ([-100, 7], [-2, 0, -2]), ([-100, 9], [-1, -2, -1]), ([-99, 3], [0, 0, 1, -1, -1]), ([-99, 5], [1, 0, 1, -1]), ([-99, 7], [-1, 0, -2])], [([-100, 5], [0, 0, 1, -1]), ([-100, 9], [-1, -2, -1]), ([-100, 3], [-1, 0, 1, -1, -1]), ([100, 9], [1, 2, 1]), ([-96, 5], [-1, 1, 1, -1]), ([-96, 7], [2, 0, -2]), ([-96, 9], [3, -2, -1]), ([-95, 3], [1, 1, 1, -1, -1])], [([-100, 7], [-2, 0, -2]), ([-99, 7], [-1, 0, -2]), ([-100, 3], [-1, 0, 1, -1, -1]), ([100, 9], [1, 2, 1]), ([-92, 7], [-1, 1, -2]), ([-92, 9], [-2, -1, -1]), ([-91, 3], [-1, 0, -1, 0, -1]), ([-91, 5], [-1, 2, 1, -1])], [([-100, 9], [-1, -2, -1]), ([-98, 5], [2, 0, 1, -1]), ([-100, 3], [-1, 0, 1, -1, -1]), ([100, 9], [1, 2, 1]), ([-88, 9], [2, -1, -1]), ([-87, 3], [0, 1, -1, 0, -1]), ([-87, 5], [-2, -2, 2, -1]), ([-87, 7], [-3, 2, -2])], [([-99, 3], [0, 0, 1, -1, -1]), ([-97, 3], [-1, 1, 1, -1, -1]), ([-100, 3], [-1, 0, 1, -1, -1]), ([100, 9], [1, 2, 1]), ([-83, 3], [1, -1, 0, 0, -1]), ([-83, 5], [2, -2, 2, -1]), ([-83, 7], [1, 2, -2]), ([-83, 9], [-2, 0, -1])]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| explicit oracle 0 | [-1, -1, 0, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] | [-1, 0, 1, -1, -1] | Failed |
| explicit oracle 1 | [1, 2, 1] | [1, 2, 1] | Passed |
| explicit oracle 2 | [0, 0, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] | [0, 0, 1, -1] | Failed |
| explicit oracle 3 | [-2, -1, -3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] | [-2, 0, -2] | Failed |
| explicit oracle 4 | [-1, -3, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] | [-1, -2, -1] | Failed |
| explicit oracle 5 | [0, 0, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] | [0, 0, 1, -1, -1] | Failed |
| explicit oracle 6 | [1, 0, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] | [1, 0, 1, -1] | Failed |
| explicit oracle 7 | [-1, -1, -3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] | [-1, 0, -2] | Failed |
SHA-256 / d4db540d555fcc7762ec6cb04f8ccb2a4bd29d40863cf55d9d4c23c985cd3acd
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=[];half=b//2
for _ in range(60):
if n==0:break
r=n%b
if r>half:r-=b
out.append(r)
n=(n+r)//b
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([-100, 3], [-1, 0, 1, -1, -1]), ([100, 9], [1, 2, 1]), ([-100, 5], [0, 0, 1, -1]), ([-100, 7], [-2, 0, -2]), ([-100, 9], [-1, -2, -1]), ([-99, 3], [0, 0, 1, -1, -1]), ([-99, 5], [1, 0, 1, -1]), ([-99, 7], [-1, 0, -2])], [([-100, 5], [0, 0, 1, -1]), ([-100, 9], [-1, -2, -1]), ([-100, 3], [-1, 0, 1, -1, -1]), ([100, 9], [1, 2, 1]), ([-96, 5], [-1, 1, 1, -1]), ([-96, 7], [2, 0, -2]), ([-96, 9], [3, -2, -1]), ([-95, 3], [1, 1, 1, -1, -1])], [([-100, 7], [-2, 0, -2]), ([-99, 7], [-1, 0, -2]), ([-100, 3], [-1, 0, 1, -1, -1]), ([100, 9], [1, 2, 1]), ([-92, 7], [-1, 1, -2]), ([-92, 9], [-2, -1, -1]), ([-91, 3], [-1, 0, -1, 0, -1]), ([-91, 5], [-1, 2, 1, -1])], [([-100, 9], [-1, -2, -1]), ([-98, 5], [2, 0, 1, -1]), ([-100, 3], [-1, 0, 1, -1, -1]), ([100, 9], [1, 2, 1]), ([-88, 9], [2, -1, -1]), ([-87, 3], [0, 1, -1, 0, -1]), ([-87, 5], [-2, -2, 2, -1]), ([-87, 7], [-3, 2, -2])], [([-99, 3], [0, 0, 1, -1, -1]), ([-97, 3], [-1, 1, 1, -1, -1]), ([-100, 3], [-1, 0, 1, -1, -1]), ([100, 9], [1, 2, 1]), ([-83, 3], [1, -1, 0, 0, -1]), ([-83, 5], [2, -2, 2, -1]), ([-83, 7], [1, 2, -2]), ([-83, 9], [-2, 0, -1])]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| explicit oracle 0 | [-1, -1, 0, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] | [-1, 0, 1, -1, -1] | Failed |
| explicit oracle 1 | [1, 2, 1] | [1, 2, 1] | Passed |
| explicit oracle 2 | [0, 0, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] | [0, 0, 1, -1] | Failed |
| explicit oracle 3 | [-2, -1, -3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] | [-2, 0, -2] | Failed |
| explicit oracle 4 | [-1, -3, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] | [-1, -2, -1] | Failed |
| explicit oracle 5 | [0, 0, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] | [0, 0, 1, -1, -1] | Failed |
| explicit oracle 6 | [1, 0, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] | [1, 0, 1, -1] | Failed |
| explicit oracle 7 | [-1, -1, -3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] | [-1, 0, -2] | Failed |
SHA-256 / 15dc96152eedd839596d5c9871bc5defd94652cb5c8c8fcde5ede6040c14dd3e
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=[];half=b//2
for _ in range(60):
if n==0:break
r=n%b
if r>half:r-=b
out.append(r)
n=(n-r)//b
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([-100, 3], [-1, 0, 1, -1, -1]), ([100, 9], [1, 2, 1]), ([-100, 5], [0, 0, 1, -1]), ([-100, 7], [-2, 0, -2]), ([-100, 9], [-1, -2, -1]), ([-99, 3], [0, 0, 1, -1, -1]), ([-99, 5], [1, 0, 1, -1]), ([-99, 7], [-1, 0, -2])], [([-100, 5], [0, 0, 1, -1]), ([-100, 9], [-1, -2, -1]), ([-100, 3], [-1, 0, 1, -1, -1]), ([100, 9], [1, 2, 1]), ([-96, 5], [-1, 1, 1, -1]), ([-96, 7], [2, 0, -2]), ([-96, 9], [3, -2, -1]), ([-95, 3], [1, 1, 1, -1, -1])], [([-100, 7], [-2, 0, -2]), ([-99, 7], [-1, 0, -2]), ([-100, 3], [-1, 0, 1, -1, -1]), ([100, 9], [1, 2, 1]), ([-92, 7], [-1, 1, -2]), ([-92, 9], [-2, -1, -1]), ([-91, 3], [-1, 0, -1, 0, -1]), ([-91, 5], [-1, 2, 1, -1])], [([-100, 9], [-1, -2, -1]), ([-98, 5], [2, 0, 1, -1]), ([-100, 3], [-1, 0, 1, -1, -1]), ([100, 9], [1, 2, 1]), ([-88, 9], [2, -1, -1]), ([-87, 3], [0, 1, -1, 0, -1]), ([-87, 5], [-2, -2, 2, -1]), ([-87, 7], [-3, 2, -2])], [([-99, 3], [0, 0, 1, -1, -1]), ([-97, 3], [-1, 1, 1, -1, -1]), ([-100, 3], [-1, 0, 1, -1, -1]), ([100, 9], [1, 2, 1]), ([-83, 3], [1, -1, 0, 0, -1]), ([-83, 5], [2, -2, 2, -1]), ([-83, 7], [1, 2, -2]), ([-83, 9], [-2, 0, -1])]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| explicit oracle 0 | [-1, 0, 1, -1, -1] | [-1, 0, 1, -1, -1] | Passed |
| explicit oracle 1 | [1, 2, 1] | [1, 2, 1] | Passed |
| explicit oracle 2 | [0, 0, 1, -1] | [0, 0, 1, -1] | Passed |
| explicit oracle 3 | [-2, 0, -2] | [-2, 0, -2] | Passed |
| explicit oracle 4 | [-1, -2, -1] | [-1, -2, -1] | Passed |
| explicit oracle 5 | [0, 0, 1, -1, -1] | [0, 0, 1, -1, -1] | Passed |
| explicit oracle 6 | [1, 0, 1, -1] | [1, 0, 1, -1] | Passed |
| explicit oracle 7 | [-1, 0, -2] | [-1, 0, -2] | Passed |
SHA-256 / a3840837212030eab0dd89ebe18a97c99f80a2a6033135b6bfde29bcaf539489
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.694415+00:00.
Case digest / 837b035ec68d3d8ae814bfbc406e15f378c878b01eef81be19739f20d507f93d