A Lean 4 port of the Iris separation-logic tutorial. It is authored as a Verso manual-genre textbook: the prose and the Lean proofs live together in .lean files, and the proofs are elaborated (type-checked) by the same Lean toolchain that builds the book. The build also extracts the example code into standalone modules.
The repo serves two outputs from one source: the rendered HTML book, and a downloadable code.zip of the extracted, compilable examples.
lake exe textbook— build the book. Elaborates every chapter (so this also type-checks all Iris proofs) and writes HTML to_out/html-multi/plus extracted example code to_out/example-code/.make/make out— build, then assembleout/html-multi/andout/code.zipfor publishing.make serve— build and serve the HTML locally (PORT=8000by default;make serve PORT=9000).make clean— removeout/and_out/.lake build IrisTutorial.Basics— elaborate a single chapter module without rendering HTML. Use this to iterate on one chapter's proofs — much faster than a fulllake exe textbook.
The Lean toolchain is pinned in lean-toolchain (leanprover/lean4:4.30.0); verso and iris-lean are both pinned to v4.30.0 in lakefile.toml. These three versions must stay in lockstep.
-
Book root and generation infrastructure.
IrisTutorialBook.lean— the#docbook root: front matter, authors, and the{include}directives that order the chapters into the rendered book. This is the book itself; edit it to change front matter or chapter ordering.BookGenMain.lean— thetextbookexecutable (its lakefileroot). ItsbuildExercisestraverse step walks the whole book before HTML generation, collecting saved code blocks into files underexample-code/, andmainrenders the book root via%doc IrisTutorialBook.BookGen/Meta/Lean.lean— defines the customsavedLean/savedImport/savedCommentcode-block elaborators (innamespace BookGen) and their backingBlock.savedLean/Block.savedImportextensions. This is the mechanism that lets a code block be both type-checked inline and extracted to a file.BookGen/andBookGenMain.leanare inherited from the Verso textbook template and remain under their original copyright (Lean FRO LLC, Apache 2.0) — usually leave them alone.
-
Tutorial content —
IrisTutorial/*.lean, one file per chapter, aggregated byIrisTutorial.lean. Each chapter is a#doc (Manual) "Title" => ...document mixing Verso prose with elaborated Lean/Iris proofs. -
Dependencies —
verso(the documentation/genre framework) andiris-lean(the Lean port of Iris that providesIProp, the BI connectives, and the Iris Proof Mode tactics likeiintro,iapply,iexact,ipure_intro).
The block language tag determines how a fenced block is treated:
```savedLean— elaborated inline (type-checked as part of the build) and appended to the extracted example file for that chapter. This is the workhorse for definitions, theorems,namespace/variable/open/endlines.```savedImport— animportline. Suppressed in the rendered output, but hoisted to the top of the extracted file (buildExercisesprependssavedImportblocks while appendingsavedLeanblocks; seeBookGenMain.lean).```savedComment— prose wrapped as a/-! ... -/module docstring in the extracted file.
Because saved blocks are concatenated in source order into one module per chapter, the namespace/open/variable/end blocks must bracket the theorems correctly as a sequence — the extracted file is exactly the saved blocks joined with newlines.
.mcp.json wires the lean-lsp MCP server with a local Loogle instance (LOOGLE_URL=http://localhost:8088) and disables the hosted natural-language search tools (lean_leansearch, lean_leanfinder, lean_state_search, lean_hammer_premise). Prefer lean_local_search, lean_loogle, lean_goal, and lean_hover_info; the disabled tools will not be available.