FAILURE MAP
← Case archive

FA-5341 / Integer arithmetic / Open access

Symmetric modular distance · case 01

Linear distance ignores wraparound.

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

ROOT CAUSE

Linear distance ignores wraparound.

VERIFIED REPAIR

Apply the specified mathematical contract directly, preserving all terms and boundary cases: return min((a-b)%m, (b-a)%m)

Unsuccessful approach: Reducing a forward distance still ignores the shorter reverse arc.

Case contract

Integer arguments; denominators, steps, moduli, and bit widths are positive. Unsigned word inputs fit the specified width except where masking is explicitly the operation. Sequence sizes are nonnegative. Return the smaller nonnegative arc length on a cycle of circumference m. Exact operational definition: min((a-b)%m, (b-a)%m)

Why this case matters

Small exact fixtures expose this error without platform timing, external services, or probabilistic observations. Integer mathematics results depend on the stated convention.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(a, b, m):
    return abs(a-b)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (1, 9, 10)', solve(*(1, 9, 10)), 2)
check('fixture 2: (2, 5, 10)', solve(*(2, 5, 10)), 3)
check('fixture 3: (12, 2, 10)', solve(*(12, 2, 10)), 0)
check('fixture 4: (-1, 1, 10)', solve(*(-1, 1, 10)), 2)
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
fixture 1: (1, 9, 10)82Failed
fixture 2: (2, 5, 10)33Passed
fixture 3: (12, 2, 10)100Failed
fixture 4: (-1, 1, 10)22Passed

SHA-256 / 2b710dbaa35bb98e3fce9bb34a7d09a1ba99fcc1c6d95b2d32407314466ea740

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(a, b, m):
    return abs(a-b)%m
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (1, 9, 10)', solve(*(1, 9, 10)), 2)
check('fixture 2: (2, 5, 10)', solve(*(2, 5, 10)), 3)
check('fixture 3: (12, 2, 10)', solve(*(12, 2, 10)), 0)
check('fixture 4: (-1, 1, 10)', solve(*(-1, 1, 10)), 2)
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
fixture 1: (1, 9, 10)82Failed
fixture 2: (2, 5, 10)33Passed
fixture 3: (12, 2, 10)00Passed
fixture 4: (-1, 1, 10)22Passed

SHA-256 / b2572dc837149f295a7c0d738f8c5081979a9fd18ed43d2f77c2bbb89b2302e9

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(a, b, m):
    return min((a-b)%m, (b-a)%m)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (1, 9, 10)', solve(*(1, 9, 10)), 2)
check('fixture 2: (2, 5, 10)', solve(*(2, 5, 10)), 3)
check('fixture 3: (12, 2, 10)', solve(*(12, 2, 10)), 0)
check('fixture 4: (-1, 1, 10)', solve(*(-1, 1, 10)), 2)
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
fixture 1: (1, 9, 10)22Passed
fixture 2: (2, 5, 10)33Passed
fixture 3: (12, 2, 10)00Passed
fixture 4: (-1, 1, 10)22Passed

SHA-256 / ab00accde31fe456f5a2a85abe1221929b2d34683e3be6789ffaea05ce69a5f5

Verification & scope

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

Case digest / 509181ca0b796c548f41871e962f273e0933238af336305b34c90fbdb35ad2e2