FAILURE MAP
← Case archive

FA-15176 / Numerics / Open access

Combinadic unrank: residual colex rank · case 01

The exact combinadic unrank result violates the stated contract at residual colex rank.

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

ROOT CAUSE

The residual colex rank step uses r instead of r-(math.comb(a,j) if a>=j else 0).

VERIFIED REPAIR

Use r-(math.comb(a,j) if a>=j else 0) at the residual colex rank step.

Unsuccessful approach: The partial repair r-(a-j+1) still violates the residual colex rank invariant.

Case contract

Input [k,r], k>=1 and r>=0; unique increasing combination of k nonnegative integers with colex rank r. Bounds: 1<=k<=5 and 0<=r<=49.

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):
    k,r=x;out=[];ceiling=r+k+1
    for j in range(k,0,-1):
     a=ceiling-1
     for _ in range(200):
      if a<j or math.comb(a,j)<=r:break
      a-=1
     out.append(a)
     r=r
     ceiling=a
    return out[::-1]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([2, 1], [0, 2]), ([2, 3], [0, 3]), ([1, 0], [0]), ([5, 49], [0, 3, 5, 6, 7]), ([1, 1], [1]), ([1, 2], [2]), ([1, 3], [3]), ([1, 4], [4])], [([2, 3], [0, 3]), ([2, 7], [1, 4]), ([1, 0], [0]), ([5, 49], [0, 3, 5, 6, 7]), ([1, 17], [17]), ([1, 18], [18]), ([1, 19], [19]), ([1, 20], [20])], [([2, 4], [1, 3]), ([2, 11], [1, 5]), ([1, 0], [0]), ([5, 49], [0, 3, 5, 6, 7]), ([1, 34], [34]), ([1, 35], [35]), ([1, 36], [36]), ([1, 37], [37])], [([2, 6], [0, 4]), ([2, 15], [0, 6]), ([1, 0], [0]), ([5, 49], [0, 3, 5, 6, 7]), ([2, 1], [0, 2]), ([2, 2], [1, 2]), ([2, 3], [0, 3]), ([2, 4], [1, 3])], [([2, 7], [1, 4]), ([2, 18], [3, 6]), ([1, 0], [0]), ([5, 49], [0, 3, 5, 6, 7]), ([2, 19], [4, 6]), ([2, 20], [5, 6]), ([2, 21], [0, 7]), ([2, 22], [1, 7])]]
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 fixtureActualExpectedOutcome
explicit oracle 0[1, 2][0, 2]Failed
explicit oracle 1[2, 3][0, 3]Failed
explicit oracle 2[0][0]Passed
explicit oracle 3[3, 4, 5, 6, 7][0, 3, 5, 6, 7]Failed
explicit oracle 4[1][1]Passed
explicit oracle 5[2][2]Passed
explicit oracle 6[3][3]Passed
explicit oracle 7[4][4]Passed

