FAILURE MAP
← Case archive

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

Interval inversion by quality and number: inversion complement taken to eight · case 01

M3 inverts to m5 and P4 to P4: every inverted number is one too small.

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

ROOT CAUSE

The inverted number uses 8 - n as if the octave had eight semitone-free steps.

VERIFIED REPAIR

Restore the inverted number step so that it reads `str(9 - n)`.

Unsuccessful approach: Reducing 9 - n modulo eight turns the inversion of a unison into P0.

Case contract

Input an interval string: quality from P, M, m, A, d, AA, dd followed by a positive integer. Compound numbers above 8 reduce by 7 until <= 8. P is valid only for 1, 4, 5, 8; M and m only for 2, 3, 6, 7. Inversion maps M<->m, A<->d, AA<->dd, P->P and number n -> 9-n. Invalid input returns None.

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):
    swap = {'M': 'm', 'm': 'M', 'A': 'd', 'd': 'A', 'AA': 'dd', 'dd': 'AA', 'P': 'P'}
    if not isinstance(x, str):
        return None
    q = x.rstrip('0123456789')
    digits = x[len(q):]
    if q not in swap or not digits.isdigit() or int(digits) < 1:
        return None
    n = int(digits)
    while n > 8:
        n -= 7
    perfect = n in (1, 4, 5, 8)
    if (q == 'P' and not perfect) or (q in ('M', 'm') and perfect):
        return None
    return swap[q] + str(8 - n)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('M3', 'm6'), ('P5', 'P4'), ('P1', 'P8'), ('A1', 'd8'), ('P3', None), ('M4', None), ('X3', None), ('M0', None)], [('M3', 'm6'), ('m3', 'M6'), ('P4', 'P5'), ('P1', 'P8'), ('A1', 'd8'), ('M0', None), ('M', None), ('3', None)], [('M3', 'm6'), ('m3', 'M6'), ('P5', 'P4'), ('P4', 'P5'), ('P1', 'P8'), ('P8', 'P1'), ('A4', 'd5'), ('A1', 'd8')], [('P4', 'P5'), ('P1', 'P8'), ('P8', 'P1'), ('A4', 'd5'), ('d5', 'A4'), ('M2', 'm7'), ('m7', 'M2'), ('A1', 'd8')], [('P1', 'P8'), ('A4', 'd5'), ('d5', 'A4'), ('M2', 'm7'), ('m7', 'M2'), ('M10', 'm6'), ('P15', 'P1'), ('A1', 'd8')]]
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 0m5m6Failed
oracle 1P3P4Failed
oracle 2P7P8Failed
oracle 3d7d8Failed
oracle 4NoneNonePassed
oracle 5NoneNonePassed
oracle 6NoneNonePassed
oracle 7NoneNonePassed

SHA-256 / c6fe7ba31ef6ec2769f1c5d53bcfe79b2bcdd3de899b59de0e3ca4f7c75afab6

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    swap = {'M': 'm', 'm': 'M', 'A': 'd', 'd': 'A', 'AA': 'dd', 'dd': 'AA', 'P': 'P'}
    if not isinstance(x, str):
        return None
    q = x.rstrip('0123456789')
    digits = x[len(q):]
    if q not in swap or not digits.isdigit() or int(digits) < 1:
        return None
    n = int(digits)
    while n > 8:
        n -= 7
    perfect = n in (1, 4, 5, 8)
    if (q == 'P' and not perfect) or (q in ('M', 'm') and perfect):
        return None
    return swap[q] + str((9 - n) % 8)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('M3', 'm6'), ('P5', 'P4'), ('P1', 'P8'), ('A1', 'd8'), ('P3', None), ('M4', None), ('X3', None), ('M0', None)], [('M3', 'm6'), ('m3', 'M6'), ('P4', 'P5'), ('P1', 'P8'), ('A1', 'd8'), ('M0', None), ('M', None), ('3', None)], [('M3', 'm6'), ('m3', 'M6'), ('P5', 'P4'), ('P4', 'P5'), ('P1', 'P8'), ('P8', 'P1'), ('A4', 'd5'), ('A1', 'd8')], [('P4', 'P5'), ('P1', 'P8'), ('P8', 'P1'), ('A4', 'd5'), ('d5', 'A4'), ('M2', 'm7'), ('m7', 'M2'), ('A1', 'd8')], [('P1', 'P8'), ('A4', 'd5'), ('d5', 'A4'), ('M2', 'm7'), ('m7', 'M2'), ('M10', 'm6'), ('P15', 'P1'), ('A1', 'd8')]]
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 0m6m6Passed
oracle 1P4P4Passed
oracle 2P0P8Failed
oracle 3d0d8Failed
oracle 4NoneNonePassed
oracle 5NoneNonePassed
oracle 6NoneNonePassed
oracle 7NoneNonePassed

SHA-256 / 0ffcf69a11c12aba47303b7854fd3ad15f62706b134fc02d1756692fe44ea479

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    swap = {'M': 'm', 'm': 'M', 'A': 'd', 'd': 'A', 'AA': 'dd', 'dd': 'AA', 'P': 'P'}
    if not isinstance(x, str):
        return None
    q = x.rstrip('0123456789')
    digits = x[len(q):]
    if q not in swap or not digits.isdigit() or int(digits) < 1:
        return None
    n = int(digits)
    while n > 8:
        n -= 7
    perfect = n in (1, 4, 5, 8)
    if (q == 'P' and not perfect) or (q in ('M', 'm') and perfect):
        return None
    return swap[q] + str(9 - n)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('M3', 'm6'), ('P5', 'P4'), ('P1', 'P8'), ('A1', 'd8'), ('P3', None), ('M4', None), ('X3', None), ('M0', None)], [('M3', 'm6'), ('m3', 'M6'), ('P4', 'P5'), ('P1', 'P8'), ('A1', 'd8'), ('M0', None), ('M', None), ('3', None)], [('M3', 'm6'), ('m3', 'M6'), ('P5', 'P4'), ('P4', 'P5'), ('P1', 'P8'), ('P8', 'P1'), ('A4', 'd5'), ('A1', 'd8')], [('P4', 'P5'), ('P1', 'P8'), ('P8', 'P1'), ('A4', 'd5'), ('d5', 'A4'), ('M2', 'm7'), ('m7', 'M2'), ('A1', 'd8')], [('P1', 'P8'), ('A4', 'd5'), ('d5', 'A4'), ('M2', 'm7'), ('m7', 'M2'), ('M10', 'm6'), ('P15', 'P1'), ('A1', 'd8')]]
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 0m6m6Passed
oracle 1P4P4Passed
oracle 2P8P8Passed
oracle 3d8d8Passed
oracle 4NoneNonePassed
oracle 5NoneNonePassed
oracle 6NoneNonePassed
oracle 7NoneNonePassed

SHA-256 / 0a943be6bf49ca9731f68dfe35376de6c876692ff116ec49f2573ad4c9edeba4

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

Case digest / 6d7364ef65ce9e35242232d06ae137594904ebeec999003b58784f8000cfe95c