FA-80986 / Music interval and transposition theory / Open access
Key signature and measure accidental resolution: accidental applies to every octave of the letter · case 01
C#4 followed by C5 in the same measure plays C#5 although the accidental applies only to octave 4.
ROOT CAUSE
Accidental memory is keyed by letter alone instead of letter plus octave.
VERIFIED REPAIR
Restore the octave scoping step so that it reads `slot = letter + octave`.
Unsuccessful approach: Storing under letter+octave but reading under the bare letter means carried accidentals are never found at all.
Case contract
Input [fifths, tokens]. fifths -7..7 gives signature sharps on F C G D A E B or flats on B E A D G C F. Tokens are "|" (barline) or letter + optional sign (# b x bb n) + single-digit octave. An explicit sign sets the alteration for that letter in that octave until the next barline (n = 0 cancels the signature); otherwise the signature applies. Return the MIDI numbers (C4 = 60) or None if any token or the signature is invalid.
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):
if not isinstance(x, list) or len(x) != 2:
return None
fifths, tokens = x
if not isinstance(fifths, int) or fifths < -7 or fifths > 7:
return None
base = {'C': 0, 'D': 2, 'E': 4, 'F': 5, 'G': 7, 'A': 9, 'B': 11}
keysig = {}
if fifths > 0:
for letter in 'FCGDAEB'[:fifths]:
keysig[letter] = 1
else:
for letter in 'BEADGCF'[:-fifths]:
keysig[letter] = -1
marks = {}
out = []
for tok in tokens:
if tok == '|':
marks = {}
continue
letter, sign, octave = tok[0], tok[1:-1], tok[-1]
if letter not in base or not octave.isdigit() or sign not in ('', '#', 'b', 'n', 'x', 'bb'):
return None
slot = letter
if sign:
marks[slot] = {'#': 1, 'b': -1, 'n': 0, 'x': 2, 'bb': -2}[sign]
alter = marks[slot] if slot in marks else keysig.get(letter, 0)
out.append(12 * (int(octave) + 1) + base[letter] + alter)
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([1, ['F4', 'Fn4', 'F4', '|', 'F4']], [66, 65, 65, 66]), ([0, ['C#4', 'C5', 'C4']], [61, 72, 61]), ([-1, ['B4', 'Bn4', 'B4', '|', 'B4']], [70, 71, 71, 70]), ([-3, ['E4', 'A4', 'B4', 'D4']], [63, 68, 70, 62]), ([2, ['F4', 'C5', 'G4']], [66, 73, 67]), ([-7, ['F4', 'C4', 'B3']], [64, 59, 58]), ([7, ['B3', 'E4', 'C4']], [60, 65, 61]), ([-5, ['G4', 'Gn4', 'G4', 'G5']], [66, 67, 67, 78])], [([0, ['C#4', 'C4', '|', 'C4']], [61, 61, 60]), ([0, ['C#4', 'C5', 'C4']], [61, 72, 61]), ([-2, ['Eb4', 'E4', 'En4', 'E4']], [63, 63, 64, 64]), ([7, ['B3', 'E4', 'C4']], [60, 65, 61]), ([8, ['C4']], None), ([0, ['H4']], None), ([0, ['C#44']], None), ([4, ['D4', 'Dn4', 'D5', 'D4']], [63, 62, 75, 62])], [([0, ['C#4', 'C5', 'C4']], [61, 72, 61]), ([0, ['Gbb4', 'G4', '|', 'G4']], [65, 65, 67]), ([0, ['C#44']], None), ([4, ['D4', 'Dn4', 'D5', 'D4']], [63, 62, 75, 62]), ([-4, ['D4', 'Db4', 'D4', '|', 'D4']], [61, 61, 61, 61]), ([5, ['A4', 'An4', '|', 'A4']], [70, 69, 70]), ([-5, ['G4', 'Gn4', 'G4', 'G5']], [66, 67, 67, 78]), ([-6, ['C5', 'Cn5', '|', 'C5']], [71, 72, 71])], [([1, ['F4', 'Fn4', 'F4', '|', 'F4']], [66, 65, 65, 66]), ([0, ['C#4', 'C5', 'C4']], [61, 72, 61]), ([-1, ['B4', 'Bn4', 'B4', '|', 'B4']], [70, 71, 71, 70]), ([3, ['Fx4', 'F4', '|', 'F4', 'G4']], [67, 67, 66, 68]), ([-5, ['G4', 'Gn4', 'G4', 'G5']], [66, 67, 67, 78]), ([-6, ['C5', 'Cn5', '|', 'C5']], [71, 72, 71]), ([6, ['E4', 'B4', 'A4']], [65, 71, 70]), ([0, ['Cq4']], None)], [([1, ['F4', 'Fn4', 'F4', '|', 'F4']], [66, 65, 65, 66]), ([0, ['C#4', 'C4', '|', 'C4']], [61, 61, 60]), ([0, ['C#4', 'C5', 'C4']], [61, 72, 61]), ([-1, ['B4', 'Bn4', 'B4', '|', 'B4']], [70, 71, 71, 70]), ([-2, ['Eb4', 'E4', 'En4', 'E4']], [63, 63, 64, 64]), ([0, ['Gbb4', 'G4', '|', 'G4']], [65, 65, 67]), ([3, ['Fx4', 'F4', '|', 'F4', 'G4']], [67, 67, 66, 68]), ([4, ['D4', 'Dn4', 'D5', 'D4']], [63, 62, 75, 62])]]
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 | [66, 65, 65, 66] | [66, 65, 65, 66] | Passed |
| oracle 1 | [61, 73, 61] | [61, 72, 61] | Failed |
| oracle 2 | [70, 71, 71, 70] | [70, 71, 71, 70] | Passed |
| oracle 3 | [63, 68, 70, 62] | [63, 68, 70, 62] | Passed |
| oracle 4 | [66, 73, 67] | [66, 73, 67] | Passed |
| oracle 5 | [64, 59, 58] | [64, 59, 58] | Passed |
| oracle 6 | [60, 65, 61] | [60, 65, 61] | Passed |
| oracle 7 | [66, 67, 67, 79] | [66, 67, 67, 78] | Failed |
SHA-256 / 4584611a232026f782058b9c35de84d04c330b973963b2a3414eb08893a8d42e
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
if not isinstance(x, list) or len(x) != 2:
return None
fifths, tokens = x
if not isinstance(fifths, int) or fifths < -7 or fifths > 7:
return None
base = {'C': 0, 'D': 2, 'E': 4, 'F': 5, 'G': 7, 'A': 9, 'B': 11}
keysig = {}
if fifths > 0:
for letter in 'FCGDAEB'[:fifths]:
keysig[letter] = 1
else:
for letter in 'BEADGCF'[:-fifths]:
keysig[letter] = -1
marks = {}
out = []
for tok in tokens:
if tok == '|':
marks = {}
continue
letter, sign, octave = tok[0], tok[1:-1], tok[-1]
if letter not in base or not octave.isdigit() or sign not in ('', '#', 'b', 'n', 'x', 'bb'):
return None
slot = letter + octave if sign else letter
if sign:
marks[slot] = {'#': 1, 'b': -1, 'n': 0, 'x': 2, 'bb': -2}[sign]
alter = marks[slot] if slot in marks else keysig.get(letter, 0)
out.append(12 * (int(octave) + 1) + base[letter] + alter)
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([1, ['F4', 'Fn4', 'F4', '|', 'F4']], [66, 65, 65, 66]), ([0, ['C#4', 'C5', 'C4']], [61, 72, 61]), ([-1, ['B4', 'Bn4', 'B4', '|', 'B4']], [70, 71, 71, 70]), ([-3, ['E4', 'A4', 'B4', 'D4']], [63, 68, 70, 62]), ([2, ['F4', 'C5', 'G4']], [66, 73, 67]), ([-7, ['F4', 'C4', 'B3']], [64, 59, 58]), ([7, ['B3', 'E4', 'C4']], [60, 65, 61]), ([-5, ['G4', 'Gn4', 'G4', 'G5']], [66, 67, 67, 78])], [([0, ['C#4', 'C4', '|', 'C4']], [61, 61, 60]), ([0, ['C#4', 'C5', 'C4']], [61, 72, 61]), ([-2, ['Eb4', 'E4', 'En4', 'E4']], [63, 63, 64, 64]), ([7, ['B3', 'E4', 'C4']], [60, 65, 61]), ([8, ['C4']], None), ([0, ['H4']], None), ([0, ['C#44']], None), ([4, ['D4', 'Dn4', 'D5', 'D4']], [63, 62, 75, 62])], [([0, ['C#4', 'C5', 'C4']], [61, 72, 61]), ([0, ['Gbb4', 'G4', '|', 'G4']], [65, 65, 67]), ([0, ['C#44']], None), ([4, ['D4', 'Dn4', 'D5', 'D4']], [63, 62, 75, 62]), ([-4, ['D4', 'Db4', 'D4', '|', 'D4']], [61, 61, 61, 61]), ([5, ['A4', 'An4', '|', 'A4']], [70, 69, 70]), ([-5, ['G4', 'Gn4', 'G4', 'G5']], [66, 67, 67, 78]), ([-6, ['C5', 'Cn5', '|', 'C5']], [71, 72, 71])], [([1, ['F4', 'Fn4', 'F4', '|', 'F4']], [66, 65, 65, 66]), ([0, ['C#4', 'C5', 'C4']], [61, 72, 61]), ([-1, ['B4', 'Bn4', 'B4', '|', 'B4']], [70, 71, 71, 70]), ([3, ['Fx4', 'F4', '|', 'F4', 'G4']], [67, 67, 66, 68]), ([-5, ['G4', 'Gn4', 'G4', 'G5']], [66, 67, 67, 78]), ([-6, ['C5', 'Cn5', '|', 'C5']], [71, 72, 71]), ([6, ['E4', 'B4', 'A4']], [65, 71, 70]), ([0, ['Cq4']], None)], [([1, ['F4', 'Fn4', 'F4', '|', 'F4']], [66, 65, 65, 66]), ([0, ['C#4', 'C4', '|', 'C4']], [61, 61, 60]), ([0, ['C#4', 'C5', 'C4']], [61, 72, 61]), ([-1, ['B4', 'Bn4', 'B4', '|', 'B4']], [70, 71, 71, 70]), ([-2, ['Eb4', 'E4', 'En4', 'E4']], [63, 63, 64, 64]), ([0, ['Gbb4', 'G4', '|', 'G4']], [65, 65, 67]), ([3, ['Fx4', 'F4', '|', 'F4', 'G4']], [67, 67, 66, 68]), ([4, ['D4', 'Dn4', 'D5', 'D4']], [63, 62, 75, 62])]]
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 | [66, 65, 66, 66] | [66, 65, 65, 66] | Failed |
| oracle 1 | [61, 72, 60] | [61, 72, 61] | Failed |
| oracle 2 | [70, 71, 70, 70] | [70, 71, 71, 70] | Failed |
| oracle 3 | [63, 68, 70, 62] | [63, 68, 70, 62] | Passed |
| oracle 4 | [66, 73, 67] | [66, 73, 67] | Passed |
| oracle 5 | [64, 59, 58] | [64, 59, 58] | Passed |
| oracle 6 | [60, 65, 61] | [60, 65, 61] | Passed |
| oracle 7 | [66, 67, 66, 78] | [66, 67, 67, 78] | Failed |
SHA-256 / 3186fdbdc014e6278a4c98924b0f62d564dd6e5af4df783eee774946984d5829
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
if not isinstance(x, list) or len(x) != 2:
return None
fifths, tokens = x
if not isinstance(fifths, int) or fifths < -7 or fifths > 7:
return None
base = {'C': 0, 'D': 2, 'E': 4, 'F': 5, 'G': 7, 'A': 9, 'B': 11}
keysig = {}
if fifths > 0:
for letter in 'FCGDAEB'[:fifths]:
keysig[letter] = 1
else:
for letter in 'BEADGCF'[:-fifths]:
keysig[letter] = -1
marks = {}
out = []
for tok in tokens:
if tok == '|':
marks = {}
continue
letter, sign, octave = tok[0], tok[1:-1], tok[-1]
if letter not in base or not octave.isdigit() or sign not in ('', '#', 'b', 'n', 'x', 'bb'):
return None
slot = letter + octave
if sign:
marks[slot] = {'#': 1, 'b': -1, 'n': 0, 'x': 2, 'bb': -2}[sign]
alter = marks[slot] if slot in marks else keysig.get(letter, 0)
out.append(12 * (int(octave) + 1) + base[letter] + alter)
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([1, ['F4', 'Fn4', 'F4', '|', 'F4']], [66, 65, 65, 66]), ([0, ['C#4', 'C5', 'C4']], [61, 72, 61]), ([-1, ['B4', 'Bn4', 'B4', '|', 'B4']], [70, 71, 71, 70]), ([-3, ['E4', 'A4', 'B4', 'D4']], [63, 68, 70, 62]), ([2, ['F4', 'C5', 'G4']], [66, 73, 67]), ([-7, ['F4', 'C4', 'B3']], [64, 59, 58]), ([7, ['B3', 'E4', 'C4']], [60, 65, 61]), ([-5, ['G4', 'Gn4', 'G4', 'G5']], [66, 67, 67, 78])], [([0, ['C#4', 'C4', '|', 'C4']], [61, 61, 60]), ([0, ['C#4', 'C5', 'C4']], [61, 72, 61]), ([-2, ['Eb4', 'E4', 'En4', 'E4']], [63, 63, 64, 64]), ([7, ['B3', 'E4', 'C4']], [60, 65, 61]), ([8, ['C4']], None), ([0, ['H4']], None), ([0, ['C#44']], None), ([4, ['D4', 'Dn4', 'D5', 'D4']], [63, 62, 75, 62])], [([0, ['C#4', 'C5', 'C4']], [61, 72, 61]), ([0, ['Gbb4', 'G4', '|', 'G4']], [65, 65, 67]), ([0, ['C#44']], None), ([4, ['D4', 'Dn4', 'D5', 'D4']], [63, 62, 75, 62]), ([-4, ['D4', 'Db4', 'D4', '|', 'D4']], [61, 61, 61, 61]), ([5, ['A4', 'An4', '|', 'A4']], [70, 69, 70]), ([-5, ['G4', 'Gn4', 'G4', 'G5']], [66, 67, 67, 78]), ([-6, ['C5', 'Cn5', '|', 'C5']], [71, 72, 71])], [([1, ['F4', 'Fn4', 'F4', '|', 'F4']], [66, 65, 65, 66]), ([0, ['C#4', 'C5', 'C4']], [61, 72, 61]), ([-1, ['B4', 'Bn4', 'B4', '|', 'B4']], [70, 71, 71, 70]), ([3, ['Fx4', 'F4', '|', 'F4', 'G4']], [67, 67, 66, 68]), ([-5, ['G4', 'Gn4', 'G4', 'G5']], [66, 67, 67, 78]), ([-6, ['C5', 'Cn5', '|', 'C5']], [71, 72, 71]), ([6, ['E4', 'B4', 'A4']], [65, 71, 70]), ([0, ['Cq4']], None)], [([1, ['F4', 'Fn4', 'F4', '|', 'F4']], [66, 65, 65, 66]), ([0, ['C#4', 'C4', '|', 'C4']], [61, 61, 60]), ([0, ['C#4', 'C5', 'C4']], [61, 72, 61]), ([-1, ['B4', 'Bn4', 'B4', '|', 'B4']], [70, 71, 71, 70]), ([-2, ['Eb4', 'E4', 'En4', 'E4']], [63, 63, 64, 64]), ([0, ['Gbb4', 'G4', '|', 'G4']], [65, 65, 67]), ([3, ['Fx4', 'F4', '|', 'F4', 'G4']], [67, 67, 66, 68]), ([4, ['D4', 'Dn4', 'D5', 'D4']], [63, 62, 75, 62])]]
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 | [66, 65, 65, 66] | [66, 65, 65, 66] | Passed |
| oracle 1 | [61, 72, 61] | [61, 72, 61] | Passed |
| oracle 2 | [70, 71, 71, 70] | [70, 71, 71, 70] | Passed |
| oracle 3 | [63, 68, 70, 62] | [63, 68, 70, 62] | Passed |
| oracle 4 | [66, 73, 67] | [66, 73, 67] | Passed |
| oracle 5 | [64, 59, 58] | [64, 59, 58] | Passed |
| oracle 6 | [60, 65, 61] | [60, 65, 61] | Passed |
| oracle 7 | [66, 67, 67, 78] | [66, 67, 67, 78] | Passed |
SHA-256 / 7154b46230f51271259ae539299fc84b7ac89ac4b66bb876d49f9ba3e09ccecf
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.713326+00:00.
Case digest / 710741e6383714a4ba8985872abb582cdf72a0b1a6e3af174ccecef7c5cad21c