FAILURE MAP
← Case archive

FA-71971 / Error-correcting codes / Open access

GF(256) division reduces logarithms modulo 256 · case 01

Quotients are wrong whenever the log difference is negative.

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

ROOT CAUSE

The log difference is reduced mod 256; the multiplicative group has order 255.

VERIFIED REPAIR

Reduce exponents modulo 255.

Unsuccessful approach: Taking the absolute log difference computes b/a for half the inputs.

Case contract

Table-driven GF(2^8) (polynomial 0x11D, generator 2) operations: "div" a/b (None for b = 0, 0 for a = 0 otherwise), "inv" 1/a (None for 0) and "pow" a^b for integer b >= 0 (0^0 = 1, 0^b = 0). EXP is extended to 510 entries so sums of logarithms need no reduction. Unknown ops return None.

Why this case matters

Reed-Solomon decoders spend most time in log/antilog table lookups for division and inversion.

1 / The failure

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

N = 1
observations = []
def solve(op, a, b):
    EXP = [0] * 510
    LOG = [0] * 256
    x = 1
    for i in range(255):
        EXP[i] = x
        LOG[x] = i
        x <<= 1
        if x & 0x100:
            x ^= 0x11D
    for i in range(255, 510):
        EXP[i] = EXP[i - 255]
    if op == 'div':
        if b == 0:
            return None
        if a == 0:
            return 0
        return EXP[(LOG[a] - LOG[b]) % 256]
    if op == 'inv':
        if a == 0:
            return None
        return EXP[255 - LOG[a]]
    if op == 'pow':
        if a == 0:
            return 0 if b > 0 else 1
        return EXP[(LOG[a] * b) % 255]
    return None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["div", 1, 2]', ['div', 1, 2], 142], ['regression ["div", 70, 40]', ['div', 70, 40], 108], ['control ["div", 226, 96]', ['div', 226, 96], 190], ['control ["div", 65, 255]', ['div', 65, 255], 76], ['control ["div", 73, 232]', ['div', 73, 232], 21], ['control ["div", 255, 217]', ['div', 255, 217], 240], ['control ["div", 82, 3]', ['div', 82, 3], 197], ['control ["inv", 204, 0]', ['inv', 204, 0], 133]], [['regression ["div", 238, 211]', ['div', 238, 211], 155], ['regression ["div", 48, 99]', ['div', 48, 99], 118], ['control ["inv", 204, 0]', ['inv', 204, 0], 133], ['control ["inv", 143, 0]', ['inv', 143, 0], 245], ['control ["inv", 212, 0]', ['inv', 212, 0], 249], ['control ["inv", 188, 0]', ['inv', 188, 0], 149], ['control ["inv", 186, 0]', ['inv', 186, 0], 7], ['control ["inv", 215, 0]', ['inv', 215, 0], 214]], [['regression ["div", 2, 4]', ['div', 2, 4], 142], ['regression ["div", 1, 2]', ['div', 1, 2], 142], ['control ["inv", 215, 0]', ['inv', 215, 0], 214], ['control ["pow", 155, 166]', ['pow', 155, 166], 194], ['control ["pow", 28, 117]', ['pow', 28, 117], 100], ['control ["pow", 149, 57]', ['pow', 149, 57], 39], ['control ["pow", 63, 61]', ['pow', 63, 61], 49], ['control ["pow", 9, 596]', ['pow', 9, 596], 40]], [['regression ["div", 57, 11]', ['div', 57, 11], 179], ['regression ["div", 238, 211]', ['div', 238, 211], 155], ['control ["pow", 9, 596]', ['pow', 9, 596], 40], ['control ["pow", 55, 427]', ['pow', 55, 427], 28], ['control ["div", 0, 0]', ['div', 0, 0], None], ['control ["div", 0, 7]', ['div', 0, 7], 0], ['control ["div", 7, 0]', ['div', 7, 0], None], ['control ["div", 1, 1]', ['div', 1, 1], 1]], [['regression ["div", 152, 74]', ['div', 152, 74], 235], ['regression ["div", 2, 4]', ['div', 2, 4], 142], ['control ["div", 1, 1]', ['div', 1, 1], 1], ['control ["inv", 1, 0]', ['inv', 1, 0], 1], ['control ["inv", 0, 0]', ['inv', 0, 0], None], ['control ["inv", 2, 0]', ['inv', 2, 0], 142], ['control ["pow", 0, 0]', ['pow', 0, 0], 1], ['control ["pow", 0, 3]', ['pow', 0, 3], 0]]]
