FA-15226 / Numerics / Open access
Multiset permutation unrank: rank block membership · case 01
The exact multiset permutation unrank result violates the stated contract at rank block membership.
ROOT CAUSE
The rank block membership step uses r<=block instead of r<block.
VERIFIED REPAIR
Use r<block at the rank block membership step.
Unsuccessful approach: The partial repair r==0 still violates the rank block membership invariant.
Case contract
Input [sorted multiset of small integer symbols, rank], valid zero-based lexicographic rank among distinct permutations.
Why this case matters
Exact discrete arithmetic with observable algorithmic state; no floating point approximation is used.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
import itertools
from fractions import Fraction
N = 1
observations = []
def solve(x):
items,r=x
from collections import Counter
counts=Counter(items);out=[]
def ways(c):
v=math.factorial(sum(c.values()))
for n in c.values():v//=math.factorial(n)
return v
for _ in range(len(items)):
for symbol in sorted(counts):
if counts[symbol]==0:continue
counts[symbol]-=1
block=ways(counts)
if r<=block:
out.append(symbol)
break
r=r-block
counts[symbol]=counts[symbol]+1
else:return None
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([[0, 0, 1], 1], [0, 1, 0]), ([[0, 0, 1], 0], [0, 0, 1]), ([[1, 1, 2, 2, 3], 29], [3, 2, 2, 1, 1]), ([[0, 0, 1], 2], [1, 0, 0]), ([[0, 1, 1, 2], 0], [0, 1, 1, 2]), ([[0, 1, 1, 2], 1], [0, 1, 2, 1]), ([[0, 1, 1, 2], 2], [0, 2, 1, 1]), ([[0, 1, 1, 2], 3], [1, 0, 1, 2])], [([[0, 0, 1], 2], [1, 0, 0]), ([[0, 1, 1, 2], 4], [1, 0, 2, 1]), ([[0, 0, 1], 0], [0, 0, 1]), ([[1, 1, 2, 2, 3], 29], [3, 2, 2, 1, 1]), ([[0, 0, 1, 1], 2], [0, 1, 1, 0]), ([[0, 0, 1, 1], 3], [1, 0, 0, 1]), ([[0, 0, 1, 1], 4], [1, 0, 1, 0]), ([[0, 0, 1, 1], 5], [1, 1, 0, 0])], [([[0, 1, 1, 2], 1], [0, 1, 2, 1]), ([[0, 1, 1, 2], 7], [1, 2, 0, 1]), ([[0, 0, 1], 0], [0, 0, 1]), ([[1, 1, 2, 2, 3], 29], [3, 2, 2, 1, 1]), ([[0, 0, 0, 1, 2], 13], [1, 0, 0, 2, 0]), ([[0, 0, 0, 1, 2], 14], [1, 0, 2, 0, 0]), ([[0, 0, 0, 1, 2], 15], [1, 2, 0, 0, 0]), ([[0, 0, 0, 1, 2], 16], [2, 0, 0, 0, 1])], [([[0, 1, 1, 2], 2], [0, 2, 1, 1]), ([[0, 1, 1, 2], 11], [2, 1, 1, 0]), ([[0, 0, 1], 0], [0, 0, 1]), ([[1, 1, 2, 2, 3], 29], [3, 2, 2, 1, 1]), ([[0, 1, 2, 3], 10], [1, 3, 0, 2]), ([[0, 1, 2, 3], 11], [1, 3, 2, 0]), ([[0, 1, 2, 3], 12], [2, 0, 1, 3]), ([[0, 1, 2, 3], 13], [2, 0, 3, 1])], [([[0, 1, 1, 2], 3], [1, 0, 1, 2]), ([[0, 0, 1, 1], 4], [1, 0, 1, 0]), ([[0, 0, 1], 0], [0, 0, 1]), ([[1, 1, 2, 2, 3], 29], [3, 2, 2, 1, 1]), ([[1, 1, 2, 2, 3], 3], [1, 2, 1, 2, 3]), ([[1, 1, 2, 2, 3], 4], [1, 2, 1, 3, 2]), ([[1, 1, 2, 2, 3], 5], [1, 2, 2, 1, 3]), ([[1, 1, 2, 2, 3], 6], [1, 2, 2, 3, 1])]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("explicit oracle %d" % i, solve(args), expected)
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 |
|---|---|---|---|
| explicit oracle 0 | [0, 0, 1] | [0, 1, 0] | Failed |
| explicit oracle 1 | [0, 0, 1] | [0, 0, 1] | Passed |
| explicit oracle 2 | [3, 2, 1, 2, 1] | [3, 2, 2, 1, 1] | Failed |
| explicit oracle 3 | [0, 1, 0] | [1, 0, 0] | Failed |
| explicit oracle 4 | [0, 1, 1, 2] | [0, 1, 1, 2] | Passed |
| explicit oracle 5 | [0, 1, 1, 2] | [0, 1, 2, 1] | Failed |
| explicit oracle 6 | [0, 1, 2, 1] | [0, 2, 1, 1] | Failed |
| explicit oracle 7 | [0, 2, 1, 1] | [1, 0, 1, 2] | Failed |
SHA-256 / 3d129da1f2d367d0c2361a665b31fd46c5f23198e5718bc6f4e3b31537f91b61
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
import itertools
from fractions import Fraction
N = 1
observations = []
def solve(x):
items,r=x
from collections import Counter
counts=Counter(items);out=[]
def ways(c):
v=math.factorial(sum(c.values()))
for n in c.values():v//=math.factorial(n)
return v
for _ in range(len(items)):
for symbol in sorted(counts):
if counts[symbol]==0:continue
counts[symbol]-=1
block=ways(counts)
if r==0:
out.append(symbol)
break
r=r-block
counts[symbol]=counts[symbol]+1
else:return None
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([[0, 0, 1], 1], [0, 1, 0]), ([[0, 0, 1], 0], [0, 0, 1]), ([[1, 1, 2, 2, 3], 29], [3, 2, 2, 1, 1]), ([[0, 0, 1], 2], [1, 0, 0]), ([[0, 1, 1, 2], 0], [0, 1, 1, 2]), ([[0, 1, 1, 2], 1], [0, 1, 2, 1]), ([[0, 1, 1, 2], 2], [0, 2, 1, 1]), ([[0, 1, 1, 2], 3], [1, 0, 1, 2])], [([[0, 0, 1], 2], [1, 0, 0]), ([[0, 1, 1, 2], 4], [1, 0, 2, 1]), ([[0, 0, 1], 0], [0, 0, 1]), ([[1, 1, 2, 2, 3], 29], [3, 2, 2, 1, 1]), ([[0, 0, 1, 1], 2], [0, 1, 1, 0]), ([[0, 0, 1, 1], 3], [1, 0, 0, 1]), ([[0, 0, 1, 1], 4], [1, 0, 1, 0]), ([[0, 0, 1, 1], 5], [1, 1, 0, 0])], [([[0, 1, 1, 2], 1], [0, 1, 2, 1]), ([[0, 1, 1, 2], 7], [1, 2, 0, 1]), ([[0, 0, 1], 0], [0, 0, 1]), ([[1, 1, 2, 2, 3], 29], [3, 2, 2, 1, 1]), ([[0, 0, 0, 1, 2], 13], [1, 0, 0, 2, 0]), ([[0, 0, 0, 1, 2], 14], [1, 0, 2, 0, 0]), ([[0, 0, 0, 1, 2], 15], [1, 2, 0, 0, 0]), ([[0, 0, 0, 1, 2], 16], [2, 0, 0, 0, 1])], [([[0, 1, 1, 2], 2], [0, 2, 1, 1]), ([[0, 1, 1, 2], 11], [2, 1, 1, 0]), ([[0, 0, 1], 0], [0, 0, 1]), ([[1, 1, 2, 2, 3], 29], [3, 2, 2, 1, 1]), ([[0, 1, 2, 3], 10], [1, 3, 0, 2]), ([[0, 1, 2, 3], 11], [1, 3, 2, 0]), ([[0, 1, 2, 3], 12], [2, 0, 1, 3]), ([[0, 1, 2, 3], 13], [2, 0, 3, 1])], [([[0, 1, 1, 2], 3], [1, 0, 1, 2]), ([[0, 0, 1, 1], 4], [1, 0, 1, 0]), ([[0, 0, 1], 0], [0, 0, 1]), ([[1, 1, 2, 2, 3], 29], [3, 2, 2, 1, 1]), ([[1, 1, 2, 2, 3], 3], [1, 2, 1, 2, 3]), ([[1, 1, 2, 2, 3], 4], [1, 2, 1, 3, 2]), ([[1, 1, 2, 2, 3], 5], [1, 2, 2, 1, 3]), ([[1, 1, 2, 2, 3], 6], [1, 2, 2, 3, 1])]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("explicit oracle %d" % i, solve(args), expected)
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 |
|---|---|---|---|
| explicit oracle 0 | None | [0, 1, 0] | Failed |
| explicit oracle 1 | [0, 0, 1] | [0, 0, 1] | Passed |
| explicit oracle 2 | None | [3, 2, 2, 1, 1] | Failed |
| explicit oracle 3 | [1, 0, 0] | [1, 0, 0] | Passed |
| explicit oracle 4 | [0, 1, 1, 2] | [0, 1, 1, 2] | Passed |
| explicit oracle 5 | None | [0, 1, 2, 1] | Failed |
| explicit oracle 6 | None | [0, 2, 1, 1] | Failed |
| explicit oracle 7 | [1, 0, 1, 2] | [1, 0, 1, 2] | Passed |
SHA-256 / 09f1d444db8a7e7e1e43c5ce9eeb409d103fd51b3a315a0eaa7e3fdd69a2ecce
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
import itertools
from fractions import Fraction
N = 1
observations = []
def solve(x):
items,r=x
from collections import Counter
counts=Counter(items);out=[]
def ways(c):
v=math.factorial(sum(c.values()))
for n in c.values():v//=math.factorial(n)
return v
for _ in range(len(items)):
for symbol in sorted(counts):
if counts[symbol]==0:continue
counts[symbol]-=1
block=ways(counts)
if r<block:
out.append(symbol)
break
r=r-block
counts[symbol]=counts[symbol]+1
else:return None
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([[0, 0, 1], 1], [0, 1, 0]), ([[0, 0, 1], 0], [0, 0, 1]), ([[1, 1, 2, 2, 3], 29], [3, 2, 2, 1, 1]), ([[0, 0, 1], 2], [1, 0, 0]), ([[0, 1, 1, 2], 0], [0, 1, 1, 2]), ([[0, 1, 1, 2], 1], [0, 1, 2, 1]), ([[0, 1, 1, 2], 2], [0, 2, 1, 1]), ([[0, 1, 1, 2], 3], [1, 0, 1, 2])], [([[0, 0, 1], 2], [1, 0, 0]), ([[0, 1, 1, 2], 4], [1, 0, 2, 1]), ([[0, 0, 1], 0], [0, 0, 1]), ([[1, 1, 2, 2, 3], 29], [3, 2, 2, 1, 1]), ([[0, 0, 1, 1], 2], [0, 1, 1, 0]), ([[0, 0, 1, 1], 3], [1, 0, 0, 1]), ([[0, 0, 1, 1], 4], [1, 0, 1, 0]), ([[0, 0, 1, 1], 5], [1, 1, 0, 0])], [([[0, 1, 1, 2], 1], [0, 1, 2, 1]), ([[0, 1, 1, 2], 7], [1, 2, 0, 1]), ([[0, 0, 1], 0], [0, 0, 1]), ([[1, 1, 2, 2, 3], 29], [3, 2, 2, 1, 1]), ([[0, 0, 0, 1, 2], 13], [1, 0, 0, 2, 0]), ([[0, 0, 0, 1, 2], 14], [1, 0, 2, 0, 0]), ([[0, 0, 0, 1, 2], 15], [1, 2, 0, 0, 0]), ([[0, 0, 0, 1, 2], 16], [2, 0, 0, 0, 1])], [([[0, 1, 1, 2], 2], [0, 2, 1, 1]), ([[0, 1, 1, 2], 11], [2, 1, 1, 0]), ([[0, 0, 1], 0], [0, 0, 1]), ([[1, 1, 2, 2, 3], 29], [3, 2, 2, 1, 1]), ([[0, 1, 2, 3], 10], [1, 3, 0, 2]), ([[0, 1, 2, 3], 11], [1, 3, 2, 0]), ([[0, 1, 2, 3], 12], [2, 0, 1, 3]), ([[0, 1, 2, 3], 13], [2, 0, 3, 1])], [([[0, 1, 1, 2], 3], [1, 0, 1, 2]), ([[0, 0, 1, 1], 4], [1, 0, 1, 0]), ([[0, 0, 1], 0], [0, 0, 1]), ([[1, 1, 2, 2, 3], 29], [3, 2, 2, 1, 1]), ([[1, 1, 2, 2, 3], 3], [1, 2, 1, 2, 3]), ([[1, 1, 2, 2, 3], 4], [1, 2, 1, 3, 2]), ([[1, 1, 2, 2, 3], 5], [1, 2, 2, 1, 3]), ([[1, 1, 2, 2, 3], 6], [1, 2, 2, 3, 1])]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("explicit oracle %d" % i, solve(args), expected)
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 |
|---|---|---|---|
| explicit oracle 0 | [0, 1, 0] | [0, 1, 0] | Passed |
| explicit oracle 1 | [0, 0, 1] | [0, 0, 1] | Passed |
| explicit oracle 2 | [3, 2, 2, 1, 1] | [3, 2, 2, 1, 1] | Passed |
| explicit oracle 3 | [1, 0, 0] | [1, 0, 0] | Passed |
| explicit oracle 4 | [0, 1, 1, 2] | [0, 1, 1, 2] | Passed |
| explicit oracle 5 | [0, 1, 2, 1] | [0, 1, 2, 1] | Passed |
| explicit oracle 6 | [0, 2, 1, 1] | [0, 2, 1, 1] | Passed |
| explicit oracle 7 | [1, 0, 1, 2] | [1, 0, 1, 2] | Passed |
SHA-256 / 47a3b39613ddfc2318c16b94ec08dff192e2fee5ed86c354bdfecff4696e4bf6
Verification & scope
A deterministic bounded teaching model. Inputs are restricted to the explicit contract; this is not a production algebra library. 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:24.654920+00:00.
Case digest / 0b4922ef1831ddda4c5802ed1cef27d59f210179723ad140e03dac606a15db60