[{"data":1,"prerenderedAt":4},["ShallowReactive",2],{"wamUK8jjQC":3},"# waterfall\n\nSmall, configurable proof search for inductive Lean goals, inspired by ACL2. waterfall combines simplification, theorem application, case analysis, and induction in one search tactic.\n\n```lean\nimport waterfall\n\ninductive Tree (V : Type) where\n  | empty\n  | node (left : Tree V) (key : Nat) (value : V) (right : Tree V)\n\ndef elements : Tree V → List (Nat × V)\n  | .empty => []\n  | .node left key value right => elements left ++ (key, value) :: elements right\n\ndef fastElements : Tree V → List (Nat × V) → List (Nat × V)\n  | .empty, acc => acc\n  | .node left key value right, acc =>\n      fastElements left ((key, value) :: fastElements right acc)\n\ntheorem fast_elements_helper (t : Tree V) (acc : List (Nat × V)) :\n    fastElements t acc = elements t ++ acc := by\n  waterfall\n```\n\nThis example proves the equivalence of two tree traversal functions: `elements` uses list append, while `fastElements` uses an accumulator. `waterfall` completes the entire proof by itself. \n\nThe current release is **waterfall 0.1** You can find the website at\n[Website and documentation](https://samth.github.io/waterfall/).\n\n\n## Software Foundations\n\nAcross an agent-generated port of Software Foundations, waterfall proves 1,455 of the goals, out of 2,190 total. The following table summarizes the results:\n\n| Volume | Goals | Baseline | Search | Committed |\n| --- | ---: | ---: | ---: | ---: |\n| LF | 937 | 659 | 740 | 739 |\n| PLF | 744 | 230 | 325 | 354 |\n| VFA | 509 | 315 | 390 | 354 |\n| Total | 2,190 | 1,204 | 1,455 | 1,447 |\n\n\"Baseline\" here combines `simp_all`, `grind`, and `induction` followed by `simp_all`/`grind`.\n\nThe \"Committed\" mode for `waterfall` avoids backtracking, and thus can be faster but may miss some proofs. \n\nFor small examples you can read and run, see [Tutorial/Examples.lean](Tutorial/Examples.lean):\n\n- **LF / Imp:** prove that eliminating `0 + e` preserves expression evaluation.\n- **VFA / Sort:** insertion-sort correctness, including sortedness and permutation\n  preservation. Every theorem uses waterfall; one helper has an explicit `grind`\n  matching pattern.\n- **VFA / SearchTree:** prove accumulator-based tree traversal equivalent to\n  the simple implementation, as shown above.\n\n\n## Install with Lake\n\nA `lakefile.toml` dependency can use the public Git repository:\n\n```toml\n[[require]]\nname = \"waterfall\"\ngit = \"https://github.com/samth/waterfall.git\"\nrev = \"main\"\n```\n\n`waterfall` is a Lean module. The same import works from module files and\nordinary Lean source files.\n\n## Usage and configuration options\n\n```lean\nimport waterfall\n\nnamespace waterfallReadme\n\ndef append : List Nat → List Nat → List Nat\n  | [], ys => ys\n  | x :: xs, ys => x :: append xs ys\n\nexample (xs : List Nat) : append xs [] = xs := by\n  waterfall [append]\n\nexample (xs : List Nat) : append xs [] = xs := by\n  waterfall (mode := .committed) (effort := 3000) [append]\n\nexample (P : Prop) (h : P) : P := by\n  waterfall (config := {mode := .search, effort := 1000, lazy := true})\n\nend waterfallReadme\n```\n\nThe default `mode := .search` is the default backtracking mode. `mode := .committed` is a simpler forward search that never backtracks after it makes progress.\n\n`effort` configures how hard the search works: more effort permits more attempts, deeper plans and stronger operations. Lean's enclosing resource limits still apply. \n`waterfall?` provides a “Try this” editor hint that replaces the invocation\nwith ordinary Lean proof commands. Use `(report := true)` for search statistics.\nLocal hypotheses, registered `simp` and `grind` rules, and definitions from the\ncurrent module are used automatically. When a local rule matches the target\nexcept for one missing proposition, waterfall can split on that blocked premise\nand continue each case. waterfall also retrieves library theorems\nfor backward application. Imported definitions and additional rewrite or\ninstantiation rules can be supplied in brackets.\n\n| Option | Default | Meaning |\n| --- | --- | --- |\n| `mode` | `.search` | Backtracking search or `.committed` |\n| `cpus` | `1` | Maximum concurrent workers; total budgets remain shared |\n| `effort` | `1000` | Global attempted-operation allowance |\n| `attemptHeartbeats` | `20000000` | Base raw heartbeat slice per operation; strength scales it |\n| `lazy` | `true` | Enumerate batches only when reached |\n| `deferChecks` | `false` | Delay candidate applicability probes |\n| `report` | `false` | Print search statistics |\n\nSee the [compiled Lean tutorial](Tutorial/Guide.lean) and\n[API reference](docs/API.md). For a guided source review, read the\n[proof architecture](docs/IMPLEMENTATION.md). The website includes usage examples and an option reference.\n\nUse `waterfall (cpus := 4)` to explore different depth/strength trials of the\nsame policy concurrently on at most four dedicated worker threads. The first completed proof wins; timings,\nretained plans and finite-budget coverage can vary. Workers share the attempt\nallowance and divide the remaining heartbeat allowance. Operating-system CPU affinity can further limit concurrency. Cancellation is\ncooperative, and all workers are joined before returning. The default of one\nCPU uses the existing sequential path. See [parallel execution](docs/API.md#parallel-execution).\n\n## Build and check\n\n```sh\nlake build\nlake test\nlake -d site build\nlake -d site test\nlake -d site exe site check-docs\n```\n\n## AI Use\n\nWaterfall was primarily developed by GPT-6 Astra. This README was written by me.\n",1789847393321]