FAILURE MAP
← Case archive

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

Modal scale spelling from a tonic: steps taken from letter position not scale position · case 01

Non-ionian modes come out as the major scale of the tonic because the pitch advance follows the letter names.

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

ROOT CAUSE

The pitch-class advance indexes the unrotated major pattern by letter position, not the rotated mode pattern by degree.

VERIFIED REPAIR

Restore the step accumulation step so that it reads `pc += step`.

Unsuccessful approach: Using the rotated pattern but indexing it by the absolute letter still misaligns every mode whose tonic is not C.

Case contract

Input [tonic, mode]: tonic is a letter plus optional accidental from "", #, b, x, bb; mode is one of the seven church modes ionian..locrian. The step pattern is the major pattern 2 2 1 2 2 2 1 rotated left by the mode index. Each degree uses the next letter; its alteration is the pitch-class difference from the natural letter folded into -6..5. Return the seven names, or None if any alteration exceeds two or input 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):
    base = {'C': 0, 'D': 2, 'E': 4, 'F': 5, 'G': 7, 'A': 9, 'B': 11}
    modes = ['ionian', 'dorian', 'phrygian', 'lydian', 'mixolydian', 'aeolian', 'locrian']
    if not isinstance(x, list) or len(x) != 2:
        return None
    tonic, mode = x
    if mode not in modes or not isinstance(tonic, str) or not tonic or tonic[0] not in base:
        return None
    signs = {'': 0, '#': 1, 'b': -1, 'x': 2, 'bb': -2}
    if tonic[1:] not in signs:
        return None
    steps = [2, 2, 1, 2, 2, 2, 1]
    k = modes.index(mode)
    steps = steps[k:] + steps[:k]
    pc = base[tonic[0]] + signs[tonic[1:]]
    li = 'CDEFGAB'.index(tonic[0])
    out = []
    for step in steps:
        letter = 'CDEFGAB'[li % 7]
        alter = (pc - base[letter] + 6) % 12 - 6
        if abs(alter) > 2:
            return None
        out.append(letter + {0: '', 1: '#', -1: 'b', 2: 'x', -2: 'bb'}[alter])
        pc += [2, 2, 1, 2, 2, 2, 1][li % 7]
        li += 1
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[(['C', 'ionian'], ['C', 'D', 'E', 'F', 'G', 'A', 'B']), (['D', 'dorian'], ['D', 'E', 'F', 'G', 'A', 'B', 'C']), (['G', 'mixolydian'], ['G', 'A', 'B', 'C', 'D', 'E', 'F']), (['C', 'dorian'], ['C', 'D', 'Eb', 'F', 'G', 'A', 'Bb']), (['C', 'lydian'], ['C', 'D', 'E', 'F#', 'G', 'A', 'B']), (['D', 'major'], None), (['H', 'ionian'], None), (['Cq', 'ionian'], None)], [(['D', 'dorian'], ['D', 'E', 'F', 'G', 'A', 'B', 'C']), (['E', 'phrygian'], ['E', 'F', 'G', 'A', 'B', 'C', 'D']), (['F', 'lydian'], ['F', 'G', 'A', 'B', 'C', 'D', 'E']), (['G', 'mixolydian'], ['G', 'A', 'B', 'C', 'D', 'E', 'F']), (['A', 'aeolian'], ['A', 'B', 'C', 'D', 'E', 'F', 'G']), (['C', 'phrygian'], ['C', 'Db', 'Eb', 'F', 'G', 'Ab', 'Bb']), (['C', 'locrian'], ['C', 'Db', 'Eb', 'F', 'Gb', 'Ab', 'Bb']), (['Cq', 'ionian'], None)], [(['F', 'lydian'], ['F', 'G', 'A', 'B', 'C', 'D', 'E']), (['G', 'mixolydian'], ['G', 'A', 'B', 'C', 'D', 'E', 'F']), (['A', 'aeolian'], ['A', 'B', 'C', 'D', 'E', 'F', 'G']), (['B', 'locrian'], ['B', 'C', 'D', 'E', 'F', 'G', 'A']), (['C', 'dorian'], ['C', 'D', 'Eb', 'F', 'G', 'A', 'Bb']), (['C', 'phrygian'], ['C', 'Db', 'Eb', 'F', 'G', 'Ab', 'Bb']), (['C', 'lydian'], ['C', 'D', 'E', 'F#', 'G', 'A', 'B']), (['Eb', 'aeolian'], ['Eb', 'F', 'Gb', 'Ab', 'Bb', 'Cb', 'Db'])], [(['G', 'mixolydian'], ['G', 'A', 'B', 'C', 'D', 'E', 'F']), (['B', 'locrian'], ['B', 'C', 'D', 'E', 'F', 'G', 'A']), (['C', 'dorian'], ['C', 'D', 'Eb', 'F', 'G', 'A', 'Bb']), (['C', 'phrygian'], ['C', 'Db', 'Eb', 'F', 'G', 'Ab', 'Bb']), (['C', 'lydian'], ['C', 'D', 'E', 'F#', 'G', 'A', 'B']), (['C', 'locrian'], ['C', 'Db', 'Eb', 'F', 'Gb', 'Ab', 'Bb']), (['Eb', 'aeolian'], ['Eb', 'F', 'Gb', 'Ab', 'Bb', 'Cb', 'Db']), (['F#', 'ionian'], ['F#', 'G#', 'A#', 'B', 'C#', 'D#', 'E#'])], [(['A', 'aeolian'], ['A', 'B', 'C', 'D', 'E', 'F', 'G']), (['C', 'lydian'], ['C', 'D', 'E', 'F#', 'G', 'A', 'B']), (['C', 'locrian'], ['C', 'Db', 'Eb', 'F', 'Gb', 'Ab', 'Bb']), (['Eb', 'aeolian'], ['Eb', 'F', 'Gb', 'Ab', 'Bb', 'Cb', 'Db']), (['F#', 'ionian'], ['F#', 'G#', 'A#', 'B', 'C#', 'D#', 'E#']), (['Bb', 'mixolydian'], ['Bb', 'C', 'D', 'Eb', 'F', 'G', 'Ab']), (['C#', 'locrian'], ['C#', 'D', 'E', 'F#', 'G', 'A', 'B']), (['Gb', 'lydian'], ['Gb', 'Ab', 'Bb', 'C', 'Db', 'Eb', 'F'])]]
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['C', 'D', 'E', 'F', 'G', 'A', 'B']['C', 'D', 'E', 'F', 'G', 'A', 'B']Passed
oracle 1['D', 'E', 'F', 'G', 'A', 'B', 'C']['D', 'E', 'F', 'G', 'A', 'B', 'C']Passed
oracle 2['G', 'A', 'B', 'C', 'D', 'E', 'F']['G', 'A', 'B', 'C', 'D', 'E', 'F']Passed
oracle 3['C', 'D', 'E', 'F', 'G', 'A', 'B']['C', 'D', 'Eb', 'F', 'G', 'A', 'Bb']Failed
oracle 4['C', 'D', 'E', 'F', 'G', 'A', 'B']['C', 'D', 'E', 'F#', 'G', 'A', 'B']Failed
oracle 5NoneNonePassed
oracle 6NoneNonePassed
oracle 7NoneNonePassed

