FA-15011 / Numerics / Open access
Best bounded rational: tie selection · case 01
The exact best bounded rational result violates the stated contract at tie selection.
ROOT CAUSE
The tie selection step uses max(candidates) instead of min(candidates).
VERIFIED REPAIR
Use min(candidates) at the tie selection step.
Unsuccessful approach: The partial repair min(candidates,key=lambda z:(z[0],-z[1],z[2])) still violates the tie selection 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+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=max(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, 8, 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, 1, 2], [-12, 1]), ([-11, 6, 3], [-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, 1, 3], [-12, 1]), ([-10, 8, 2], [-3, 2]), ([-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, 1, 4], [-12, 1]), ([-9, 6, 1], [-2, 1]), ([-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, 1, 5], [-12, 1]), ([-7, 2, 1], [-4, 1]), ([-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 | [-11, 1] | [-12, 1] | Failed |
| explicit oracle 1 | [-1, 1] | [-2, 1] | Failed |
| explicit oracle 2 | [2, 1] | [8, 7] | Failed |
| explicit oracle 3 | [-11, 1] | [-12, 1] | Failed |
| explicit oracle 4 | [-11, 1] | [-12, 1] | Failed |
| explicit oracle 5 | [-11, 1] | [-12, 1] | Failed |
| explicit oracle 6 | [-11, 1] | [-12, 1] | Failed |
| explicit oracle 7 | [-11, 1] | [-12, 1] | Failed |
SHA-256 / 9b037f2a34e1b12a3b6cc94ac770ca8c038c9bf60fd517580b118c864b1940c0
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(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,key=lambda z:(z[0],-z[1],z[2]))
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, 8, 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, 1, 2], [-12, 1]), ([-11, 6, 3], [-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, 1, 3], [-12, 1]), ([-10, 8, 2], [-3, 2]), ([-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, 1, 4], [-12, 1]), ([-9, 6, 1], [-2, 1]), ([-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, 1, 5], [-12, 1]), ([-7, 2, 1], [-4, 1]), ([-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 | [-1, 1] | [-2, 1] | Failed |
| 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 / 3ed50afa555d682c9600690af0a48660b9c9ced42f9a8fe978d18a7decbf23cc
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, 8, 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, 1, 2], [-12, 1]), ([-11, 6, 3], [-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, 1, 3], [-12, 1]), ([-10, 8, 2], [-3, 2]), ([-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, 1, 4], [-12, 1]), ([-9, 6, 1], [-2, 1]), ([-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, 1, 5], [-12, 1]), ([-7, 2, 1], [-4, 1]), ([-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 / ec9c0c5fb431b9b1da181e7254b1449a9093a98b9ecc945e496ee4ab002cfcfa
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.573915+00:00.
Case digest / d4f8446e849266e62bbc4eb1565f4ece6ec46a6852310ed7d17c3d3f32ecfc0f