FAILURE MAP
← Case archive

FA-62576 / Tax bracket computation / Open access

Marginal relief is measured from the lower limit instead of the upper limit · case 01

Relief grows as profits rise, so companies near the upper limit pay less than at the lower limit.

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

ROOT CAUSE

The relief uses (A - L) instead of (U - A).

VERIFIED REPAIR

Relief is 3/200 * (U - A) * N / A.

Unsuccessful approach: A constant relief based on (U - L) ignores where the company sits in the band.

Case contract

solve(profits, dividends, associates, days): stipulated small-profits relief. Limits L = 50000 and U = 250000 are divided by (associates + 1) and prorated by days/365 (exact fractions). Augmented profits A = profits + dividends decide the band: A <= L taxes profits N at 19%; A >= U at 25%; otherwise tax = 25% of N minus 3/200 * (U - A) * N / A. Return integer cents rounded half-up.

Why this case matters

Tax computations hinge on which slice, threshold, ordering and rounding rule applies at each step; a misplaced boundary silently misstates liabilities.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(profits, dividends, associates, days):
    def prog(x, br):
        tax, lower = Fraction(0), 0
        for upper, rate in br:
            top = x if upper is None else min(x, upper)
            if top > lower: tax += (top - lower) * Fraction(rate) / 100
            if upper is None or x <= upper: break
            lower = upper
        return tax
    def cents(v):
        v = v * 100
        return int(v + Fraction(1, 2)) if v >= 0 else -int(-v + Fraction(1, 2))
    
    div = associates + 1
    L = Fraction(50000 * days, 365 * div)
    U = Fraction(250000 * days, 365 * div)
    A = profits + dividends
    N = Fraction(profits)
    if A <= L: tax = N * 19 / 100
    elif A >= U: tax = N * 25 / 100
    else: tax = N * 25 / 100 - Fraction(3, 200) * (A - L) * N / A
    return cents(tax)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression relief-distance 1', (100000, 0, 0, 365), 2275000),
  ('regression relief-distance 2', (60000, 0, 1, 365), 1402500), ('control: small profits', (40000, 0, 0, 365), 760000),
  ('control: main rate', (300000, 0, 0, 365), 7500000), ('control: with dividends', (100000, 25000, 0, 365), 2350000),
  ('control: short period', (30000, 0, 0, 181), 609041)],
 [('regression relief-distance 1', (100000, 25000, 0, 365), 2350000),
  ('regression relief-distance 2', (30000, 0, 0, 181), 609041),
  ('control: associated company', (60000, 0, 1, 365), 1402500),
  ('control: two associates short', (70000, 5000, 2, 200), 1750000),
  ('control: dividends push to main rate', (200000, 60000, 0, 365), 5000000),
  ('control: small profits', (40000, 0, 0, 365), 760000)],
 [('regression relief-distance 1', (100000, 5000, 1, 365), 2471429),
  ('regression relief-distance 2', (50000, 25000, 0, 365), 1075000),
  ('control: two associates short', (70000, 5000, 2, 200), 1750000),
  ('control: dividends push to main rate', (200000, 60000, 0, 365), 5000000),
  ('control: small profits', (40000, 0, 0, 365), 760000), ('control: relief zone', (100000, 0, 0, 365), 2275000)],
 [('regression relief-distance 1', (100000, 5000, 0, 300), 2356458),
  ('regression relief-distance 2', (50000, 60000, 0, 365), 1154545),
  ('control: relief zone', (100000, 0, 0, 365), 2275000), ('control: main rate', (300000, 0, 0, 365), 7500000),
  ('control: associated company', (60000, 0, 1, 365), 1402500),
  ('control: with dividends', (100000, 25000, 0, 365), 2350000)],
 [('regression relief-distance 1', (30000, 5000, 0, 200), 618875),
  ('regression relief-distance 2', (50000, 0, 1, 300), 1170890),
  ('control: with dividends', (100000, 25000, 0, 365), 2350000), ('control: short period', (30000, 0, 0, 181), 609041),
  ('control: two associates short', (70000, 5000, 2, 200), 1750000),
  ('control: dividends push to main rate', (200000, 60000, 0, 365), 5000000)]]