SHA-256 / 2aaf92206d70ff9c7cff75362a2dacb84ef9c6d6c9e57ea70ae43d073bf6b366

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}
    modes = ['ionian', 'dorian', 'phrygian', 'lydian', 'mixolydian', 'aeolian', 'locrian']
    if not isinstance(x, list) or len(x) != 2:
        return None
    tonic, mode = x
    if mode not in modes or not isinstance(tonic, str) or not tonic or tonic[0] not in base:
        return None
    signs = {'': 0, '#': 1, 'b': -1, 'x': 2, 'bb': -2}
    if tonic[1:] not in signs:
        return None
    steps = [2, 2, 1, 2, 2, 2, 1]
    k = modes.index(mode)
    steps = steps[k:] + steps[:k]
    pc = base[tonic[0]] + signs[tonic[1:]]
    li = 'CDEFGAB'.index(tonic[0])
    out = []
    for step in steps:
        letter = 'CDEFGAB'[li % 7]
        alter = (pc - base[letter] + 6) % 12 - 6
        if abs(alter) > 2:
            return None
        out.append(letter + {0: '', 1: '#', -1: 'b', 2: 'x', -2: 'bb'}[alter])
        pc += steps[li % 7]
        li += 1
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[(['C', 'ionian'], ['C', 'D', 'E', 'F', 'G', 'A', 'B']), (['D', 'dorian'], ['D', 'E', 'F', 'G', 'A', 'B', 'C']), (['G', 'mixolydian'], ['G', 'A', 'B', 'C', 'D', 'E', 'F']), (['C', 'dorian'], ['C', 'D', 'Eb', 'F', 'G', 'A', 'Bb']), (['C', 'lydian'], ['C', 'D', 'E', 'F#', 'G', 'A', 'B']), (['D', 'major'], None), (['H', 'ionian'], None), (['Cq', 'ionian'], None)], [(['D', 'dorian'], ['D', 'E', 'F', 'G', 'A', 'B', 'C']), (['E', 'phrygian'], ['E', 'F', 'G', 'A', 'B', 'C', 'D']), (['F', 'lydian'], ['F', 'G', 'A', 'B', 'C', 'D', 'E']), (['G', 'mixolydian'], ['G', 'A', 'B', 'C', 'D', 'E', 'F']), (['A', 'aeolian'], ['A', 'B', 'C', 'D', 'E', 'F', 'G']), (['C', 'phrygian'], ['C', 'Db', 'Eb', 'F', 'G', 'Ab', 'Bb']), (['C', 'locrian'], ['C', 'Db', 'Eb', 'F', 'Gb', 'Ab', 'Bb']), (['Cq', 'ionian'], None)], [(['F', 'lydian'], ['F', 'G', 'A', 'B', 'C', 'D', 'E']), (['G', 'mixolydian'], ['G', 'A', 'B', 'C', 'D', 'E', 'F']), (['A', 'aeolian'], ['A', 'B', 'C', 'D', 'E', 'F', 'G']), (['B', 'locrian'], ['B', 'C', 'D', 'E', 'F', 'G', 'A']), (['C', 'dorian'], ['C', 'D', 'Eb', 'F', 'G', 'A', 'Bb']), (['C', 'phrygian'], ['C', 'Db', 'Eb', 'F', 'G', 'Ab', 'Bb']), (['C', 'lydian'], ['C', 'D', 'E', 'F#', 'G', 'A', 'B']), (['Eb', 'aeolian'], ['Eb', 'F', 'Gb', 'Ab', 'Bb', 'Cb', 'Db'])], [(['G', 'mixolydian'], ['G', 'A', 'B', 'C', 'D', 'E', 'F']), (['B', 'locrian'], ['B', 'C', 'D', 'E', 'F', 'G', 'A']), (['C', 'dorian'], ['C', 'D', 'Eb', 'F', 'G', 'A', 'Bb']), (['C', 'phrygian'], ['C', 'Db', 'Eb', 'F', 'G', 'Ab', 'Bb']), (['C', 'lydian'], ['C', 'D', 'E', 'F#', 'G', 'A', 'B']), (['C', 'locrian'], ['C', 'Db', 'Eb', 'F', 'Gb', 'Ab', 'Bb']), (['Eb', 'aeolian'], ['Eb', 'F', 'Gb', 'Ab', 'Bb', 'Cb', 'Db']), (['F#', 'ionian'], ['F#', 'G#', 'A#', 'B', 'C#', 'D#', 'E#'])], [(['A', 'aeolian'], ['A', 'B', 'C', 'D', 'E', 'F', 'G']), (['C', 'lydian'], ['C', 'D', 'E', 'F#', 'G', 'A', 'B']), (['C', 'locrian'], ['C', 'Db', 'Eb', 'F', 'Gb', 'Ab', 'Bb']), (['Eb', 'aeolian'], ['Eb', 'F', 'Gb', 'Ab', 'Bb', 'Cb', 'Db']), (['F#', 'ionian'], ['F#', 'G#', 'A#', 'B', 'C#', 'D#', 'E#']), (['Bb', 'mixolydian'], ['Bb', 'C', 'D', 'Eb', 'F', 'G', 'Ab']), (['C#', 'locrian'], ['C#', 'D', 'E', 'F#', 'G', 'A', 'B']), (['Gb', 'lydian'], ['Gb', 'Ab', 'Bb', 'C', 'Db', 'Eb', 'F'])]]
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['C', 'D', 'E', 'F', 'G', 'A', 'B']['C', 'D', 'E', 'F', 'G', 'A', 'B']Passed
oracle 1['D', 'Eb', 'F', 'G', 'A', 'Bb', 'C']['D', 'E', 'F', 'G', 'A', 'B', 'C']Failed
oracle 2['G', 'A', 'Bb', 'C', 'D', 'E', 'F']['G', 'A', 'B', 'C', 'D', 'E', 'F']Failed
oracle 3['C', 'D', 'Eb', 'F', 'G', 'A', 'Bb']['C', 'D', 'Eb', 'F', 'G', 'A', 'Bb']Passed
oracle 4['C', 'D', 'E', 'F#', 'G', 'A', 'B']['C', 'D', 'E', 'F#', 'G', 'A', 'B']Passed
oracle 5NoneNonePassed
oracle 6NoneNonePassed
oracle 7NoneNonePassed

