FA-81296 / Music interval and transposition theory / Open access
Staff position and ledger lines for a clef: upper ledger count rounded up · case 01
G5 above the treble staff reports a ledger line although it sits on top of the staff.
ROOT CAUSE
Positions above the staff are rounded up to the next ledger line.
VERIFIED REPAIR
Restore the upper ledger count step so that it reads `(pos - 8) // 2`.
Unsuccessful approach: Offsetting from position 9 misses the ledger line through A5.
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) * 7 + base.index(note[0])) - (octave * 7 + base.index(letter))
if pos < 0:
ledgers = -pos // 2
elif pos > 8:
ledgers = (pos - 8 + 1) // 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]), (['G5', 'treble'], [9, 0]), (['A5', 'treble'], [10, 1]), (['D6', 'treble'], [13, 2]), (['E6', 'treble'], [14, 3])], [(['B3', 'treble'], [-3, 1]), (['A3', 'treble'], [-4, 2]), (['F5', 'treble'], [8, 0]), (['A5', 'treble'], [10, 1]), (['C6', 'treble'], [12, 2]), (['C#4', 'treble'], [-2, 1]), (['B5', 'treble'], [11, 1]), (['A4', 'alto'], [9, 0])], [(['G5', 'treble'], [9, 0]), (['C6', 'treble'], [12, 2]), (['C#4', 'treble'], [-2, 1]), (['Fx4', 'treble'], [1, 0]), (['Bb3', 'treble'], [-3, 1]), (['C4', 'alto'], [4, 0]), (['C4', 'bass'], [10, 1]), (['D6', 'treble'], [13, 2])], [(['C4', 'alto'], [4, 0]), (['C4', 'bass'], [10, 1]), (['E2', 'bass'], [-2, 1]), (['C4', 'tenor'], [6, 0]), (['G2', 'bass'], [0, 0]), (['B5', 'treble'], [11, 1]), (['A4', 'alto'], [9, 0]), (['E6', 'treble'], [14, 3])], [(['G5', 'treble'], [9, 0]), (['A5', 'treble'], [10, 1]), (['G2', 'bass'], [0, 0]), (['F3', 'alto'], [0, 0]), (['B2', 'alto'], [-4, 2]), (['H4', 'treble'], None), (['D6', 'treble'], [13, 2]), (['E6', 'treble'], [14, 3])]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| 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 | [9, 1] | [9, 0] | Failed |
| oracle 5 | [10, 1] | [10, 1] | Passed |
| oracle 6 | [13, 3] | [13, 2] | Failed |
| oracle 7 | [14, 3] | [14, 3] | Passed |
SHA-256 / cd782171ff3d22a495f21c6c9492cdf2833e7acfc0978fcae7958b17892226c3
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) * 7 + base.index(note[0])) - (octave * 7 + base.index(letter))
if pos < 0:
ledgers = -pos // 2
elif pos > 8:
ledgers = (pos - 9) // 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]), (['G5', 'treble'], [9, 0]), (['A5', 'treble'], [10, 1]), (['D6', 'treble'], [13, 2]), (['E6', 'treble'], [14, 3])], [(['B3', 'treble'], [-3, 1]), (['A3', 'treble'], [-4, 2]), (['F5', 'treble'], [8, 0]), (['A5', 'treble'], [10, 1]), (['C6', 'treble'], [12, 2]), (['C#4', 'treble'], [-2, 1]), (['B5', 'treble'], [11, 1]), (['A4', 'alto'], [9, 0])], [(['G5', 'treble'], [9, 0]), (['C6', 'treble'], [12, 2]), (['C#4', 'treble'], [-2, 1]), (['Fx4', 'treble'], [1, 0]), (['Bb3', 'treble'], [-3, 1]), (['C4', 'alto'], [4, 0]), (['C4', 'bass'], [10, 1]), (['D6', 'treble'], [13, 2])], [(['C4', 'alto'], [4, 0]), (['C4', 'bass'], [10, 1]), (['E2', 'bass'], [-2, 1]), (['C4', 'tenor'], [6, 0]), (['G2', 'bass'], [0, 0]), (['B5', 'treble'], [11, 1]), (['A4', 'alto'], [9, 0]), (['E6', 'treble'], [14, 3])], [(['G5', 'treble'], [9, 0]), (['A5', 'treble'], [10, 1]), (['G2', 'bass'], [0, 0]), (['F3', 'alto'], [0, 0]), (['B2', 'alto'], [-4, 2]), (['H4', 'treble'], None), (['D6', 'treble'], [13, 2]), (['E6', 'treble'], [14, 3])]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| 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 | [9, 0] | [9, 0] | Passed |
| oracle 5 | [10, 0] | [10, 1] | Failed |
| oracle 6 | [13, 2] | [13, 2] | Passed |
| oracle 7 | [14, 2] | [14, 3] | Failed |
SHA-256 / 494e373e413808a82ba3dc78d14d881e0c263be2c587eb36856d6736e46125a6
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]), (['G5', 'treble'], [9, 0]), (['A5', 'treble'], [10, 1]), (['D6', 'treble'], [13, 2]), (['E6', 'treble'], [14, 3])], [(['B3', 'treble'], [-3, 1]), (['A3', 'treble'], [-4, 2]), (['F5', 'treble'], [8, 0]), (['A5', 'treble'], [10, 1]), (['C6', 'treble'], [12, 2]), (['C#4', 'treble'], [-2, 1]), (['B5', 'treble'], [11, 1]), (['A4', 'alto'], [9, 0])], [(['G5', 'treble'], [9, 0]), (['C6', 'treble'], [12, 2]), (['C#4', 'treble'], [-2, 1]), (['Fx4', 'treble'], [1, 0]), (['Bb3', 'treble'], [-3, 1]), (['C4', 'alto'], [4, 0]), (['C4', 'bass'], [10, 1]), (['D6', 'treble'], [13, 2])], [(['C4', 'alto'], [4, 0]), (['C4', 'bass'], [10, 1]), (['E2', 'bass'], [-2, 1]), (['C4', 'tenor'], [6, 0]), (['G2', 'bass'], [0, 0]), (['B5', 'treble'], [11, 1]), (['A4', 'alto'], [9, 0]), (['E6', 'treble'], [14, 3])], [(['G5', 'treble'], [9, 0]), (['A5', 'treble'], [10, 1]), (['G2', 'bass'], [0, 0]), (['F3', 'alto'], [0, 0]), (['B2', 'alto'], [-4, 2]), (['H4', 'treble'], None), (['D6', 'treble'], [13, 2]), (['E6', 'treble'], [14, 3])]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| 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 | [9, 0] | [9, 0] | Passed |
| oracle 5 | [10, 1] | [10, 1] | Passed |
| oracle 6 | [13, 2] | [13, 2] | Passed |
| oracle 7 | [14, 3] | [14, 3] | Passed |
SHA-256 / d92f600d5b8bc0b2494d78cf58813ef6fa2485f04087e9942e5f86417ae67d6d
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.805987+00:00.
Case digest / 028b6f5fb7814f07f174005e0d039629c0cdd86c11fcd7d37b79dec17ebda691