FA-14991 / Numerics / Open access
Best bounded rational: denominator bound inclusion · case 01
The exact best bounded rational result violates the stated contract at denominator bound inclusion.
ROOT CAUSE
The denominator bound inclusion step uses range(1,B) instead of range(1,B+1).
VERIFIED REPAIR
Use range(1,B+1) at the denominator bound inclusion step.
Unsuccessful approach: The partial repair range(2,B+2) still violates the denominator bound inclusion invariant.
Case contract
Input [p,q,B], q>0 B>0; nearest rational to p/q with denominator<=B, ties choose smaller rational then denominator.
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):
p,q,B=x;target=Fraction(p,q);candidates=[]
for d in range(1,B):
a=(p*d)//q
for n in (a,a+1):
r=Fraction(n,d)
candidates.append((abs(r-target),r,d))
if not candidates:return None
best=min(candidates)
r=best[1]
return [r.numerator,r.denominator]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([-12, 1, 1], [-12, 1]), ([-12, 5, 1], [-2, 1]), ([12, 11, 7], [8, 7]), ([-12, 1, 2], [-12, 1]), ([-12, 1, 3], [-12, 1]), ([-12, 1, 4], [-12, 1]), ([-12, 1, 5], [-12, 1]), ([-12, 1, 6], [-12, 1])], [([-12, 2, 1], [-6, 1]), ([-12, 7, 1], [-2, 1]), ([-12, 1, 1], [-12, 1]), ([12, 11, 7], [8, 7]), ([-12, 3, 4], [-4, 1]), ([-12, 3, 5], [-4, 1]), ([-12, 3, 6], [-4, 1]), ([-12, 3, 7], [-4, 1])], [([-12, 3, 1], [-4, 1]), ([-12, 7, 6], [-7, 4]), ([-12, 1, 1], [-12, 1]), ([12, 11, 7], [8, 7]), ([-12, 5, 7], [-12, 5]), ([-12, 6, 1], [-2, 1]), ([-12, 6, 2], [-2, 1]), ([-12, 6, 3], [-2, 1])], [([-12, 4, 1], [-3, 1]), ([-12, 9, 2], [-3, 2]), ([-12, 1, 1], [-12, 1]), ([12, 11, 7], [8, 7]), ([-12, 8, 3], [-3, 2]), ([-12, 8, 4], [-3, 2]), ([-12, 8, 5], [-3, 2]), ([-12, 8, 6], [-3, 2])], [([-12, 5, 1], [-2, 1]), ([-12, 10, 4], [-5, 4]), ([-12, 1, 1], [-12, 1]), ([12, 11, 7], [8, 7]), ([-12, 10, 6], [-6, 5]), ([-12, 10, 7], [-6, 5]), ([-12, 11, 1], [-1, 1]), ([-12, 11, 2], [-1, 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 | None | [-12, 1] | Failed |
| explicit oracle 1 | None | [-2, 1] | Failed |
| explicit oracle 2 | [7, 6] | [8, 7] | Failed |
| explicit oracle 3 | [-12, 1] | [-12, 1] | Passed |
| explicit oracle 4 | [-12, 1] | [-12, 1] | Passed |
| explicit oracle 5 | [-12, 1] | [-12, 1] | Passed |
| explicit oracle 6 | [-12, 1] | [-12, 1] | Passed |
| explicit oracle 7 | [-12, 1] | [-12, 1] | Passed |
SHA-256 / 24aa6c975157819f53fa9b998da7336de887e2c1ce38a0a6444da000b6f17850
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):
p,q,B=x;target=Fraction(p,q);candidates=[]
for d in range(2,B+2):
a=(p*d)//q
for n in (a,a+1):
r=Fraction(n,d)
candidates.append((abs(r-target),r,d))
if not candidates:return None
best=min(candidates)
r=best[1]
return [r.numerator,r.denominator]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([-12, 1, 1], [-12, 1]), ([-12, 5, 1], [-2, 1]), ([12, 11, 7], [8, 7]), ([-12, 1, 2], [-12, 1]), ([-12, 1, 3], [-12, 1]), ([-12, 1, 4], [-12, 1]), ([-12, 1, 5], [-12, 1]), ([-12, 1, 6], [-12, 1])], [([-12, 2, 1], [-6, 1]), ([-12, 7, 1], [-2, 1]), ([-12, 1, 1], [-12, 1]), ([12, 11, 7], [8, 7]), ([-12, 3, 4], [-4, 1]), ([-12, 3, 5], [-4, 1]), ([-12, 3, 6], [-4, 1]), ([-12, 3, 7], [-4, 1])], [([-12, 3, 1], [-4, 1]), ([-12, 7, 6], [-7, 4]), ([-12, 1, 1], [-12, 1]), ([12, 11, 7], [8, 7]), ([-12, 5, 7], [-12, 5]), ([-12, 6, 1], [-2, 1]), ([-12, 6, 2], [-2, 1]), ([-12, 6, 3], [-2, 1])], [([-12, 4, 1], [-3, 1]), ([-12, 9, 2], [-3, 2]), ([-12, 1, 1], [-12, 1]), ([12, 11, 7], [8, 7]), ([-12, 8, 3], [-3, 2]), ([-12, 8, 4], [-3, 2]), ([-12, 8, 5], [-3, 2]), ([-12, 8, 6], [-3, 2])], [([-12, 5, 1], [-2, 1]), ([-12, 10, 4], [-5, 4]), ([-12, 1, 1], [-12, 1]), ([12, 11, 7], [8, 7]), ([-12, 10, 6], [-6, 5]), ([-12, 10, 7], [-6, 5]), ([-12, 11, 1], [-1, 1]), ([-12, 11, 2], [-1, 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 | [-12, 1] | [-12, 1] | Passed |
| explicit oracle 1 | [-5, 2] | [-2, 1] | Failed |
| explicit oracle 2 | [9, 8] | [8, 7] | Failed |
| explicit oracle 3 | [-12, 1] | [-12, 1] | Passed |
| explicit oracle 4 | [-12, 1] | [-12, 1] | Passed |
| explicit oracle 5 | [-12, 1] | [-12, 1] | Passed |
| explicit oracle 6 | [-12, 1] | [-12, 1] | Passed |
| explicit oracle 7 | [-12, 1] | [-12, 1] | Passed |
SHA-256 / ec9ba459a9867ad0679fc8a069f5d8f9c1f3e6c45a8e05737790bfb184395f49
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):
p,q,B=x;target=Fraction(p,q);candidates=[]
for d in range(1,B+1):
a=(p*d)//q
for n in (a,a+1):
r=Fraction(n,d)
candidates.append((abs(r-target),r,d))
if not candidates:return None
best=min(candidates)
r=best[1]
return [r.numerator,r.denominator]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([-12, 1, 1], [-12, 1]), ([-12, 5, 1], [-2, 1]), ([12, 11, 7], [8, 7]), ([-12, 1, 2], [-12, 1]), ([-12, 1, 3], [-12, 1]), ([-12, 1, 4], [-12, 1]), ([-12, 1, 5], [-12, 1]), ([-12, 1, 6], [-12, 1])], [([-12, 2, 1], [-6, 1]), ([-12, 7, 1], [-2, 1]), ([-12, 1, 1], [-12, 1]), ([12, 11, 7], [8, 7]), ([-12, 3, 4], [-4, 1]), ([-12, 3, 5], [-4, 1]), ([-12, 3, 6], [-4, 1]), ([-12, 3, 7], [-4, 1])], [([-12, 3, 1], [-4, 1]), ([-12, 7, 6], [-7, 4]), ([-12, 1, 1], [-12, 1]), ([12, 11, 7], [8, 7]), ([-12, 5, 7], [-12, 5]), ([-12, 6, 1], [-2, 1]), ([-12, 6, 2], [-2, 1]), ([-12, 6, 3], [-2, 1])], [([-12, 4, 1], [-3, 1]), ([-12, 9, 2], [-3, 2]), ([-12, 1, 1], [-12, 1]), ([12, 11, 7], [8, 7]), ([-12, 8, 3], [-3, 2]), ([-12, 8, 4], [-3, 2]), ([-12, 8, 5], [-3, 2]), ([-12, 8, 6], [-3, 2])], [([-12, 5, 1], [-2, 1]), ([-12, 10, 4], [-5, 4]), ([-12, 1, 1], [-12, 1]), ([12, 11, 7], [8, 7]), ([-12, 10, 6], [-6, 5]), ([-12, 10, 7], [-6, 5]), ([-12, 11, 1], [-1, 1]), ([-12, 11, 2], [-1, 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 | [-12, 1] | [-12, 1] | Passed |
| explicit oracle 1 | [-2, 1] | [-2, 1] | Passed |
| explicit oracle 2 | [8, 7] | [8, 7] | Passed |
| explicit oracle 3 | [-12, 1] | [-12, 1] | Passed |
| explicit oracle 4 | [-12, 1] | [-12, 1] | Passed |
| explicit oracle 5 | [-12, 1] | [-12, 1] | Passed |
| explicit oracle 6 | [-12, 1] | [-12, 1] | Passed |
| explicit oracle 7 | [-12, 1] | [-12, 1] | Passed |
SHA-256 / bda0cdff644b76f74b13d4887d4d230ff0d5e3fab0743d6141da2e1e68271ef9
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:22.470498+00:00.
Case digest / 549982e1e22a62bae8586fe562775af1b9a0c2f23652bb031b306ce44e6341cb