for label, args, expected in cases[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 relief-distance 124250002275000Failed
regression relief-distance 214475001402500Failed
control: small profits760000760000Passed
control: main rate75000007500000Passed
control: with dividends24100002350000Failed
control: short period742192609041Failed

SHA-256 / 926fb3b0d44451d586797c33b33fb4343e4d86f252c74c5dfacfed6ea928655c

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(profits, dividends, associates, days):
    def prog(x, br):
        tax, lower = Fraction(0), 0
        for upper, rate in br:
            top = x if upper is None else min(x, upper)
            if top > lower: tax += (top - lower) * Fraction(rate) / 100
            if upper is None or x <= upper: break
            lower = upper
        return tax
    def cents(v):
        v = v * 100
        return int(v + Fraction(1, 2)) if v >= 0 else -int(-v + Fraction(1, 2))
    
    div = associates + 1
    L = Fraction(50000 * days, 365 * div)
    U = Fraction(250000 * days, 365 * div)
    A = profits + dividends
    N = Fraction(profits)
    if A <= L: tax = N * 19 / 100
    elif A >= U: tax = N * 25 / 100
    else: tax = N * 25 / 100 - Fraction(3, 200) * (U - L) * N / A
    return cents(tax)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression relief-distance 1', (100000, 0, 0, 365), 2275000),
  ('regression relief-distance 2', (60000, 0, 1, 365), 1402500), ('control: small profits', (40000, 0, 0, 365), 760000),
  ('control: main rate', (300000, 0, 0, 365), 7500000), ('control: with dividends', (100000, 25000, 0, 365), 2350000),
  ('control: short period', (30000, 0, 0, 181), 609041)],
 [('regression relief-distance 1', (100000, 25000, 0, 365), 2350000),
  ('regression relief-distance 2', (30000, 0, 0, 181), 609041),
  ('control: associated company', (60000, 0, 1, 365), 1402500),
  ('control: two associates short', (70000, 5000, 2, 200), 1750000),
  ('control: dividends push to main rate', (200000, 60000, 0, 365), 5000000),
  ('control: small profits', (40000, 0, 0, 365), 760000)],
 [('regression relief-distance 1', (100000, 5000, 1, 365), 2471429),
  ('regression relief-distance 2', (50000, 25000, 0, 365), 1075000),
  ('control: two associates short', (70000, 5000, 2, 200), 1750000),
  ('control: dividends push to main rate', (200000, 60000, 0, 365), 5000000),
  ('control: small profits', (40000, 0, 0, 365), 760000), ('control: relief zone', (100000, 0, 0, 365), 2275000)],
 [('regression relief-distance 1', (100000, 5000, 0, 300), 2356458),
  ('regression relief-distance 2', (50000, 60000, 0, 365), 1154545),
  ('control: relief zone', (100000, 0, 0, 365), 2275000), ('control: main rate', (300000, 0, 0, 365), 7500000),
  ('control: associated company', (60000, 0, 1, 365), 1402500),
  ('control: with dividends', (100000, 25000, 0, 365), 2350000)],
 [('regression relief-distance 1', (30000, 5000, 0, 200), 618875),
  ('regression relief-distance 2', (50000, 0, 1, 300), 1170890),
  ('control: with dividends', (100000, 25000, 0, 365), 2350000), ('control: short period', (30000, 0, 0, 181), 609041),
  ('control: two associates short', (70000, 5000, 2, 200), 1750000),
  ('control: dividends push to main rate', (200000, 60000, 0, 365), 5000000)]]