for label, args, expected in fixtures[N - 1]:
    check(label, 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
regression ["div", 1, 2]1142Failed
regression ["div", 70, 40]216108Failed
control ["div", 226, 96]190190Passed
control ["div", 65, 255]7676Passed
control ["div", 73, 232]2121Passed
control ["div", 255, 217]240240Passed
control ["div", 82, 3]197197Passed
control ["inv", 204, 0]133133Passed

SHA-256 / 2d28c41a1f410649d3897af229bb3ca556262294080a523549fd67befd94f4cc

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(op, a, b):
    EXP = [0] * 510
    LOG = [0] * 256
    x = 1
    for i in range(255):
        EXP[i] = x
        LOG[x] = i
        x <<= 1
        if x & 0x100:
            x ^= 0x11D
    for i in range(255, 510):
        EXP[i] = EXP[i - 255]
    if op == 'div':
        if b == 0:
            return None
        if a == 0:
            return 0
        return EXP[abs(LOG[a] - LOG[b])]
    if op == 'inv':
        if a == 0:
            return None
        return EXP[255 - LOG[a]]
    if op == 'pow':
        if a == 0:
            return 0 if b > 0 else 1
        return EXP[(LOG[a] * b) % 255]
    return None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["div", 1, 2]', ['div', 1, 2], 142], ['regression ["div", 70, 40]', ['div', 70, 40], 108], ['control ["div", 226, 96]', ['div', 226, 96], 190], ['control ["div", 65, 255]', ['div', 65, 255], 76], ['control ["div", 73, 232]', ['div', 73, 232], 21], ['control ["div", 255, 217]', ['div', 255, 217], 240], ['control ["div", 82, 3]', ['div', 82, 3], 197], ['control ["inv", 204, 0]', ['inv', 204, 0], 133]], [['regression ["div", 238, 211]', ['div', 238, 211], 155], ['regression ["div", 48, 99]', ['div', 48, 99], 118], ['control ["inv", 204, 0]', ['inv', 204, 0], 133], ['control ["inv", 143, 0]', ['inv', 143, 0], 245], ['control ["inv", 212, 0]', ['inv', 212, 0], 249], ['control ["inv", 188, 0]', ['inv', 188, 0], 149], ['control ["inv", 186, 0]', ['inv', 186, 0], 7], ['control ["inv", 215, 0]', ['inv', 215, 0], 214]], [['regression ["div", 2, 4]', ['div', 2, 4], 142], ['regression ["div", 1, 2]', ['div', 1, 2], 142], ['control ["inv", 215, 0]', ['inv', 215, 0], 214], ['control ["pow", 155, 166]', ['pow', 155, 166], 194], ['control ["pow", 28, 117]', ['pow', 28, 117], 100], ['control ["pow", 149, 57]', ['pow', 149, 57], 39], ['control ["pow", 63, 61]', ['pow', 63, 61], 49], ['control ["pow", 9, 596]', ['pow', 9, 596], 40]], [['regression ["div", 57, 11]', ['div', 57, 11], 179], ['regression ["div", 238, 211]', ['div', 238, 211], 155], ['control ["pow", 9, 596]', ['pow', 9, 596], 40], ['control ["pow", 55, 427]', ['pow', 55, 427], 28], ['control ["div", 0, 0]', ['div', 0, 0], None], ['control ["div", 0, 7]', ['div', 0, 7], 0], ['control ["div", 7, 0]', ['div', 7, 0], None], ['control ["div", 1, 1]', ['div', 1, 1], 1]], [['regression ["div", 152, 74]', ['div', 152, 74], 235], ['regression ["div", 2, 4]', ['div', 2, 4], 142], ['control ["div", 1, 1]', ['div', 1, 1], 1], ['control ["inv", 1, 0]', ['inv', 1, 0], 1], ['control ["inv", 0, 0]', ['inv', 0, 0], None], ['control ["inv", 2, 0]', ['inv', 2, 0], 142], ['control ["pow", 0, 0]', ['pow', 0, 0], 1], ['control ["pow", 0, 3]', ['pow', 0, 3], 0]]]
for label, args, expected in fixtures[N - 1]:
    check(label, 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
regression ["div", 1, 2]2142Failed
regression ["div", 70, 40]32108Failed
control ["div", 226, 96]190190Passed
control ["div", 65, 255]7676Passed
control ["div", 73, 232]2121Passed
control ["div", 255, 217]240240Passed
control ["div", 82, 3]197197Passed
control ["inv", 204, 0]133133Passed

SHA-256 / ff991d366f86c295efd6d501542b1631a72d5390c158b0521c55090210ff3d09

3 / The verified repair

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

N = 1
observations = []
def solve(op, a, b):
    EXP = [0] * 510
    LOG = [0] * 256
    x = 1
    for i in range(255):
        EXP[i] = x
        LOG[x] = i
        x <<= 1
        if x & 0x100:
            x ^= 0x11D
    for i in range(255, 510):
        EXP[i] = EXP[i - 255]
    if op == 'div':
        if b == 0:
            return None
        if a == 0:
            return 0
        return EXP[(LOG[a] - LOG[b]) % 255]
    if op == 'inv':
        if a == 0:
            return None
        return EXP[255 - LOG[a]]
    if op == 'pow':
        if a == 0:
            return 0 if b > 0 else 1
        return EXP[(LOG[a] * b) % 255]
    return None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["div", 1, 2]', ['div', 1, 2], 142], ['regression ["div", 70, 40]', ['div', 70, 40], 108], ['control ["div", 226, 96]', ['div', 226, 96], 190], ['control ["div", 65, 255]', ['div', 65, 255], 76], ['control ["div", 73, 232]', ['div', 73, 232], 21], ['control ["div", 255, 217]', ['div', 255, 217], 240], ['control ["div", 82, 3]', ['div', 82, 3], 197], ['control ["inv", 204, 0]', ['inv', 204, 0], 133]], [['regression ["div", 238, 211]', ['div', 238, 211], 155], ['regression ["div", 48, 99]', ['div', 48, 99], 118], ['control ["inv", 204, 0]', ['inv', 204, 0], 133], ['control ["inv", 143, 0]', ['inv', 143, 0], 245], ['control ["inv", 212, 0]', ['inv', 212, 0], 249], ['control ["inv", 188, 0]', ['inv', 188, 0], 149], ['control ["inv", 186, 0]', ['inv', 186, 0], 7], ['control ["inv", 215, 0]', ['inv', 215, 0], 214]], [['regression ["div", 2, 4]', ['div', 2, 4], 142], ['regression ["div", 1, 2]', ['div', 1, 2], 142], ['control ["inv", 215, 0]', ['inv', 215, 0], 214], ['control ["pow", 155, 166]', ['pow', 155, 166], 194], ['control ["pow", 28, 117]', ['pow', 28, 117], 100], ['control ["pow", 149, 57]', ['pow', 149, 57], 39], ['control ["pow", 63, 61]', ['pow', 63, 61], 49], ['control ["pow", 9, 596]', ['pow', 9, 596], 40]], [['regression ["div", 57, 11]', ['div', 57, 11], 179], ['regression ["div", 238, 211]', ['div', 238, 211], 155], ['control ["pow", 9, 596]', ['pow', 9, 596], 40], ['control ["pow", 55, 427]', ['pow', 55, 427], 28], ['control ["div", 0, 0]', ['div', 0, 0], None], ['control ["div", 0, 7]', ['div', 0, 7], 0], ['control ["div", 7, 0]', ['div', 7, 0], None], ['control ["div", 1, 1]', ['div', 1, 1], 1]], [['regression ["div", 152, 74]', ['div', 152, 74], 235], ['regression ["div", 2, 4]', ['div', 2, 4], 142], ['control ["div", 1, 1]', ['div', 1, 1], 1], ['control ["inv", 1, 0]', ['inv', 1, 0], 1], ['control ["inv", 0, 0]', ['inv', 0, 0], None], ['control ["inv", 2, 0]', ['inv', 2, 0], 142], ['control ["pow", 0, 0]', ['pow', 0, 0], 1], ['control ["pow", 0, 3]', ['pow', 0, 3], 0]]]
for label, args, expected in fixtures[N - 1]:
    check(label, 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
regression ["div", 1, 2]142142Passed
regression ["div", 70, 40]108108Passed
control ["div", 226, 96]190190Passed
control ["div", 65, 255]7676Passed
control ["div", 73, 232]2121Passed
control ["div", 255, 217]240240Passed
control ["div", 82, 3]197197Passed
control ["inv", 204, 0]133133Passed

SHA-256 / c26e7701066d71130dec4f37ad57b63edeed047817efe6eb968b1055156facb0

Verification & scope

A deterministic, bounded teaching model of the named code under the stated contract; not a production codec. 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:48:34.345172+00:00.

Case digest / 6c6f51a986e88283cac6b34501d83221089bfa49248bbf7395bc3c13535e891d