docs: law 39 names its Lean theorems
Law 39 said no Lean theorem was needed because the Books model has no tax categories. That reasoning was wrong: the law is pure kernel arithmetic, like Prorate's roundUnit laws, and needs no Books model. verify/lean/Wanderbooks/Deductible.lean now proves it at any size. verification.md law 39 lists the Lean theorems in the usual format and states the split plainly: Lean proves the law on integers over a common denominator (one rounding, Prorate.roundUnit on the magnitude, signed after); Kani proves the code on i64; the bridge and exact-reference properties carry it to Decimal; overflow stays outside the model. rules.md B-32's Checked line and plan/STATUS.md name the Lean file. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2d345d02bc
commit
aa1331c8bd
3 files changed
+37
-11
No files matched your search
+4
-1
@@ -2272,7 +2272,10 @@ their first `settings.set` naming the key, B-27); `ledger-mcp` `books.add_accoun
|
|||||||
`tests/tax.rs` (the rounding: `a_category_rounds_its_deductible_amount_once_not_per_account`,
|
`tests/tax.rs` (the rounding: `a_category_rounds_its_deductible_amount_once_not_per_account`,
|
||||||
`a_category_rounds_once_across_different_percents`); Kani
|
`a_category_rounds_once_across_different_percents`); Kani
|
||||||
`deductible_amount_rounds_once`, `deductible_amount_refuses_overflow`;
|
`deductible_amount_rounds_once`, `deductible_amount_refuses_overflow`;
|
||||||
bridge `deductible_amount_agrees`; `ledger-store` `tests/store.rs`
|
bridge `deductible_amount_agrees`; Lean `verify/lean/Wanderbooks/Deductible.lean`
|
||||||
|
(`Deductible.near`, `tie_away_pos`, `tie_away_neg`, `sign`, `neg`, `of_sum`,
|
||||||
|
`per_account_differs`, `scale_books`, `scale_percents`: the one rounding, at any
|
||||||
|
number of accounts and any sizes); `ledger-store` `tests/store.rs`
|
||||||
(`prop_tax_policy_refuses_exactly`, `a_journaled_clear_replays_under_refuse`);
|
(`prop_tax_policy_refuses_exactly`, `a_journaled_clear_replays_under_refuse`);
|
||||||
`ledger-cli` `tests/spec_tax_policy.rs`; `ledger-gui` `tests/view_model.rs`
|
`ledger-cli` `tests/spec_tax_policy.rs`; `ledger-gui` `tests/view_model.rs`
|
||||||
(`needs_attention_flags_every_uncategorized_pl_account_defect_8`);
|
(`needs_attention_flags_every_uncategorized_pl_account_defect_8`);
|
||||||
|
|||||||
+31
-8
@@ -679,14 +679,37 @@ new command, so a new Lean step, and no kernel function.
|
|||||||
the same function; the bridge properties above carry it to
|
the same function; the bridge properties above carry it to
|
||||||
Decimal, the exact-reference one over the decimal shapes Kani's
|
Decimal, the exact-reference one over the decimal shapes Kani's
|
||||||
integer model does not have.
|
integer model does not have.
|
||||||
- No Lean model: this is arithmetic on a report figure, like
|
- Lean `Deductible.near`, `Deductible.tie_away_pos`,
|
||||||
`discount_max` (law 33) and `unrecovered_cost` (law 32), not a
|
`Deductible.tie_away_neg`, `Deductible.sign`, `Deductible.neg`,
|
||||||
`Ledger` command or a law about posted entries. The model's `Books`
|
`Deductible.of_sum`, `Deductible.of_perm`, `Deductible.append`,
|
||||||
has no tax categories; adding them would model presentation (a
|
`Deductible.split_percent`, `Deductible.per_account_differs` (with
|
||||||
category is a label on an account, and the summary is read from the
|
`_mixed` and `Deductible.tie_example`, the spec's three scenarios by
|
||||||
P&L), not a change to the books, and the law it would restate is the
|
`decide`), `Deductible.scale_books`, `Deductible.scale_percents`
|
||||||
kernel function's own definition. Kani proves that function, and the
|
(and their rounding lemmas `Deductible.roundHA_*`, all in
|
||||||
bridge carries it to `Decimal`.
|
`Audit.lean`), for any number of accounts and any sizes: the result
|
||||||
|
is within half a cent of the exact sum (`|2(D·c − N)| ≤ D`); at
|
||||||
|
exactly k + ½ cents it is k + 1 (and −(k + 1)), the cent farther
|
||||||
|
from zero; it never has the sum's opposite sign and is 0 for a zero
|
||||||
|
sum; negating every book negates it; it depends on the shares only
|
||||||
|
through their exact sum (reordering, regrouping, or splitting an
|
||||||
|
account's percent changes nothing), while the sum of per-account
|
||||||
|
roundings does differ (1.01 + 1.01 at 50%: 1.01 once, 1.02 by
|
||||||
|
account); and writing books or percents at a finer common
|
||||||
|
denominator (more decimal places) changes nothing.
|
||||||
|
- What the model is, and what it is not: no `Books` model is needed,
|
||||||
|
the way `Prorate.lean` needs none for the proration kernel. A share
|
||||||
|
is a pair of integers over one positive common denominator `D`
|
||||||
|
(`10^(p+s)` for books at p and percents at s decimal places, the
|
||||||
|
mantissas the `Decimal` path of `checked_div_round_cent` works on);
|
||||||
|
the category in cents is `N / D`, `N = Σ bookᵢ × percentᵢ` (the
|
||||||
|
`÷ 100` and the dollars-to-cents `× 100` cancel); one rounding,
|
||||||
|
`roundHA`, is `Prorate.roundUnit` (reused, unit one) on the magnitude,
|
||||||
|
signed after, as the kernel's `a_mag`/`b_mag`/`negative` do. Lean
|
||||||
|
proves the **law** of that arithmetic at any size; it does not prove
|
||||||
|
the Rust. Kani proves the code on `i64` (bounded, above); the bridge
|
||||||
|
and exact-reference properties carry it to `Decimal`; overflow
|
||||||
|
(`None`) is outside the model, Kani's `deductible_amount_refuses_overflow`
|
||||||
|
and the tests cover it.
|
||||||
|
|
||||||
## What the proofs found
|
## What the proofs found
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -29,8 +29,8 @@ both were fixed before merging.
|
|||||||
- **2026-11-08:** the deductible share is `kernel::deductible_amount`
|
- **2026-11-08:** the deductible share is `kernel::deductible_amount`
|
||||||
with Kani harnesses (`deductible_amount_rounds_once`, in `kani_slow`,
|
with Kani harnesses (`deductible_amount_rounds_once`, in `kani_slow`,
|
||||||
~17 min; `deductible_amount_refuses_overflow`), bridge and exact-reference
|
~17 min; `deductible_amount_refuses_overflow`), bridge and exact-reference
|
||||||
properties, and docs/verification.md law 39 (no Lean theorem: report
|
properties, and docs/verification.md law 39 (Lean `Deductible.lean`: the
|
||||||
arithmetic, reasoning there). `just prove` green; the slow harness
|
law at any size, no Books model needed). `just prove` green; the slow harness
|
||||||
verified. Review caught a false overflow on huge Decimal results, fixed.
|
verified. Review caught a false overflow on huge Decimal results, fixed.
|
||||||
|
|
||||||
**Left:** as before: P12 step 2 (the owner's overnight run, not started);
|
**Left:** as before: P12 step 2 (the owner's overnight run, not started);
|
||||||
|
|||||||
Reference in new issue
Block a user