FA-5376 / Integer arithmetic / Open access
Unsigned saturating subtraction · case 01
Underflow wraps into a large positive number.
ROOT CAUSE
Underflow wraps into a large positive number.
VERIFIED REPAIR
Apply the specified mathematical contract directly, preserving all terms and boundary cases: return max(0,a-b)
Unsuccessful approach: Absolute difference reverses an underflow into a positive result.
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. a and b are unsigned words; floor a-b at zero. Exact operational definition: max(0,a-b)
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(a, b, bits):
return (a-b)%(1<<bits)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (1, 3, 8)', solve(*(1, 3, 8)), 0)
check('fixture 2: (3, 1, 8)', solve(*(3, 1, 8)), 2)
check('fixture 3: (0, 0, 8)', solve(*(0, 0, 8)), 0)
check('fixture 4: (255, 255, 8)', solve(*(255, 255, 8)), 0)
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: (1, 3, 8) | 254 | 0 | Failed |
| fixture 2: (3, 1, 8) | 2 | 2 | Passed |
| fixture 3: (0, 0, 8) | 0 | 0 | Passed |
| fixture 4: (255, 255, 8) | 0 | 0 | Passed |
SHA-256 / 6bafdd7a4b26bd77e0f7c612da559d1e0e362bf904315a92d87a1d32c768a8fc
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(a, b, bits):
return abs(a-b)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (1, 3, 8)', solve(*(1, 3, 8)), 0)
check('fixture 2: (3, 1, 8)', solve(*(3, 1, 8)), 2)
check('fixture 3: (0, 0, 8)', solve(*(0, 0, 8)), 0)
check('fixture 4: (255, 255, 8)', solve(*(255, 255, 8)), 0)
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: (1, 3, 8) | 2 | 0 | Failed |
| fixture 2: (3, 1, 8) | 2 | 2 | Passed |
| fixture 3: (0, 0, 8) | 0 | 0 | Passed |
| fixture 4: (255, 255, 8) | 0 | 0 | Passed |
SHA-256 / a813f21ba99312a7b294eee9dceff6348172b69794a2f57acdbfb570028f1fd8
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(a, b, bits):
return max(0,a-b)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (1, 3, 8)', solve(*(1, 3, 8)), 0)
check('fixture 2: (3, 1, 8)', solve(*(3, 1, 8)), 2)
check('fixture 3: (0, 0, 8)', solve(*(0, 0, 8)), 0)
check('fixture 4: (255, 255, 8)', solve(*(255, 255, 8)), 0)
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: (1, 3, 8) | 0 | 0 | Passed |
| fixture 2: (3, 1, 8) | 2 | 2 | Passed |
| fixture 3: (0, 0, 8) | 0 | 0 | Passed |
| fixture 4: (255, 255, 8) | 0 | 0 | Passed |
SHA-256 / 4c69683fff5502d675f5958e9f89614b5907097e5641d604c5029eaa28b022e7
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:48.636930+00:00.
Case digest / 652cda199827cedb067e949bd962f360b6eabb9e815b527ed74bc121df99abf7