FAILURE MAP
← Case archive

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

Diatonic step transposition within a major key: no octave carry past the seventh degree · case 01

B4 up one step in C major gives C4 instead of C5: the result wraps within the original octave.

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

ROOT CAUSE

The output octave is the source octave; carries from the step arithmetic are discarded.

VERIFIED REPAIR

Restore the octave carry step so that it reads `tonic + 12 * (pos // 7) + scale[pos % 7]`.

Unsuccessful approach: Dividing by eight treats the octave as eight degrees, so the carry arrives one step late.

Case contract

Input [tonic, notes, steps] where tonic is a MIDI reference note. Each note must belong to the major scale on the tonic (else return None). Its scale position is its degree plus 7 per octave counted from the tonic note with floor division (notes below the tonic note are in negative octaves). Move by the signed number of steps and return the resulting MIDI notes.

Why this case matters

Harmonisers and sequence generators transpose melodies diatonically rather than chromatically.

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) != 3:
        return None
    tonic, notes, steps = x
    scale = [0, 2, 4, 5, 7, 9, 11]
    out = []
    for n in notes:
        rel = (n - tonic) % 12
        if rel not in scale:
            return None
        octave = (n - tonic) // 12
        pos = octave * 7 + scale.index(rel) + steps
        out.append(tonic + 12 * octave + scale[pos % 7])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([60, [60, 62, 64], 2], [64, 65, 67]), ([60, [60, 64, 67], 1], [62, 65, 69]), ([60, [71], 1], [72]), ([60, [59, 57], 2], [62, 60]), ([67, [67, 71, 74], 2], [71, 74, 78]), ([60, [61], 1], None), ([60, [60, 65], 3], [65, 71]), ([60, [72, 74], 7], [84, 86])], [([60, [71], 1], [72]), ([60, [60], -1], [59]), ([60, [48, 50], -3], [43, 45]), ([60, [61], 1], None), ([60, [60, 65], 3], [65, 71]), ([60, [72, 74], 7], [84, 86]), ([60, [], 3], []), ([60, [57], -2], [53])], [([60, [71], 1], [72]), ([60, [60], -1], [59]), ([60, [59, 57], 2], [62, 60]), ([60, [48, 50], -3], [43, 45]), ([67, [66], 1], [67]), ([60, [72, 74], 7], [84, 86]), ([60, [57], -2], [53]), ([60, [65, 71], 0], [65, 71])], [([60, [71], 1], [72]), ([60, [60], -1], [59]), ([60, [59, 57], 2], [62, 60]), ([60, [48, 50], -3], [43, 45]), ([67, [66], 1], [67]), ([67, [55, 54], -2], [52, 50]), ([62, [62, 66], -7], [50, 54]), ([60, [72, 74], 7], [84, 86])], [([60, [71], 1], [72]), ([67, [66], 1], [67]), ([67, [55, 54], -2], [52, 50]), ([62, [62, 66], -7], [50, 54]), ([60, [72, 74], 7], [84, 86]), ([65, [53, 58], 4], [60, 65]), ([60, [64], -9], [48]), ([69, [57, 56], 1], [59, 57])]]
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[64, 65, 67][64, 65, 67]Passed
oracle 1[62, 65, 69][62, 65, 69]Passed
oracle 2[60][72]Failed
oracle 3[50, 48][62, 60]Failed
oracle 4[71, 74, 78][71, 74, 78]Passed
oracle 5NoneNonePassed
oracle 6[65, 71][65, 71]Passed
oracle 7[72, 74][84, 86]Failed

