FAILURE MAP
← Case archive

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

Staff position and ledger lines for a clef: octaves weighted in semitones · case 01

Notes outside the reference octave land dozens of positions away (C5 in treble at position 18).

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

ROOT CAUSE

The octave is multiplied by twelve semitones instead of seven diatonic steps.

VERIFIED REPAIR

Restore the diatonic octave weight step so that it reads `int(tail) * 7`.

Unsuccessful approach: Weighting octaves as eight steps counts the repeated letter twice.

Case contract

Input [note, clef] where note is a letter, accidentals (# b x, ignored for placement) and a nonnegative octave, and clef is treble (bottom line E4), bass (G2), alto (F3) or tenor (D3). Position counts diatonic steps above the bottom line (lines are even positions 0..8). Ledger lines: below the staff (-position)//2 for negative positions, above (position-8)//2 for positions over 8, else 0. Return [position, ledgers] or None when invalid.

Why this case matters

Engraving and notation-rendering code places noteheads and ledger lines from pitch spellings.

1 / The failure

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

N = 1
observations = []
def solve(x):
    base = 'CDEFGAB'
    refs = {'treble': ('E', 4), 'bass': ('G', 2), 'alto': ('F', 3), 'tenor': ('D', 3)}
    if not isinstance(x, list) or len(x) != 2 or x[1] not in refs:
        return None
    note, clef = x
    if not isinstance(note, str) or len(note) < 2 or note[0] not in base:
        return None
    tail = note[1:].lstrip('#bx')
    if not tail.isdigit():
        return None
    letter, octave = refs[clef]
    pos = (int(tail) * 12 + base.index(note[0])) - (octave * 7 + base.index(letter))
    if pos < 0:
        ledgers = -pos // 2
    elif pos > 8:
        ledgers = (pos - 8) // 2
    else:
        ledgers = 0
    return [pos, ledgers]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[(['E4', 'treble'], [0, 0]), (['C4', 'treble'], [-2, 1]), (['D4', 'treble'], [-1, 0]), (['B3', 'treble'], [-3, 1]), (['A3', 'treble'], [-4, 2]), (['H4', 'treble'], None), (['C4', 'piano'], None), (['C', 'treble'], None)], [(['E4', 'treble'], [0, 0]), (['C4', 'treble'], [-2, 1]), (['D4', 'treble'], [-1, 0]), (['B3', 'treble'], [-3, 1]), (['A3', 'treble'], [-4, 2]), (['F5', 'treble'], [8, 0]), (['G5', 'treble'], [9, 0]), (['A5', 'treble'], [10, 1])], [(['D4', 'treble'], [-1, 0]), (['B3', 'treble'], [-3, 1]), (['A3', 'treble'], [-4, 2]), (['F5', 'treble'], [8, 0]), (['G5', 'treble'], [9, 0]), (['A5', 'treble'], [10, 1]), (['C6', 'treble'], [12, 2]), (['C#4', 'treble'], [-2, 1])], [(['B3', 'treble'], [-3, 1]), (['F5', 'treble'], [8, 0]), (['G5', 'treble'], [9, 0]), (['A5', 'treble'], [10, 1]), (['C6', 'treble'], [12, 2]), (['C#4', 'treble'], [-2, 1]), (['Fx4', 'treble'], [1, 0]), (['Bb3', 'treble'], [-3, 1])], [(['A3', 'treble'], [-4, 2]), (['G5', 'treble'], [9, 0]), (['A5', 'treble'], [10, 1]), (['C#4', 'treble'], [-2, 1]), (['Fx4', 'treble'], [1, 0]), (['Bb3', 'treble'], [-3, 1]), (['C4', 'alto'], [4, 0]), (['C4', 'bass'], [10, 1])]]
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 0[20, 6][0, 0]Failed
oracle 1[18, 5][-2, 1]Failed
oracle 2[19, 5][-1, 0]Failed
oracle 3[12, 2][-3, 1]Failed
oracle 4[11, 1][-4, 2]Failed
oracle 5NoneNonePassed
oracle 6NoneNonePassed
oracle 7NoneNonePassed

