FA-15516 / Numerics / Open access
Lucas binomial residue: digit product identity · case 01
The exact lucas binomial residue result violates the stated contract at digit product identity.
ROOT CAUSE
The digit product identity step uses 0 instead of 1.
VERIFIED REPAIR
Use 1 at the digit product identity step.
Unsuccessful approach: The partial repair p still violates the digit product identity 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=0
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 = [[([0, 0, 2], 1), ([34, 37, 7], 0), ([0, 1, 2], 0), ([0, 2, 2], 0), ([0, 3, 2], 0), ([0, 4, 2], 0), ([0, 5, 2], 0), ([0, 6, 2], 0)], [([1, 0, 2], 1), ([2, 0, 2], 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)], [([1, 1, 2], 1), ([3, 1, 2], 1), ([0, 0, 2], 1), ([34, 37, 7], 0), ([0, 34, 2], 0), ([0, 35, 2], 0), ([0, 36, 2], 0), ([0, 37, 2], 0)], [([2, 0, 2], 1), ([4, 0, 2], 1), ([0, 0, 2], 1), ([34, 37, 7], 0), ([1, 13, 2], 0), ([1, 14, 2], 0), ([1, 15, 2], 0), ([1, 16, 2], 0)], [([2, 2, 2], 1), ([5, 1, 2], 1), ([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 | 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 / b5063100c964ba9af2ce44401cd9fbe848d9a468462730a89a8113e60a1fd224
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=p
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 = [[([0, 0, 2], 1), ([34, 37, 7], 0), ([0, 1, 2], 0), ([0, 2, 2], 0), ([0, 3, 2], 0), ([0, 4, 2], 0), ([0, 5, 2], 0), ([0, 6, 2], 0)], [([1, 0, 2], 1), ([2, 0, 2], 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)], [([1, 1, 2], 1), ([3, 1, 2], 1), ([0, 0, 2], 1), ([34, 37, 7], 0), ([0, 34, 2], 0), ([0, 35, 2], 0), ([0, 36, 2], 0), ([0, 37, 2], 0)], [([2, 0, 2], 1), ([4, 0, 2], 1), ([0, 0, 2], 1), ([34, 37, 7], 0), ([1, 13, 2], 0), ([1, 14, 2], 0), ([1, 15, 2], 0), ([1, 16, 2], 0)], [([2, 2, 2], 1), ([5, 1, 2], 1), ([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 | 2 | 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 / 9bc533cb5464a814452095526ad6594ef9eaf87010d8a4eae51998d2ecf7bc35
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 = [[([0, 0, 2], 1), ([34, 37, 7], 0), ([0, 1, 2], 0), ([0, 2, 2], 0), ([0, 3, 2], 0), ([0, 4, 2], 0), ([0, 5, 2], 0), ([0, 6, 2], 0)], [([1, 0, 2], 1), ([2, 0, 2], 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)], [([1, 1, 2], 1), ([3, 1, 2], 1), ([0, 0, 2], 1), ([34, 37, 7], 0), ([0, 34, 2], 0), ([0, 35, 2], 0), ([0, 36, 2], 0), ([0, 37, 2], 0)], [([2, 0, 2], 1), ([4, 0, 2], 1), ([0, 0, 2], 1), ([34, 37, 7], 0), ([1, 13, 2], 0), ([1, 14, 2], 0), ([1, 15, 2], 0), ([1, 16, 2], 0)], [([2, 2, 2], 1), ([5, 1, 2], 1), ([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 | 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 / e0fa246a65d64ea151f2c1fb0307bae70b3dc87037baa5c1999c125b7439762c
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.413586+00:00.
Case digest / 220bc7911db8858b95edd5bca1ce1a7af918127c78c29e755f6a084474c7273c