FAILURE MAP
← Case archive

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

Pitch-class set normal form (right-packed): span ties broken from the left · case 01

Sets such as [0,1,5,6,8] and [0,1,3,5,8,9] get the left-packed normal form instead of the stipulated right-packed one.

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

ROOT CAUSE

After the outer span, ties are compared first-to-second, first-to-third instead of first-to-penultimate inward.

VERIFIED REPAIR

Restore the packing priority step so that it reads `[rot[-1] - rot[0]] + [rot[j] - rot[0] for j in range(n - 2, 0, -1)]`.

Unsuccessful approach: Comparing only the outer span leaves all remaining ties to the starting pitch class.

Case contract

Input a list of integers (reduced mod 12, duplicates removed). Return the normal form: among all rotations of the ascending set, choose the one with the smallest span first-to-last, then smallest span first-to-penultimate, and so on toward the second element; a full tie picks the rotation starting on the lowest pitch class. Empty input returns []; non-integer input returns None.

Why this case matters

Post-tonal analysis tools use normal form to compare and catalogue pitch-class sets.

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 not all(isinstance(v, int) for v in x):
        return None
    pcs = sorted(set(v % 12 for v in x))
    if not pcs:
        return []
    n = len(pcs)
    best = None
    for r in range(n):
        rot = pcs[r:] + [p + 12 for p in pcs[:r]]
        key = [rot[-1] - rot[0]] + [rot[j] - rot[0] for j in range(1, n - 1)]
        cand = (key, rot[0])
        if best is None or cand < best[0]:
            best = (cand, [p % 12 for p in rot])
    return best[1]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([0, 4, 7], [0, 4, 7]), ([7, 4, 0], [0, 4, 7]), ([11, 0, 4], [11, 0, 4]), ([0, 1, 5, 6, 8], [0, 1, 5, 6, 8]), ([0, 1, 3, 5, 8, 9], [8, 9, 0, 1, 3, 5]), ([0, 2, 3, 6, 7, 9], [0, 2, 3, 6, 7, 9]), ([0, 1, 2, 4, 5, 7, 9, 10], [9, 10, 0, 1, 2, 4, 5, 7]), ([0, 4, 8], [0, 4, 8])], [([0, 1, 3, 5, 8, 9], [8, 9, 0, 1, 3, 5]), ([0, 1, 2, 5, 6, 7, 9], [0, 1, 2, 5, 6, 7, 9]), ([0, 1, 2, 4, 5, 7, 9, 10], [9, 10, 0, 1, 2, 4, 5, 7]), ([0, 4, 8], [0, 4, 8]), ([0, 3, 6, 9], [0, 3, 6, 9]), ([0, 6], [0, 6]), ([9, 0, 4, 4, 16], [9, 0, 4]), ([2, 5, 9], [2, 5, 9])], [([0, 1, 3, 5, 8, 9], [8, 9, 0, 1, 3, 5]), ([0, 2, 3, 6, 7, 9], [0, 2, 3, 6, 7, 9]), ([0, 1, 2, 4, 5, 7, 9, 10], [9, 10, 0, 1, 2, 4, 5, 7]), ([9, 0, 4, 4, 16], [9, 0, 4]), ([2, 5, 9], [2, 5, 9]), ([10, 2, 5], [10, 2, 5]), ([1, 5, 8], [1, 5, 8]), ([11, 2, 6], [11, 2, 6])], [([0, 1, 5, 6, 8], [0, 1, 5, 6, 8]), ([0, 1, 3, 5, 8, 9], [8, 9, 0, 1, 3, 5]), ([0, 1, 2, 5, 6, 7, 9], [0, 1, 2, 5, 6, 7, 9]), ([0, 1, 2, 4, 5, 7, 9, 10], [9, 10, 0, 1, 2, 4, 5, 7]), ([1, 5, 8], [1, 5, 8]), ([11, 2, 6], [11, 2, 6]), ([0, 1, 4, 6], [0, 1, 4, 6]), ([0, 1, 3, 7], [0, 1, 3, 7])], [([0, 1, 3, 5, 8, 9], [8, 9, 0, 1, 3, 5]), ([0, 1, 2, 4, 5, 7, 9, 10], [9, 10, 0, 1, 2, 4, 5, 7]), ([0, 1, 3, 7], [0, 1, 3, 7]), ([5], [5]), ([], []), ([3, 15, 27], [3]), ([-1, 0, 1], [11, 0, 1]), ([0, 2, 4, 6, 8, 10], [0, 2, 4, 6, 8, 10])]]
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[0, 4, 7][0, 4, 7]Passed
oracle 1[0, 4, 7][0, 4, 7]Passed
oracle 2[11, 0, 4][11, 0, 4]Passed
oracle 3[5, 6, 8, 0, 1][0, 1, 5, 6, 8]Failed
oracle 4[0, 1, 3, 5, 8, 9][8, 9, 0, 1, 3, 5]Failed
oracle 5[6, 7, 9, 0, 2, 3][0, 2, 3, 6, 7, 9]Failed
oracle 6[0, 1, 2, 4, 5, 7, 9, 10][9, 10, 0, 1, 2, 4, 5, 7]Failed
oracle 7[0, 4, 8][0, 4, 8]Passed

