FA-14516 / Numerics / Open access
Stern brocot path: root termination · case 01
The exact stern brocot path result violates the stated contract at root termination.
ROOT CAUSE
The root termination step uses p==1 or q==1 instead of p==q.
VERIFIED REPAIR
Use p==q at the root termination step.
Unsuccessful approach: The partial repair p==1 and q==1 and len(out)>0 still violates the root termination invariant.
Case contract
Input reduced positive [p,q]; return run-expanded L/R path from 1/1. Bounds: 1<=p,q<=24.
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(100):
if p==1 or q==1: break
if p<q:
out.append('L')
q=q-p
else:
out.append('R')
p=p-q
return ''.join(out)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([1, 2], 'L'), ([1, 1], ''), ([24, 23], 'RLLLLLLLLLLLLLLLLLLLLLL'), ([1, 3], 'LL'), ([1, 4], 'LLL'), ([1, 5], 'LLLL'), ([1, 6], 'LLLLL'), ([1, 7], 'LLLLLL')], [([1, 3], 'LL'), ([1, 1], ''), ([24, 23], 'RLLLLLLLLLLLLLLLLLLLLLL'), ([1, 18], 'LLLLLLLLLLLLLLLLL'), ([1, 19], 'LLLLLLLLLLLLLLLLLL'), ([1, 20], 'LLLLLLLLLLLLLLLLLLL'), ([1, 21], 'LLLLLLLLLLLLLLLLLLLL'), ([1, 22], 'LLLLLLLLLLLLLLLLLLLLL')], [([1, 4], 'LLL'), ([1, 1], ''), ([24, 23], 'RLLLLLLLLLLLLLLLLLLLLLL'), ([2, 21], 'LLLLLLLLLLR'), ([2, 23], 'LLLLLLLLLLLR'), ([3, 1], 'RR'), ([3, 2], 'RL'), ([3, 4], 'LRR')], [([1, 5], 'LLLL'), ([1, 1], ''), ([24, 23], 'RLLLLLLLLLLLLLLLLLLLLLL'), ([3, 23], 'LLLLLLLRL'), ([4, 1], 'RRR'), ([4, 3], 'RLL'), ([4, 5], 'LRRR'), ([4, 7], 'LRLL')], [([1, 6], 'LLLLL'), ([1, 1], ''), ([24, 23], 'RLLLLLLLLLLLLLLLLLLLLLL'), ([5, 6], 'LRRRR'), ([5, 7], 'LRRL'), ([5, 8], 'LRLR'), ([5, 9], 'LRLLL'), ([5, 11], 'LLRRRR')]]
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 | | L | Failed |
| explicit oracle 1 | | | Passed |
| explicit oracle 2 | R | RLLLLLLLLLLLLLLLLLLLLLL | Failed |
| explicit oracle 3 | | LL | Failed |
| explicit oracle 4 | | LLL | Failed |
| explicit oracle 5 | | LLLL | Failed |
| explicit oracle 6 | | LLLLL | Failed |
| explicit oracle 7 | | LLLLLL | Failed |
SHA-256 / 33a82428f8e39e0ab85eb56fd7d22ff381cd7bd2da8d628c8ea655473f19d3b5
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(100):
if p==1 and q==1 and len(out)>0: break
if p<q:
out.append('L')
q=q-p
else:
out.append('R')
p=p-q
return ''.join(out)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([1, 2], 'L'), ([1, 1], ''), ([24, 23], 'RLLLLLLLLLLLLLLLLLLLLLL'), ([1, 3], 'LL'), ([1, 4], 'LLL'), ([1, 5], 'LLLL'), ([1, 6], 'LLLLL'), ([1, 7], 'LLLLLL')], [([1, 3], 'LL'), ([1, 1], ''), ([24, 23], 'RLLLLLLLLLLLLLLLLLLLLLL'), ([1, 18], 'LLLLLLLLLLLLLLLLL'), ([1, 19], 'LLLLLLLLLLLLLLLLLL'), ([1, 20], 'LLLLLLLLLLLLLLLLLLL'), ([1, 21], 'LLLLLLLLLLLLLLLLLLLL'), ([1, 22], 'LLLLLLLLLLLLLLLLLLLLL')], [([1, 4], 'LLL'), ([1, 1], ''), ([24, 23], 'RLLLLLLLLLLLLLLLLLLLLLL'), ([2, 21], 'LLLLLLLLLLR'), ([2, 23], 'LLLLLLLLLLLR'), ([3, 1], 'RR'), ([3, 2], 'RL'), ([3, 4], 'LRR')], [([1, 5], 'LLLL'), ([1, 1], ''), ([24, 23], 'RLLLLLLLLLLLLLLLLLLLLLL'), ([3, 23], 'LLLLLLLRL'), ([4, 1], 'RRR'), ([4, 3], 'RLL'), ([4, 5], 'LRRR'), ([4, 7], 'LRLL')], [([1, 6], 'LLLLL'), ([1, 1], ''), ([24, 23], 'RLLLLLLLLLLLLLLLLLLLLLL'), ([5, 6], 'LRRRR'), ([5, 7], 'LRRL'), ([5, 8], 'LRLR'), ([5, 9], 'LRLLL'), ([5, 11], 'LLRRRR')]]
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 | L | L | Passed |
| explicit oracle 1 | RLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL | | Failed |
| explicit oracle 2 | RLLLLLLLLLLLLLLLLLLLLLL | RLLLLLLLLLLLLLLLLLLLLLL | Passed |
| explicit oracle 3 | LL | LL | Passed |
| explicit oracle 4 | LLL | LLL | Passed |
| explicit oracle 5 | LLLL | LLLL | Passed |
| explicit oracle 6 | LLLLL | LLLLL | Passed |
| explicit oracle 7 | LLLLLL | LLLLLL | Passed |
SHA-256 / 1de9c9b036216d357e3f50d701e3b4ae1d7273d72e8ed77aa04f66b0d52a0113
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(100):
if p==q: break
if p<q:
out.append('L')
q=q-p
else:
out.append('R')
p=p-q
return ''.join(out)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([1, 2], 'L'), ([1, 1], ''), ([24, 23], 'RLLLLLLLLLLLLLLLLLLLLLL'), ([1, 3], 'LL'), ([1, 4], 'LLL'), ([1, 5], 'LLLL'), ([1, 6], 'LLLLL'), ([1, 7], 'LLLLLL')], [([1, 3], 'LL'), ([1, 1], ''), ([24, 23], 'RLLLLLLLLLLLLLLLLLLLLLL'), ([1, 18], 'LLLLLLLLLLLLLLLLL'), ([1, 19], 'LLLLLLLLLLLLLLLLLL'), ([1, 20], 'LLLLLLLLLLLLLLLLLLL'), ([1, 21], 'LLLLLLLLLLLLLLLLLLLL'), ([1, 22], 'LLLLLLLLLLLLLLLLLLLLL')], [([1, 4], 'LLL'), ([1, 1], ''), ([24, 23], 'RLLLLLLLLLLLLLLLLLLLLLL'), ([2, 21], 'LLLLLLLLLLR'), ([2, 23], 'LLLLLLLLLLLR'), ([3, 1], 'RR'), ([3, 2], 'RL'), ([3, 4], 'LRR')], [([1, 5], 'LLLL'), ([1, 1], ''), ([24, 23], 'RLLLLLLLLLLLLLLLLLLLLLL'), ([3, 23], 'LLLLLLLRL'), ([4, 1], 'RRR'), ([4, 3], 'RLL'), ([4, 5], 'LRRR'), ([4, 7], 'LRLL')], [([1, 6], 'LLLLL'), ([1, 1], ''), ([24, 23], 'RLLLLLLLLLLLLLLLLLLLLLL'), ([5, 6], 'LRRRR'), ([5, 7], 'LRRL'), ([5, 8], 'LRLR'), ([5, 9], 'LRLLL'), ([5, 11], 'LLRRRR')]]
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 | L | L | Passed |
| explicit oracle 1 | | | Passed |
| explicit oracle 2 | RLLLLLLLLLLLLLLLLLLLLLL | RLLLLLLLLLLLLLLLLLLLLLL | Passed |
| explicit oracle 3 | LL | LL | Passed |
| explicit oracle 4 | LLL | LLL | Passed |
| explicit oracle 5 | LLLL | LLLL | Passed |
| explicit oracle 6 | LLLLL | LLLLL | Passed |
| explicit oracle 7 | LLLLLL | LLLLLL | Passed |
SHA-256 / 84bb3c89ea808859befa9e960bb49c6622392d1f3e5c5789d095bcf13241caa6
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:17.730664+00:00.
Case digest / f2a2fe32b7d8a1399d715708811e8b064afe7cf022ebcbe252ad2262649c5bff