FAILURE MAP
← Case archive

FA-15541 / Numerics / Open access

Kummer binomial valuation: first addend selection · case 01

The exact kummer binomial valuation result violates the stated contract at first addend selection.

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

ROOT CAUSE

The first addend selection step uses n instead of k.

VERIFIED REPAIR

Use k at the first addend selection step.

Unsuccessful approach: The partial repair n-k still violates the first addend selection invariant.

Case contract

Input [n,k,p], 0<=k<=n p prime; return exponent of p in binomial(n,k) via carries adding k and n-k. Bounds: n<2^39.

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):
    n,k,p=x;a=n;b=n-k;carry=0;count=0
    for _ in range(40):
     if a==0 and b==0 and carry==0:break
     t=a%p+b%p+carry
     carry=int(t>=p)
     count+=carry
     a,b=a//p,b//p
    return count
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([1, 0, 2], 0), ([59, 59, 7], 0), ([1, 1, 2], 0), ([2, 0, 2], 0), ([2, 1, 2], 1), ([2, 2, 2], 0), ([3, 0, 2], 0), ([3, 1, 2], 0)], [([2, 0, 2], 0), ([3, 1, 2], 0), ([1, 0, 2], 0), ([59, 59, 7], 0), ([5, 3, 2], 1), ([5, 4, 2], 0), ([5, 5, 2], 0), ([6, 0, 2], 0)], [([2, 1, 2], 1), ([4, 3, 2], 2), ([1, 0, 2], 0), ([59, 59, 7], 0), ([7, 7, 2], 0), ([8, 0, 2], 0), ([8, 1, 2], 3), ([8, 2, 2], 2)], [([3, 0, 2], 0), ([5, 2, 2], 1), ([1, 0, 2], 0), ([59, 59, 7], 0), ([9, 7, 2], 2), ([9, 8, 2], 0), ([9, 9, 2], 0), ([10, 0, 2], 0)], [([3, 1, 2], 0), ([6, 1, 2], 1), ([1, 0, 2], 0), ([59, 59, 7], 0), ([11, 3, 2], 0), ([11, 4, 2], 1), ([11, 5, 2], 1), ([11, 6, 2], 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 fixtureActualExpectedOutcome
explicit oracle 010Failed
explicit oracle 100Passed
explicit oracle 200Passed
explicit oracle 310Failed
explicit oracle 401Failed
explicit oracle 500Passed
explicit oracle 620Failed
explicit oracle 710Failed

SHA-256 / 7475ca164c7601d765c7868705b5a84c7b5cd8f6aa7c8dff852cffc5aae86bc2

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):
    n,k,p=x;a=n-k;b=n-k;carry=0;count=0
    for _ in range(40):
     if a==0 and b==0 and carry==0:break
     t=a%p+b%p+carry
     carry=int(t>=p)
     count+=carry
     a,b=a//p,b//p
    return count
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([1, 0, 2], 0), ([59, 59, 7], 0), ([1, 1, 2], 0), ([2, 0, 2], 0), ([2, 1, 2], 1), ([2, 2, 2], 0), ([3, 0, 2], 0), ([3, 1, 2], 0)], [([2, 0, 2], 0), ([3, 1, 2], 0), ([1, 0, 2], 0), ([59, 59, 7], 0), ([5, 3, 2], 1), ([5, 4, 2], 0), ([5, 5, 2], 0), ([6, 0, 2], 0)], [([2, 1, 2], 1), ([4, 3, 2], 2), ([1, 0, 2], 0), ([59, 59, 7], 0), ([7, 7, 2], 0), ([8, 0, 2], 0), ([8, 1, 2], 3), ([8, 2, 2], 2)], [([3, 0, 2], 0), ([5, 2, 2], 1), ([1, 0, 2], 0), ([59, 59, 7], 0), ([9, 7, 2], 2), ([9, 8, 2], 0), ([9, 9, 2], 0), ([10, 0, 2], 0)], [([3, 1, 2], 0), ([6, 1, 2], 1), ([1, 0, 2], 0), ([59, 59, 7], 0), ([11, 3, 2], 0), ([11, 4, 2], 1), ([11, 5, 2], 1), ([11, 6, 2], 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 fixtureActualExpectedOutcome
explicit oracle 010Failed
explicit oracle 100Passed
explicit oracle 200Passed
explicit oracle 310Failed
explicit oracle 411Passed
explicit oracle 500Passed
explicit oracle 620Failed
explicit oracle 710Failed

SHA-256 / dac84cf453e46ae423db4db11f2bb3abd7785d45f6c125a14f227c23bbe71998

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):
    n,k,p=x;a=k;b=n-k;carry=0;count=0
    for _ in range(40):
     if a==0 and b==0 and carry==0:break
     t=a%p+b%p+carry
     carry=int(t>=p)
     count+=carry
     a,b=a//p,b//p
    return count
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([1, 0, 2], 0), ([59, 59, 7], 0), ([1, 1, 2], 0), ([2, 0, 2], 0), ([2, 1, 2], 1), ([2, 2, 2], 0), ([3, 0, 2], 0), ([3, 1, 2], 0)], [([2, 0, 2], 0), ([3, 1, 2], 0), ([1, 0, 2], 0), ([59, 59, 7], 0), ([5, 3, 2], 1), ([5, 4, 2], 0), ([5, 5, 2], 0), ([6, 0, 2], 0)], [([2, 1, 2], 1), ([4, 3, 2], 2), ([1, 0, 2], 0), ([59, 59, 7], 0), ([7, 7, 2], 0), ([8, 0, 2], 0), ([8, 1, 2], 3), ([8, 2, 2], 2)], [([3, 0, 2], 0), ([5, 2, 2], 1), ([1, 0, 2], 0), ([59, 59, 7], 0), ([9, 7, 2], 2), ([9, 8, 2], 0), ([9, 9, 2], 0), ([10, 0, 2], 0)], [([3, 1, 2], 0), ([6, 1, 2], 1), ([1, 0, 2], 0), ([59, 59, 7], 0), ([11, 3, 2], 0), ([11, 4, 2], 1), ([11, 5, 2], 1), ([11, 6, 2], 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 fixtureActualExpectedOutcome
explicit oracle 000Passed
explicit oracle 100Passed
explicit oracle 200Passed
explicit oracle 300Passed
explicit oracle 411Passed
explicit oracle 500Passed
explicit oracle 600Passed
explicit oracle 700Passed

SHA-256 / 5e364b4b5949484edbdf7656f043fc16e79b32145b184e6540624fa1ffb521bf

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

Case digest / 9d9d0e405ec798ec617f1e83f77440d4b843ed7ae1b31c055694465fcd63b45c