Hub documentation
Formal Proofs (Lean 4)
Formal Proofs (Lean 4)
The Hub natively renders Lean 4 (.lean) files in all repos, with a Statements view, an Outline sidebar, and Lean 4 syntax highlighting.

Statements view
Opening a .lean file in Files and versions or a Storage Bucket shows its Statements view by default, so you can read what a file defines and proves without scrolling past long proofs:
- KaTeX docstrings:
/-- ... -/docstrings render inline ($...$) and display ($$...$$) math, code, and links. - Foldable proofs and bodies: proofs (
theorem,lemma,example) and definitions (def,abbrev,structure,inductive, …) stay folded behind a toggle. - Unfinished proofs:
sorry,admit, and#exitare highlighted in red so gaps stand out immediately.
Click any proof or body toggle to expand it inline:

Try it on a public file:
- ErdosProblems/1.lean — KaTeX docstrings, folded proofs, and
sorry - CubicQuartic.lean — multi-line proofs of the cubic and quartic formulas
- ChallengeDeps.lean —
abbrev,def, andstructuredeclarations
Outline
On desktop, a sticky Outline sidebar lists every declaration with its kind and line number. Click any entry to jump straight to it (#L<line>), or click a declaration’s line number for a shareable link.
Full view
Click Full in the top-right switcher—or append ?code=true to the URL—to view the complete file with Lean 4 syntax highlighting, line numbers, and the Outline sidebar. Line links copied from Full view preserve ?code=true (for example, 1.lean?code=true#L54).

Markdown code blocks
Lean 4 syntax highlighting also works in Model Cards, Dataset Cards, Space Cards, Discussions, and Pull Requests using lean or lean4 code fences:
```lean
/-- Every natural number plus zero is itself. -/
theorem add_zero_example (n : ℕ) : n + 0 = n := by
exact Nat.add_zero n
```