FA-15236 / Numerics / Open access
Multiset permutation unrank: trial symbol restoration · case 01
The exact multiset permutation unrank result violates the stated contract at trial symbol restoration.
ROOT CAUSE
The trial symbol restoration step uses counts[symbol] instead of counts[symbol]+1.
VERIFIED REPAIR
Use counts[symbol]+1 at the trial symbol restoration step.
Unsuccessful approach: The partial repair counts[symbol]+2 still violates the trial symbol restoration 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]
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, 1, 1, 2], 3], [1, 0, 1, 2]), ([[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, 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], 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], 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, 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, 0, 1, 1], 1], [0, 1, 0, 1]), ([[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 | None | [1, 0, 1, 2] | Failed |
| explicit oracle 2 | [0, 0, 1] | [0, 0, 1] | Passed |
| explicit oracle 3 | None | [3, 2, 2, 1, 1] | Failed |
| explicit oracle 4 | None | [1, 0, 0] | Failed |
| explicit oracle 5 | [0, 1, 1, 2] | [0, 1, 1, 2] | Passed |
| explicit oracle 6 | None | [0, 1, 2, 1] | Failed |
| explicit oracle 7 | None | [0, 2, 1, 1] | Failed |
SHA-256 / a2724b5545ffe40096d894873e4399afadd5c56e972420d5800a2ad9355c1a7f
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]+2
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, 1, 1, 2], 3], [1, 0, 1, 2]), ([[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, 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], 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], 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, 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, 0, 1, 1], 1], [0, 1, 0, 1]), ([[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 | [1, 0, 0, 1] | [1, 0, 1, 2] | Failed |
| explicit oracle 2 | [0, 0, 1] | [0, 0, 1] | Passed |
| explicit oracle 3 | [2, 3, 1, 1, 1] | [3, 2, 2, 1, 1] | Failed |
| explicit oracle 4 | [1, 0, 0] | [1, 0, 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 / 16379875d458b4ba9078b62ee61653e94bc677b9deeb8b1346ce53258582091c
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, 1, 1, 2], 3], [1, 0, 1, 2]), ([[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, 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], 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], 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, 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, 0, 1, 1], 1], [0, 1, 0, 1]), ([[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 | [1, 0, 1, 2] | [1, 0, 1, 2] | 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 | [1, 0, 0] | [1, 0, 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 / 02999de63aaa09369b5d0acd3ae6aa821a9166e56698940560ebb0003908311e
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.655419+00:00.
Case digest / 82d3680c8b9f46edd52c7d29b8e341e02ed3553ff20cdae068f58f53fab8859c