FA-14436 / Numerics / Open access
Rational continued fraction: coefficient order · case 01
The exact rational continued fraction result violates the stated contract at coefficient order.
ROOT CAUSE
The coefficient order step uses list(reversed(out)) instead of out.
VERIFIED REPAIR
Use out at the coefficient order step.
Unsuccessful approach: The partial repair sorted(out) still violates the coefficient order invariant.
Case contract
Input [p,q], q>0; canonical simple continued fraction of p/q with last term>1 unless singleton. Bounds: -25<=p<=25 and 1<=q<=17.
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=x
out=[]
for _ in range(30):
if q==0: break
a=p//q
out.append(a)
r=p-a*q
p,q=q,r
if len(out)>1 and out[-1]==1:
out[-2]+=1
out.pop()
return list(reversed(out))
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([-25, 2], [-13, 2]), ([-25, 9], [-3, 4, 2]), ([-25, 1], [-25]), ([25, 17], [1, 2, 8]), ([-25, 3], [-9, 1, 2]), ([-25, 4], [-7, 1, 3]), ([-25, 5], [-5]), ([-25, 6], [-5, 1, 5])], [([-25, 3], [-9, 1, 2]), ([-25, 16], [-2, 2, 3, 2]), ([-25, 1], [-25]), ([25, 17], [1, 2, 8]), ([-24, 1], [-24]), ([-24, 2], [-12]), ([-24, 3], [-8]), ([-24, 4], [-6])], [([-25, 4], [-7, 1, 3]), ([-24, 14], [-2, 3, 2]), ([-25, 1], [-25]), ([25, 17], [1, 2, 8]), ([-23, 1], [-23]), ([-23, 2], [-12, 2]), ([-23, 3], [-8, 3]), ([-23, 4], [-6, 4])], [([-25, 6], [-5, 1, 5]), ([-23, 16], [-2, 1, 1, 3, 2]), ([-25, 1], [-25]), ([25, 17], [1, 2, 8]), ([-22, 1], [-22]), ([-22, 2], [-11]), ([-22, 3], [-8, 1, 2]), ([-22, 4], [-6, 2])], [([-25, 7], [-4, 2, 3]), ([-20, 9], [-3, 1, 3, 2]), ([-25, 1], [-25]), ([25, 17], [1, 2, 8]), ([-21, 1], [-21]), ([-21, 2], [-11, 2]), ([-21, 3], [-7]), ([-21, 4], [-6, 1, 3])]]
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, -13] | [-13, 2] | Failed |
| explicit oracle 1 | [2, 4, -3] | [-3, 4, 2] | Failed |
| explicit oracle 2 | [-25] | [-25] | Passed |
| explicit oracle 3 | [8, 2, 1] | [1, 2, 8] | Failed |
| explicit oracle 4 | [2, 1, -9] | [-9, 1, 2] | Failed |
| explicit oracle 5 | [3, 1, -7] | [-7, 1, 3] | Failed |
| explicit oracle 6 | [-5] | [-5] | Passed |
| explicit oracle 7 | [5, 1, -5] | [-5, 1, 5] | Failed |
SHA-256 / 33ff0f1308357020a9d6246d0162808199aee8fae47d3bc7301aa6ee0a4b6167
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=x
out=[]
for _ in range(30):
if q==0: break
a=p//q
out.append(a)
r=p-a*q
p,q=q,r
if len(out)>1 and out[-1]==1:
out[-2]+=1
out.pop()
return sorted(out)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([-25, 2], [-13, 2]), ([-25, 9], [-3, 4, 2]), ([-25, 1], [-25]), ([25, 17], [1, 2, 8]), ([-25, 3], [-9, 1, 2]), ([-25, 4], [-7, 1, 3]), ([-25, 5], [-5]), ([-25, 6], [-5, 1, 5])], [([-25, 3], [-9, 1, 2]), ([-25, 16], [-2, 2, 3, 2]), ([-25, 1], [-25]), ([25, 17], [1, 2, 8]), ([-24, 1], [-24]), ([-24, 2], [-12]), ([-24, 3], [-8]), ([-24, 4], [-6])], [([-25, 4], [-7, 1, 3]), ([-24, 14], [-2, 3, 2]), ([-25, 1], [-25]), ([25, 17], [1, 2, 8]), ([-23, 1], [-23]), ([-23, 2], [-12, 2]), ([-23, 3], [-8, 3]), ([-23, 4], [-6, 4])], [([-25, 6], [-5, 1, 5]), ([-23, 16], [-2, 1, 1, 3, 2]), ([-25, 1], [-25]), ([25, 17], [1, 2, 8]), ([-22, 1], [-22]), ([-22, 2], [-11]), ([-22, 3], [-8, 1, 2]), ([-22, 4], [-6, 2])], [([-25, 7], [-4, 2, 3]), ([-20, 9], [-3, 1, 3, 2]), ([-25, 1], [-25]), ([25, 17], [1, 2, 8]), ([-21, 1], [-21]), ([-21, 2], [-11, 2]), ([-21, 3], [-7]), ([-21, 4], [-6, 1, 3])]]
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 | [-13, 2] | [-13, 2] | Passed |
| explicit oracle 1 | [-3, 2, 4] | [-3, 4, 2] | Failed |
| explicit oracle 2 | [-25] | [-25] | Passed |
| explicit oracle 3 | [1, 2, 8] | [1, 2, 8] | Passed |
| explicit oracle 4 | [-9, 1, 2] | [-9, 1, 2] | Passed |
| explicit oracle 5 | [-7, 1, 3] | [-7, 1, 3] | Passed |
| explicit oracle 6 | [-5] | [-5] | Passed |
| explicit oracle 7 | [-5, 1, 5] | [-5, 1, 5] | Passed |
SHA-256 / ee799d13ac79c004fd3dabd6ef0caf2c1606b82227df248ebb61a755c555a549
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=x
out=[]
for _ in range(30):
if q==0: break
a=p//q
out.append(a)
r=p-a*q
p,q=q,r
if len(out)>1 and out[-1]==1:
out[-2]+=1
out.pop()
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([-25, 2], [-13, 2]), ([-25, 9], [-3, 4, 2]), ([-25, 1], [-25]), ([25, 17], [1, 2, 8]), ([-25, 3], [-9, 1, 2]), ([-25, 4], [-7, 1, 3]), ([-25, 5], [-5]), ([-25, 6], [-5, 1, 5])], [([-25, 3], [-9, 1, 2]), ([-25, 16], [-2, 2, 3, 2]), ([-25, 1], [-25]), ([25, 17], [1, 2, 8]), ([-24, 1], [-24]), ([-24, 2], [-12]), ([-24, 3], [-8]), ([-24, 4], [-6])], [([-25, 4], [-7, 1, 3]), ([-24, 14], [-2, 3, 2]), ([-25, 1], [-25]), ([25, 17], [1, 2, 8]), ([-23, 1], [-23]), ([-23, 2], [-12, 2]), ([-23, 3], [-8, 3]), ([-23, 4], [-6, 4])], [([-25, 6], [-5, 1, 5]), ([-23, 16], [-2, 1, 1, 3, 2]), ([-25, 1], [-25]), ([25, 17], [1, 2, 8]), ([-22, 1], [-22]), ([-22, 2], [-11]), ([-22, 3], [-8, 1, 2]), ([-22, 4], [-6, 2])], [([-25, 7], [-4, 2, 3]), ([-20, 9], [-3, 1, 3, 2]), ([-25, 1], [-25]), ([25, 17], [1, 2, 8]), ([-21, 1], [-21]), ([-21, 2], [-11, 2]), ([-21, 3], [-7]), ([-21, 4], [-6, 1, 3])]]
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 | [-13, 2] | [-13, 2] | Passed |
| explicit oracle 1 | [-3, 4, 2] | [-3, 4, 2] | Passed |
| explicit oracle 2 | [-25] | [-25] | Passed |
| explicit oracle 3 | [1, 2, 8] | [1, 2, 8] | Passed |
| explicit oracle 4 | [-9, 1, 2] | [-9, 1, 2] | Passed |
| explicit oracle 5 | [-7, 1, 3] | [-7, 1, 3] | Passed |
| explicit oracle 6 | [-5] | [-5] | Passed |
| explicit oracle 7 | [-5, 1, 5] | [-5, 1, 5] | Passed |
SHA-256 / ca91f961846bdafacbe0fbcb7bdaa88544624cc1ecb9b6adb5c63c11523aba74
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:16.906805+00:00.
Case digest / fe3db9f71241d88ba9984fcba67a917017edab576eb0e34680cdac105f9984c2