The Formal Documentation Engine for Lean 4.
doc is an integrated documentation and typesetting library for Lean 4. It allows researchers and engineers to generate publication-quality LaTeX papers, books, and technical reports directly from verified Lean source code.
By leveraging Leanβs metaprogramming capabilities, doc ensures that your documentation is never out of sync with your proofs.
@[doc] attribute to mark theorems and definitions for export.lake for a one-command PDF generation process.Add doc to your lakefile.lean:
require doc from git
"[https://github.com/4137314/doc.git](https://github.com/4137314/doc.git)" @ "main"
Then run:
lake update
Tag the declarations you want to include in your paper:
import Doc
/-- The Square of a sum identity. -/
@[doc]
theorem square_sum (a b : β) : (a + b)^2 = a^2 + 2*a*b + b^2 := by
sorry
Run the documentation engine via Lake:
lake run doc
This command will:
@[doc] attributes..tex file..tex file into a .pdf (requires pdflatex or lualatex installed).The project is organized into three main functional domains (EPICs):
SRC-CORE-ATTR: Custom attribute registry.SRC-CORE-SCAN: Environment scraping and filtering.SRC-CORE-FMT: Pretty-printing Lean expressions for LaTeX.SRC-TEX-PRE: Automated LaTeX preamble generation.SRC-TEX-SYM: Unicode-to-LaTeX symbol mapping.SRC-TEX-IO: File system emission.UI-CLI-LAKE: Integration with Lake scripts.UI-CLI-RUN: PDF compiler subprocess management.Contributions in metaprogramming, LaTeX templating, and scientific visualization are welcome.
feat(core): ..., fix(tex): ...).This project is licensed under the Apache 2.0 License.