docs: the Lean laws, and their paths, are bookspec's
The laws are proved once in bookspec (D-69), so the documents that said "put the new theorem in `verify/lean`" or cited `verify/lean/Wanderbooks/<File>.lean` now say otherwise: - AGENTS.md's formal-methods bar: a new law is written in bookspec's `lean/Bookspec/`; wanderbooks requires it and moves its pin (the lakefile, the manifest, and the crates' Cargo.toml together; the pin test fails if they drift). `Audit.lean` lists every theorem. - docs/verification.md: the model and every cited Lean file are `bookspec/lean/Bookspec/<File>.lean`; "Running it" says the dependency is fetched and that all 151 theorems are audited. - docs/testing.md and docs/spec/rules.md: the same paths, and the apportion row records where its law moved. - README's repo map and the two test comments that named the Lean peer. No accounting behavior changes; only where the proofs and their names live. Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
This commit is contained in:
1 parent
e431791bbc
commit
4d9c73deef
7 files changed
+34
-22
No files matched your search
@@ -111,10 +111,17 @@ So the bar, for every agent, every change:
|
|||||||
2. **Every kernel function gets a Kani harness** in `src/proofs.rs`, on
|
2. **Every kernel function gets a Kani harness** in `src/proofs.rs`, on
|
||||||
fixed arrays (no symbolic-length `Vec` growth, no `copy_from_slice`),
|
fixed arrays (no symbolic-length `Vec` growth, no `copy_from_slice`),
|
||||||
with a `kani::cover!` showing the interesting case is reached.
|
with a `kani::cover!` showing the interesting case is reached.
|
||||||
3. **Every new law gets a Lean theorem** in `verify/lean`. Laws about
|
3. **Every new law gets a Lean theorem**, and the laws live once: in
|
||||||
the books over time are theorems about `Reachable` states. A new
|
bookspec's Lean (`bookspec/lean/Bookspec/`, namespace `Bookspec`, D-69).
|
||||||
`Ledger` command is a new `Step` constructor, with its preservation
|
The theorem is written there, in bookspec's own repository, not in
|
||||||
proof. No `sorry`, ever; `Audit.lean` lists every headline theorem.
|
`verify/lean` — wanderbooks requires that package and holds no copy of
|
||||||
|
it. Laws about the books over time are theorems about `Reachable`
|
||||||
|
states. A new `Ledger` command is a new `Step` constructor, with its
|
||||||
|
preservation proof. No `sorry`, ever; `Audit.lean` lists every theorem.
|
||||||
|
After landing a law in bookspec, move wanderbooks' pin to that rev in
|
||||||
|
`verify/lean/lakefile.toml` and `lake-manifest.json` **and** in the
|
||||||
|
crates' `Cargo.toml` (the checker and the Lean must be the same spec
|
||||||
|
version; `tests/bookspec/pin.rs` fails when they drift).
|
||||||
4. **Every kernel instantiation gets a bridge property** in
|
4. **Every kernel instantiation gets a bridge property** in
|
||||||
`tests/kernel_bridge.rs`, so what Kani proved on `i64` holds on
|
`tests/kernel_bridge.rs`, so what Kani proved on `i64` holds on
|
||||||
`Decimal`.
|
`Decimal`.
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ crates/ledger-host/ # the host, the agents' bridge, the owner's commands
|
|||||||
crates/ledger-package/ # the shared read-only view: the CPA package, the invoice PDF, Needs attention
|
crates/ledger-package/ # the shared read-only view: the CPA package, the invoice PDF, Needs attention
|
||||||
crates/ledger-vault/ # the TIN vault (XChaCha20-Poly1305 under the book's key)
|
crates/ledger-vault/ # the TIN vault (XChaCha20-Poly1305 under the book's key)
|
||||||
crates/ledger-gui/ # the viewer: read-only, live (egui)
|
crates/ledger-gui/ # the viewer: read-only, live (egui)
|
||||||
verify/lean/ # the accounting laws as Lean theorems (`just prove`)
|
verify/lean/ # builds bookspec's accountancy laws as Lean theorems (`just prove`)
|
||||||
# the formal accounting specification lives in its own repository, https://git.swaits.com/swaits/bookspec (pinned dev-dependency, P13)
|
# the formal accounting specification lives in its own repository, https://git.swaits.com/swaits/bookspec (pinned dev-dependency, P13)
|
||||||
fuzz/, oracle/ # fuzz targets; the GnuCash differential (`just oracle`)
|
fuzz/, oracle/ # fuzz targets; the GnuCash differential (`just oracle`)
|
||||||
deploy/ # the self-host recipe and system unit (P9a)
|
deploy/ # the self-host recipe and system unit (P9a)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//! Model-based stateful test (rank 3: a peer).
|
//! Model-based stateful test (rank 3: a peer).
|
||||||
//!
|
//!
|
||||||
//! The peer is the Lean state machine (verify/lean/Wanderbooks/Ledger.lean)
|
//! The peer is the Lean state machine (bookspec/lean/Bookspec/Ledger.lean)
|
||||||
//! transcribed into the simplest Rust that has the same observable
|
//! transcribed into the simplest Rust that has the same observable
|
||||||
//! behavior: a list of accounts, a list of drafts, an append-only list of
|
//! behavior: a list of accounts, a list of drafts, an append-only list of
|
||||||
//! posted entries, a list of periods, and loops. It is written from the
|
//! posted entries, a list of periods, and loops. It is written from the
|
||||||
|
|||||||
@@ -1598,7 +1598,7 @@ mod refusals {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The Lean model's `Inv` (verify/lean/Wanderbooks/Ledger.lean), checked
|
/// The Lean model's `Inv` (bookspec/lean/Bookspec/Ledger.lean), checked
|
||||||
/// on the real store: every posted entry is acceptable, the books net
|
/// on the real store: every posted entry is acceptable, the books net
|
||||||
/// to zero, and no draft is dated in a closed period.
|
/// to zero, and no draft is dated in a closed period.
|
||||||
fn check_invariants(store: &Store) -> Result<(), TestCaseError> {
|
fn check_invariants(store: &Store) -> Result<(), TestCaseError> {
|
||||||
|
|||||||
+1
-1
@@ -2272,7 +2272,7 @@ 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`; Lean `verify/lean/Wanderbooks/Deductible.lean`
|
bridge `deductible_amount_agrees`; Lean `bookspec/lean/Bookspec/Deductible.lean`
|
||||||
(`Deductible.near`, `tie_away_pos`, `tie_away_neg`, `sign`, `neg`, `of_sum`,
|
(`Deductible.near`, `tie_away_pos`, `tie_away_neg`, `sign`, `neg`, `of_sum`,
|
||||||
`per_account_differs`, `scale_books`, `scale_percents`: the one rounding, at any
|
`per_account_differs`, `scale_books`, `scale_percents`: the one rounding, at any
|
||||||
number of accounts and any sizes); `ledger-store` `tests/store.rs`
|
number of accounts and any sizes); `ledger-store` `tests/store.rs`
|
||||||
|
|||||||
+3
-3
@@ -2548,7 +2548,7 @@ B-14) are the first.
|
|||||||
| End-to-end | SKIP for the core (a library) | the MCP tests through a real books server (ledger-cli) cover the journeys |
|
| End-to-end | SKIP for the core (a library) | the MCP tests through a real books server (ledger-cli) cover the journeys |
|
||||||
| Security properties | SKIP for the core (no roles, no secrets) | the first permission concept, or a secret-bearing field |
|
| Security properties | SKIP for the core (no roles, no secrets) | the first permission concept, or a secret-bearing field |
|
||||||
| Concurrency stress | SKIP for the core (no shared state); DONE for the store's writer + viewer (found the false "differs") | the first `Arc`, atomic, or lock in the core; the MCP server's HTTP transport shares one store across sessions (next) |
|
| Concurrency stress | SKIP for the core (no shared state); DONE for the store's writer + viewer (found the false "differs") | the first `Arc`, atomic, or lock in the core; the MCP server's HTTP transport shares one store across sessions (next) |
|
||||||
| Lean: apportion's sum law for any n | DONE (2026-10-14) | verify/lean/Wanderbooks/Apportion.lean: ranks are a permutation of 0..n-1 (strict total order + pigeonhole, core Lean only), so exactly u parts get a unit and one the fraction; `apportion_sum` and `apportion_sum_of_shortfall`, standard axioms only |
|
| Lean: apportion's sum law for any n | DONE (2026-10-14) | bookspec/lean/Bookspec/Apportion.lean (once `verify/lean/Wanderbooks/Apportion.lean`; D-69): ranks are a permutation of 0..n-1 (strict total order + pigeonhole, core Lean only), so exactly u parts get a unit and one the fraction; `apportion_sum` and `apportion_sum_of_shortfall`, standard axioms only |
|
||||||
| ASC paragraphs not yet read | DONE (2026-10-14) | read in the ASC basic view (`docs/spec/sources/fasb-asc.md`): all confirm the rules; one citation fixed (230-10-45-14(b), not (2)) |
|
| ASC paragraphs not yet read | DONE (2026-10-14) | read in the ASC basic view (`docs/spec/sources/fasb-asc.md`): all confirm the rules; one citation fixed (230-10-45-14(b), not (2)) |
|
||||||
| GnuCash's own close | OPEN | the oracle books closes as ordinary entries; comparing GnuCash's Close Book needs its Scheme API |
|
| GnuCash's own close | OPEN | the oracle books closes as ordinary entries; comparing GnuCash's Close Book needs its Scheme API |
|
||||||
| Import: spec-blind suite, footing properties, mutation | DONE | sources vendored (Intuit bank CSV and IIF, ECMA-376/Excel numbers, IRS form lines); specs on every module; tests/spec_import.rs (spec-blind, footing and round-trip properties, XLSX read back from its XML, layout and styles); fuzz_import_csv; templates checked against the engine's control accounts; mutation one equivalent left |
|
| Import: spec-blind suite, footing properties, mutation | DONE | sources vendored (Intuit bank CSV and IIF, ECMA-376/Excel numbers, IRS form lines); specs on every module; tests/spec_import.rs (spec-blind, footing and round-trip properties, XLSX read back from its XML, layout and styles); fuzz_import_csv; templates checked against the engine's control accounts; mutation one equivalent left |
|
||||||
@@ -2638,7 +2638,7 @@ the wiring into verify, the digest and Needs attention) is part B.
|
|||||||
is the definition), `bounds_kept_is_the_definition_on_books_in_bounds`
|
is the definition), `bounds_kept_is_the_definition_on_books_in_bounds`
|
||||||
(the command's check is the definition on books in bounds, and never
|
(the command's check is the definition on books in bounds, and never
|
||||||
lets a day get worse on books out of bounds).
|
lets a day get worse on books out of bounds).
|
||||||
- **Lean:** `Wanderbooks/Documents.lean`: `control_agrees` (GL = Σ docs
|
- **Lean:** `bookspec/lean/Bookspec/Documents.lean`: `control_agrees` (GL = Σ docs
|
||||||
+ unattached, for any lines, and through any day), `Step.document_unattached`,
|
+ unattached, for any lines, and through any day), `Step.document_unattached`,
|
||||||
`Step.reverse_moves`, `reverse_twice`, `Reachable.unattached_zero`,
|
`Step.reverse_moves`, `reverse_twice`, `Reachable.unattached_zero`,
|
||||||
`Reachable.control_is_documents`. The steps include assigning a
|
`Reachable.control_is_documents`. The steps include assigning a
|
||||||
@@ -3397,7 +3397,7 @@ in the same call.
|
|||||||
`crates/ledger-gui/tests/view_model.rs`: `a_write_off_is_flagged_for_the_cpa`
|
`crates/ledger-gui/tests/view_model.rs`: `a_write_off_is_flagged_for_the_cpa`
|
||||||
(one item, "Write-off awaiting the CPA's note", the same through the
|
(one item, "Write-off awaiting the CPA's note", the same through the
|
||||||
server's read of the store and the viewer's snapshot).
|
server's read of the store and the viewer's snapshot).
|
||||||
- **Lean, `Wanderbooks/Documents.lean`:** `Step.writeOff` (a tagged
|
- **Lean, `bookspec/lean/Bookspec/Documents.lean`:** `Step.writeOff` (a tagged
|
||||||
control line and an untagged expense line: a `Step.document` in shape),
|
control line and an untagged expense line: a `Step.document` in shape),
|
||||||
`Step.writeOff_unattached` (it moves nothing unattached, so
|
`Step.writeOff_unattached` (it moves nothing unattached, so
|
||||||
`control_agrees` and `Reachable.control_is_documents` still hold),
|
`control_agrees` and `Reachable.control_is_documents` still hold),
|
||||||
|
|||||||
+16
-11
@@ -31,16 +31,18 @@ smallest unit; the four proration charge harnesses at `i32`) and
|
|||||||
explores every input in the bounds. (Grouping by
|
explores every input in the bounds. (Grouping by
|
||||||
account is proved through `movements_into`, the allocation-free core
|
account is proved through `movements_into`, the allocation-free core
|
||||||
that `movements` wraps: symbolic heap growth is beyond what the model
|
that `movements` wraps: symbolic heap growth is beyond what the model
|
||||||
checker explores in reasonable time.) The Lean model in
|
checker explores in reasonable time.) The Lean model (bookspec's, which
|
||||||
`verify/lean` restates each function over `Int` (proration over `Nat`,
|
`verify/lean` requires) restates each function over `Int` (proration over `Nat`,
|
||||||
both of `prorated_through`'s branches) and proves the laws with no bounds
|
both of `prorated_through`'s branches) and proves the laws with no bounds
|
||||||
at all.
|
at all. That model lives once, in bookspec's Lean (`bookspec/lean/`,
|
||||||
|
namespace `Bookspec`); `verify/lean` requires it at the same pinned rev as
|
||||||
|
the Rust checker (D-69) and holds no copy of its files.
|
||||||
|
|
||||||
## The laws
|
## The laws
|
||||||
|
|
||||||
Each law, and what proves it. Kani harnesses are in
|
Each law, and what proves it. Kani harnesses are in
|
||||||
`crates/ledger-core/src/proofs.rs`; Lean theorems are in
|
`crates/ledger-core/src/proofs.rs`; Lean theorems are in
|
||||||
`verify/lean/Wanderbooks/`.
|
`bookspec/lean/Bookspec/` (the laws live once, in bookspec: D-69).
|
||||||
|
|
||||||
### Entries
|
### Entries
|
||||||
|
|
||||||
@@ -504,7 +506,7 @@ it. Rule: `docs/spec/rules.md` B-38.
|
|||||||
`crates/ledger-store/tests/arap_props.rs` (`subledger_equals_control`
|
`crates/ledger-store/tests/arap_props.rs` (`subledger_equals_control`
|
||||||
after every operation, at every date; `status_is_a_function_of_journal
|
after every operation, at every date; `status_is_a_function_of_journal
|
||||||
_and_date`; `reversal_twice_restores_state`).
|
_and_date`; `reversal_twice_restores_state`).
|
||||||
- Lean, `verify/lean/Wanderbooks/Documents.lean`: `control_agrees` and
|
- Lean, `bookspec/lean/Bookspec/Documents.lean`: `control_agrees` and
|
||||||
`control_agrees_through` (the identity, for every account and through
|
`control_agrees_through` (the identity, for every account and through
|
||||||
every day), `Step.document_unattached` (an untagged legacy line only
|
every day), `Step.document_unattached` (an untagged legacy line only
|
||||||
grows `unattached`, never a document), `Step.reverse_moves` and
|
grows `unattached`, never a document), `Step.reverse_moves` and
|
||||||
@@ -834,8 +836,8 @@ panic, the import roots' lockdown (a property over generated paths, and a
|
|||||||
component walk that refuses a folder swapped for a link; removed with the
|
component walk that refuses a folder swapped for a link; removed with the
|
||||||
import roots in P2 slice 5), files with full
|
import roots in P2 slice 5), files with full
|
||||||
TINs kept out of the books (B-26), and the agent text lint. Out of scope
|
TINs kept out of the books (B-26), and the agent text lint. Out of scope
|
||||||
for proof today: the format gate and the walk are I/O, and the model in
|
for proof today: the format gate and the walk are I/O, and bookspec's Lean
|
||||||
`verify/lean` stops at the ledger.
|
model stops at the ledger.
|
||||||
|
|
||||||
### P3: the odd cent (2026-10-20)
|
### P3: the odd cent (2026-10-20)
|
||||||
|
|
||||||
@@ -873,10 +875,13 @@ just prove-all # both
|
|||||||
```
|
```
|
||||||
|
|
||||||
`just prove` runs every Kani harness but the justfile's `kani_slow`, in
|
`just prove` runs every Kani harness but the justfile's `kani_slow`, in
|
||||||
parallel (`-j $(nproc)`), the whole run under a 30-minute timeout; builds
|
parallel (`-j $(nproc)`), the whole run under a 30-minute timeout; fetches
|
||||||
the Lean proofs (seconds); and fails if any headline theorem depends on
|
and builds bookspec's Lean proofs (seconds; the git dependency is pinned in
|
||||||
anything beyond Lean's standard axioms (`propext`, `Quot.sound`,
|
`verify/lean/lakefile.toml` and its manifest); and fails if any theorem
|
||||||
`Classical.choice`). In particular, `sorryAx` fails it. `just prove-slow`
|
depends on anything beyond Lean's standard axioms (`propext`,
|
||||||
|
`Quot.sound`, `Classical.choice`). It audits all 151 theorems: the 118
|
||||||
|
headline laws and the 33 named laws in `Laws.lean` that cite them. In
|
||||||
|
particular, `sorryAx` fails it. `just prove-slow`
|
||||||
runs the slow harnesses, `$(nproc)` at a time, each under its own
|
runs the slow harnesses, `$(nproc)` at a time, each under its own
|
||||||
30-minute timeout. Both fail if a harness they ask for isn't verified (the
|
30-minute timeout. Both fail if a harness they ask for isn't verified (the
|
||||||
count is checked), if any cover is unsatisfiable (a vacuous proof), or if
|
count is checked), if any cover is unsatisfiable (a vacuous proof), or if
|
||||||
|
|||||||
Reference in new issue
Block a user