SHA-256 / a7b7dc24b3130cfedd2d7b67c05187a6f8a66a0d0e743f8e44150d3bddcdbc3d

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}
    modes = ['ionian', 'dorian', 'phrygian', 'lydian', 'mixolydian', 'aeolian', 'locrian']
    if not isinstance(x, list) or len(x) != 2:
        return None
    tonic, mode = x
    if mode not in modes or not isinstance(tonic, str) or not tonic or tonic[0] not in base:
        return None
    signs = {'': 0, '#': 1, 'b': -1, 'x': 2, 'bb': -2}
    if tonic[1:] not in signs:
        return None
    steps = [2, 2, 1, 2, 2, 2, 1]
    k = modes.index(mode)
    steps = steps[k:] + steps[:k]
    pc = base[tonic[0]] + signs[tonic[1:]]
    li = 'CDEFGAB'.index(tonic[0])
    out = []
    for step in steps:
        letter = 'CDEFGAB'[li % 7]
        alter = (pc - base[letter] + 6) % 12 - 6
        if abs(alter) > 2:
            return None
        out.append(letter + {0: '', 1: '#', -1: 'b', 2: 'x', -2: 'bb'}[alter])
        pc += step
        li += 1
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[(['C', 'ionian'], ['C', 'D', 'E', 'F', 'G', 'A', 'B']), (['D', 'dorian'], ['D', 'E', 'F', 'G', 'A', 'B', 'C']), (['G', 'mixolydian'], ['G', 'A', 'B', 'C', 'D', 'E', 'F']), (['C', 'dorian'], ['C', 'D', 'Eb', 'F', 'G', 'A', 'Bb']), (['C', 'lydian'], ['C', 'D', 'E', 'F#', 'G', 'A', 'B']), (['D', 'major'], None), (['H', 'ionian'], None), (['Cq', 'ionian'], None)], [(['D', 'dorian'], ['D', 'E', 'F', 'G', 'A', 'B', 'C']), (['E', 'phrygian'], ['E', 'F', 'G', 'A', 'B', 'C', 'D']), (['F', 'lydian'], ['F', 'G', 'A', 'B', 'C', 'D', 'E']), (['G', 'mixolydian'], ['G', 'A', 'B', 'C', 'D', 'E', 'F']), (['A', 'aeolian'], ['A', 'B', 'C', 'D', 'E', 'F', 'G']), (['C', 'phrygian'], ['C', 'Db', 'Eb', 'F', 'G', 'Ab', 'Bb']), (['C', 'locrian'], ['C', 'Db', 'Eb', 'F', 'Gb', 'Ab', 'Bb']), (['Cq', 'ionian'], None)], [(['F', 'lydian'], ['F', 'G', 'A', 'B', 'C', 'D', 'E']), (['G', 'mixolydian'], ['G', 'A', 'B', 'C', 'D', 'E', 'F']), (['A', 'aeolian'], ['A', 'B', 'C', 'D', 'E', 'F', 'G']), (['B', 'locrian'], ['B', 'C', 'D', 'E', 'F', 'G', 'A']), (['C', 'dorian'], ['C', 'D', 'Eb', 'F', 'G', 'A', 'Bb']), (['C', 'phrygian'], ['C', 'Db', 'Eb', 'F', 'G', 'Ab', 'Bb']), (['C', 'lydian'], ['C', 'D', 'E', 'F#', 'G', 'A', 'B']), (['Eb', 'aeolian'], ['Eb', 'F', 'Gb', 'Ab', 'Bb', 'Cb', 'Db'])], [(['G', 'mixolydian'], ['G', 'A', 'B', 'C', 'D', 'E', 'F']), (['B', 'locrian'], ['B', 'C', 'D', 'E', 'F', 'G', 'A']), (['C', 'dorian'], ['C', 'D', 'Eb', 'F', 'G', 'A', 'Bb']), (['C', 'phrygian'], ['C', 'Db', 'Eb', 'F', 'G', 'Ab', 'Bb']), (['C', 'lydian'], ['C', 'D', 'E', 'F#', 'G', 'A', 'B']), (['C', 'locrian'], ['C', 'Db', 'Eb', 'F', 'Gb', 'Ab', 'Bb']), (['Eb', 'aeolian'], ['Eb', 'F', 'Gb', 'Ab', 'Bb', 'Cb', 'Db']), (['F#', 'ionian'], ['F#', 'G#', 'A#', 'B', 'C#', 'D#', 'E#'])], [(['A', 'aeolian'], ['A', 'B', 'C', 'D', 'E', 'F', 'G']), (['C', 'lydian'], ['C', 'D', 'E', 'F#', 'G', 'A', 'B']), (['C', 'locrian'], ['C', 'Db', 'Eb', 'F', 'Gb', 'Ab', 'Bb']), (['Eb', 'aeolian'], ['Eb', 'F', 'Gb', 'Ab', 'Bb', 'Cb', 'Db']), (['F#', 'ionian'], ['F#', 'G#', 'A#', 'B', 'C#', 'D#', 'E#']), (['Bb', 'mixolydian'], ['Bb', 'C', 'D', 'Eb', 'F', 'G', 'Ab']), (['C#', 'locrian'], ['C#', 'D', 'E', 'F#', 'G', 'A', 'B']), (['Gb', 'lydian'], ['Gb', 'Ab', 'Bb', 'C', 'Db', 'Eb', 'F'])]]
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['C', 'D', 'E', 'F', 'G', 'A', 'B']['C', 'D', 'E', 'F', 'G', 'A', 'B']Passed
oracle 1['D', 'E', 'F', 'G', 'A', 'B', 'C']['D', 'E', 'F', 'G', 'A', 'B', 'C']Passed
oracle 2['G', 'A', 'B', 'C', 'D', 'E', 'F']['G', 'A', 'B', 'C', 'D', 'E', 'F']Passed
oracle 3['C', 'D', 'Eb', 'F', 'G', 'A', 'Bb']['C', 'D', 'Eb', 'F', 'G', 'A', 'Bb']Passed
oracle 4['C', 'D', 'E', 'F#', 'G', 'A', 'B']['C', 'D', 'E', 'F#', 'G', 'A', 'B']Passed
oracle 5NoneNonePassed
oracle 6NoneNonePassed
oracle 7NoneNonePassed

SHA-256 / 0c07a97367dc1b412bf274ddc280f7537d199a821a57278edf7b2cdc44d0a056

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

Case digest / 4aed76ca475c161f5444c02b714870757af0134eeb21d55afee1caebd93a3cb8