Files
wanderbooks/verify/lean/Audit.lean
T
swaitsandDeepSeek V4.1 Flash e431791bbc build(lean): verify/lean requires bookspec's Lean; the laws live once
D-69 puts the accounting laws in one place: bookspec's Lean, namespace
`Bookspec`. L-F1 landed there every file of `verify/lean/Wanderbooks/`.
Before deleting the copies, each was checked: comments stripped, namespace
normalised, blank lines dropped, and diffed against its bookspec peer --
all ten are identical (Basic, Entry, Statements, Closing, Ledger,
Apportion, Parties, Prorate, Deductible, Documents). There is nothing
wanderbooks-only left to keep.

So `verify/lean/lakefile.toml` now `[[require]]`s bookspec as a git
dependency at 77e046334eea29e082b53bbe907017d9ffef5a0a -- the same rev
`crates/ledger-core/Cargo.toml` pins the Rust checker to -- with
`subDir = "lean"`. The generated `lake-manifest.json` is committed, because
Lake builds from it and it must not float.

`Wanderbooks.lean` is now a thin local target that imports `Bookspec`:
`lake build` builds and checks the whole law set, and the file says where
a law is edited and how wanderbooks picks it up (move the pin). The
duplicated modules and the `Wanderbooks/` directory are gone.

`Audit.lean` imports `Bookspec` and audits all 151 theorems (the 118
headline laws plus the 33 named laws in `Laws.lean` that cite them) --
the whole set bookspec itself audits. `just prove` still checks standard
axioms only; its summary now says "theorems", since the set is more than
headline ones.

The new `tests/bookspec/pin.rs` reads the rev out of the lakefile, the
manifest, and both crates' Cargo.toml, and fails unless all four name the
same repository at the same commit, and bookspec's `lean/` package. Without
it the Lean laws and the Rust checker could silently be different spec
versions.

Verified: `lake build` from a clean `.lake` (fetches and builds in 7 s);
`just prove` 871 s (Kani 53 harnesses, then 151 theorems, standard axioms
only); `cargo test -p ledger-core --test bookspec pin`; `cargo fmt --check`;
`cargo clippy -p ledger-core --tests -D warnings`.

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

160 lines
6.0 KiB
Lean4