SHA-256 / 1f46e05ed30c6381cb33ac063a600a4f7f0a312ac879ee67d27611b36c0fbeb8

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 not all(isinstance(v, int) for v in x):
        return None
    pcs = sorted(set(v % 12 for v in x))
    if not pcs:
        return []
    n = len(pcs)
    best = None
    for r in range(n):
        rot = pcs[r:] + [p + 12 for p in pcs[:r]]
        key = [rot[-1] - rot[0]]
        cand = (key, rot[0])
        if best is None or cand < best[0]:
            best = (cand, [p % 12 for p in rot])
    return best[1]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([0, 4, 7], [0, 4, 7]), ([7, 4, 0], [0, 4, 7]), ([11, 0, 4], [11, 0, 4]), ([0, 1, 5, 6, 8], [0, 1, 5, 6, 8]), ([0, 1, 3, 5, 8, 9], [8, 9, 0, 1, 3, 5]), ([0, 2, 3, 6, 7, 9], [0, 2, 3, 6, 7, 9]), ([0, 1, 2, 4, 5, 7, 9, 10], [9, 10, 0, 1, 2, 4, 5, 7]), ([0, 4, 8], [0, 4, 8])], [([0, 1, 3, 5, 8, 9], [8, 9, 0, 1, 3, 5]), ([0, 1, 2, 5, 6, 7, 9], [0, 1, 2, 5, 6, 7, 9]), ([0, 1, 2, 4, 5, 7, 9, 10], [9, 10, 0, 1, 2, 4, 5, 7]), ([0, 4, 8], [0, 4, 8]), ([0, 3, 6, 9], [0, 3, 6, 9]), ([0, 6], [0, 6]), ([9, 0, 4, 4, 16], [9, 0, 4]), ([2, 5, 9], [2, 5, 9])], [([0, 1, 3, 5, 8, 9], [8, 9, 0, 1, 3, 5]), ([0, 2, 3, 6, 7, 9], [0, 2, 3, 6, 7, 9]), ([0, 1, 2, 4, 5, 7, 9, 10], [9, 10, 0, 1, 2, 4, 5, 7]), ([9, 0, 4, 4, 16], [9, 0, 4]), ([2, 5, 9], [2, 5, 9]), ([10, 2, 5], [10, 2, 5]), ([1, 5, 8], [1, 5, 8]), ([11, 2, 6], [11, 2, 6])], [([0, 1, 5, 6, 8], [0, 1, 5, 6, 8]), ([0, 1, 3, 5, 8, 9], [8, 9, 0, 1, 3, 5]), ([0, 1, 2, 5, 6, 7, 9], [0, 1, 2, 5, 6, 7, 9]), ([0, 1, 2, 4, 5, 7, 9, 10], [9, 10, 0, 1, 2, 4, 5, 7]), ([1, 5, 8], [1, 5, 8]), ([11, 2, 6], [11, 2, 6]), ([0, 1, 4, 6], [0, 1, 4, 6]), ([0, 1, 3, 7], [0, 1, 3, 7])], [([0, 1, 3, 5, 8, 9], [8, 9, 0, 1, 3, 5]), ([0, 1, 2, 4, 5, 7, 9, 10], [9, 10, 0, 1, 2, 4, 5, 7]), ([0, 1, 3, 7], [0, 1, 3, 7]), ([5], [5]), ([], []), ([3, 15, 27], [3]), ([-1, 0, 1], [11, 0, 1]), ([0, 2, 4, 6, 8, 10], [0, 2, 4, 6, 8, 10])]]
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[0, 4, 7][0, 4, 7]Passed
oracle 1[0, 4, 7][0, 4, 7]Passed
oracle 2[11, 0, 4][11, 0, 4]Passed
oracle 3[0, 1, 5, 6, 8][0, 1, 5, 6, 8]Passed
oracle 4[0, 1, 3, 5, 8, 9][8, 9, 0, 1, 3, 5]Failed
oracle 5[0, 2, 3, 6, 7, 9][0, 2, 3, 6, 7, 9]Passed
oracle 6[0, 1, 2, 4, 5, 7, 9, 10][9, 10, 0, 1, 2, 4, 5, 7]Failed
oracle 7[0, 4, 8][0, 4, 8]Passed

