FAILURE MAP
← Case archive

FA-14876 / Numerics / Open access

Extended euclidean certificate: first coefficient recurrence · case 01

The exact extended euclidean certificate result violates the stated contract at first coefficient recurrence.

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

ROOT CAUSE

The first coefficient recurrence step uses s1,s0+q*s1 instead of s1,s0-q*s1.

VERIFIED REPAIR

Use s1,s0-q*s1 at the first coefficient recurrence step.

Unsuccessful approach: The partial repair s0,s0-q*s1 still violates the first coefficient recurrence invariant.

Case contract

Input [a,b], integers not both zero; return [g,u,v] with g>=0 and a*u+b*v=g using standard Euclidean quotient recurrence. Bounds: |a|,|b|<=1000000.

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):
    a,b=x
    r0,r1=a,b
    s0,s1=1,0
    t0,t1=0,1
    for _ in range(60):
     if r1==0:break
     q=r0//r1
     r0,r1=r1,r0-q*r1
     s0,s1=s1,s0+q*s1
     t0,t1=t1,t0-q*t1
    if r0<0:r0,s0,t0=-r0,-s0,-t0
    return [r0,s0,t0]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([-20, -14], [2, 2, -3]), ([-20, -20], [20, 0, -1]), ([20, 20], [20, 0, 1]), ([-20, -19], [1, -1, 1]), ([-20, -18], [2, -1, 1]), ([-20, -17], [1, -6, 7]), ([-20, -16], [4, -1, 1]), ([-20, -15], [5, -1, 1])], [([-20, -12], [4, 1, -2]), ([-20, -13], [1, -2, 3]), ([-20, -20], [20, 0, -1]), ([20, 20], [20, 0, 1]), ([-20, -3], [1, 1, -7]), ([-20, -2], [2, 0, -1]), ([-20, -1], [1, 0, -1]), ([-20, 0], [20, -1, 0])], [([-20, -9], [1, 4, -9]), ([-20, -10], [10, 0, -1]), ([-20, -20], [20, 0, -1]), ([20, 20], [20, 0, 1]), ([-20, 14], [2, 2, 3]), ([-20, 15], [5, -1, -1]), ([-20, 16], [4, -1, -1]), ([-20, 17], [1, -6, -7])], [([-20, -7], [1, 1, -3]), ([-20, -5], [5, 0, -1]), ([-20, -20], [20, 0, -1]), ([20, 20], [20, 0, 1]), ([-19, -10], [1, 1, -2]), ([-19, -9], [1, -1, 2]), ([-19, -8], [1, -3, 7]), ([-19, -7], [1, -3, 8])], [([-20, -3], [1, 1, -7]), ([-20, -2], [2, 0, -1]), ([-20, -20], [20, 0, -1]), ([20, 20], [20, 0, 1]), ([-19, 7], [1, -3, -8]), ([-19, 8], [1, -3, -7]), ([-19, 9], [1, -1, -2]), ([-19, 10], [1, 1, 2])]]
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 0[2, -2, -3][2, 2, -3]Failed
explicit oracle 1[20, 0, -1][20, 0, -1]Passed
explicit oracle 2[20, 0, 1][20, 0, 1]Passed
explicit oracle 3[1, -1, 1][1, -1, 1]Passed
explicit oracle 4[2, -1, 1][2, -1, 1]Passed
explicit oracle 5[1, -6, 7][1, -6, 7]Passed
explicit oracle 6[4, -1, 1][4, -1, 1]Passed
explicit oracle 7[5, -1, 1][5, -1, 1]Passed

