FA-16581 / Floating-point arithmetic / Open access
Infinity addition treats equal signs as invalid · case 01
Infinity addition treats equal signs as invalid.
ROOT CAUSE
Infinity addition treats equal signs as invalid. The faulty expression is if math.isinf(a) and math.isinf(b):.
VERIFIED REPAIR
Apply the contract at this fault site using if math.isinf(a) and math.isinf(b) and a!=b:.
Unsuccessful approach: The attempted local correction if math.isinf(a) or math.isinf(b): still violates the explicit regression fixtures.
Case contract
Stipulated binary64 addition policy: propagate first signaling NaN, otherwise largest quiet-NaN diagnostic payload (left wins ties); quiet propagated NaNs preserving sign. Opposite infinities produce canonical quiet NaN. Finite values use Python binary64 addition. Return bits and invalid flag.
Why this case matters
An offline floating representation model isolates a reproducible arithmetic fault.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(ab,bb):
mask=(1<<52)-1
an=(ab>>52)&2047==2047 and bool(ab&mask)
bn=(bb>>52)&2047==2047 and bool(bb&mask)
asig=an and not bool(ab&(1<<51))
bsig=bn and not bool(bb&(1<<51))
if asig or bsig:
chosen=ab if asig else bb
return [chosen|(1<<51),True]
if an or bn:
if an and bn:
chosen=ab if (ab&((1<<51)-1)) >= (bb&((1<<51)-1)) else bb
else:
chosen=ab if an else bb
return [chosen,False]
a=struct.unpack('>d',ab.to_bytes(8,'big'))[0]
b=struct.unpack('>d',bb.to_bytes(8,'big'))[0]
if math.isinf(a) and math.isinf(b):
return [0x7ff8000000000000,True]
result=a+b
return [int.from_bytes(struct.pack('>d',result),'big'),False]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('left signaling', solve(0x7ff0000000000000|N,0x3ff0000000000000), [0x7ff8000000000000|N,True])
check('right signaling', solve(0x3ff0000000000000,0xfff0000000000000|N), [0xfff8000000000000|N,True])
check('signaling precedence', solve(0x7ff8000000000064,0x7ff0000000000000|N), [0x7ff8000000000000|N,True])
check('two signaling', solve(0xfff0000000000000|N,0x7ff0000000000010), [0xfff8000000000000|N,True])
check('larger right payload', solve(0x7ff8000000000000|N,0xfff8000000000064), [0xfff8000000000064,False])
check('larger left payload', solve(0xfff8000000000064,0x7ff8000000000000|N), [0xfff8000000000064,False])
check('equal left wins', solve(0xfff8000000000000|N,0x7ff8000000000000|N), [0xfff8000000000000|N,False])
check('positive quiet', solve(0x7ff8000000000000|N,0x3ff0000000000000), [0x7ff8000000000000|N,False])
check('quiet left only', solve(0xfff8000000000000|N,0x3ff0000000000000), [0xfff8000000000000|N,False])
check('quiet right only', solve(0x3ff0000000000000,0xfff8000000000000|N), [0xfff8000000000000|N,False])
check('opposite infinities', solve(0x7ff0000000000000,0xfff0000000000000), [0x7ff8000000000000,True])
check('same infinity', solve(0xfff0000000000000,0xfff0000000000000), [0xfff0000000000000,False])
check('finite addition', solve(0x3ff0000000000000,0x3ff0000000000000), [0x4000000000000000,False])
check('negative zeros', solve(1<<63,1<<63), [1<<63,False])
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 |
|---|---|---|---|
| left signaling | [9221120237041090561, True] | [9221120237041090561, True] | Passed |
| right signaling | [18444492273895866369, True] | [18444492273895866369, True] | Passed |
| signaling precedence | [9221120237041090561, True] | [9221120237041090561, True] | Passed |
| two signaling | [18444492273895866369, True] | [18444492273895866369, True] | Passed |
| larger right payload | [18444492273895866468, False] | [18444492273895866468, False] | Passed |
| larger left payload | [18444492273895866468, False] | [18444492273895866468, False] | Passed |
| equal left wins | [18444492273895866369, False] | [18444492273895866369, False] | Passed |
| positive quiet | [9221120237041090561, False] | [9221120237041090561, False] | Passed |
| quiet left only | [18444492273895866369, False] | [18444492273895866369, False] | Passed |
| quiet right only | [18444492273895866369, False] | [18444492273895866369, False] | Passed |
| opposite infinities | [9221120237041090560, True] | [9221120237041090560, True] | Passed |
| same infinity | [9221120237041090560, True] | [18442240474082181120, False] | Failed |
| finite addition | [4611686018427387904, False] | [4611686018427387904, False] | Passed |
| negative zeros | [9223372036854775808, False] | [9223372036854775808, False] | Passed |
SHA-256 / f712c22002e0de60e46a4e4a7086785fcdf8849d36b3c604cfcfde4b29c3da6e
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(ab,bb):
mask=(1<<52)-1
an=(ab>>52)&2047==2047 and bool(ab&mask)
bn=(bb>>52)&2047==2047 and bool(bb&mask)
asig=an and not bool(ab&(1<<51))
bsig=bn and not bool(bb&(1<<51))
if asig or bsig:
chosen=ab if asig else bb
return [chosen|(1<<51),True]
if an or bn:
if an and bn:
chosen=ab if (ab&((1<<51)-1)) >= (bb&((1<<51)-1)) else bb
else:
chosen=ab if an else bb
return [chosen,False]
a=struct.unpack('>d',ab.to_bytes(8,'big'))[0]
b=struct.unpack('>d',bb.to_bytes(8,'big'))[0]
if math.isinf(a) or math.isinf(b):
return [0x7ff8000000000000,True]
result=a+b
return [int.from_bytes(struct.pack('>d',result),'big'),False]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('left signaling', solve(0x7ff0000000000000|N,0x3ff0000000000000), [0x7ff8000000000000|N,True])
check('right signaling', solve(0x3ff0000000000000,0xfff0000000000000|N), [0xfff8000000000000|N,True])
check('signaling precedence', solve(0x7ff8000000000064,0x7ff0000000000000|N), [0x7ff8000000000000|N,True])
check('two signaling', solve(0xfff0000000000000|N,0x7ff0000000000010), [0xfff8000000000000|N,True])
check('larger right payload', solve(0x7ff8000000000000|N,0xfff8000000000064), [0xfff8000000000064,False])
check('larger left payload', solve(0xfff8000000000064,0x7ff8000000000000|N), [0xfff8000000000064,False])
check('equal left wins', solve(0xfff8000000000000|N,0x7ff8000000000000|N), [0xfff8000000000000|N,False])
check('positive quiet', solve(0x7ff8000000000000|N,0x3ff0000000000000), [0x7ff8000000000000|N,False])
check('quiet left only', solve(0xfff8000000000000|N,0x3ff0000000000000), [0xfff8000000000000|N,False])
check('quiet right only', solve(0x3ff0000000000000,0xfff8000000000000|N), [0xfff8000000000000|N,False])
check('opposite infinities', solve(0x7ff0000000000000,0xfff0000000000000), [0x7ff8000000000000,True])
check('same infinity', solve(0xfff0000000000000,0xfff0000000000000), [0xfff0000000000000,False])
check('finite addition', solve(0x3ff0000000000000,0x3ff0000000000000), [0x4000000000000000,False])
check('negative zeros', solve(1<<63,1<<63), [1<<63,False])
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 |
|---|---|---|---|
| left signaling | [9221120237041090561, True] | [9221120237041090561, True] | Passed |
| right signaling | [18444492273895866369, True] | [18444492273895866369, True] | Passed |
| signaling precedence | [9221120237041090561, True] | [9221120237041090561, True] | Passed |
| two signaling | [18444492273895866369, True] | [18444492273895866369, True] | Passed |
| larger right payload | [18444492273895866468, False] | [18444492273895866468, False] | Passed |
| larger left payload | [18444492273895866468, False] | [18444492273895866468, False] | Passed |
| equal left wins | [18444492273895866369, False] | [18444492273895866369, False] | Passed |
| positive quiet | [9221120237041090561, False] | [9221120237041090561, False] | Passed |
| quiet left only | [18444492273895866369, False] | [18444492273895866369, False] | Passed |
| quiet right only | [18444492273895866369, False] | [18444492273895866369, False] | Passed |
| opposite infinities | [9221120237041090560, True] | [9221120237041090560, True] | Passed |
| same infinity | [9221120237041090560, True] | [18442240474082181120, False] | Failed |
| finite addition | [4611686018427387904, False] | [4611686018427387904, False] | Passed |
| negative zeros | [9223372036854775808, False] | [9223372036854775808, False] | Passed |
SHA-256 / 31a1740958087f3d27c5a5825fa317c0e4be3a90df3b5f933325140813d377bc
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
N = 1
observations = []
def solve(ab,bb):
mask=(1<<52)-1
an=(ab>>52)&2047==2047 and bool(ab&mask)
bn=(bb>>52)&2047==2047 and bool(bb&mask)
asig=an and not bool(ab&(1<<51))
bsig=bn and not bool(bb&(1<<51))
if asig or bsig:
chosen=ab if asig else bb
return [chosen|(1<<51),True]
if an or bn:
if an and bn:
chosen=ab if (ab&((1<<51)-1)) >= (bb&((1<<51)-1)) else bb
else:
chosen=ab if an else bb
return [chosen,False]
a=struct.unpack('>d',ab.to_bytes(8,'big'))[0]
b=struct.unpack('>d',bb.to_bytes(8,'big'))[0]
if math.isinf(a) and math.isinf(b) and a!=b:
return [0x7ff8000000000000,True]
result=a+b
return [int.from_bytes(struct.pack('>d',result),'big'),False]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('left signaling', solve(0x7ff0000000000000|N,0x3ff0000000000000), [0x7ff8000000000000|N,True])
check('right signaling', solve(0x3ff0000000000000,0xfff0000000000000|N), [0xfff8000000000000|N,True])
check('signaling precedence', solve(0x7ff8000000000064,0x7ff0000000000000|N), [0x7ff8000000000000|N,True])
check('two signaling', solve(0xfff0000000000000|N,0x7ff0000000000010), [0xfff8000000000000|N,True])
check('larger right payload', solve(0x7ff8000000000000|N,0xfff8000000000064), [0xfff8000000000064,False])
check('larger left payload', solve(0xfff8000000000064,0x7ff8000000000000|N), [0xfff8000000000064,False])
check('equal left wins', solve(0xfff8000000000000|N,0x7ff8000000000000|N), [0xfff8000000000000|N,False])
check('positive quiet', solve(0x7ff8000000000000|N,0x3ff0000000000000), [0x7ff8000000000000|N,False])
check('quiet left only', solve(0xfff8000000000000|N,0x3ff0000000000000), [0xfff8000000000000|N,False])
check('quiet right only', solve(0x3ff0000000000000,0xfff8000000000000|N), [0xfff8000000000000|N,False])
check('opposite infinities', solve(0x7ff0000000000000,0xfff0000000000000), [0x7ff8000000000000,True])
check('same infinity', solve(0xfff0000000000000,0xfff0000000000000), [0xfff0000000000000,False])
check('finite addition', solve(0x3ff0000000000000,0x3ff0000000000000), [0x4000000000000000,False])
check('negative zeros', solve(1<<63,1<<63), [1<<63,False])
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 |
|---|---|---|---|
| left signaling | [9221120237041090561, True] | [9221120237041090561, True] | Passed |
| right signaling | [18444492273895866369, True] | [18444492273895866369, True] | Passed |
| signaling precedence | [9221120237041090561, True] | [9221120237041090561, True] | Passed |
| two signaling | [18444492273895866369, True] | [18444492273895866369, True] | Passed |
| larger right payload | [18444492273895866468, False] | [18444492273895866468, False] | Passed |
| larger left payload | [18444492273895866468, False] | [18444492273895866468, False] | Passed |
| equal left wins | [18444492273895866369, False] | [18444492273895866369, False] | Passed |
| positive quiet | [9221120237041090561, False] | [9221120237041090561, False] | Passed |
| quiet left only | [18444492273895866369, False] | [18444492273895866369, False] | Passed |
| quiet right only | [18444492273895866369, False] | [18444492273895866369, False] | Passed |
| opposite infinities | [9221120237041090560, True] | [9221120237041090560, True] | Passed |
| same infinity | [18442240474082181120, False] | [18442240474082181120, False] | Passed |
| finite addition | [4611686018427387904, False] | [4611686018427387904, False] | Passed |
| negative zeros | [9223372036854775808, False] | [9223372036854775808, False] | Passed |
SHA-256 / a22a003c8dfdecc224fbfc96d6bd9268c4c9fc9fb4044fdbdad84b62a3040788
Verification & scope
Controlled binary64 or explicitly stipulated miniature format; no hardware exception flags or platform floating environment are modeled. 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:37.678459+00:00.
Case digest / dc8a01c1b652cab9fed6acde3d1f28050771e4c62eb4079c4f3f87bcdec7cf97