FAILURE MAP
← Case archive

FA-4321 / Collection algebra / Open access

Bag equality retains counts · case 01

The operation returns a result or retained state that violates this contract: Return true for equal occurrence counts regardless of positional order.

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

ROOT CAUSE

Positional equality rejects valid permutations of the same bag.

THE FAILURE

Positional equality rejects valid permutations of the same bag.

Unsuccessful approach: Set equality ignores occurrence counts.

Case contract

Return true for equal occurrence counts regardless of positional 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

N = 1
observations = []
def solve(x, y=None):
    return x==y
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('both empty', solve([], []), True)
check('empty right operand', solve(['a'], []), False)
check('empty left operand', solve([], ['b']), False)
check('overlap and multiplicity', solve(['b', 'a', 'b'], ['b', 'c', 'c']), False)
check('permutation is equal bag', solve(['a','b'], ['b','a']), True)
check('count mismatch differs', solve(['a','a'], ['a']), 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 fixtureActualExpectedOutcome
both emptyTrueTruePassed
empty right operandFalseFalsePassed
empty left operandFalseFalsePassed
overlap and multiplicityFalseFalsePassed
permutation is equal bagFalseTrueFailed
count mismatch differsFalseFalsePassed

SHA-256 / 9e59ec278d03db698794fc2cfb2823c3cea0fa5f504d5f323265e5dbe4eee1dd

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x, y=None):
    return set(x)==set(y)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('both empty', solve([], []), True)
check('empty right operand', solve(['a'], []), False)
check('empty left operand', solve([], ['b']), False)
check('overlap and multiplicity', solve(['b', 'a', 'b'], ['b', 'c', 'c']), False)
check('permutation is equal bag', solve(['a','b'], ['b','a']), True)
check('count mismatch differs', solve(['a','a'], ['a']), 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 fixtureActualExpectedOutcome
both emptyTrueTruePassed
empty right operandFalseFalsePassed
empty left operandFalseFalsePassed
overlap and multiplicityFalseFalsePassed
permutation is equal bagTrueTruePassed
count mismatch differsTrueFalseFailed

SHA-256 / 0a8382a1777ac2c33f66c91a3defaa3a8de69ee031e068df550356d1d9ea3380

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 6 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

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

Case digest / cd1237fd7a3fe92d0fcf753062de8c0125c612c91dcb18711bb1ec7d05d2bf38