SHA-256 / 49911246fd4acdf7ae6f606adcd900565c2bb0e3c68508f167ad274ae0032037

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):
    k,r=x;out=[];ceiling=r+k+1
    for j in range(k,0,-1):
     a=ceiling-1
     for _ in range(200):
      if a<j or math.comb(a,j)<=r:break
      a-=1
     out.append(a)
     r=r-(a-j+1)
     ceiling=a
    return out[::-1]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([2, 1], [0, 2]), ([2, 3], [0, 3]), ([1, 0], [0]), ([5, 49], [0, 3, 5, 6, 7]), ([1, 1], [1]), ([1, 2], [2]), ([1, 3], [3]), ([1, 4], [4])], [([2, 3], [0, 3]), ([2, 7], [1, 4]), ([1, 0], [0]), ([5, 49], [0, 3, 5, 6, 7]), ([1, 17], [17]), ([1, 18], [18]), ([1, 19], [19]), ([1, 20], [20])], [([2, 4], [1, 3]), ([2, 11], [1, 5]), ([1, 0], [0]), ([5, 49], [0, 3, 5, 6, 7]), ([1, 34], [34]), ([1, 35], [35]), ([1, 36], [36]), ([1, 37], [37])], [([2, 6], [0, 4]), ([2, 15], [0, 6]), ([1, 0], [0]), ([5, 49], [0, 3, 5, 6, 7]), ([2, 1], [0, 2]), ([2, 2], [1, 2]), ([2, 3], [0, 3]), ([2, 4], [1, 3])], [([2, 7], [1, 4]), ([2, 18], [3, 6]), ([1, 0], [0]), ([5, 49], [0, 3, 5, 6, 7]), ([2, 19], [4, 6]), ([2, 20], [5, 6]), ([2, 21], [0, 7]), ([2, 22], [1, 7])]]
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 fixtureActualExpectedOutcome
explicit oracle 0[0, 2][0, 2]Passed
explicit oracle 1[1, 3][0, 3]Failed
explicit oracle 2[0][0]Passed
explicit oracle 3[3, 4, 5, 6, 7][0, 3, 5, 6, 7]Failed
explicit oracle 4[1][1]Passed
explicit oracle 5[2][2]Passed
explicit oracle 6[3][3]Passed
explicit oracle 7[4][4]Passed

SHA-256 / b90f33b001323e03d3332d98ed31a4c8cd003448babe1872db68196f0928dcce

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):
    k,r=x;out=[];ceiling=r+k+1
    for j in range(k,0,-1):
     a=ceiling-1
     for _ in range(200):
      if a<j or math.comb(a,j)<=r:break
      a-=1
     out.append(a)
     r=r-(math.comb(a,j) if a>=j else 0)
     ceiling=a
    return out[::-1]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([2, 1], [0, 2]), ([2, 3], [0, 3]), ([1, 0], [0]), ([5, 49], [0, 3, 5, 6, 7]), ([1, 1], [1]), ([1, 2], [2]), ([1, 3], [3]), ([1, 4], [4])], [([2, 3], [0, 3]), ([2, 7], [1, 4]), ([1, 0], [0]), ([5, 49], [0, 3, 5, 6, 7]), ([1, 17], [17]), ([1, 18], [18]), ([1, 19], [19]), ([1, 20], [20])], [([2, 4], [1, 3]), ([2, 11], [1, 5]), ([1, 0], [0]), ([5, 49], [0, 3, 5, 6, 7]), ([1, 34], [34]), ([1, 35], [35]), ([1, 36], [36]), ([1, 37], [37])], [([2, 6], [0, 4]), ([2, 15], [0, 6]), ([1, 0], [0]), ([5, 49], [0, 3, 5, 6, 7]), ([2, 1], [0, 2]), ([2, 2], [1, 2]), ([2, 3], [0, 3]), ([2, 4], [1, 3])], [([2, 7], [1, 4]), ([2, 18], [3, 6]), ([1, 0], [0]), ([5, 49], [0, 3, 5, 6, 7]), ([2, 19], [4, 6]), ([2, 20], [5, 6]), ([2, 21], [0, 7]), ([2, 22], [1, 7])]]
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 fixtureActualExpectedOutcome
explicit oracle 0[0, 2][0, 2]Passed
explicit oracle 1[0, 3][0, 3]Passed
explicit oracle 2[0][0]Passed
explicit oracle 3[0, 3, 5, 6, 7][0, 3, 5, 6, 7]Passed
explicit oracle 4[1][1]Passed
explicit oracle 5[2][2]Passed
explicit oracle 6[3][3]Passed
explicit oracle 7[4][4]Passed

SHA-256 / fe3e5d1ef73afa5ad4005ac61c5c512ac9285d2a53a722295aa3b3611210608b

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

Case digest / f374fb9252866609683015aeff68c2b2b17de2184cbf6f0329d33d9da2810422