Files
wanderbooks/docs/proofs/entries.md
T
swaitsandDeepSeek V4.1 Flash 0e049d9188 docs(proofs): the kernel sweep's notes folded into verification.md
Fold the six proof notes of plan P14's kernel sweep into the one place the
proofs are described. verification.md gains:

- the harness table's thirty-four new rows, each with its note's law
  number and measured time (all run in `prove`; none is in `kani_slow`);
- four new law sections in the existing house style: law 40 rounding to a
  step (K-U2), law 41 FX booking at the transaction-date rate (K-U1), law
  42 shares by weights (K-U3), and law 43 equal monthly parts (K-U5);
- law 4's collection-total harnesses (K-U4), law 23's Direction::of and
  law 27's part_weight harnesses (the entries note), with their bridges
  and the Lean theorems each cites;
- the sweep's Kani bounds (fixed steps, rates, month counts, weights
  totals, the `unwind(4)` and MAX_CORRECTION_STEPS bounds) and the
  symbolic-divisor note that carries them to Lean and the bridge;
- "What the proofs found" and "What is and isn't proved": K-U1's double
  rounding and D-75 precondition with its open 96-bit edge, K-U4's
  checked_add dust at Decimal::MAX, K-U3's quotient-crossing-a-step and
  non-terminating correction loop, the pinned tie ranking, the preserved
  printed scale, and K-U10's MAX and scale-28 edges, each with the test
  that pins it;
- the overview table's scope, the sweep's bridge reference, and the
  harness/audit counts (97 harnesses, 87 in `prove`; 188 Lean theorems).

Each unit note now opens with the section it was folded into; the notes
stay as the units' records. No code changed.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-09 05:42:07 -07:00

2.9 KiB
Raw Blame History

Entries: the party direction and a part's weight

Folded into docs/verification.md, sections "Parties" (law 23) and "Proration by days, catching up, truing up" (law 27).

Status: landed 2026-11-08 with the traceability gate's review fixes. Two kernel functions that had no proof of their own now have one; both were on the exception list before.

The functions

Function Meaning
kernel::Direction::of the direction of a signed amount: paid above zero, received below zero, neither at zero (BS-partner-3)
kernel::part_weight a month part's weight in MONTH_Lths: days × MONTH_L / month_days, exactly; None for a part no calendar month has (BS-asset-1, BS-prepaid-1)

Kani harnesses (crates/ledger-core/src/proofs/mod.rs)

Harness Law Bounds
direction_of_is_the_sign 23 any i64 amount; all three signs covered
part_weight_is_days_of_the_month 27 days and month_days 0..=40; valid, partial, whole and invalid parts covered

part_weight_is_days_of_the_month proves the weight formula a proration charge is computed from, which is law 27's statement (each part but the last is its days times the monthly rate); it is a lemma for laws 26-28, not a restatement of law 26 (that the parts sum to the total, which is prorate_parts_sum_to_total below).

The bookspec law each harness proves (machine-readable for the traceability gate, crates/ledger-core/tests/bookspec/traceability.rs):

Harness Law
direction_of_is_the_sign 23
part_weight_is_days_of_the_month 27

Times: measured alone with cargo kani -p ledger-core --exact --harness proofs::<name> on 2026-11-08: direction_of_is_the_sign 18 s wall (0.06 s verification, 3 covers, build included); part_weight_is_days_of_the_month 11 s wall (0.49 s verification, 3 covers, build included).

Bridge (crates/ledger-core/tests/kernel_bridge/entries.rs)

  • direction_of_agrees: Direction::of classifies the same sign at i64 and Decimal, and each case keeps its meaning (law 23).
  • part_weight_agrees: part_weight is the same weight at i32, i64 and i128, and None exactly for a part no month has (laws 26-28).
  • reverse_target_agrees: reverse_target is the exact opposite at both types. The edge strategy reaches i64::MIN, which i64 refuses because no negation can hold it; Decimal can hold the negation, so the property compares its answer there (the exact opposite). The refusal is the integer proof model's bound, not the law's. The earlier bridge only passed it to and_then, which is a mention, not a call; this property calls it.

Why these laws: Direction::of is the sign classification the party direction law (23) is stated over, and part_weight is the weight the proration charges of laws 26-28 are computed from, its harness numbered for the law it restates most closely (27).