FAILURE MAP
← Case archive

FA-5671 / Combinatorics / Open access

Stirling second kind · case 01

Labelled assignments include empty blocks and distinguish block names.

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

ROOT CAUSE

Labelled assignments include empty blocks and distinguish block names.

VERIFIED REPAIR

Apply the specified mathematical contract directly, preserving all terms and boundary cases: return sum((-1)**i*math.comb(k,i)*(k-i)**n for i in range(k+1))//math.factorial(k)

Unsuccessful approach: Onto assignments still distinguish permutations of block labels.

Case contract

Nonnegative integer counts. Permutation and combination counts are zero when a requested selection exceeds the available objects. Shape sizes satisfy the preconditions stated below. Count partitions of n labelled elements into k nonempty unlabelled blocks, with S(0,0)=1. Exact operational definition: sum((-1)**i*math.comb(k,i)*(k-i)**n for i in range(k+1))//math.factorial(k)

Why this case matters

Small exact fixtures expose this error without platform timing, external services, or probabilistic observations. Combinatorics 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(n, k):
    return k**n
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (3, 2)', solve(*(3, 2)), 3)
check('fixture 2: (4, 2)', solve(*(4, 2)), 7)
check('fixture 3: (0, 0)', solve(*(0, 0)), 1)
check('fixture 4: (2, 3)', solve(*(2, 3)), 0)
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
fixture 1: (3, 2)83Failed
fixture 2: (4, 2)167Failed
fixture 3: (0, 0)11Passed
fixture 4: (2, 3)90Failed

SHA-256 / 19c045e9b79d780b2ca704e348eaea7a7b65a414abd1745e768588e35a0dddbc

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(n, k):
    return sum((-1)**i*math.comb(k,i)*(k-i)**n for i in range(k+1))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (3, 2)', solve(*(3, 2)), 3)
check('fixture 2: (4, 2)', solve(*(4, 2)), 7)
check('fixture 3: (0, 0)', solve(*(0, 0)), 1)
check('fixture 4: (2, 3)', solve(*(2, 3)), 0)
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
fixture 1: (3, 2)63Failed
fixture 2: (4, 2)147Failed
fixture 3: (0, 0)11Passed
fixture 4: (2, 3)00Passed

SHA-256 / 765163f497fb62c87b61696eac6092c76f5183693f6347a042c03255db1b87af

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(n, k):
    return sum((-1)**i*math.comb(k,i)*(k-i)**n for i in range(k+1))//math.factorial(k)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (3, 2)', solve(*(3, 2)), 3)
check('fixture 2: (4, 2)', solve(*(4, 2)), 7)
check('fixture 3: (0, 0)', solve(*(0, 0)), 1)
check('fixture 4: (2, 3)', solve(*(2, 3)), 0)
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
fixture 1: (3, 2)33Passed
fixture 2: (4, 2)77Passed
fixture 3: (0, 0)11Passed
fixture 4: (2, 3)00Passed

SHA-256 / f93429a148b626a8ec997b3443b7b3594ae0f55624d6444f38f15192916d9afd

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

Case digest / b9c0101ef9e7dfb2b13973880318b124044411945dbc8559bdf04316fb827e6d