FAILURE MAP
← Case archive

FA-15561 / Numerics / Open access

Kummer binomial valuation: next prime digits · case 01

The exact kummer binomial valuation result violates the stated contract at next prime digits.

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

ROOT CAUSE

The next prime digits step uses a%p,b%p instead of a//p,b//p.

VERIFIED REPAIR

Use a//p,b//p at the next prime digits step.

Unsuccessful approach: The partial repair a//p,b still violates the next prime digits 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=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 = [[([2, 1, 2], 1), ([1, 0, 2], 0), ([59, 59, 7], 0), ([1, 1, 2], 0), ([2, 0, 2], 0), ([2, 2, 2], 0), ([3, 0, 2], 0), ([3, 1, 2], 0)], [([4, 1, 2], 2), ([4, 2, 2], 1), ([1, 0, 2], 0), ([59, 59, 7], 0), ([5, 3, 2], 1), ([5, 4, 2], 0), ([5, 5, 2], 0), ([6, 0, 2], 0)], [([4, 2, 2], 1), ([5, 3, 2], 1), ([1, 0, 2], 0), ([59, 59, 7], 0), ([7, 7, 2], 0), ([8, 0, 2], 0), ([8, 1, 2], 3), ([8, 2, 2], 2)], [([4, 3, 2], 2), ([6, 3, 2], 2), ([1, 0, 2], 0), ([59, 59, 7], 0), ([9, 7, 2], 2), ([9, 8, 2], 0), ([9, 9, 2], 0), ([10, 0, 2], 0)], [([5, 2, 2], 1), ([7, 4, 2], 0), ([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 0401Failed
explicit oracle 100Passed
explicit oracle 200Passed
explicit oracle 300Passed
explicit oracle 400Passed
explicit oracle 500Passed
explicit oracle 600Passed
explicit oracle 700Passed

SHA-256 / 24931c8a6dbac63786bfb64e3c876b36bb77fc2612e0c8ffeb90fa4779f35c8b

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=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
    return count
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([2, 1, 2], 1), ([1, 0, 2], 0), ([59, 59, 7], 0), ([1, 1, 2], 0), ([2, 0, 2], 0), ([2, 2, 2], 0), ([3, 0, 2], 0), ([3, 1, 2], 0)], [([4, 1, 2], 2), ([4, 2, 2], 1), ([1, 0, 2], 0), ([59, 59, 7], 0), ([5, 3, 2], 1), ([5, 4, 2], 0), ([5, 5, 2], 0), ([6, 0, 2], 0)], [([4, 2, 2], 1), ([5, 3, 2], 1), ([1, 0, 2], 0), ([59, 59, 7], 0), ([7, 7, 2], 0), ([8, 0, 2], 0), ([8, 1, 2], 3), ([8, 2, 2], 2)], [([4, 3, 2], 2), ([6, 3, 2], 2), ([1, 0, 2], 0), ([59, 59, 7], 0), ([9, 7, 2], 2), ([9, 8, 2], 0), ([9, 9, 2], 0), ([10, 0, 2], 0)], [([5, 2, 2], 1), ([7, 4, 2], 0), ([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 0401Failed
explicit oracle 100Passed
explicit oracle 200Passed
explicit oracle 300Passed
explicit oracle 400Passed
explicit oracle 500Passed
explicit oracle 600Passed
explicit oracle 700Passed

SHA-256 / e6e1745b247bb73d54b66af474e04f827e37aec50b2cf8486b45c90f893bedc6

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 = [[([2, 1, 2], 1), ([1, 0, 2], 0), ([59, 59, 7], 0), ([1, 1, 2], 0), ([2, 0, 2], 0), ([2, 2, 2], 0), ([3, 0, 2], 0), ([3, 1, 2], 0)], [([4, 1, 2], 2), ([4, 2, 2], 1), ([1, 0, 2], 0), ([59, 59, 7], 0), ([5, 3, 2], 1), ([5, 4, 2], 0), ([5, 5, 2], 0), ([6, 0, 2], 0)], [([4, 2, 2], 1), ([5, 3, 2], 1), ([1, 0, 2], 0), ([59, 59, 7], 0), ([7, 7, 2], 0), ([8, 0, 2], 0), ([8, 1, 2], 3), ([8, 2, 2], 2)], [([4, 3, 2], 2), ([6, 3, 2], 2), ([1, 0, 2], 0), ([59, 59, 7], 0), ([9, 7, 2], 2), ([9, 8, 2], 0), ([9, 9, 2], 0), ([10, 0, 2], 0)], [([5, 2, 2], 1), ([7, 4, 2], 0), ([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 011Passed
explicit oracle 100Passed
explicit oracle 200Passed
explicit oracle 300Passed
explicit oracle 400Passed
explicit oracle 500Passed
explicit oracle 600Passed
explicit oracle 700Passed

SHA-256 / bc9dbb406e2c165340a7f928bf515b018b0b05efa4bc7b0cc56b26b3ad854531

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

Case digest / 4090ef236aa7c4654cc5f8ec0cfc4eb1ffc1d0b8bc8e22001efb6bf99753f7e7