FA-15556 / Numerics / Open access
Kummer binomial valuation: digit overflow carry · case 01
The exact kummer binomial valuation result violates the stated contract at digit overflow carry.
ROOT CAUSE
The digit overflow carry step uses int(t>p) instead of int(t>=p).
VERIFIED REPAIR
Use int(t>=p) at the digit overflow carry step.
Unsuccessful approach: The partial repair t%p still violates the digit overflow carry 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), ([2, 1, 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), ([3, 1, 2], 0), ([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), ([4, 0, 2], 0), ([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), ([4, 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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| explicit oracle 0 | 0 | 1 | Failed |
| explicit oracle 1 | 0 | 0 | Passed |
| explicit oracle 2 | 0 | 0 | Passed |
| explicit oracle 3 | 0 | 0 | Passed |
| explicit oracle 4 | 0 | 0 | Passed |
| explicit oracle 5 | 0 | 0 | Passed |
| explicit oracle 6 | 0 | 0 | Passed |
| explicit oracle 7 | 0 | 0 | Passed |
SHA-256 / 4e4c4aee8b745a17feb88f5f32fdd115d36b1b16488c071441cf4988a568d9b0
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=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), ([2, 1, 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), ([3, 1, 2], 0), ([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), ([4, 0, 2], 0), ([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), ([4, 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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| explicit oracle 0 | 0 | 1 | Failed |
| explicit oracle 1 | 40 | 0 | Failed |
| explicit oracle 2 | 197 | 0 | Failed |
| explicit oracle 3 | 40 | 0 | Failed |
| explicit oracle 4 | 39 | 0 | Failed |
| explicit oracle 5 | 39 | 0 | Failed |
| explicit oracle 6 | 1 | 0 | Failed |
| explicit oracle 7 | 1 | 0 | Failed |
SHA-256 / 9f38fe9e9ba05a80a6dd82ed4a3286d5fcb416af1a1eab935b1b40c32475ed6c
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), ([2, 1, 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), ([3, 1, 2], 0), ([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), ([4, 0, 2], 0), ([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), ([4, 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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| explicit oracle 0 | 1 | 1 | Passed |
| explicit oracle 1 | 0 | 0 | Passed |
| explicit oracle 2 | 0 | 0 | Passed |
| explicit oracle 3 | 0 | 0 | Passed |
| explicit oracle 4 | 0 | 0 | Passed |
| explicit oracle 5 | 0 | 0 | Passed |
| explicit oracle 6 | 0 | 0 | Passed |
| explicit oracle 7 | 0 | 0 | Passed |
SHA-256 / 373e3d597d2ce0cce3f6937bc017b97078dc980b00958b8052c9fb9cb4ee98dc
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.049384+00:00.
Case digest / 36c71b3150bba10a1affbe0962e34805969592379e85813ee3fe51779417b98f