FAILURE MAP
← Case archive

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

Interval quality and number naming: descent judged by sound instead of letters · case 01

B#3 to Cb4 (letters ascend, pitch descends) is rejected, while C4 to B#3 slips through and produces a bogus label.

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

ROOT CAUSE

The descending guard tests the semitone span, which can be negative for correctly ascending letter spellings.

VERIFIED REPAIR

Restore the descending rejection step so that it reads `if steps < 0:`.

Unsuccessful approach: Requiring both spans to be negative still lets letter-descending, pitch-equal pairs such as C4 to B#3 through.

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 * 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 semis < 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'), (['C4', 'C5'], 'P8'), (['C4', 'B#3'], None), (['Cb4', 'B#3'], None)], [(['C4', 'Gb4'], 'd5'), (['C4', 'F#4'], 'A4'), (['C4', 'C5'], 'P8'), (['C4', 'D5'], 'M9'), (['C4', 'C4'], 'P1'), (['C4', 'C#4'], 'A1'), (['C4', 'B#3'], None), (['Cb4', 'B#3'], None)], [(['C4', 'D5'], 'M9'), (['C4', 'C4'], 'P1'), (['C4', 'C#4'], 'A1'), (['B#3', 'C4'], 'd2'), (['E4', 'F4'], 'm2'), (['C4', 'B4'], 'M7'), (['C4', 'B#3'], None), (['Cb4', 'B#3'], None)], [(['B#3', 'C4'], 'd2'), (['E4', 'F4'], 'm2'), (['C4', 'B4'], 'M7'), (['C4', 'Bb4'], 'm7'), (['C4', 'Bbb4'], 'd7'), (['C4', 'C6'], 'P15'), (['C4', 'B#3'], None), (['Cb4', 'B#3'], None)], [(['C4', 'Bb4'], 'm7'), (['C4', 'Bbb4'], 'd7'), (['C4', 'C6'], 'P15'), (['C4', 'G5'], 'P12'), (['C4', 'F5'], 'P11'), (['D4', 'C4'], None), (['C4', 'B#3'], None), (['Cb4', 'B#3'], None)]]
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 5P8P8Passed
oracle 6A0NoneFailed
oracle 7AA0NoneFailed

SHA-256 / e46aab13d1e91b964b89c14ae61e8e095371566203b8a7835ca0876afcc7f922

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 * 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 and semis < 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'), (['C4', 'C5'], 'P8'), (['C4', 'B#3'], None), (['Cb4', 'B#3'], None)], [(['C4', 'Gb4'], 'd5'), (['C4', 'F#4'], 'A4'), (['C4', 'C5'], 'P8'), (['C4', 'D5'], 'M9'), (['C4', 'C4'], 'P1'), (['C4', 'C#4'], 'A1'), (['C4', 'B#3'], None), (['Cb4', 'B#3'], None)], [(['C4', 'D5'], 'M9'), (['C4', 'C4'], 'P1'), (['C4', 'C#4'], 'A1'), (['B#3', 'C4'], 'd2'), (['E4', 'F4'], 'm2'), (['C4', 'B4'], 'M7'), (['C4', 'B#3'], None), (['Cb4', 'B#3'], None)], [(['B#3', 'C4'], 'd2'), (['E4', 'F4'], 'm2'), (['C4', 'B4'], 'M7'), (['C4', 'Bb4'], 'm7'), (['C4', 'Bbb4'], 'd7'), (['C4', 'C6'], 'P15'), (['C4', 'B#3'], None), (['Cb4', 'B#3'], None)], [(['C4', 'Bb4'], 'm7'), (['C4', 'Bbb4'], 'd7'), (['C4', 'C6'], 'P15'), (['C4', 'G5'], 'P12'), (['C4', 'F5'], 'P11'), (['D4', 'C4'], None), (['C4', 'B#3'], None), (['Cb4', 'B#3'], None)]]
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 5P8P8Passed
oracle 6A0NoneFailed
oracle 7AA0NoneFailed

SHA-256 / 88b2d2b1ccc038fc388a112ebf1ffd4f36f9a7253b7525b103eb90e6483094e2

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'), (['C4', 'C5'], 'P8'), (['C4', 'B#3'], None), (['Cb4', 'B#3'], None)], [(['C4', 'Gb4'], 'd5'), (['C4', 'F#4'], 'A4'), (['C4', 'C5'], 'P8'), (['C4', 'D5'], 'M9'), (['C4', 'C4'], 'P1'), (['C4', 'C#4'], 'A1'), (['C4', 'B#3'], None), (['Cb4', 'B#3'], None)], [(['C4', 'D5'], 'M9'), (['C4', 'C4'], 'P1'), (['C4', 'C#4'], 'A1'), (['B#3', 'C4'], 'd2'), (['E4', 'F4'], 'm2'), (['C4', 'B4'], 'M7'), (['C4', 'B#3'], None), (['Cb4', 'B#3'], None)], [(['B#3', 'C4'], 'd2'), (['E4', 'F4'], 'm2'), (['C4', 'B4'], 'M7'), (['C4', 'Bb4'], 'm7'), (['C4', 'Bbb4'], 'd7'), (['C4', 'C6'], 'P15'), (['C4', 'B#3'], None), (['Cb4', 'B#3'], None)], [(['C4', 'Bb4'], 'm7'), (['C4', 'Bbb4'], 'd7'), (['C4', 'C6'], 'P15'), (['C4', 'G5'], 'P12'), (['C4', 'F5'], 'P11'), (['D4', 'C4'], None), (['C4', 'B#3'], None), (['Cb4', 'B#3'], None)]]
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 5P8P8Passed
oracle 6NoneNonePassed
oracle 7NoneNonePassed

SHA-256 / 2e2f15ae1a857cdfd7561d9bcd97b7f2ff0d6dec7175eb7e7ca2975e22a45234

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

Case digest / dcd96377cd95b5498caff22c41bd3049638f5a2d15caedd6ddaf8696ede65bcb