SHA-256 / 145d8c2005b7423ea0353654d038b831f215367748dfef19c47271729a1a07ec

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 not all(isinstance(v, int) for v in x):
        return None
    pcs = sorted(set(v % 12 for v in x))
    if not pcs:
        return []
    n = len(pcs)
    best = None
    for r in range(n):
        rot = pcs[r:] + [p + 12 for p in pcs[:r]]
        key = [rot[-1] - rot[0]] + [rot[j] - rot[0] for j in range(n - 2, 0, -1)]
        cand = (key, rot[0])
        if best is None or cand < best[0]:
            best = (cand, [p % 12 for p in rot])
    return best[1]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([0, 4, 7], [0, 4, 7]), ([7, 4, 0], [0, 4, 7]), ([11, 0, 4], [11, 0, 4]), ([0, 1, 5, 6, 8], [0, 1, 5, 6, 8]), ([0, 1, 3, 5, 8, 9], [8, 9, 0, 1, 3, 5]), ([0, 2, 3, 6, 7, 9], [0, 2, 3, 6, 7, 9]), ([0, 1, 2, 4, 5, 7, 9, 10], [9, 10, 0, 1, 2, 4, 5, 7]), ([0, 4, 8], [0, 4, 8])], [([0, 1, 3, 5, 8, 9], [8, 9, 0, 1, 3, 5]), ([0, 1, 2, 5, 6, 7, 9], [0, 1, 2, 5, 6, 7, 9]), ([0, 1, 2, 4, 5, 7, 9, 10], [9, 10, 0, 1, 2, 4, 5, 7]), ([0, 4, 8], [0, 4, 8]), ([0, 3, 6, 9], [0, 3, 6, 9]), ([0, 6], [0, 6]), ([9, 0, 4, 4, 16], [9, 0, 4]), ([2, 5, 9], [2, 5, 9])], [([0, 1, 3, 5, 8, 9], [8, 9, 0, 1, 3, 5]), ([0, 2, 3, 6, 7, 9], [0, 2, 3, 6, 7, 9]), ([0, 1, 2, 4, 5, 7, 9, 10], [9, 10, 0, 1, 2, 4, 5, 7]), ([9, 0, 4, 4, 16], [9, 0, 4]), ([2, 5, 9], [2, 5, 9]), ([10, 2, 5], [10, 2, 5]), ([1, 5, 8], [1, 5, 8]), ([11, 2, 6], [11, 2, 6])], [([0, 1, 5, 6, 8], [0, 1, 5, 6, 8]), ([0, 1, 3, 5, 8, 9], [8, 9, 0, 1, 3, 5]), ([0, 1, 2, 5, 6, 7, 9], [0, 1, 2, 5, 6, 7, 9]), ([0, 1, 2, 4, 5, 7, 9, 10], [9, 10, 0, 1, 2, 4, 5, 7]), ([1, 5, 8], [1, 5, 8]), ([11, 2, 6], [11, 2, 6]), ([0, 1, 4, 6], [0, 1, 4, 6]), ([0, 1, 3, 7], [0, 1, 3, 7])], [([0, 1, 3, 5, 8, 9], [8, 9, 0, 1, 3, 5]), ([0, 1, 2, 4, 5, 7, 9, 10], [9, 10, 0, 1, 2, 4, 5, 7]), ([0, 1, 3, 7], [0, 1, 3, 7]), ([5], [5]), ([], []), ([3, 15, 27], [3]), ([-1, 0, 1], [11, 0, 1]), ([0, 2, 4, 6, 8, 10], [0, 2, 4, 6, 8, 10])]]
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[0, 4, 7][0, 4, 7]Passed
oracle 1[0, 4, 7][0, 4, 7]Passed
oracle 2[11, 0, 4][11, 0, 4]Passed
oracle 3[0, 1, 5, 6, 8][0, 1, 5, 6, 8]Passed
oracle 4[8, 9, 0, 1, 3, 5][8, 9, 0, 1, 3, 5]Passed
oracle 5[0, 2, 3, 6, 7, 9][0, 2, 3, 6, 7, 9]Passed
oracle 6[9, 10, 0, 1, 2, 4, 5, 7][9, 10, 0, 1, 2, 4, 5, 7]Passed
oracle 7[0, 4, 8][0, 4, 8]Passed

SHA-256 / a4f50ffe1fd8ef62b694e7b5a02ab06cf36ce97a8e0a323b32ce28b1146e7cc5

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

Case digest / 18cf1368ad0f6ac31f086c60618962d81f9d9b294ceb6097b637a483a8254b28