FA-15231 / Numerics / Open access
Multiset permutation unrank: skipped block subtraction · case 01
The exact multiset permutation unrank result violates the stated contract at skipped block subtraction.
ROOT CAUSE
The skipped block subtraction step uses r-1 instead of r-block.
VERIFIED REPAIR
Use r-block at the skipped block subtraction step.
Unsuccessful approach: The partial repair r%block still violates the skipped block subtraction 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-1
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], 2], [1, 0, 0]), ([[0, 1, 1, 2], 6], [1, 1, 2, 0]), ([[0, 0, 1], 0], [0, 0, 1]), ([[1, 1, 2, 2, 3], 29], [3, 2, 2, 1, 1]), ([[0, 0, 1], 1], [0, 1, 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], 2], [0, 2, 1, 1]), ([[0, 1, 1, 2], 9], [2, 0, 1, 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], 3], [1, 0, 1, 2]), ([[0, 0, 1, 1], 2], [0, 1, 1, 0]), ([[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], 4], [1, 0, 2, 1]), ([[0, 1, 2, 3], 4], [0, 3, 1, 2]), ([[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], 5], [1, 1, 0, 2]), ([[0, 1, 2, 3], 11], [1, 3, 2, 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 | [1, 0, 0] | Failed |
| explicit oracle 1 | None | [1, 1, 2, 0] | Failed |
| explicit oracle 2 | [0, 0, 1] | [0, 0, 1] | Passed |
| explicit oracle 3 | None | [3, 2, 2, 1, 1] | Failed |
| explicit oracle 4 | [0, 1, 0] | [0, 1, 0] | Passed |
| explicit oracle 5 | [0, 1, 1, 2] | [0, 1, 1, 2] | Passed |
| explicit oracle 6 | [0, 1, 2, 1] | [0, 1, 2, 1] | Passed |
| explicit oracle 7 | None | [0, 2, 1, 1] | Failed |
SHA-256 / 64658672f73e57d446b6d201d1d320a5898f1266c9e957a67431cb74ec943630
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<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], 2], [1, 0, 0]), ([[0, 1, 1, 2], 6], [1, 1, 2, 0]), ([[0, 0, 1], 0], [0, 0, 1]), ([[1, 1, 2, 2, 3], 29], [3, 2, 2, 1, 1]), ([[0, 0, 1], 1], [0, 1, 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], 2], [0, 2, 1, 1]), ([[0, 1, 1, 2], 9], [2, 0, 1, 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], 3], [1, 0, 1, 2]), ([[0, 0, 1, 1], 2], [0, 1, 1, 0]), ([[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], 4], [1, 0, 2, 1]), ([[0, 1, 2, 3], 4], [0, 3, 1, 2]), ([[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], 5], [1, 1, 0, 2]), ([[0, 1, 2, 3], 11], [1, 3, 2, 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 | [1, 0, 0] | [1, 0, 0] | Passed |
| explicit oracle 1 | [1, 0, 1, 2] | [1, 1, 2, 0] | Failed |
| explicit oracle 2 | [0, 0, 1] | [0, 0, 1] | Passed |
| explicit oracle 3 | [2, 1, 2, 3, 1] | [3, 2, 2, 1, 1] | Failed |
| explicit oracle 4 | [0, 1, 0] | [0, 1, 0] | Passed |
| explicit oracle 5 | [0, 1, 1, 2] | [0, 1, 1, 2] | Passed |
| explicit oracle 6 | [0, 1, 2, 1] | [0, 1, 2, 1] | Passed |
| explicit oracle 7 | [0, 2, 1, 1] | [0, 2, 1, 1] | Passed |
SHA-256 / d16a6788b37d576b15a568df20c3efc60fe9087bde213e613b22aaf3b3bb3774
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], 2], [1, 0, 0]), ([[0, 1, 1, 2], 6], [1, 1, 2, 0]), ([[0, 0, 1], 0], [0, 0, 1]), ([[1, 1, 2, 2, 3], 29], [3, 2, 2, 1, 1]), ([[0, 0, 1], 1], [0, 1, 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], 2], [0, 2, 1, 1]), ([[0, 1, 1, 2], 9], [2, 0, 1, 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], 3], [1, 0, 1, 2]), ([[0, 0, 1, 1], 2], [0, 1, 1, 0]), ([[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], 4], [1, 0, 2, 1]), ([[0, 1, 2, 3], 4], [0, 3, 1, 2]), ([[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], 5], [1, 1, 0, 2]), ([[0, 1, 2, 3], 11], [1, 3, 2, 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 | [1, 0, 0] | [1, 0, 0] | Passed |
| explicit oracle 1 | [1, 1, 2, 0] | [1, 1, 2, 0] | Passed |
| explicit oracle 2 | [0, 0, 1] | [0, 0, 1] | Passed |
| explicit oracle 3 | [3, 2, 2, 1, 1] | [3, 2, 2, 1, 1] | Passed |
| explicit oracle 4 | [0, 1, 0] | [0, 1, 0] | Passed |
| explicit oracle 5 | [0, 1, 1, 2] | [0, 1, 1, 2] | Passed |
| explicit oracle 6 | [0, 1, 2, 1] | [0, 1, 2, 1] | Passed |
| explicit oracle 7 | [0, 2, 1, 1] | [0, 2, 1, 1] | Passed |
SHA-256 / cd09f042063b288263c0d2e79fad528616bf3f56db505d8601c4b4795fa3f18a
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.653701+00:00.
Case digest / accb1fb70e5a04f79fe693b0a56b6908e7e56a0f72ace0392b39c25fd5afd5fb