# Rate from a table ## Intention I want to pick exactly one rate over non-overlapping ranges. Putting the 1000 boundary in both rows yields LDC-E8304: the table cannot prove the rows do not overlap. ## Incorrect form and why it stays silent ```text title="Incorrect form" when x <= 1000 => 10 percent; when x >= 1000 and x < 2000 => 15 percent; ``` Both rows accept 1000: unique must reject the overlap rather than take the first row. ## Correct form ```law language "law.core" version "0.2"; package recipes.l.r01 version "0.1.0"; namespace "urn:recipe:l-calc:01"; decision Rate(x: Integer) -> Decimal { table hit unique { when x < 1000 => 10 percent; when x >= 1000 and x < 2000 => 15 percent; otherwise => 20 percent; } } ``` ## Frozen execution scene | Facts and choice | Question | Answer | |---|---|---| | 1. base 999 | `Rate(999)` | `0.1` / `COMPUTED` | | 2. base 1000 | `Rate(1000)` | `0.15` / `COMPUTED` | | 3. base 1999 | `Rate(1999)` | `0.15` / `COMPUTED` | | 4. base 2000 | `Rate(2000)` | `0.2` / `COMPUTED` | ```law test "below first threshold" { given { context { legal_time @2026-09-13; decision_time @2026-09-13T09:00:00+05:00; knowledge_time @2026-09-13T09:00:00+05:00; timezone "Asia/Almaty"; } } evaluate Rate(999); expect value == 0.1; expect evaluation_status == COMPUTED; } ``` ```law test "first threshold rate" { given { context { legal_time @2026-09-13; decision_time @2026-09-13T09:00:00+05:00; knowledge_time @2026-09-13T09:00:00+05:00; timezone "Asia/Almaty"; } } evaluate Rate(1000); expect value == 0.15; expect evaluation_status == COMPUTED; } ``` ```law test "inside middle band" { given { context { legal_time @2026-09-13; decision_time @2026-09-13T09:00:00+05:00; knowledge_time @2026-09-13T09:00:00+05:00; timezone "Asia/Almaty"; } } evaluate Rate(1999); expect value == 0.15; expect evaluation_status == COMPUTED; } ``` ```law test "second threshold rate" { given { context { legal_time @2026-09-13; decision_time @2026-09-13T09:00:00+05:00; knowledge_time @2026-09-13T09:00:00+05:00; timezone "Asia/Almaty"; } } evaluate Rate(2000); expect value == 0.2; expect evaluation_status == COMPUTED; } ``` ## Counterfactual Mutation: `when x < 1000` → `when x <= 1000`; expected `LDC-E8304`. Additional counterfactuals are shown as separate table rows. ## Boundary The example sets a rate, not a progressive sum; the latter is [Progressive scale by brackets](/recipes/l-calc/progressive-scale/). ## Pitfall With hit unique, an overlap is rejected rather than resolved by taking the first row.