FAILURE MAP
← Case archive

FA-14536 / Numerics / Open access

Stern brocot path: right residual · case 01

The exact stern brocot path result violates the stated contract at right residual.

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The right residual step uses p%q instead of p-q.

THE FAILURE

The right residual step uses p%q instead of p-q.

Unsuccessful approach: The partial repair p-q-1 still violates the right residual 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==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 = [[([2, 1], 'R'), ([1, 1], ''), ([24, 23], 'RLLLLLLLLLLLLLLLLLLLLLL'), ([1, 2], 'L'), ([1, 3], 'LL'), ([1, 4], 'LLL'), ([1, 5], 'LLLL'), ([1, 6], 'LLLLL')], [([2, 3], 'LR'), ([2, 7], 'LLLR'), ([1, 1], ''), ([24, 23], 'RLLLLLLLLLLLLLLLLLLLLLL'), ([1, 18], 'LLLLLLLLLLLLLLLLL'), ([1, 19], 'LLLLLLLLLLLLLLLLLL'), ([1, 20], 'LLLLLLLLLLLLLLLLLLL'), ([1, 21], 'LLLLLLLLLLLLLLLLLLLL')], [([2, 5], 'LLR'), ([2, 13], 'LLLLLLR'), ([1, 1], ''), ([24, 23], 'RLLLLLLLLLLLLLLLLLLLLLL'), ([2, 21], 'LLLLLLLLLLR'), ([2, 23], 'LLLLLLLLLLLR'), ([3, 1], 'RR'), ([3, 2], 'RL')], [([2, 7], 'LLLR'), ([2, 19], 'LLLLLLLLLR'), ([1, 1], ''), ([24, 23], 'RLLLLLLLLLLLLLLLLLLLLLL'), ([3, 23], 'LLLLLLLRL'), ([4, 1], 'RRR'), ([4, 3], 'RLL'), ([4, 5], 'LRRR')], [([2, 9], 'LLLLR'), ([3, 1], 'RR'), ([1, 1], ''), ([24, 23], 'RLLLLLLLLLLLLLLLLLLLLLL'), ([5, 6], 'LRRRR'), ([5, 7], 'LRRL'), ([5, 8], 'LRLR'), ([5, 9], 'LRLLL')]]
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 fixtureActualExpectedOutcome
explicit oracle 0RLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLRFailed
explicit oracle 1Passed
explicit oracle 2RLLLLLLLLLLLLLLLLLLLLLLRLLLLLLLLLLLLLLLLLLLLLLPassed
explicit oracle 3LLPassed
explicit oracle 4LLLLPassed
explicit oracle 5LLLLLLPassed
explicit oracle 6LLLLLLLLPassed
explicit oracle 7LLLLLLLLLLPassed

SHA-256 / 12f248acb61ba027b0ffdb749218c3db8b3b3a3e3e6b42c82b299592ddb8d083

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==q: break
     if p<q:
      out.append('L')
      q=q-p
     else:
      out.append('R')
      p=p-q-1
    return ''.join(out)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([2, 1], 'R'), ([1, 1], ''), ([24, 23], 'RLLLLLLLLLLLLLLLLLLLLLL'), ([1, 2], 'L'), ([1, 3], 'LL'), ([1, 4], 'LLL'), ([1, 5], 'LLLL'), ([1, 6], 'LLLLL')], [([2, 3], 'LR'), ([2, 7], 'LLLR'), ([1, 1], ''), ([24, 23], 'RLLLLLLLLLLLLLLLLLLLLLL'), ([1, 18], 'LLLLLLLLLLLLLLLLL'), ([1, 19], 'LLLLLLLLLLLLLLLLLL'), ([1, 20], 'LLLLLLLLLLLLLLLLLLL'), ([1, 21], 'LLLLLLLLLLLLLLLLLLLL')], [([2, 5], 'LLR'), ([2, 13], 'LLLLLLR'), ([1, 1], ''), ([24, 23], 'RLLLLLLLLLLLLLLLLLLLLLL'), ([2, 21], 'LLLLLLLLLLR'), ([2, 23], 'LLLLLLLLLLLR'), ([3, 1], 'RR'), ([3, 2], 'RL')], [([2, 7], 'LLLR'), ([2, 19], 'LLLLLLLLLR'), ([1, 1], ''), ([24, 23], 'RLLLLLLLLLLLLLLLLLLLLLL'), ([3, 23], 'LLLLLLLRL'), ([4, 1], 'RRR'), ([4, 3], 'RLL'), ([4, 5], 'LRRR')], [([2, 9], 'LLLLR'), ([3, 1], 'RR'), ([1, 1], ''), ([24, 23], 'RLLLLLLLLLLLLLLLLLLLLLL'), ([5, 6], 'LRRRR'), ([5, 7], 'LRRL'), ([5, 8], 'LRLR'), ([5, 9], 'LRLLL')]]
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 fixtureActualExpectedOutcome
explicit oracle 0RLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLRFailed
explicit oracle 1Passed
explicit oracle 2RLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLRLLLLLLLLLLLLLLLLLLLLLLFailed
explicit oracle 3LLPassed
explicit oracle 4LLLLPassed
explicit oracle 5LLLLLLPassed
explicit oracle 6LLLLLLLLPassed
explicit oracle 7LLLLLLLLLLPassed

SHA-256 / ed03c1331f4a0e9d7e55c8504a7df4b93fdd061c6af402fa06e40cbf9a06f607

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:17.818394+00:00.

Case digest / 26b24a5008cca86126d1e2101d002b2b08ffee8dfe23378067c4b3dc7c247a59