FAILURE MAP
← Case archive

FA-62906 / Insurance premium rating / Open access

Deductible credit interpolation: Zero deductible is rejected as invalid · case 01

A full-coverage zero-deductible quote returns invalid.

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

ROOT CAUSE

Validation rejects d<=0 although zero is a legal deductible.

VERIFIED REPAIR

Reject only negative deductibles.

Unsuccessful approach: Rejecting everything below the first row refuses legal low deductibles instead of clamping.

Case contract

Input premium, deductible and table [[deductible, credit per mille]] ascending (credits may be negative surcharges). Deductibles at or below the first row take its credit, at or above the last row take the last credit (no extrapolation), otherwise interpolate linearly. Credit cents = floor(prem*c/1000+1/2). Negative deductible or empty table -> 'invalid'. Return [credit, premium-credit].

Why this case matters

Premium rating engines apply ordered tabular rules where one misplaced boundary or step silently misprices policies.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    tab=x['table']; d=x['deductible']; prem=x['premium']
    if d<=0 or not tab: return 'invalid'
    if d<=tab[0][0]: c=Fraction(tab[0][1])
    elif d>=tab[-1][0]: c=Fraction(tab[-1][1])
    else:
        i=0
        while tab[i+1][0]<d: i+=1
        d0,c0=tab[i]; d1,c1=tab[i+1]
        c=c0+Fraction(c1-c0)*(d-d0)/(d1-d0)
    credit=math.floor(prem*c/1000+Fraction(1,2))
    return [credit, prem-credit]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['base deductible', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 50000, 'premium': 261724}, [0, 261724]], ['interpolated low segment', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 78500, 'premium': 331983}, [11543, 320440]], ['interpolated upper segment', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 481000, 'premium': 116345}, [23939, 92406]], ['beyond largest tabulated deductible', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 751000, 'premium': 322204}, [67985, 254219]], ['exact largest deductible', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 500000, 'premium': 393848}, [83102, 310746]], ['zero deductible uses lowest row', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 0, 'premium': 210458}, [-631, 211089]], ['deductible below table surcharged', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 10000, 'premium': 199242}, [-598, 199840]], ['negative deductible rejected', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': -100, 'premium': 226782}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 25000, 'premium': 22500}, [-67, 22567]], ['interior knot', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 250000, 'premium': 94197}, [13376, 80821]]], [['base deductible', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 50000, 'premium': 199101}, [0, 199101]], ['interpolated low segment', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 86000, 'premium': 159529}, [7121, 152408]], ['interpolated upper segment', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 369000, 'premium': 114198}, [20141, 94057]], ['beyond largest tabulated deductible', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 752000, 'premium': 110216}, [23366, 86850]], ['exact largest deductible', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 500000, 'premium': 313269}, [66413, 246856]], ['zero deductible uses lowest row', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 0, 'premium': 174100}, [-870, 174970]], ['deductible below table surcharged', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 10000, 'premium': 243190}, [-1216, 244406]], ['negative deductible rejected', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': -100, 'premium': 214814}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 25000, 'premium': 23500}, [-117, 23617]], ['interior knot', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 250000, 'premium': 349563}, [50337, 299226]]], [['base deductible', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 50000, 'premium': 263025}, [0, 263025]], ['interpolated low segment', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 55000, 'premium': 117616}, [741, 116875]], ['interpolated upper segment', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 315000, 'premium': 209271}, [34199, 175072]], ['beyond largest tabulated deductible', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 753000, 'premium': 115225}, [24543, 90682]], ['exact largest deductible', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 500000, 'premium': 322765}, [68749, 254016]], ['zero deductible uses lowest row', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 0, 'premium': 297017}, [-2079, 299096]], ['deductible below table surcharged', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 10000, 'premium': 263626}, [-1845, 265471]], ['negative deductible rejected', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': -100, 'premium': 120680}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 25000, 'premium': 24500}, [-171, 24671]], ['interior knot', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 250000, 'premium': 301911}, [44079, 257832]]], [['base deductible', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 50000, 'premium': 340242}, [0, 340242]], ['interpolated low segment', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 96500, 'premium': 240169}, [14295, 225874]], ['interpolated upper segment', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 339000, 'premium': 148801}, [25519, 123282]], ['beyond largest tabulated deductible', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 754000, 'premium': 216687}, [46371, 170316]], ['exact largest deductible', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 500000, 'premium': 388433}, [83125, 305308]], ['zero deductible uses lowest row', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 0, 'premium': 394112}, [-3547, 397659]], ['deductible below table surcharged', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 10000, 'premium': 145337}, [-1308, 146645]], ['negative deductible rejected', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': -100, 'premium': 335212}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 25000, 'premium': 25500}, [-229, 25729]], ['interior knot', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 250000, 'premium': 128496}, [19017, 109479]]], [['base deductible', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 50000, 'premium': 113213}, [0, 113213]], ['interpolated low segment', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 56500, 'premium': 364381}, [3079, 361302]], ['interpolated upper segment', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 374000, 'premium': 322937}, [58852, 264085]], ['beyond largest tabulated deductible', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 755000, 'premium': 161418}, [34705, 126713]], ['exact largest deductible', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 500000, 'premium': 386131}, [83018, 303113]], ['zero deductible uses lowest row', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 0, 'premium': 264667}, [-2911, 267578]], ['deductible below table surcharged', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 10000, 'premium': 141161}, [-1553, 142714]], ['negative deductible rejected', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': -100, 'premium': 190310}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 25000, 'premium': 26500}, [-291, 26791]], ['interior knot', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 250000, 'premium': 86734}, [13010, 73724]]]]
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
base deductible[0, 261724][0, 261724]Passed
interpolated low segment[11543, 320440][11543, 320440]Passed
interpolated upper segment[23939, 92406][23939, 92406]Passed
beyond largest tabulated deductible[67985, 254219][67985, 254219]Passed
exact largest deductible[83102, 310746][83102, 310746]Passed
zero deductible uses lowest rowinvalid[-631, 211089]Failed
deductible below table surcharged[-598, 199840][-598, 199840]Passed
negative deductible rejectedinvalidinvalidPassed
surcharge tie rounds toward positive[-67, 22567][-67, 22567]Passed
interior knot[13376, 80821][13376, 80821]Passed

SHA-256 / 7438a0949095e9fde422024b679ed796a790c70d4a2fdbb0a2f5e9ab8b192361

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    tab=x['table']; d=x['deductible']; prem=x['premium']
    if d<0 or not tab or d<tab[0][0]: return 'invalid'
    if d<=tab[0][0]: c=Fraction(tab[0][1])
    elif d>=tab[-1][0]: c=Fraction(tab[-1][1])
    else:
        i=0
        while tab[i+1][0]<d: i+=1
        d0,c0=tab[i]; d1,c1=tab[i+1]
        c=c0+Fraction(c1-c0)*(d-d0)/(d1-d0)
    credit=math.floor(prem*c/1000+Fraction(1,2))
    return [credit, prem-credit]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['base deductible', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 50000, 'premium': 261724}, [0, 261724]], ['interpolated low segment', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 78500, 'premium': 331983}, [11543, 320440]], ['interpolated upper segment', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 481000, 'premium': 116345}, [23939, 92406]], ['beyond largest tabulated deductible', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 751000, 'premium': 322204}, [67985, 254219]], ['exact largest deductible', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 500000, 'premium': 393848}, [83102, 310746]], ['zero deductible uses lowest row', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 0, 'premium': 210458}, [-631, 211089]], ['deductible below table surcharged', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 10000, 'premium': 199242}, [-598, 199840]], ['negative deductible rejected', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': -100, 'premium': 226782}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 25000, 'premium': 22500}, [-67, 22567]], ['interior knot', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 250000, 'premium': 94197}, [13376, 80821]]], [['base deductible', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 50000, 'premium': 199101}, [0, 199101]], ['interpolated low segment', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 86000, 'premium': 159529}, [7121, 152408]], ['interpolated upper segment', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 369000, 'premium': 114198}, [20141, 94057]], ['beyond largest tabulated deductible', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 752000, 'premium': 110216}, [23366, 86850]], ['exact largest deductible', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 500000, 'premium': 313269}, [66413, 246856]], ['zero deductible uses lowest row', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 0, 'premium': 174100}, [-870, 174970]], ['deductible below table surcharged', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 10000, 'premium': 243190}, [-1216, 244406]], ['negative deductible rejected', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': -100, 'premium': 214814}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 25000, 'premium': 23500}, [-117, 23617]], ['interior knot', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 250000, 'premium': 349563}, [50337, 299226]]], [['base deductible', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 50000, 'premium': 263025}, [0, 263025]], ['interpolated low segment', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 55000, 'premium': 117616}, [741, 116875]], ['interpolated upper segment', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 315000, 'premium': 209271}, [34199, 175072]], ['beyond largest tabulated deductible', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 753000, 'premium': 115225}, [24543, 90682]], ['exact largest deductible', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 500000, 'premium': 322765}, [68749, 254016]], ['zero deductible uses lowest row', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 0, 'premium': 297017}, [-2079, 299096]], ['deductible below table surcharged', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 10000, 'premium': 263626}, [-1845, 265471]], ['negative deductible rejected', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': -100, 'premium': 120680}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 25000, 'premium': 24500}, [-171, 24671]], ['interior knot', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 250000, 'premium': 301911}, [44079, 257832]]], [['base deductible', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 50000, 'premium': 340242}, [0, 340242]], ['interpolated low segment', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 96500, 'premium': 240169}, [14295, 225874]], ['interpolated upper segment', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 339000, 'premium': 148801}, [25519, 123282]], ['beyond largest tabulated deductible', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 754000, 'premium': 216687}, [46371, 170316]], ['exact largest deductible', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 500000, 'premium': 388433}, [83125, 305308]], ['zero deductible uses lowest row', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 0, 'premium': 394112}, [-3547, 397659]], ['deductible below table surcharged', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 10000, 'premium': 145337}, [-1308, 146645]], ['negative deductible rejected', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': -100, 'premium': 335212}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 25000, 'premium': 25500}, [-229, 25729]], ['interior knot', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 250000, 'premium': 128496}, [19017, 109479]]], [['base deductible', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 50000, 'premium': 113213}, [0, 113213]], ['interpolated low segment', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 56500, 'premium': 364381}, [3079, 361302]], ['interpolated upper segment', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 374000, 'premium': 322937}, [58852, 264085]], ['beyond largest tabulated deductible', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 755000, 'premium': 161418}, [34705, 126713]], ['exact largest deductible', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 500000, 'premium': 386131}, [83018, 303113]], ['zero deductible uses lowest row', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 0, 'premium': 264667}, [-2911, 267578]], ['deductible below table surcharged', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 10000, 'premium': 141161}, [-1553, 142714]], ['negative deductible rejected', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': -100, 'premium': 190310}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 25000, 'premium': 26500}, [-291, 26791]], ['interior knot', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 250000, 'premium': 86734}, [13010, 73724]]]]
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
base deductible[0, 261724][0, 261724]Passed
interpolated low segment[11543, 320440][11543, 320440]Passed
interpolated upper segment[23939, 92406][23939, 92406]Passed
beyond largest tabulated deductible[67985, 254219][67985, 254219]Passed
exact largest deductible[83102, 310746][83102, 310746]Passed
zero deductible uses lowest rowinvalid[-631, 211089]Failed
deductible below table surchargedinvalid[-598, 199840]Failed
negative deductible rejectedinvalidinvalidPassed
surcharge tie rounds toward positive[-67, 22567][-67, 22567]Passed
interior knot[13376, 80821][13376, 80821]Passed

SHA-256 / a4096656b3d74535b0fd6e8497b00bd8bd8f4f80427a18fcf00156c9a3485233

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    tab=x['table']; d=x['deductible']; prem=x['premium']
    if d<0 or not tab: return 'invalid'
    if d<=tab[0][0]: c=Fraction(tab[0][1])
    elif d>=tab[-1][0]: c=Fraction(tab[-1][1])
    else:
        i=0
        while tab[i+1][0]<d: i+=1
        d0,c0=tab[i]; d1,c1=tab[i+1]
        c=c0+Fraction(c1-c0)*(d-d0)/(d1-d0)
    credit=math.floor(prem*c/1000+Fraction(1,2))
    return [credit, prem-credit]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['base deductible', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 50000, 'premium': 261724}, [0, 261724]], ['interpolated low segment', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 78500, 'premium': 331983}, [11543, 320440]], ['interpolated upper segment', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 481000, 'premium': 116345}, [23939, 92406]], ['beyond largest tabulated deductible', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 751000, 'premium': 322204}, [67985, 254219]], ['exact largest deductible', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 500000, 'premium': 393848}, [83102, 310746]], ['zero deductible uses lowest row', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 0, 'premium': 210458}, [-631, 211089]], ['deductible below table surcharged', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 10000, 'premium': 199242}, [-598, 199840]], ['negative deductible rejected', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': -100, 'premium': 226782}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 25000, 'premium': 22500}, [-67, 22567]], ['interior knot', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 250000, 'premium': 94197}, [13376, 80821]]], [['base deductible', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 50000, 'premium': 199101}, [0, 199101]], ['interpolated low segment', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 86000, 'premium': 159529}, [7121, 152408]], ['interpolated upper segment', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 369000, 'premium': 114198}, [20141, 94057]], ['beyond largest tabulated deductible', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 752000, 'premium': 110216}, [23366, 86850]], ['exact largest deductible', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 500000, 'premium': 313269}, [66413, 246856]], ['zero deductible uses lowest row', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 0, 'premium': 174100}, [-870, 174970]], ['deductible below table surcharged', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 10000, 'premium': 243190}, [-1216, 244406]], ['negative deductible rejected', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': -100, 'premium': 214814}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 25000, 'premium': 23500}, [-117, 23617]], ['interior knot', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 250000, 'premium': 349563}, [50337, 299226]]], [['base deductible', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 50000, 'premium': 263025}, [0, 263025]], ['interpolated low segment', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 55000, 'premium': 117616}, [741, 116875]], ['interpolated upper segment', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 315000, 'premium': 209271}, [34199, 175072]], ['beyond largest tabulated deductible', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 753000, 'premium': 115225}, [24543, 90682]], ['exact largest deductible', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 500000, 'premium': 322765}, [68749, 254016]], ['zero deductible uses lowest row', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 0, 'premium': 297017}, [-2079, 299096]], ['deductible below table surcharged', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 10000, 'premium': 263626}, [-1845, 265471]], ['negative deductible rejected', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': -100, 'premium': 120680}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 25000, 'premium': 24500}, [-171, 24671]], ['interior knot', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 250000, 'premium': 301911}, [44079, 257832]]], [['base deductible', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 50000, 'premium': 340242}, [0, 340242]], ['interpolated low segment', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 96500, 'premium': 240169}, [14295, 225874]], ['interpolated upper segment', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 339000, 'premium': 148801}, [25519, 123282]], ['beyond largest tabulated deductible', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 754000, 'premium': 216687}, [46371, 170316]], ['exact largest deductible', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 500000, 'premium': 388433}, [83125, 305308]], ['zero deductible uses lowest row', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 0, 'premium': 394112}, [-3547, 397659]], ['deductible below table surcharged', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 10000, 'premium': 145337}, [-1308, 146645]], ['negative deductible rejected', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': -100, 'premium': 335212}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 25000, 'premium': 25500}, [-229, 25729]], ['interior knot', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 250000, 'premium': 128496}, [19017, 109479]]], [['base deductible', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 50000, 'premium': 113213}, [0, 113213]], ['interpolated low segment', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 56500, 'premium': 364381}, [3079, 361302]], ['interpolated upper segment', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 374000, 'premium': 322937}, [58852, 264085]], ['beyond largest tabulated deductible', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 755000, 'premium': 161418}, [34705, 126713]], ['exact largest deductible', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 500000, 'premium': 386131}, [83018, 303113]], ['zero deductible uses lowest row', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 0, 'premium': 264667}, [-2911, 267578]], ['deductible below table surcharged', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 10000, 'premium': 141161}, [-1553, 142714]], ['negative deductible rejected', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': -100, 'premium': 190310}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 25000, 'premium': 26500}, [-291, 26791]], ['interior knot', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 250000, 'premium': 86734}, [13010, 73724]]]]
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
base deductible[0, 261724][0, 261724]Passed
interpolated low segment[11543, 320440][11543, 320440]Passed
interpolated upper segment[23939, 92406][23939, 92406]Passed
beyond largest tabulated deductible[67985, 254219][67985, 254219]Passed
exact largest deductible[83102, 310746][83102, 310746]Passed
zero deductible uses lowest row[-631, 211089][-631, 211089]Passed
deductible below table surcharged[-598, 199840][-598, 199840]Passed
negative deductible rejectedinvalidinvalidPassed
surcharge tie rounds toward positive[-67, 22567][-67, 22567]Passed
interior knot[13376, 80821][13376, 80821]Passed

SHA-256 / d8143b057c5f753e8c81b5267b7a28222a7c5667173b46f4a298c6600336effb

Verification & scope

A deterministic bounded teaching model of a stipulated toy rating contract. Amounts are integer cents and factors exact rationals; it makes no claim of conformance with any filed rating plan, bureau manual or jurisdiction. 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:09.144547+00:00.

Case digest / ed5e873d742ecd552cbe16c28622d2dfbb037de12d6e260f9032a758ed164808