FA-14431 / Numerics / Open access
Rational continued fraction: terminal unit folding · case 01
The exact rational continued fraction result violates the stated contract at terminal unit folding.
ROOT CAUSE
The terminal unit folding step uses len(out)>1 instead of len(out)>1 and out[-1]==1.
THE FAILURE
The terminal unit folding step uses len(out)>1 instead of len(out)>1 and out[-1]==1.
Unsuccessful approach: The partial repair len(out)>1 and out[0]==1 still violates the terminal unit folding 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:
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]), ([3, 2], [1, 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]), ([5, 4], [1, 4]), ([-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]), ([7, 4], [1, 1, 3]), ([-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]), ([8, 5], [1, 1, 1, 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]), ([9, 5], [1, 1, 4]), ([-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 | [-12] | [-13, 2] | Failed |
| explicit oracle 1 | [2] | [1, 2] | Failed |
| explicit oracle 2 | [-25] | [-25] | Passed |
| explicit oracle 3 | [1, 3] | [1, 2, 8] | Failed |
| explicit oracle 4 | [-9, 2] | [-9, 1, 2] | Failed |
| explicit oracle 5 | [-7, 2] | [-7, 1, 3] | Failed |
| explicit oracle 6 | [-5] | [-5] | Passed |
| explicit oracle 7 | [-5, 2] | [-5, 1, 5] | Failed |
SHA-256 / 022f11e11aff599926ba499b67a61065b3d216594a4f6575741ec2def5d20db0
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[0]==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]), ([3, 2], [1, 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]), ([5, 4], [1, 4]), ([-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]), ([7, 4], [1, 1, 3]), ([-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]), ([8, 5], [1, 1, 1, 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]), ([9, 5], [1, 1, 4]), ([-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 | [2] | [1, 2] | Failed |
| explicit oracle 2 | [-25] | [-25] | Passed |
| explicit oracle 3 | [1, 3] | [1, 2, 8] | Failed |
| 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 / c0c75ff25f013200ebbec27a8291108cac34b27973c511f617fde039f5606d3e
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:16.859824+00:00.
Case digest / a63d7a5f424d8d377cf1d17b0c10220e2e523b14e098c3d8aca9d833582af7ec