FA-5381 / Integer arithmetic / Open access
Signed saturating addition · case 01
Only positive overflow is bounded.
ROOT CAUSE
Only positive overflow is bounded.
VERIFIED REPAIR
Apply the specified mathematical contract directly, preserving all terms and boundary cases: return max(-(1<<(bits-1)), min((1<<(bits-1))-1,a+b))
Unsuccessful approach: A symmetric bound excludes the representable negative endpoint.
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. Cap a+b to [-2**(bits-1),2**(bits-1)-1]. Exact operational definition: max(-(1<<(bits-1)), min((1<<(bits-1))-1,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 min((1<<(bits-1))-1,a+b)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (-120, -20, 8)', solve(*(-120, -20, 8)), -128)
check('fixture 2: (120, 20, 8)', solve(*(120, 20, 8)), 127)
check('fixture 3: (1, -1, 8)', solve(*(1, -1, 8)), 0)
check('fixture 4: (-128, 0, 8)', solve(*(-128, 0, 8)), -128)
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: (-120, -20, 8) | -140 | -128 | Failed |
| fixture 2: (120, 20, 8) | 127 | 127 | Passed |
| fixture 3: (1, -1, 8) | 0 | 0 | Passed |
| fixture 4: (-128, 0, 8) | -128 | -128 | Passed |
SHA-256 / e9494df1baed8880a25e2734a61bc99b4e72abc1035337d9a9997f9a6ef0bdb8
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 max(-(1<<(bits-1))+1, min((1<<(bits-1))-1,a+b))
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (-120, -20, 8)', solve(*(-120, -20, 8)), -128)
check('fixture 2: (120, 20, 8)', solve(*(120, 20, 8)), 127)
check('fixture 3: (1, -1, 8)', solve(*(1, -1, 8)), 0)
check('fixture 4: (-128, 0, 8)', solve(*(-128, 0, 8)), -128)
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: (-120, -20, 8) | -127 | -128 | Failed |
| fixture 2: (120, 20, 8) | 127 | 127 | Passed |
| fixture 3: (1, -1, 8) | 0 | 0 | Passed |
| fixture 4: (-128, 0, 8) | -127 | -128 | Failed |
SHA-256 / 78ef09f17a52bb08b8616c6b687bbc2816db4c0c3e16612157ec818743d44572
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(-(1<<(bits-1)), min((1<<(bits-1))-1,a+b))
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (-120, -20, 8)', solve(*(-120, -20, 8)), -128)
check('fixture 2: (120, 20, 8)', solve(*(120, 20, 8)), 127)
check('fixture 3: (1, -1, 8)', solve(*(1, -1, 8)), 0)
check('fixture 4: (-128, 0, 8)', solve(*(-128, 0, 8)), -128)
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: (-120, -20, 8) | -128 | -128 | Passed |
| fixture 2: (120, 20, 8) | 127 | 127 | Passed |
| fixture 3: (1, -1, 8) | 0 | 0 | Passed |
| fixture 4: (-128, 0, 8) | -128 | -128 | Passed |
SHA-256 / 7402f5d0c405b449e8c05d69d357099ca04bf3ce3c50c01e7c9ae0ac3efe7378
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.713471+00:00.
Case digest / 7368a38a502840fc6f3cc3cd0f618af81c17b55b032c9136c5cf2834cb7a8c49