FAILURE MAP
← Case archive

FA-15546 / Numerics / Open access

Kummer binomial valuation: carry propagation termination · case 01

The exact kummer binomial valuation result violates the stated contract at carry propagation termination.

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

ROOT CAUSE

The carry propagation termination step uses a==0 or b==0 instead of a==0 and b==0 and carry==0.

VERIFIED REPAIR

Use a==0 and b==0 and carry==0 at the carry propagation termination step.

Unsuccessful approach: The partial repair a<p and b<p still violates the carry propagation termination 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 or b==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), ([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)], [([4, 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), ([6, 1, 2], 1)], [([8, 1, 2], 3), ([6, 3, 2], 2), ([1, 0, 2], 0), ([59, 59, 7], 0), ([7, 7, 2], 0), ([8, 0, 2], 0), ([8, 2, 2], 2), ([8, 3, 2], 3)], [([8, 2, 2], 2), ([8, 3, 2], 3), ([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), ([8, 6, 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 111Passed
explicit oracle 200Passed
explicit oracle 300Passed
explicit oracle 400Passed
explicit oracle 500Passed
explicit oracle 600Passed
explicit oracle 700Passed

SHA-256 / c3e1499366322d9dde8e6abf3eca1d920f075ddacd93a921a4586ac7dbb0d5bf

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<p and b<p: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), ([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)], [([4, 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), ([6, 1, 2], 1)], [([8, 1, 2], 3), ([6, 3, 2], 2), ([1, 0, 2], 0), ([59, 59, 7], 0), ([7, 7, 2], 0), ([8, 0, 2], 0), ([8, 2, 2], 2), ([8, 3, 2], 3)], [([8, 2, 2], 2), ([8, 3, 2], 3), ([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), ([8, 6, 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 101Failed
explicit oracle 200Passed
explicit oracle 300Passed
explicit oracle 400Passed
explicit oracle 500Passed
explicit oracle 600Passed
explicit oracle 700Passed

SHA-256 / d34efe39962e0cd4bb1447ffa18ac43e3818300b5e57583ac422bcb652bae1b6

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

SHA-256 / 67839bf4b6ac0f58427d3b807c6d071125519edd606d265ebc5e2789b9b4a73c

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

Case digest / 12d0182872b78978caaa613987b590fe5847bf5e07710e8ec2d4ba01b691f6dd