SHA-256 / 1e51d5ad886eeddae350f31baaca35bf7ef547f01686fa866069d9a7d808658c

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):
    a,b=x
    r0,r1=a,b
    s0,s1=1,0
    t0,t1=0,1
    for _ in range(60):
     if r1==0:break
     q=r0//r1
     r0,r1=r1,r0-q*r1
     s0,s1=s0,s0-q*s1
     t0,t1=t1,t0-q*t1
    if r0<0:r0,s0,t0=-r0,-s0,-t0
    return [r0,s0,t0]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([-20, -14], [2, 2, -3]), ([-20, -20], [20, 0, -1]), ([20, 20], [20, 0, 1]), ([-20, -19], [1, -1, 1]), ([-20, -18], [2, -1, 1]), ([-20, -17], [1, -6, 7]), ([-20, -16], [4, -1, 1]), ([-20, -15], [5, -1, 1])], [([-20, -12], [4, 1, -2]), ([-20, -13], [1, -2, 3]), ([-20, -20], [20, 0, -1]), ([20, 20], [20, 0, 1]), ([-20, -3], [1, 1, -7]), ([-20, -2], [2, 0, -1]), ([-20, -1], [1, 0, -1]), ([-20, 0], [20, -1, 0])], [([-20, -9], [1, 4, -9]), ([-20, -10], [10, 0, -1]), ([-20, -20], [20, 0, -1]), ([20, 20], [20, 0, 1]), ([-20, 14], [2, 2, 3]), ([-20, 15], [5, -1, -1]), ([-20, 16], [4, -1, -1]), ([-20, 17], [1, -6, -7])], [([-20, -7], [1, 1, -3]), ([-20, -5], [5, 0, -1]), ([-20, -20], [20, 0, -1]), ([20, 20], [20, 0, 1]), ([-19, -10], [1, 1, -2]), ([-19, -9], [1, -1, 2]), ([-19, -8], [1, -3, 7]), ([-19, -7], [1, -3, 8])], [([-20, -3], [1, 1, -7]), ([-20, -2], [2, 0, -1]), ([-20, -20], [20, 0, -1]), ([20, 20], [20, 0, 1]), ([-19, 7], [1, -3, -8]), ([-19, 8], [1, -3, -7]), ([-19, 9], [1, -1, -2]), ([-19, 10], [1, 1, 2])]]
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 0[2, -1, -3][2, 2, -3]Failed
explicit oracle 1[20, -1, -1][20, 0, -1]Failed
explicit oracle 2[20, 1, 1][20, 0, 1]Failed
explicit oracle 3[1, -1, 1][1, -1, 1]Passed
explicit oracle 4[2, -1, 1][2, -1, 1]Passed
explicit oracle 5[1, -1, 7][1, -6, 7]Failed
explicit oracle 6[4, -1, 1][4, -1, 1]Passed
explicit oracle 7[5, -1, 1][5, -1, 1]Passed

SHA-256 / 3a22f913d21769006be3b246195155ace175218551301f28efbb0533f3e4a7d4

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):
    a,b=x
    r0,r1=a,b
    s0,s1=1,0
    t0,t1=0,1
    for _ in range(60):
     if r1==0:break
     q=r0//r1
     r0,r1=r1,r0-q*r1
     s0,s1=s1,s0-q*s1
     t0,t1=t1,t0-q*t1
    if r0<0:r0,s0,t0=-r0,-s0,-t0
    return [r0,s0,t0]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([-20, -14], [2, 2, -3]), ([-20, -20], [20, 0, -1]), ([20, 20], [20, 0, 1]), ([-20, -19], [1, -1, 1]), ([-20, -18], [2, -1, 1]), ([-20, -17], [1, -6, 7]), ([-20, -16], [4, -1, 1]), ([-20, -15], [5, -1, 1])], [([-20, -12], [4, 1, -2]), ([-20, -13], [1, -2, 3]), ([-20, -20], [20, 0, -1]), ([20, 20], [20, 0, 1]), ([-20, -3], [1, 1, -7]), ([-20, -2], [2, 0, -1]), ([-20, -1], [1, 0, -1]), ([-20, 0], [20, -1, 0])], [([-20, -9], [1, 4, -9]), ([-20, -10], [10, 0, -1]), ([-20, -20], [20, 0, -1]), ([20, 20], [20, 0, 1]), ([-20, 14], [2, 2, 3]), ([-20, 15], [5, -1, -1]), ([-20, 16], [4, -1, -1]), ([-20, 17], [1, -6, -7])], [([-20, -7], [1, 1, -3]), ([-20, -5], [5, 0, -1]), ([-20, -20], [20, 0, -1]), ([20, 20], [20, 0, 1]), ([-19, -10], [1, 1, -2]), ([-19, -9], [1, -1, 2]), ([-19, -8], [1, -3, 7]), ([-19, -7], [1, -3, 8])], [([-20, -3], [1, 1, -7]), ([-20, -2], [2, 0, -1]), ([-20, -20], [20, 0, -1]), ([20, 20], [20, 0, 1]), ([-19, 7], [1, -3, -8]), ([-19, 8], [1, -3, -7]), ([-19, 9], [1, -1, -2]), ([-19, 10], [1, 1, 2])]]
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 0[2, 2, -3][2, 2, -3]Passed
explicit oracle 1[20, 0, -1][20, 0, -1]Passed
explicit oracle 2[20, 0, 1][20, 0, 1]Passed
explicit oracle 3[1, -1, 1][1, -1, 1]Passed
explicit oracle 4[2, -1, 1][2, -1, 1]Passed
explicit oracle 5[1, -6, 7][1, -6, 7]Passed
explicit oracle 6[4, -1, 1][4, -1, 1]Passed
explicit oracle 7[5, -1, 1][5, -1, 1]Passed

SHA-256 / 2ff3409d60918977c94fe0d152fed09a0d4dbc6dbfc0aea56486d0a4be578874

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

Case digest / e0d6e1fe1e8e22c3b1a2e15f06c270f3a6a7a686bce654947e43ec9d33b12852