FAILURE MAP
← Case archive

FA-4691 / Multiset accounting / Open access

Counter unary minus selects negative side · case 01

The operation returns a result or retained state that violates this contract: Unary minus returns positive magnitudes of negative counts only.

Verified by executionVariant 1 · 4 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Negating every count creates negative output from originally positive entries.

VERIFIED REPAIR

Unary minus returns positive magnitudes of negative counts only.

Unsuccessful approach: Absolute values incorrectly include originally positive entries.

Case contract

Unary minus returns positive magnitudes of negative counts only. Inputs are the finite Python values shown by the executable fixtures; no concurrent execution is assumed.

Why this case matters

A controlled local-runtime regression for collection APIs, language semantics, or ownership wrappers. Fixtures include boundary and interaction cases.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from collections import Counter, ChainMap, deque
import heapq
N = 1
observations = []
def solve(x, y=None):
    return {k:-v for k,v in x.items()}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('mixed signs', solve({'a': 2, 'b': 0, 'c': -1}), {'c': 1})
check('positive omitted', solve({'a': 2}), {})
check('negative becomes positive', solve({'a': -2}), {'a': 2})
check('empty', solve({}), {})
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 fixtureActualExpectedOutcome
mixed signs{'a': -2, 'b': 0, 'c': 1}{'c': 1}Failed
positive omitted{'a': -2}{}Failed
negative becomes positive{'a': 2}{'a': 2}Passed
empty{}{}Passed

SHA-256 / ac2470fa58dd03da401e45e491ebc81c6f4bfa74c22e8da9856505092ad73cbe

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from collections import Counter, ChainMap, deque
import heapq
N = 1
observations = []
def solve(x, y=None):
    return {k:abs(v) for k,v in x.items() if v!=0}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('mixed signs', solve({'a': 2, 'b': 0, 'c': -1}), {'c': 1})
check('positive omitted', solve({'a': 2}), {})
check('negative becomes positive', solve({'a': -2}), {'a': 2})
check('empty', solve({}), {})
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 fixtureActualExpectedOutcome
mixed signs{'a': 2, 'c': 1}{'c': 1}Failed
positive omitted{'a': 2}{}Failed
negative becomes positive{'a': 2}{'a': 2}Passed
empty{}{}Passed

SHA-256 / 2e6afeaf7abb5c5bc1fa93a3277d1c89d1fa4ac3c2938bfa8d58c432da8c7592

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
from collections import Counter, ChainMap, deque
import heapq
N = 1
observations = []
def solve(x, y=None):
    return dict(-Counter(x))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('mixed signs', solve({'a': 2, 'b': 0, 'c': -1}), {'c': 1})
check('positive omitted', solve({'a': 2}), {})
check('negative becomes positive', solve({'a': -2}), {'a': 2})
check('empty', solve({}), {})
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 fixtureActualExpectedOutcome
mixed signs{'c': 1}{'c': 1}Passed
positive omitted{}{}Passed
negative becomes positive{'a': 2}{'a': 2}Passed
empty{}{}Passed

SHA-256 / 31af9645fc76d8d8c3fac904290ae9b1db5f87ac6af703455ca2a6c36e6ca72c

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:41.826752+00:00.

Case digest / ef5b956664ff88d2b55d60f061eb34875d9a9d8d37062ec335a6a2e6afc9efa9