import Bookspec
/-! `just prove` runs this file: each theorem's axioms are printed, and must
be only Lean's standard three (`propext`, `Quot.sound`, `Classical.choice`)
or fewer. No `sorryAx`, nothing assumed. The theorems are bookspec's: the
118 headline laws and the 33 named laws that cite them (D-69). -/
open Bookspec
#print axioms Accepted.net_zero
#print axioms sum_movements
#print axioms movement_with_reversal
#print axioms accepted_reversal_iff
#print axioms accounting_equation
#print axioms balance_after_line
#print axioms trial_balance_iff
#print axioms closingEntry_net
#print axioms closingEntry_zeroes
#print axioms closingEntry_accepted
#print axioms net_closings_is_net_income
#print axioms plugLast_total
#print axioms plugLast_keeps
#print axioms runPart_telescopes
#print axioms closePart_total
#print axioms trueUp_total
#print axioms trueUp_running
#print axioms closePart_eq_trueUp
#print axioms cumulative_drift
#print axioms statement_after_close
#print axioms statement_unmoved_by_close
#print axioms Reachable.inv
#print axioms Reachable.books_net_zero
#print axioms Reachable.trial_balance
#print axioms Reachable.trial_balance_through
#print axioms Reachable.accounting_equation
#print axioms Reachable.accounting_equation_through
#print axioms Steps.extends
#print axioms Steps.frozen
#print axioms close_zeroes
#print axioms close_credits_net_income
#print axioms statements_add_up
#print axioms Apportion.ranks_perm
#print axioms Apportion.apportion_sum
#print axioms Apportion.apportion_sum_of_shortfall
#print axioms Apportion.rem_pos_of_rank_lt
#print axioms Apportion.apportion_drift
#print axioms Apportion.allocW_sum
#print axioms Apportion.allocW_drift
#print axioms Apportion.allocW_cumulative_drift
#print axioms Apportion.allocW_cumulative_total
#print axioms Step.record_changes_no_figure
#print axioms Reachable.records
#print axioms net_splits_by_flow
#print axioms applyCash_conserves
#print axioms applyCash_exhausts
#print axioms applyCash_neg
#print axioms entry_flows_sum
#print axioms flows_reversal
#print axioms constructive_nets
#print axioms constructive_neg
#print axioms constructive_sections_net
#print axioms stmt_flows_sum
#print axioms stmt_flows_reversal
#print axioms cashflow_sections_sum_to_cash_change
#print axioms secNet_cash_is_movement
#print axioms operating_reconciliation_ties
#print axioms operating_reconciliation_ties_all
#print axioms cashflow_reversal_nets
#print axioms Reachable.cashflow_foots
#print axioms Reachable.cashflow_is_change_in_cash
#print axioms reverseTarget_involutive
#print axioms capitalTarget_odd
#print axioms partyTarget_odd
#print axioms sumOver_movement_reversal
#print axioms Prorate.cum_mono
#print axioms Prorate.cum_le
#print axioms Prorate.cum_full
#print axioms Prorate.parts_telescope
#print axioms Prorate.prorate_total
#print axioms Prorate.prorate_nonneg
#print axioms Prorate.part_within_a_unit
#print axioms Prorate.roundUnit_near
#print axioms Prorate.roundUnit_scale
#print axioms Prorate.cum_near
#print axioms Prorate.cum_dvd
#print axioms Prorate.part_near
#print axioms Prorate.chargeMid_eq_cum
#print axioms Prorate.chargeLast_eq_cum
#print axioms Prorate.chargeLast_start
#print axioms Prorate.chargeLast_mono
#print axioms Prorate.kernel_parts_total
#print axioms Prorate.kernel_parts_nonneg
#print axioms Documents.control_agrees
#print axioms Documents.control_agrees_through
#print axioms Documents.Step.document_unattached
#print axioms Documents.settle_posts_a_document_step
#print axioms Documents.settle_unattached
#print axioms Documents.Step.reverse_moves
#print axioms Documents.reverse_twice
#print axioms Documents.Step.markSent_changes_no_figure
#print axioms Documents.Reachable.unattached_zero
#print axioms Documents.Reachable.control_is_documents
#print axioms Documents.Step.writeOff_unattached
#print axioms Documents.writeOff_within_bounds
#print axioms Step.discard_keeps_books
#print axioms Step.discard_drafts
#print axioms Step.discard_unblocks_close
#print axioms Deductible.roundHA_near
#print axioms Deductible.roundHA_tie_pos
#print axioms Deductible.roundHA_tie_neg
#print axioms Deductible.roundHA_neg
#print axioms Deductible.roundHA_sign
#print axioms Deductible.roundHA_scale
#print axioms Deductible.near
#print axioms Deductible.tie_away_pos
#print axioms Deductible.tie_away_neg
#print axioms Deductible.sign
#print axioms Deductible.neg
#print axioms Deductible.of_sum
#print axioms Deductible.of_perm
#print axioms Deductible.append
#print axioms Deductible.split_percent
#print axioms Deductible.per_account_differs
#print axioms Deductible.per_account_differs_mixed
#print axioms Deductible.tie_example
#print axioms Deductible.scale_books
#print axioms Deductible.scale_percents
#print axioms law_debits_equal_credits
#print axioms law_accounting_equation
#print axioms law_trial_balance
#print axioms law_net_income_articulates
#print axioms law_cash_flow_is_change_in_cash
#print axioms law_acceptance_is_arithmetic
#print axioms law_accepted_entry_nets_to_zero
#print axioms law_movements_partition_the_net
#print axioms law_reversal_accepted_iff
#print axioms law_reversal_cancels
#print axioms law_normal_side
#print axioms law_trial_balance_is_complete
#print axioms law_period_statements_add_up
#print axioms law_invariant_holds
#print axioms law_posted_is_forever
#print axioms law_closed_periods_frozen
#print axioms law_record_changes_no_figure
#print axioms law_closing_entry_zeroes
#print axioms law_allocation_sums_to_the_whole
#print axioms law_member_run_telescopes
#print axioms law_cumulative_close_hands_out_its_net
#print axioms law_bounded_drift
#print axioms law_capital_unmoved_by_close
#print axioms law_reversal_is_the_exact_opposite
#print axioms law_proration_parts_sum_to_the_total
#print axioms law_proration_part_is_near
#print axioms law_proration_charge_never_falls
#print axioms law_control_account_is_its_documents
#print axioms law_send_changes_no_figure
#print axioms law_settlement_is_a_document_step
#print axioms law_write_off_within_bounds
#print axioms law_discard_moves_no_figure
#print axioms law_deductible_rounds_once