FA-5421 / Integer arithmetic / Open access
Binary gray encode · case 01
OR retains overlaps that Gray coding must cancel.
ROOT CAUSE
OR retains overlaps that Gray coding must cancel.
VERIFIED REPAIR
Apply the specified mathematical contract directly, preserving all terms and boundary cases: return n ^ (n>>1)
Unsuccessful approach: The adjacent-bit comparison uses the wrong direction.
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 nonnegative; return the binary-reflected Gray code word. Exact operational definition: n ^ (n>>1)
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: (2,)', solve(*(2,)), 3)
check('fixture 4: (7,)', solve(*(7,)), 4)
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: (2,) | 3 | 3 | Passed |
| fixture 4: (7,) | 7 | 4 | Failed |
SHA-256 / 2a0e7699593b681a5c7b239e58dc64c966958cb7d2574a9ef88e6a8761f93159
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: (2,)', solve(*(2,)), 3)
check('fixture 4: (7,)', solve(*(7,)), 4)
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,) | 3 | 1 | Failed |
| fixture 3: (2,) | 6 | 3 | Failed |
| fixture 4: (7,) | 9 | 4 | Failed |
SHA-256 / 3b07391119dcd75daa88fc90492994934ba99646d520dda3ea9804388347af03
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):
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: (2,)', solve(*(2,)), 3)
check('fixture 4: (7,)', solve(*(7,)), 4)
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: (2,) | 3 | 3 | Passed |
| fixture 4: (7,) | 4 | 4 | Passed |
SHA-256 / 9d5a86604af2a34b14687e40618dfe4a2455acf26a64ce78a21165f4a4323fe2
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.459861+00:00.
Case digest / 523013402ed3956d161c3648d5f75e7e5e23f5d8a8d5180681d254f80402797c