Work with FalkorDB's Lean 4 proofs of the Rust engine in proofs/ — build and check them, keep them in sync with main, prove new or changed functions, confirm bugs the models find, and review a PR against the proofs. Use when asked to update/run/extend the proofs, check Lean coverage, re-target proofs after main moves, verify a function or PR formally, or when a change touches code listed in proofs/*/COVERAGE.tsv.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Proofs?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/falkordb-proofs)
---
name: proofs
description: Work with FalkorDB's Lean 4 proofs of the Rust engine in proofs/ — build and check them, keep them in sync with main, prove new or changed functions, confirm bugs the models find, and review a PR against the proofs. Use when asked to update/run/extend the proofs, check Lean coverage, re-target proofs after main moves, verify a function or PR formally, or when a change touches code listed in proofs/*/COVERAGE.tsv.
allowed-tools: Bash, Read, Edit, Write
---
# Proofs (Lean 4)
`proofs/` holds one standalone Lake project per engine area (`value_order`,
`binder`, `pending_commit`, `index_layer`, …). Each models the Rust code it
covers line by line and proves properties about that model. Lean 4 only, no
Mathlib. The toolchain comes from each project's `lean-toolchain`
(all pin `leanprover/lean4:v4.36.0`).
- `proofs/<area>/<Root>.lean` — imports the modules; its header is a few lines (what the project models, a pointer to the README). The project's `README.md` is the report: what is modelled, the headline theorems, open bugs, gaps.
- `proofs/<area>/COVERAGE.tsv` — one row per Rust fn: bucket PROVEN / CONDITIONAL / AXIOMATISED / MODELLED / NOT COVERED.
- `proofs/FINDINGS.md` — the bug ledger. Each bug is confirmed by a repro unless its entry is marked Lean-only, Unconfirmed or a model note; a fixed bug is deleted from the ledger (the file's git history keeps it).
- `proofs/lean_ci.sh`, `proofs/coverage.sh` — the two gates. `.github/workflows/lean-proofs.yml` (check name `Lean proofs`) reports on every pull request, so it can be a required check: the job itself skips, with a summary line, a PR that touches none of `proofs/**`, `graph/src/**`, `src/**` or the workflow file, and otherwise (and on pushes to `main`) runs both (a separate check, not in `ci-gate`).
## Quick start
```bash
# install elan once: https://github.com/leanprover/elan/releases (CI's pinned, checksum-verified install is in .github/workflows/lean-proofs.yml)
bash proofs/lean_ci.sh # build all projects; fails on sorry/admit/native_decide/unjustified axiom
bash proofs/lean_ci.sh binder value_order # just some projects
bash proofs/coverage.sh # per-file + total coverage; --unmatched lists stale rows
```
Proofs cite `origin/main`. If your checkout is on another branch, read the Rust from
a clean worktree: `git worktree add --detach ../fdb-main origin/main` then
`COVERAGE_RUST_ROOT=../fdb-main bash proofs/coverage.sh`.
## Workflows
**Re-target after main moves** (keep the proofs true for the current code):
1. `git diff <old-sha> origin/main --stat -- graph/src src`. The old sha is in FINDINGS.md "Current state".
2. Find the projects to update: `grep -l "<file>" proofs/*/COVERAGE.tsv` for each changed file.
3. For each changed fn: update the Lean model to the new code, re-prove, and fix the line in its COVERAGE.tsv row (the only place that carries Rust line numbers; Lean comments cite the file and fn name). Add rows for new fns and delete rows for removed ones. A fn has exactly one row, in the project that proves it.
4. If the commit fixed a bug, turn its counterexample theorem into a correctness theorem and delete the counterexample and any model of the old code (`pre<PR>_…`, `old…`): the fix PR's Rust test guards against a regression, and git history keeps the old proof. Remove the bug from the README and FINDINGS.md.
5. Run `lean_ci.sh` (all green) and `COVERAGE_RUST_ROOT=../fdb-main bash proofs/coverage.sh` (the worktree override above, when this checkout is not main; 0 unlisted; PROVEN + CONDITIONAL = 100% non-FFI, and no new CONDITIONAL), then update FINDINGS.md "Current state".
**Prove a new or changed function**: model it in the owning project, or start a new
project by copying the shape of an existing one. Then add the COVERAGE row and prove.
Conventions are in [REFERENCE.md](REFERENCE.md).
**When a theorem is false** (the model has a bug): get a concrete counterexample
(`#eval` or `decide`), then reproduce it against the real Rust before calling it a bug:
a Rust test, or a live query compared with the C module. Record it in FINDINGS.md with
`file:line`, the repro, and the Rust vs C output. Keep the counterexample as a theorem while the bug is open; delete it when the fix merges.
**Review a PR with the proofs**: in a new `proofs/pr<N>_review/` project, import the
definitions you need from the owning projects (Lake path dependency, see REFERENCE.md);
copy only what the PR changes. Model the PR's merged code for the
changed functions, and prove or refute each claim the PR makes. Confirm any refutation
live. Also check that the existing theorems still hold for the new code. A PR that
changes `Eq`/`Hash`/`Ord`/`sort_cmp`/`compare_value` (or anything a `HashMap` key or a
sort uses) **must** get a `pr<N>_review` project proving Eq ⇒ equal Hash and the order
laws on the PR's code (value_order `Main.lean` holds what pr2917_review proved). Until
it merges, its COVERAGE rows stay commented out. **Once the PR merges, delete the review
project**: fold each theorem into the owning project (drop it if an equivalent already
exists there, otherwise move it, re-stated on the owner's definitions), merge its COVERAGE
rows into the owner's rows, and update names cited in FINDINGS.md (see the retired
pr2845_review → binder/columnar/optimizer_rewrites `CallBoundary.lean`).
**Hypotheses about Rust code**: a theorem that takes a premise about another Rust
fn's behaviour (a contract structure, `(hc : ∀ …)`, an invariant some other code
maintains) proves nothing about main until that premise is discharged: instantiate it
with the model of the real fn (copy it and prove the premise), or bucket the row
CONDITIONAL and name the hypothesis. Only C APIs (FFI) may stay assumed.
## Hazards
- Never hand-edit Lean to match a guess about the Rust; read the cited lines in `origin/main`.
- Back up `proofs/` before mass edits (`tar --exclude=.lake -czf …`). A bad `perl -pi` once wiped citations.
- Live repros: give each run its own redis port. For flow tests use `RLTest -p <port>`; the harness connects to that port (default 6379), and `--randomize-ports` does not change it. Copy a rebuilt dylib to a fresh path before loading it (macOS kills redis-server when the loaded dylib is overwritten).
- Agents working in parallel: one owner per `proofs/<area>`, private scratch dirs, and no `./flow.sh` on 6379.