for label, args, expected in cases[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 relief-distance 122000002275000Failed
regression relief-distance 213500001402500Failed
control: small profits760000760000Passed
control: main rate75000007500000Passed
control: with dividends22600002350000Failed
control: short period601233609041Failed

SHA-256 / 07f10ed46a4913fc07ddbe16918735ce67c335b96bbf2820ebf5927e6ab0366f

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(profits, dividends, associates, days):
    def prog(x, br):
        tax, lower = Fraction(0), 0
        for upper, rate in br:
            top = x if upper is None else min(x, upper)
            if top > lower: tax += (top - lower) * Fraction(rate) / 100
            if upper is None or x <= upper: break
            lower = upper
        return tax
    def cents(v):
        v = v * 100
        return int(v + Fraction(1, 2)) if v >= 0 else -int(-v + Fraction(1, 2))
    
    div = associates + 1
    L = Fraction(50000 * days, 365 * div)
    U = Fraction(250000 * days, 365 * div)
    A = profits + dividends
    N = Fraction(profits)
    if A <= L: tax = N * 19 / 100
    elif A >= U: tax = N * 25 / 100
    else: tax = N * 25 / 100 - Fraction(3, 200) * (U - A) * N / A
    return cents(tax)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression relief-distance 1', (100000, 0, 0, 365), 2275000),
  ('regression relief-distance 2', (60000, 0, 1, 365), 1402500), ('control: small profits', (40000, 0, 0, 365), 760000),
  ('control: main rate', (300000, 0, 0, 365), 7500000), ('control: with dividends', (100000, 25000, 0, 365), 2350000),
  ('control: short period', (30000, 0, 0, 181), 609041)],
 [('regression relief-distance 1', (100000, 25000, 0, 365), 2350000),
  ('regression relief-distance 2', (30000, 0, 0, 181), 609041),
  ('control: associated company', (60000, 0, 1, 365), 1402500),
  ('control: two associates short', (70000, 5000, 2, 200), 1750000),
  ('control: dividends push to main rate', (200000, 60000, 0, 365), 5000000),
  ('control: small profits', (40000, 0, 0, 365), 760000)],
 [('regression relief-distance 1', (100000, 5000, 1, 365), 2471429),
  ('regression relief-distance 2', (50000, 25000, 0, 365), 1075000),
  ('control: two associates short', (70000, 5000, 2, 200), 1750000),
  ('control: dividends push to main rate', (200000, 60000, 0, 365), 5000000),
  ('control: small profits', (40000, 0, 0, 365), 760000), ('control: relief zone', (100000, 0, 0, 365), 2275000)],
 [('regression relief-distance 1', (100000, 5000, 0, 300), 2356458),
  ('regression relief-distance 2', (50000, 60000, 0, 365), 1154545),
  ('control: relief zone', (100000, 0, 0, 365), 2275000), ('control: main rate', (300000, 0, 0, 365), 7500000),
  ('control: associated company', (60000, 0, 1, 365), 1402500),
  ('control: with dividends', (100000, 25000, 0, 365), 2350000)],
 [('regression relief-distance 1', (30000, 5000, 0, 200), 618875),
  ('regression relief-distance 2', (50000, 0, 1, 300), 1170890),
  ('control: with dividends', (100000, 25000, 0, 365), 2350000), ('control: short period', (30000, 0, 0, 181), 609041),
  ('control: two associates short', (70000, 5000, 2, 200), 1750000),
  ('control: dividends push to main rate', (200000, 60000, 0, 365), 5000000)]]
for label, args, expected in cases[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 relief-distance 122750002275000Passed
regression relief-distance 214025001402500Passed
control: small profits760000760000Passed
control: main rate75000007500000Passed
control: with dividends23500002350000Passed
control: short period609041609041Passed

SHA-256 / cc2769b8b9eee9b8c0bb70ecd0dcee3e812c8917c033b99e4204ce8500a0ba40

Verification & scope

A deterministic, bounded teaching model with a stipulated toy contract; it makes no claim of conformance to any real regulation, standard, or institution's rules. 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:47:05.965633+00:00.

Case digest / cbfd1910a4e52edc788501f23c880ce6ee13bdfd351a33db3935dd11c3284b2b