FAILURE MAP
← Case archive

FA-4661 / Multiset accounting / Open access

Counter subtract retains nonpositive counts · case 01

The operation returns a result or retained state that violates this contract: Subtract right counts from left counts and retain zero and negative entries in insertion order.

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

ROOT CAUSE

Counter subtraction applies positive-bag normalization and discards zero and negative entries.

VERIFIED REPAIR

Subtract right counts from left counts and retain zero and negative entries in insertion order.

Unsuccessful approach: Filtering only zeros still loses explicitly retained zero bindings.

Case contract

Subtract right counts from left counts and retain zero and negative entries in insertion order. 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 list(map(list,(Counter(x)-Counter(y)).items()))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('zero and negative retained', solve({'a': 2, 'b': 1}, {'a': 2, 'b': 3, 'c': 1}), [['a', 0], ['b', -2], ['c', -1]])
check('empty left', solve({}, {'a': 1}), [['a', -1]])
check('empty right', solve({'a': 0}, {}), [['a', 0]])
check('both 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
zero and negative retained[][['a', 0], ['b', -2], ['c', -1]]Failed
empty left[][['a', -1]]Failed
empty right[][['a', 0]]Failed
both empty[][]Passed

SHA-256 / 5859c2224f370af380566892709dd030441288baf238bb33098d2f287694233d

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):
    a=Counter(x); a.subtract(y); return [[k,v] for k,v in a.items() if v!=0]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('zero and negative retained', solve({'a': 2, 'b': 1}, {'a': 2, 'b': 3, 'c': 1}), [['a', 0], ['b', -2], ['c', -1]])
check('empty left', solve({}, {'a': 1}), [['a', -1]])
check('empty right', solve({'a': 0}, {}), [['a', 0]])
check('both 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
zero and negative retained[['b', -2], ['c', -1]][['a', 0], ['b', -2], ['c', -1]]Failed
empty left[['a', -1]][['a', -1]]Passed
empty right[][['a', 0]]Failed
both empty[][]Passed

SHA-256 / 43ec0283dade9279e3c50b8e688080563d775678ab0107a338f4e2bea2691efc

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):
    a=Counter(x); a.subtract(y); return list(map(list,a.items()))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('zero and negative retained', solve({'a': 2, 'b': 1}, {'a': 2, 'b': 3, 'c': 1}), [['a', 0], ['b', -2], ['c', -1]])
check('empty left', solve({}, {'a': 1}), [['a', -1]])
check('empty right', solve({'a': 0}, {}), [['a', 0]])
check('both 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
zero and negative retained[['a', 0], ['b', -2], ['c', -1]][['a', 0], ['b', -2], ['c', -1]]Passed
empty left[['a', -1]][['a', -1]]Passed
empty right[['a', 0]][['a', 0]]Passed
both empty[][]Passed

SHA-256 / 56bd3ccca11fec6996e2c2fe794baec94421df0e039e7ae9fa6300d7898829a4

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

Case digest / fea9755d34f88b2cd6eab91c10f23bde464e7b8f12ba470279fce590719c0411