FA-15531 / Numerics / Open access
Lucas binomial residue: digit binomial multiplication · case 01
The exact lucas binomial residue result violates the stated contract at digit binomial multiplication.
ROOT CAUSE
The digit binomial multiplication step uses (r+math.comb(a,b))%p instead of r*math.comb(a,b)%p.
VERIFIED REPAIR
Use r*math.comb(a,b)%p at the digit binomial multiplication step.
Unsuccessful approach: The partial repair math.comb(a,b)%p still violates the digit binomial multiplication invariant.
Case contract
Input [n,k,p], n,k>=0 p prime; return binomial(n,k) modulo p, zero when k>n. Bounds: n,k<2^30.
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;r=1
for _ in range(30):
if n==0 and k==0:break
a,b=n%p,k%p
if b>a:return 0
r=(r+math.comb(a,b))%p
n,k=n//p,k//p
return r
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([1, 0, 2], 1), ([5, 1, 3], 2), ([0, 0, 2], 1), ([34, 37, 7], 0), ([0, 1, 2], 0), ([0, 2, 2], 0), ([0, 3, 2], 0), ([0, 4, 2], 0)], [([1, 1, 2], 1), ([8, 4, 3], 1), ([0, 0, 2], 1), ([34, 37, 7], 0), ([0, 17, 2], 0), ([0, 18, 2], 0), ([0, 19, 2], 0), ([0, 20, 2], 0)], [([4, 0, 2], 1), ([11, 10, 3], 2), ([0, 0, 2], 1), ([34, 37, 7], 0), ([0, 34, 2], 0), ([0, 35, 2], 0), ([0, 36, 2], 0), ([0, 37, 2], 0)], [([4, 4, 2], 1), ([14, 10, 3], 2), ([0, 0, 2], 1), ([34, 37, 7], 0), ([1, 13, 2], 0), ([1, 14, 2], 0), ([1, 15, 2], 0), ([1, 16, 2], 0)], [([5, 0, 2], 1), ([15, 12, 3], 2), ([0, 0, 2], 1), ([34, 37, 7], 0), ([1, 30, 2], 0), ([1, 31, 2], 0), ([1, 32, 2], 0), ([1, 33, 2], 0)]]
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 | 1 | 2 | Failed |
| explicit oracle 2 | 1 | 1 | 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 / 5d965d9110594ca67091ead45cba7f2b5ff1c4ea9b8f86c36c911ecb2038a91a
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;r=1
for _ in range(30):
if n==0 and k==0:break
a,b=n%p,k%p
if b>a:return 0
r=math.comb(a,b)%p
n,k=n//p,k//p
return r
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([1, 0, 2], 1), ([5, 1, 3], 2), ([0, 0, 2], 1), ([34, 37, 7], 0), ([0, 1, 2], 0), ([0, 2, 2], 0), ([0, 3, 2], 0), ([0, 4, 2], 0)], [([1, 1, 2], 1), ([8, 4, 3], 1), ([0, 0, 2], 1), ([34, 37, 7], 0), ([0, 17, 2], 0), ([0, 18, 2], 0), ([0, 19, 2], 0), ([0, 20, 2], 0)], [([4, 0, 2], 1), ([11, 10, 3], 2), ([0, 0, 2], 1), ([34, 37, 7], 0), ([0, 34, 2], 0), ([0, 35, 2], 0), ([0, 36, 2], 0), ([0, 37, 2], 0)], [([4, 4, 2], 1), ([14, 10, 3], 2), ([0, 0, 2], 1), ([34, 37, 7], 0), ([1, 13, 2], 0), ([1, 14, 2], 0), ([1, 15, 2], 0), ([1, 16, 2], 0)], [([5, 0, 2], 1), ([15, 12, 3], 2), ([0, 0, 2], 1), ([34, 37, 7], 0), ([1, 30, 2], 0), ([1, 31, 2], 0), ([1, 32, 2], 0), ([1, 33, 2], 0)]]
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 | 1 | 2 | Failed |
| explicit oracle 2 | 1 | 1 | 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 / 21dbb9d61c9be8723de958adea9fd8843c823e60709a814a7a774220a62cc415
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;r=1
for _ in range(30):
if n==0 and k==0:break
a,b=n%p,k%p
if b>a:return 0
r=r*math.comb(a,b)%p
n,k=n//p,k//p
return r
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([1, 0, 2], 1), ([5, 1, 3], 2), ([0, 0, 2], 1), ([34, 37, 7], 0), ([0, 1, 2], 0), ([0, 2, 2], 0), ([0, 3, 2], 0), ([0, 4, 2], 0)], [([1, 1, 2], 1), ([8, 4, 3], 1), ([0, 0, 2], 1), ([34, 37, 7], 0), ([0, 17, 2], 0), ([0, 18, 2], 0), ([0, 19, 2], 0), ([0, 20, 2], 0)], [([4, 0, 2], 1), ([11, 10, 3], 2), ([0, 0, 2], 1), ([34, 37, 7], 0), ([0, 34, 2], 0), ([0, 35, 2], 0), ([0, 36, 2], 0), ([0, 37, 2], 0)], [([4, 4, 2], 1), ([14, 10, 3], 2), ([0, 0, 2], 1), ([34, 37, 7], 0), ([1, 13, 2], 0), ([1, 14, 2], 0), ([1, 15, 2], 0), ([1, 16, 2], 0)], [([5, 0, 2], 1), ([15, 12, 3], 2), ([0, 0, 2], 1), ([34, 37, 7], 0), ([1, 30, 2], 0), ([1, 31, 2], 0), ([1, 32, 2], 0), ([1, 33, 2], 0)]]
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 | 2 | 2 | Passed |
| explicit oracle 2 | 1 | 1 | 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 / ebe5a4636f0b1bcf743bb13f155e20610cfb16890c0482ed6ba3dc9f98ce5e0e
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.687493+00:00.
Case digest / ae8801346253625c09b5543272a19951c8a7ce4687180a5b570d807cb2870755