FA-15096 / Numerics / Open access
Lehmer permutation rank: inversion digit lookup · case 01
The exact lehmer permutation rank result violates the stated contract at inversion digit lookup.
ROOT CAUSE
The inversion digit lookup step uses v instead of remaining.index(v).
THE FAILURE
The inversion digit lookup step uses v instead of remaining.index(v).
Unsuccessful approach: The partial repair len(remaining)-1-remaining.index(v) still violates the inversion digit lookup invariant.
Case contract
Input permutation of 0..n-1 with n<=7; return zero-based lexicographic rank.
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):
p=x;n=len(p)
remaining=list(range(n));rank=0
for i,v in enumerate(p):
if v not in remaining:return None
digit=v
rank=rank+digit*math.factorial(n-i-1)
remaining.pop(remaining.index(v))
return rank
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([0, 1], 0), ([0], 0), ([5, 4, 3, 2, 1, 0], 719), ([1, 0], 1), ([0, 1, 2], 0), ([0, 2, 1], 1), ([1, 0, 2], 2), ([1, 2, 0], 3)], [([0, 1, 2], 0), ([0, 2, 1], 1), ([0], 0), ([5, 4, 3, 2, 1, 0], 719), ([1, 2, 0, 3], 8), ([1, 2, 3, 0], 9), ([1, 3, 0, 2], 10), ([1, 3, 2, 0], 11)], [([0, 2, 1], 1), ([2, 0, 1], 4), ([0], 0), ([5, 4, 3, 2, 1, 0], 719), ([0, 1, 2, 4, 3], 1), ([0, 1, 3, 2, 4], 2), ([0, 1, 3, 4, 2], 3), ([0, 1, 4, 2, 3], 4)], [([1, 0, 2], 2), ([0, 1, 3, 2], 1), ([0], 0), ([5, 4, 3, 2, 1, 0], 719), ([0, 4, 1, 2, 3], 18), ([0, 4, 1, 3, 2], 19), ([0, 4, 2, 1, 3], 20), ([0, 4, 2, 3, 1], 21)], [([1, 2, 0], 3), ([0, 3, 1, 2], 4), ([0], 0), ([5, 4, 3, 2, 1, 0], 719), ([1, 2, 4, 3, 0], 35), ([1, 3, 0, 2, 4], 36), ([1, 3, 0, 4, 2], 37), ([1, 3, 2, 0, 4], 38)]]
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 | Failed |
| explicit oracle 1 | 0 | 0 | Passed |
| explicit oracle 2 | 719 | 719 | Passed |
| explicit oracle 3 | 1 | 1 | Passed |
| explicit oracle 4 | 3 | 0 | Failed |
| explicit oracle 5 | 3 | 1 | Failed |
| explicit oracle 6 | 4 | 2 | Failed |
| explicit oracle 7 | 4 | 3 | Failed |
SHA-256 / 79e456cf99b5844e1dde6dc655a1feba0c55aee02563d6054e29fe94dfbca3a9
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):
p=x;n=len(p)
remaining=list(range(n));rank=0
for i,v in enumerate(p):
if v not in remaining:return None
digit=len(remaining)-1-remaining.index(v)
rank=rank+digit*math.factorial(n-i-1)
remaining.pop(remaining.index(v))
return rank
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([0, 1], 0), ([0], 0), ([5, 4, 3, 2, 1, 0], 719), ([1, 0], 1), ([0, 1, 2], 0), ([0, 2, 1], 1), ([1, 0, 2], 2), ([1, 2, 0], 3)], [([0, 1, 2], 0), ([0, 2, 1], 1), ([0], 0), ([5, 4, 3, 2, 1, 0], 719), ([1, 2, 0, 3], 8), ([1, 2, 3, 0], 9), ([1, 3, 0, 2], 10), ([1, 3, 2, 0], 11)], [([0, 2, 1], 1), ([2, 0, 1], 4), ([0], 0), ([5, 4, 3, 2, 1, 0], 719), ([0, 1, 2, 4, 3], 1), ([0, 1, 3, 2, 4], 2), ([0, 1, 3, 4, 2], 3), ([0, 1, 4, 2, 3], 4)], [([1, 0, 2], 2), ([0, 1, 3, 2], 1), ([0], 0), ([5, 4, 3, 2, 1, 0], 719), ([0, 4, 1, 2, 3], 18), ([0, 4, 1, 3, 2], 19), ([0, 4, 2, 1, 3], 20), ([0, 4, 2, 3, 1], 21)], [([1, 2, 0], 3), ([0, 3, 1, 2], 4), ([0], 0), ([5, 4, 3, 2, 1, 0], 719), ([1, 2, 4, 3, 0], 35), ([1, 3, 0, 2, 4], 36), ([1, 3, 0, 4, 2], 37), ([1, 3, 2, 0, 4], 38)]]
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 | Failed |
| explicit oracle 1 | 0 | 0 | Passed |
| explicit oracle 2 | 0 | 719 | Failed |
| explicit oracle 3 | 0 | 1 | Failed |
| explicit oracle 4 | 5 | 0 | Failed |
| explicit oracle 5 | 4 | 1 | Failed |
| explicit oracle 6 | 3 | 2 | Failed |
| explicit oracle 7 | 2 | 3 | Failed |
SHA-256 / 0bad2fb09013b092aafa94cd554c3887836f8a16f6f168aab0c11ff47547bd4d
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 8 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
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:23.281832+00:00.
Case digest / 4cf53ab151fe225bb2d465e69e811358463549f05baf8c10b859fa2240943706