Skip to content

lean: Level 0–2 proofs of the GC admission/liveness design - #780

Open
mengmengmengqiang wants to merge 1 commit into
Ephemeral-AI-Lab:layerfs_v2_0_0from
tokenaissance:lean-gc-admission-formal
Open

mengmengmengqiang wants to merge 1 commit into
Ephemeral-AI-Lab:layerfs_v2_0_0from
tokenaissance:lean-gc-admission-formal

Conversation

@mengmengmengqiang

@mengmengmengqiang mengmengmengqiang commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Adds formal/lean/gc-admission/: a Level 0–2, Mathlib-free Lean 4 model of the shipped LayerFS GC admission/liveness design — the shipped subset of #770, not the Rust/DB implementation (Level 3+ is out of scope).

What is proved

  • The 8 invariants of the design, in the shipped subset: (1) a live mount is never reclaimed by branch.remove/store.compact; (2) retained operator done rows and uncertain rows carry a consistent admission witness; (3) a Dead witness names an explicit ordered cause; (4) the ordered rule machine incarnation → Sandbox generation/tombstone → Live; (5) a live/uncertain intent blocks store.compact; (7) Copy::Done non-removal; (8) no automatic release — the operator is the only path. Inv6 (fence/lease) is deferred; Inv3/Inv4 are witness-level corollaries (README's matrix and Limits).
  • Ordered identity and the tombstone: machine_incarnation + sandbox_generation as ordered tokens (Ordered/comparePlace/parseToken), and the durable Sandbox tombstone.
  • The done-row audit path: gc_intent release/preview/settle rows, Copy::Done retention through compact, the compact barrier and the retained done-row audit; list/audit stay read-only (not state transitions). doctor is a product check the model deliberately leaves unmodelled.
  • The operator escape: preview/settle/release (release only on an explicitly uncertain row) and force remove's release-or-mark-uncertain.
  • theorem step_preserves (op : Op) (s : State) (h : Inv s) : Inv (step op s) over the 13 transitions, with per-transition case analysis.
  • The §9.4 corollaries: no_reclaim_live, compact_barrier, reconcile_only_dead, done_is_operator, place_fallback_conservative, conservative_no_death, unordered_never_dead, restore_is_uncertain, ordered_rule, ordered_rule_sequential, compareMachine_uncertain_cases, unordered_place_never_dead, recorded_newer_is_uncertain, done_survives_compact, preview_is_done, force_remove_ends_mounts.

Toolchain and policy

  • leanprover/lean4:v4.36.0 (lean-toolchain), no Mathlib, no cache or network step after the toolchain install.
  • No sorry, admit, axiom or native_decide. GcAdmission/Axioms.lean prints the 21 receipts; tools/check_lean_axioms.py accepts only propext, Classical.choice and Quot.sound.
  • Verified locally: lake build green (16 jobs, #guards included) and python3 -B -m unittest discover -s tools -p 'test_*.py' green (182 tests).
  • formal/ is outside every root tools/production_loc.py counts: 0 product LOC, guarded by test_formal_lean_tree_is_outside_product_loc.

CI (report-only)

The intended .github/workflows/lean.yml is report-only — never a required check, it cannot block a push or merge. It builds the tree with leanprover/lean-action@v1, greps for sorry/admit/native_decide/axiom/constant, and verifies the axiom receipt.

The workflow file is included in this PR (commit 0b4b20a1).

Scope and references

Commits

  1. lean: Level 0–2 proofs of the GC admission/liveness design — the formal/ tree (12 files) + README.
  2. ci: report-only Lean job, axiom receipt and LOC guard — tools/check_lean_axioms.py and the LOC regression test.

Based on 87e46c65; the base head has since moved to fe9b4d1a and this branch merges cleanly.

…wner fallback, H3/H4 and docs

Ordered keeps the raw token (raw-first equality; two spellings of the same
label/ms/nonce are .unordered); parseToken accepts only non-empty ASCII
decimal digits below 2^64; ownerVerdict threads the Store kind (oldBoot is
Dead only on a local SQLite Store) and the witness snapshots it; H3 is the
existence form (a tombstone/incarnation may be replaced, never silently
dropped) and H4 covers every map row; README documents H0/H2d/H-done-op-id/
H-no-prune, the corrected witness matrix, the actual LOC command and the
Ephemeral-AI-Lab#782 dependency for Inv7. Examples gain raw-parse and auditWitness guards.

Verified locally from the Branch: lake build green (0 warnings), 23 axiom
receipts OK, step_preserves on [propext, Classical.choice, Quot.sound],
no sorry/admit/axiom/native_decide.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant