FA-81281 / Music interval and transposition theory / Open access
Staff position and ledger lines for a clef: altered notes cannot be placed · case 01
C#4 or Bb3 are rejected as malformed even though accidentals do not change staff position.
ROOT CAUSE
Accidental characters are left in the octave field.
VERIFIED REPAIR
Restore the accidental stripping step so that it reads `note[1:].lstrip('#bx')`.
Unsuccessful approach: Stripping only sharps and flats still rejects double sharps written as x.
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:]
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]), (['C#4', 'treble'], [-2, 1]), (['Fx4', 'treble'], [1, 0]), (['Bb3', 'treble'], [-3, 1])], [(['B3', 'treble'], [-3, 1]), (['A3', 'treble'], [-4, 2]), (['F5', 'treble'], [8, 0]), (['G5', 'treble'], [9, 0]), (['A5', 'treble'], [10, 1]), (['C6', 'treble'], [12, 2]), (['Fx4', 'treble'], [1, 0]), (['Dbb4', 'tenor'], [7, 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]), (['C4', 'alto'], [4, 0]), (['C4', 'bass'], [10, 1])], [(['Fx4', 'treble'], [1, 0]), (['C4', 'alto'], [4, 0]), (['C4', 'bass'], [10, 1]), (['E2', 'bass'], [-2, 1]), (['C4', 'tenor'], [6, 0]), (['G2', 'bass'], [0, 0]), (['F3', 'alto'], [0, 0]), (['Dbb4', 'tenor'], [7, 0])], [(['C#4', 'treble'], [-2, 1]), (['Fx4', 'treble'], [1, 0]), (['Bb3', 'treble'], [-3, 1]), (['C4', 'tenor'], [6, 0]), (['G2', 'bass'], [0, 0]), (['F3', 'alto'], [0, 0]), (['B2', 'alto'], [-4, 2]), (['H4', 'treble'], 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 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 | [-4, 2] | [-4, 2] | Passed |
| oracle 5 | None | [-2, 1] | Failed |
| oracle 6 | None | [1, 0] | Failed |
| oracle 7 | None | [-3, 1] | Failed |
SHA-256 / b64ead731fbacaefcce2ba0f0ae517f567c25cec1927ed59f64cf54a4f60c8d5
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('#b')
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]), (['C#4', 'treble'], [-2, 1]), (['Fx4', 'treble'], [1, 0]), (['Bb3', 'treble'], [-3, 1])], [(['B3', 'treble'], [-3, 1]), (['A3', 'treble'], [-4, 2]), (['F5', 'treble'], [8, 0]), (['G5', 'treble'], [9, 0]), (['A5', 'treble'], [10, 1]), (['C6', 'treble'], [12, 2]), (['Fx4', 'treble'], [1, 0]), (['Dbb4', 'tenor'], [7, 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]), (['C4', 'alto'], [4, 0]), (['C4', 'bass'], [10, 1])], [(['Fx4', 'treble'], [1, 0]), (['C4', 'alto'], [4, 0]), (['C4', 'bass'], [10, 1]), (['E2', 'bass'], [-2, 1]), (['C4', 'tenor'], [6, 0]), (['G2', 'bass'], [0, 0]), (['F3', 'alto'], [0, 0]), (['Dbb4', 'tenor'], [7, 0])], [(['C#4', 'treble'], [-2, 1]), (['Fx4', 'treble'], [1, 0]), (['Bb3', 'treble'], [-3, 1]), (['C4', 'tenor'], [6, 0]), (['G2', 'bass'], [0, 0]), (['F3', 'alto'], [0, 0]), (['B2', 'alto'], [-4, 2]), (['H4', 'treble'], 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 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 | [-4, 2] | [-4, 2] | Passed |
| oracle 5 | [-2, 1] | [-2, 1] | Passed |
| oracle 6 | None | [1, 0] | Failed |
| oracle 7 | [-3, 1] | [-3, 1] | Passed |
SHA-256 / 590dedbc2cc5633adc09605952e02befa30bcc4be591ce355391aa00bf82595a
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]), (['C#4', 'treble'], [-2, 1]), (['Fx4', 'treble'], [1, 0]), (['Bb3', 'treble'], [-3, 1])], [(['B3', 'treble'], [-3, 1]), (['A3', 'treble'], [-4, 2]), (['F5', 'treble'], [8, 0]), (['G5', 'treble'], [9, 0]), (['A5', 'treble'], [10, 1]), (['C6', 'treble'], [12, 2]), (['Fx4', 'treble'], [1, 0]), (['Dbb4', 'tenor'], [7, 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]), (['C4', 'alto'], [4, 0]), (['C4', 'bass'], [10, 1])], [(['Fx4', 'treble'], [1, 0]), (['C4', 'alto'], [4, 0]), (['C4', 'bass'], [10, 1]), (['E2', 'bass'], [-2, 1]), (['C4', 'tenor'], [6, 0]), (['G2', 'bass'], [0, 0]), (['F3', 'alto'], [0, 0]), (['Dbb4', 'tenor'], [7, 0])], [(['C#4', 'treble'], [-2, 1]), (['Fx4', 'treble'], [1, 0]), (['Bb3', 'treble'], [-3, 1]), (['C4', 'tenor'], [6, 0]), (['G2', 'bass'], [0, 0]), (['F3', 'alto'], [0, 0]), (['B2', 'alto'], [-4, 2]), (['H4', 'treble'], 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 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 | [-4, 2] | [-4, 2] | Passed |
| oracle 5 | [-2, 1] | [-2, 1] | Passed |
| oracle 6 | [1, 0] | [1, 0] | Passed |
| oracle 7 | [-3, 1] | [-3, 1] | Passed |
SHA-256 / 57295adcd345b2d35ede4d231b869f5531ae4eed7ce357c378c3ab33aba7b723
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.550589+00:00.
Case digest / 1c0b25cf6dba7c3b001b26725fdbd81d8c1fe69cced2227bff0794574a02ec8e