FAILURE MAP
← Case archive

FA-80896 / Music interval and transposition theory / Open access

Interval quality and number naming: letter position taken from the sounding octave · case 01

Intervals from B#3 are measured as if the B were in octave 4, so B#3 to C4 is rejected as descending.

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

ROOT CAUSE

The diatonic index derives the octave from the sounding pitch, which crosses octaves for B# and Cb, instead of from the spelled octave.

VERIFIED REPAIR

Restore the spelled octave basis step so that it reads `'CDEFGAB'.index(s[0]) + 7 * octave`.

Unsuccessful approach: Ignoring flats in the sounding octave fixes Cb but B# spellings still move to the next octave.

Case contract

Input [lower, upper] spelled pitches (letter, # or b accidentals, nonnegative octave). The generic number counts letter steps plus 7 per spelled octave plus one; quality compares the semitone span with the major/perfect reference (compounds add 12 per octave). Perfect class for simple numbers 1, 4, 5: P, A, d, AA, dd; others: M, m, A, d, AA, dd. Descending letter order or unrepresentable quality returns None.

Why this case matters

Pitch spelling and interval arithmetic decide the notes that notation, transposition and analysis tools display or play.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    base = {'C': 0, 'D': 2, 'E': 4, 'F': 5, 'G': 7, 'A': 9, 'B': 11}
    def parse(s):
        if not isinstance(s, str) or len(s) < 2 or s[0] not in base:
            return None
        i = 1
        acc = 0
        while i < len(s) and s[i] in '#b':
            acc += 1 if s[i] == '#' else -1
            i += 1
        if not s[i:].isdigit():
            return None
        octave = int(s[i:])
        return ['CDEFGAB'.index(s[0]) + 7 * ((12 * octave + base[s[0]] + acc) // 12), 12 * octave + base[s[0]] + acc]
    if not isinstance(x, list) or len(x) != 2:
        return None
    lo, hi = parse(x[0]), parse(x[1])
    if lo is None or hi is None:
        return None
    steps = hi[0] - lo[0]
    semis = hi[1] - lo[1]
    if steps < 0:
        return None
    number = steps + 1
    simple = (number - 1) % 7 + 1
    ref = [0, 2, 4, 5, 7, 9, 11][simple - 1] + 12 * ((number - 1) // 7)
    d = semis - ref
    if simple in (1, 4, 5):
        q = {0: 'P', 1: 'A', -1: 'd', 2: 'AA', -2: 'dd'}.get(d)
    else:
        q = {0: 'M', -1: 'm', 1: 'A', -2: 'd', 2: 'AA', -3: 'dd'}.get(d)
    if q is None:
        return None
    return q + str(number)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[(['C4', 'E4'], 'M3'), (['C4', 'Eb4'], 'm3'), (['C4', 'G4'], 'P5'), (['C4', 'Gb4'], 'd5'), (['C4', 'F#4'], 'A4'), (['B#3', 'C4'], 'd2'), (['B#3', 'Db4'], 'dd3'), (['E4', 'Cb5'], 'd6')], [(['C4', 'Gb4'], 'd5'), (['C4', 'F#4'], 'A4'), (['C4', 'C5'], 'P8'), (['C4', 'D5'], 'M9'), (['C4', 'C4'], 'P1'), (['C4', 'C#4'], 'A1'), (['B#3', 'C4'], 'd2'), (['B#3', 'Db4'], 'dd3')], [(['C4', 'D5'], 'M9'), (['C4', 'C4'], 'P1'), (['C4', 'C#4'], 'A1'), (['B#3', 'C4'], 'd2'), (['E4', 'F4'], 'm2'), (['C4', 'B4'], 'M7'), (['B#3', 'Db4'], 'dd3'), (['E4', 'Cb5'], 'd6')], [(['B#3', 'C4'], 'd2'), (['E4', 'F4'], 'm2'), (['C4', 'B4'], 'M7'), (['C4', 'Bb4'], 'm7'), (['C4', 'Bbb4'], 'd7'), (['C4', 'C6'], 'P15'), (['B#3', 'Db4'], 'dd3'), (['E4', 'Cb5'], 'd6')], [(['B#3', 'C4'], 'd2'), (['C4', 'Bbb4'], 'd7'), (['C4', 'C6'], 'P15'), (['C4', 'G5'], 'P12'), (['C4', 'F5'], 'P11'), (['D4', 'C4'], None), (['C4', 'B#3'], None), (['B#3', 'Db4'], 'dd3')]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("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
oracle 0M3M3Passed
oracle 1m3m3Passed
oracle 2P5P5Passed
oracle 3d5d5Passed
oracle 4A4A4Passed
oracle 5Noned2Failed
oracle 6Nonedd3Failed
oracle 7Noned6Failed

SHA-256 / b246bfa305a55bcd237c445e41035d6b221ad5e2e102d711252251cebf0ec3f2

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    base = {'C': 0, 'D': 2, 'E': 4, 'F': 5, 'G': 7, 'A': 9, 'B': 11}
    def parse(s):
        if not isinstance(s, str) or len(s) < 2 or s[0] not in base:
            return None
        i = 1
        acc = 0
        while i < len(s) and s[i] in '#b':
            acc += 1 if s[i] == '#' else -1
            i += 1
        if not s[i:].isdigit():
            return None
        octave = int(s[i:])
        return ['CDEFGAB'.index(s[0]) + 7 * ((12 * octave + base[s[0]] + max(acc, 0)) // 12), 12 * octave + base[s[0]] + acc]
    if not isinstance(x, list) or len(x) != 2:
        return None
    lo, hi = parse(x[0]), parse(x[1])
    if lo is None or hi is None:
        return None
    steps = hi[0] - lo[0]
    semis = hi[1] - lo[1]
    if steps < 0:
        return None
    number = steps + 1
    simple = (number - 1) % 7 + 1
    ref = [0, 2, 4, 5, 7, 9, 11][simple - 1] + 12 * ((number - 1) // 7)
    d = semis - ref
    if simple in (1, 4, 5):
        q = {0: 'P', 1: 'A', -1: 'd', 2: 'AA', -2: 'dd'}.get(d)
    else:
        q = {0: 'M', -1: 'm', 1: 'A', -2: 'd', 2: 'AA', -3: 'dd'}.get(d)
    if q is None:
        return None
    return q + str(number)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[(['C4', 'E4'], 'M3'), (['C4', 'Eb4'], 'm3'), (['C4', 'G4'], 'P5'), (['C4', 'Gb4'], 'd5'), (['C4', 'F#4'], 'A4'), (['B#3', 'C4'], 'd2'), (['B#3', 'Db4'], 'dd3'), (['E4', 'Cb5'], 'd6')], [(['C4', 'Gb4'], 'd5'), (['C4', 'F#4'], 'A4'), (['C4', 'C5'], 'P8'), (['C4', 'D5'], 'M9'), (['C4', 'C4'], 'P1'), (['C4', 'C#4'], 'A1'), (['B#3', 'C4'], 'd2'), (['B#3', 'Db4'], 'dd3')], [(['C4', 'D5'], 'M9'), (['C4', 'C4'], 'P1'), (['C4', 'C#4'], 'A1'), (['B#3', 'C4'], 'd2'), (['E4', 'F4'], 'm2'), (['C4', 'B4'], 'M7'), (['B#3', 'Db4'], 'dd3'), (['E4', 'Cb5'], 'd6')], [(['B#3', 'C4'], 'd2'), (['E4', 'F4'], 'm2'), (['C4', 'B4'], 'M7'), (['C4', 'Bb4'], 'm7'), (['C4', 'Bbb4'], 'd7'), (['C4', 'C6'], 'P15'), (['B#3', 'Db4'], 'dd3'), (['E4', 'Cb5'], 'd6')], [(['B#3', 'C4'], 'd2'), (['C4', 'Bbb4'], 'd7'), (['C4', 'C6'], 'P15'), (['C4', 'G5'], 'P12'), (['C4', 'F5'], 'P11'), (['D4', 'C4'], None), (['C4', 'B#3'], None), (['B#3', 'Db4'], 'dd3')]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("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
oracle 0M3M3Passed
oracle 1m3m3Passed
oracle 2P5P5Passed
oracle 3d5d5Passed
oracle 4A4A4Passed
oracle 5Noned2Failed
oracle 6Nonedd3Failed
oracle 7d6d6Passed

SHA-256 / ff4d321a7948ae13222164bacc36dae9abd24bd877c1dc426464158a34543a35

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    base = {'C': 0, 'D': 2, 'E': 4, 'F': 5, 'G': 7, 'A': 9, 'B': 11}
    def parse(s):
        if not isinstance(s, str) or len(s) < 2 or s[0] not in base:
            return None
        i = 1
        acc = 0
        while i < len(s) and s[i] in '#b':
            acc += 1 if s[i] == '#' else -1
            i += 1
        if not s[i:].isdigit():
            return None
        octave = int(s[i:])
        return ['CDEFGAB'.index(s[0]) + 7 * octave, 12 * octave + base[s[0]] + acc]
    if not isinstance(x, list) or len(x) != 2:
        return None
    lo, hi = parse(x[0]), parse(x[1])
    if lo is None or hi is None:
        return None
    steps = hi[0] - lo[0]
    semis = hi[1] - lo[1]
    if steps < 0:
        return None
    number = steps + 1
    simple = (number - 1) % 7 + 1
    ref = [0, 2, 4, 5, 7, 9, 11][simple - 1] + 12 * ((number - 1) // 7)
    d = semis - ref
    if simple in (1, 4, 5):
        q = {0: 'P', 1: 'A', -1: 'd', 2: 'AA', -2: 'dd'}.get(d)
    else:
        q = {0: 'M', -1: 'm', 1: 'A', -2: 'd', 2: 'AA', -3: 'dd'}.get(d)
    if q is None:
        return None
    return q + str(number)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[(['C4', 'E4'], 'M3'), (['C4', 'Eb4'], 'm3'), (['C4', 'G4'], 'P5'), (['C4', 'Gb4'], 'd5'), (['C4', 'F#4'], 'A4'), (['B#3', 'C4'], 'd2'), (['B#3', 'Db4'], 'dd3'), (['E4', 'Cb5'], 'd6')], [(['C4', 'Gb4'], 'd5'), (['C4', 'F#4'], 'A4'), (['C4', 'C5'], 'P8'), (['C4', 'D5'], 'M9'), (['C4', 'C4'], 'P1'), (['C4', 'C#4'], 'A1'), (['B#3', 'C4'], 'd2'), (['B#3', 'Db4'], 'dd3')], [(['C4', 'D5'], 'M9'), (['C4', 'C4'], 'P1'), (['C4', 'C#4'], 'A1'), (['B#3', 'C4'], 'd2'), (['E4', 'F4'], 'm2'), (['C4', 'B4'], 'M7'), (['B#3', 'Db4'], 'dd3'), (['E4', 'Cb5'], 'd6')], [(['B#3', 'C4'], 'd2'), (['E4', 'F4'], 'm2'), (['C4', 'B4'], 'M7'), (['C4', 'Bb4'], 'm7'), (['C4', 'Bbb4'], 'd7'), (['C4', 'C6'], 'P15'), (['B#3', 'Db4'], 'dd3'), (['E4', 'Cb5'], 'd6')], [(['B#3', 'C4'], 'd2'), (['C4', 'Bbb4'], 'd7'), (['C4', 'C6'], 'P15'), (['C4', 'G5'], 'P12'), (['C4', 'F5'], 'P11'), (['D4', 'C4'], None), (['C4', 'B#3'], None), (['B#3', 'Db4'], 'dd3')]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("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
oracle 0M3M3Passed
oracle 1m3m3Passed
oracle 2P5P5Passed
oracle 3d5d5Passed
oracle 4A4A4Passed
oracle 5d2d2Passed
oracle 6dd3dd3Passed
oracle 7d6d6Passed

SHA-256 / c126acdd4522ad2e15aa42a6416f6e047dd42d9592882ea574c89be6c5dbbdc8

Verification & scope

A deterministic bounded teaching model with a stipulated toy contract; it is not a complete music notation or theory engine. 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:49:58.028801+00:00.

Case digest / bba3715656f952dfb640a8e4a557771fdcc8c476f37aef72d3004d3f4fb4e1fe