SHA-256 / 352adbb952f998ddd4c7f0971f473ea0960b33a59ff838365618b670bf068a90

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(x):
    base = 'CDEFGAB'
    refs = {'treble': ('E', 4), 'bass': ('G', 2), 'alto': ('F', 3), 'tenor': ('D', 3)}
    if not isinstance(x, list) or len(x) != 2 or x[1] not in refs:
        return None
    note, clef = x
    if not isinstance(note, str) or len(note) < 2 or note[0] not in base:
        return None
    tail = note[1:].lstrip('#bx')
    if not tail.isdigit():
        return None
    letter, octave = refs[clef]
    pos = (int(tail) * 8 + base.index(note[0])) - (octave * 7 + base.index(letter))
    if pos < 0:
        ledgers = -pos // 2
    elif pos > 8:
        ledgers = (pos - 8) // 2
    else:
        ledgers = 0
    return [pos, ledgers]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[(['E4', 'treble'], [0, 0]), (['C4', 'treble'], [-2, 1]), (['D4', 'treble'], [-1, 0]), (['B3', 'treble'], [-3, 1]), (['A3', 'treble'], [-4, 2]), (['H4', 'treble'], None), (['C4', 'piano'], None), (['C', 'treble'], None)], [(['E4', 'treble'], [0, 0]), (['C4', 'treble'], [-2, 1]), (['D4', 'treble'], [-1, 0]), (['B3', 'treble'], [-3, 1]), (['A3', 'treble'], [-4, 2]), (['F5', 'treble'], [8, 0]), (['G5', 'treble'], [9, 0]), (['A5', 'treble'], [10, 1])], [(['D4', 'treble'], [-1, 0]), (['B3', 'treble'], [-3, 1]), (['A3', 'treble'], [-4, 2]), (['F5', 'treble'], [8, 0]), (['G5', 'treble'], [9, 0]), (['A5', 'treble'], [10, 1]), (['C6', 'treble'], [12, 2]), (['C#4', 'treble'], [-2, 1])], [(['B3', 'treble'], [-3, 1]), (['F5', 'treble'], [8, 0]), (['G5', 'treble'], [9, 0]), (['A5', 'treble'], [10, 1]), (['C6', 'treble'], [12, 2]), (['C#4', 'treble'], [-2, 1]), (['Fx4', 'treble'], [1, 0]), (['Bb3', 'treble'], [-3, 1])], [(['A3', 'treble'], [-4, 2]), (['G5', 'treble'], [9, 0]), (['A5', 'treble'], [10, 1]), (['C#4', 'treble'], [-2, 1]), (['Fx4', 'treble'], [1, 0]), (['Bb3', 'treble'], [-3, 1]), (['C4', 'alto'], [4, 0]), (['C4', 'bass'], [10, 1])]]
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 0[4, 0][0, 0]Failed
oracle 1[2, 0][-2, 1]Failed
oracle 2[3, 0][-1, 0]Failed
oracle 3[0, 0][-3, 1]Failed
oracle 4[-1, 0][-4, 2]Failed
oracle 5NoneNonePassed
oracle 6NoneNonePassed
oracle 7NoneNonePassed

SHA-256 / 6e6ef841135e3a06d4188a812e895698c0e5e73d972a71348ade824ba9036b83

3 / The verified repair

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

N = 1
observations = []
def solve(x):
    base = 'CDEFGAB'
    refs = {'treble': ('E', 4), 'bass': ('G', 2), 'alto': ('F', 3), 'tenor': ('D', 3)}
    if not isinstance(x, list) or len(x) != 2 or x[1] not in refs:
        return None
    note, clef = x
    if not isinstance(note, str) or len(note) < 2 or note[0] not in base:
        return None
    tail = note[1:].lstrip('#bx')
    if not tail.isdigit():
        return None
    letter, octave = refs[clef]
    pos = (int(tail) * 7 + base.index(note[0])) - (octave * 7 + base.index(letter))
    if pos < 0:
        ledgers = -pos // 2
    elif pos > 8:
        ledgers = (pos - 8) // 2
    else:
        ledgers = 0
    return [pos, ledgers]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[(['E4', 'treble'], [0, 0]), (['C4', 'treble'], [-2, 1]), (['D4', 'treble'], [-1, 0]), (['B3', 'treble'], [-3, 1]), (['A3', 'treble'], [-4, 2]), (['H4', 'treble'], None), (['C4', 'piano'], None), (['C', 'treble'], None)], [(['E4', 'treble'], [0, 0]), (['C4', 'treble'], [-2, 1]), (['D4', 'treble'], [-1, 0]), (['B3', 'treble'], [-3, 1]), (['A3', 'treble'], [-4, 2]), (['F5', 'treble'], [8, 0]), (['G5', 'treble'], [9, 0]), (['A5', 'treble'], [10, 1])], [(['D4', 'treble'], [-1, 0]), (['B3', 'treble'], [-3, 1]), (['A3', 'treble'], [-4, 2]), (['F5', 'treble'], [8, 0]), (['G5', 'treble'], [9, 0]), (['A5', 'treble'], [10, 1]), (['C6', 'treble'], [12, 2]), (['C#4', 'treble'], [-2, 1])], [(['B3', 'treble'], [-3, 1]), (['F5', 'treble'], [8, 0]), (['G5', 'treble'], [9, 0]), (['A5', 'treble'], [10, 1]), (['C6', 'treble'], [12, 2]), (['C#4', 'treble'], [-2, 1]), (['Fx4', 'treble'], [1, 0]), (['Bb3', 'treble'], [-3, 1])], [(['A3', 'treble'], [-4, 2]), (['G5', 'treble'], [9, 0]), (['A5', 'treble'], [10, 1]), (['C#4', 'treble'], [-2, 1]), (['Fx4', 'treble'], [1, 0]), (['Bb3', 'treble'], [-3, 1]), (['C4', 'alto'], [4, 0]), (['C4', 'bass'], [10, 1])]]
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 0[0, 0][0, 0]Passed
oracle 1[-2, 1][-2, 1]Passed
oracle 2[-1, 0][-1, 0]Passed
oracle 3[-3, 1][-3, 1]Passed
oracle 4[-4, 2][-4, 2]Passed
oracle 5NoneNonePassed
oracle 6NoneNonePassed
oracle 7NoneNonePassed

SHA-256 / 508f6f1808cd5e92b68a832d2336fe296489b6846a203bab732a797e1012f4e6

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

Case digest / ebf47f1d8f65db6e227250f938780c3ddb422887a27f2caa5b7b76a6ec59f636