SHA-256 / 2b1e499062ba3c1fe6984304b38975f69885096eb864622578f0b4d2ceb79be1

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) != 3:
        return None
    tonic, notes, steps = x
    scale = [0, 2, 4, 5, 7, 9, 11]
    out = []
    for n in notes:
        rel = (n - tonic) % 12
        if rel not in scale:
            return None
        octave = (n - tonic) // 12
        pos = octave * 7 + scale.index(rel) + steps
        out.append(tonic + 12 * (pos // 8) + scale[pos % 7])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([60, [60, 62, 64], 2], [64, 65, 67]), ([60, [60, 64, 67], 1], [62, 65, 69]), ([60, [71], 1], [72]), ([60, [59, 57], 2], [62, 60]), ([67, [67, 71, 74], 2], [71, 74, 78]), ([60, [61], 1], None), ([60, [60, 65], 3], [65, 71]), ([60, [72, 74], 7], [84, 86])], [([60, [71], 1], [72]), ([60, [60], -1], [59]), ([60, [48, 50], -3], [43, 45]), ([60, [61], 1], None), ([60, [60, 65], 3], [65, 71]), ([60, [72, 74], 7], [84, 86]), ([60, [], 3], []), ([60, [57], -2], [53])], [([60, [71], 1], [72]), ([60, [60], -1], [59]), ([60, [59, 57], 2], [62, 60]), ([60, [48, 50], -3], [43, 45]), ([67, [66], 1], [67]), ([60, [72, 74], 7], [84, 86]), ([60, [57], -2], [53]), ([60, [65, 71], 0], [65, 71])], [([60, [71], 1], [72]), ([60, [60], -1], [59]), ([60, [59, 57], 2], [62, 60]), ([60, [48, 50], -3], [43, 45]), ([67, [66], 1], [67]), ([67, [55, 54], -2], [52, 50]), ([62, [62, 66], -7], [50, 54]), ([60, [72, 74], 7], [84, 86])], [([60, [71], 1], [72]), ([67, [66], 1], [67]), ([67, [55, 54], -2], [52, 50]), ([62, [62, 66], -7], [50, 54]), ([60, [72, 74], 7], [84, 86]), ([65, [53, 58], 4], [60, 65]), ([60, [64], -9], [48]), ([69, [57, 56], 1], [59, 57])]]
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[64, 65, 67][64, 65, 67]Passed
oracle 1[62, 65, 69][62, 65, 69]Passed
oracle 2[60][72]Failed
oracle 3[62, 60][62, 60]Passed
oracle 4[71, 74, 78][71, 74, 78]Passed
oracle 5NoneNonePassed
oracle 6[65, 71][65, 71]Passed
oracle 7[72, 74][84, 86]Failed

SHA-256 / 0827852331f8476cd7db153dd30cf1347dcc1b8b0c4c6983137adb85bb214cba

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) != 3:
        return None
    tonic, notes, steps = x
    scale = [0, 2, 4, 5, 7, 9, 11]
    out = []
    for n in notes:
        rel = (n - tonic) % 12
        if rel not in scale:
            return None
        octave = (n - tonic) // 12
        pos = octave * 7 + scale.index(rel) + steps
        out.append(tonic + 12 * (pos // 7) + scale[pos % 7])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([60, [60, 62, 64], 2], [64, 65, 67]), ([60, [60, 64, 67], 1], [62, 65, 69]), ([60, [71], 1], [72]), ([60, [59, 57], 2], [62, 60]), ([67, [67, 71, 74], 2], [71, 74, 78]), ([60, [61], 1], None), ([60, [60, 65], 3], [65, 71]), ([60, [72, 74], 7], [84, 86])], [([60, [71], 1], [72]), ([60, [60], -1], [59]), ([60, [48, 50], -3], [43, 45]), ([60, [61], 1], None), ([60, [60, 65], 3], [65, 71]), ([60, [72, 74], 7], [84, 86]), ([60, [], 3], []), ([60, [57], -2], [53])], [([60, [71], 1], [72]), ([60, [60], -1], [59]), ([60, [59, 57], 2], [62, 60]), ([60, [48, 50], -3], [43, 45]), ([67, [66], 1], [67]), ([60, [72, 74], 7], [84, 86]), ([60, [57], -2], [53]), ([60, [65, 71], 0], [65, 71])], [([60, [71], 1], [72]), ([60, [60], -1], [59]), ([60, [59, 57], 2], [62, 60]), ([60, [48, 50], -3], [43, 45]), ([67, [66], 1], [67]), ([67, [55, 54], -2], [52, 50]), ([62, [62, 66], -7], [50, 54]), ([60, [72, 74], 7], [84, 86])], [([60, [71], 1], [72]), ([67, [66], 1], [67]), ([67, [55, 54], -2], [52, 50]), ([62, [62, 66], -7], [50, 54]), ([60, [72, 74], 7], [84, 86]), ([65, [53, 58], 4], [60, 65]), ([60, [64], -9], [48]), ([69, [57, 56], 1], [59, 57])]]
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[64, 65, 67][64, 65, 67]Passed
oracle 1[62, 65, 69][62, 65, 69]Passed
oracle 2[72][72]Passed
oracle 3[62, 60][62, 60]Passed
oracle 4[71, 74, 78][71, 74, 78]Passed
oracle 5NoneNonePassed
oracle 6[65, 71][65, 71]Passed
oracle 7[84, 86][84, 86]Passed

SHA-256 / 3f0456a741e591508bed5996b1ab8b2e8e5af94ae98c3f3ae4a5c264f1dc56dd

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

Case digest / bf689deb1e46502229c5dcf2a38a747fcca08720761682c5c3b11389507f2c89