FAILURE MAP
← Case archive

FA-15551 / Numerics / Open access

Kummer binomial valuation: incoming carry inclusion · case 01

The exact kummer binomial valuation result violates the stated contract at incoming carry inclusion.

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

ROOT CAUSE

The incoming carry inclusion step uses a%p+b%p instead of a%p+b%p+carry.

VERIFIED REPAIR

Use a%p+b%p+carry at the incoming carry inclusion step.

Unsuccessful approach: The partial repair a%p+b%p+count still violates the incoming carry inclusion 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=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 = [[([4, 1, 2], 2), ([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)], [([4, 3, 2], 2), ([6, 3, 2], 2), ([1, 0, 2], 0), ([59, 59, 7], 0), ([5, 3, 2], 1), ([5, 4, 2], 0), ([5, 5, 2], 0), ([6, 0, 2], 0)], [([8, 1, 2], 3), ([8, 2, 2], 2), ([1, 0, 2], 0), ([59, 59, 7], 0), ([7, 7, 2], 0), ([8, 0, 2], 0), ([8, 3, 2], 3), ([8, 4, 2], 1)], [([8, 2, 2], 2), ([8, 6, 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)], [([8, 3, 2], 3), ([9, 3, 2], 2), ([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 012Failed
explicit oracle 100Passed
explicit oracle 200Passed
explicit oracle 300Passed
explicit oracle 400Passed
explicit oracle 511Passed
explicit oracle 600Passed
explicit oracle 700Passed

SHA-256 / 1c409a60680e3d23405d8e8796eaf6b6b07104498e625c34259d39a31a27a521

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

SHA-256 / b4e184793a6120b53f21d574e1ce194fa1fa4926d521e796e01d3ef34ada4ac8

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

SHA-256 / 201374408ea4beaf35d112a7a469ee68de078cf4321db7111c60f17094abe093

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

Case digest / ee075b04e871e5644d85946c8523907ea349f87a4e66fb2112c14f29c2e18de4