FAILURE MAP
← Case archive

FA-15526 / Numerics / Open access

Lucas binomial residue: digit carry zero criterion · case 01

The exact lucas binomial residue result violates the stated contract at digit carry zero criterion.

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

ROOT CAUSE

The digit carry zero criterion step uses b>=a instead of b>a.

THE FAILURE

The digit carry zero criterion step uses b>=a instead of b>a.

Unsuccessful approach: The partial repair b<a still violates the digit carry zero criterion 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, 1, 2], 1), ([1, 0, 2], 1), ([0, 0, 2], 1), ([34, 37, 7], 0), ([0, 1, 2], 0), ([0, 2, 2], 0), ([0, 3, 2], 0), ([0, 4, 2], 0)], [([2, 0, 2], 1), ([3, 1, 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)], [([2, 2, 2], 1), ([5, 0, 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)], [([3, 1, 2], 1), ([6, 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)], [([3, 2, 2], 1), ([7, 0, 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 fixtureActualExpectedOutcome
explicit oracle 001Failed
explicit oracle 111Passed
explicit oracle 211Passed
explicit oracle 300Passed
explicit oracle 400Passed
explicit oracle 500Passed
explicit oracle 600Passed
explicit oracle 700Passed

SHA-256 / dfd3e5d532db699c8da339314a2baef998625b672198239c17b81032816fd67b

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=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, 1, 2], 1), ([1, 0, 2], 1), ([0, 0, 2], 1), ([34, 37, 7], 0), ([0, 1, 2], 0), ([0, 2, 2], 0), ([0, 3, 2], 0), ([0, 4, 2], 0)], [([2, 0, 2], 1), ([3, 1, 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)], [([2, 2, 2], 1), ([5, 0, 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)], [([3, 1, 2], 1), ([6, 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)], [([3, 2, 2], 1), ([7, 0, 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 fixtureActualExpectedOutcome
explicit oracle 011Passed
explicit oracle 101Failed
explicit oracle 211Passed
explicit oracle 300Passed
explicit oracle 400Passed
explicit oracle 500Passed
explicit oracle 600Passed
explicit oracle 700Passed

SHA-256 / 65c08f77d03d1783ed47a8f0101ad1e53e45e2b01ce2511a39e511aac19d1fcb

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

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

Case digest / 9a1cb089e5498ad6b9676330cfcb7d1646492c4cd9213e4674f6027ef8c12701