FA-5426 / Integer arithmetic / Open access
Binary gray decode · case 01
Encoding a Gray word again does not decode it.
ROOT CAUSE
Encoding a Gray word again does not decode it.
VERIFIED REPAIR
Apply the specified mathematical contract directly, preserving all terms and boundary cases: result=0 while n: result ^= n n >>= 1 return result
Unsuccessful approach: A single OR cannot accumulate the prefix XOR.
Case contract
Integer arguments; denominators, steps, moduli, and bit widths are positive. Unsigned word inputs fit the specified width except where masking is explicitly the operation. Sequence sizes are nonnegative. n is a nonnegative Gray code word; return its decoded binary integer. Exact operational definition: result=0 while n: result ^= n n >>= 1 return result
Why this case matters
Small exact fixtures expose this error without platform timing, external services, or probabilistic observations. Integer mathematics results depend on the stated convention.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR
N = 1
observations = []
def solve(n):
return n ^ (n>>1)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (0,)', solve(*(0,)), 0)
check('fixture 2: (1,)', solve(*(1,)), 1)
check('fixture 3: (3,)', solve(*(3,)), 2)
check('fixture 4: (4,)', solve(*(4,)), 7)
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 |
|---|---|---|---|
| fixture 1: (0,) | 0 | 0 | Passed |
| fixture 2: (1,) | 1 | 1 | Passed |
| fixture 3: (3,) | 2 | 2 | Passed |
| fixture 4: (4,) | 6 | 7 | Failed |
SHA-256 / 9e68373068a567b06d11373ea7e453ce243dd29c8db9efbfac29deedc1943e23
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR
N = 1
observations = []
def solve(n):
return n | (n>>1)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (0,)', solve(*(0,)), 0)
check('fixture 2: (1,)', solve(*(1,)), 1)
check('fixture 3: (3,)', solve(*(3,)), 2)
check('fixture 4: (4,)', solve(*(4,)), 7)
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 |
|---|---|---|---|
| fixture 1: (0,) | 0 | 0 | Passed |
| fixture 2: (1,) | 1 | 1 | Passed |
| fixture 3: (3,) | 3 | 2 | Failed |
| fixture 4: (4,) | 6 | 7 | Failed |
SHA-256 / 1707a76f6f5150286f79334a5e3f4a06110f3b9ca7e013b237f30d338334fce3
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR
N = 1
observations = []
def solve(n):
result=0
while n:
result ^= n
n >>= 1
return result
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (0,)', solve(*(0,)), 0)
check('fixture 2: (1,)', solve(*(1,)), 1)
check('fixture 3: (3,)', solve(*(3,)), 2)
check('fixture 4: (4,)', solve(*(4,)), 7)
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 |
|---|---|---|---|
| fixture 1: (0,) | 0 | 0 | Passed |
| fixture 2: (1,) | 1 | 1 | Passed |
| fixture 3: (3,) | 2 | 2 | Passed |
| fixture 4: (4,) | 7 | 7 | Passed |
SHA-256 / 1a8e6ea1a5660af8895cbd5625132b15c6d43e8124d9766e63e56a9c2d476835
Verification & scope
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:37:49.457537+00:00.
Case digest / b5288af1f4a00289c02701fd0fae99037d3a1a2e4424ecceac4b4f7fdf9faace