Skip to content

Lean 4: Proofs a Machine Can Check, Chapter 0, 7 min read, updated 2026-12-06

Before you start

On this page

At a glance

  • You'll find out who this book is for, how it is built, and how to read its examples and labels.
  • Why it matters: every example in this book was run on real software, and these pages tell you exactly what that promise covers.
  • Time: about 5 minutes to read.

Lean 4: Proofs a Machine Can Check. Mathlib and AI-assisted mathematics, from your first proof to agent workflows. A Machine Proved book. Published by Atlas Kits Press, an imprint of ATLAS KITS.

You may have seen the headlines: an AI helped prove a famous theorem, and a computer checked the proof. This book shows you what "a computer checked the proof" really means. You will write such proofs yourself, starting in your browser in the first chapter. No experience with Lean is needed.

In plain words: Lean is a program that checks mathematical proofs one step at a time, like a strict referee who never gets tired. If Lean accepts a proof, no step was skipped. This book teaches you to write proofs for that referee, to use AI as a fast but unreliable assistant, and to judge what a "checked" proof does and does not promise.

Who this book is for

  • Mathematicians and students who want to write proofs that a computer checks, and who got stuck after the first tutorial.
  • Engineers and ML researchers who want to connect AI models to Lean and need to know what the checker does and does not guarantee.
  • Readers of the November 2026 news who want to understand what was actually checked about the Riemann Hypothesis proof, in enough detail to explain it to someone else.

You need school algebra and some patience. Chapters 6–9 use first-year university mathematics. You do not need to know type theory or any programming language.

Tip: If you came for the news, you can read Chapter 15 on its own. It points back to the chapters where each tool is taught.

What this book does differently

  1. Every Lean example compiles. A script extracts every Lean block in this book and compiles it against a fixed Lean and Mathlib version. Blocks that are meant to fail are marked, and the script checks that they fail. The book's labs/ folder has the script and the report.
  2. Tactics are shown as before-and-after goal states, with the error message you get when they fail. A tactic is a command that moves a proof one step forward, and the goal state is Lean's summary of what is left to prove. This is the material learners most often say is missing.
  3. AI is treated as a collaborator that must be checked. Part IV shows how to connect an AI agent to Lean. Chapter 13 collects the ways an AI-written formalization can be wrong while still compiling.
  4. Trust is a skill you can learn. Part V shows the tools that check axioms, re-check proofs in the kernel and compare a solution against a trusted statement, and it applies them to a real case.

Tested on: the exact versions behind every example

Lean and its library change often, so this book names the exact versions it was checked against. Here they are:

Item Version
Lean leanprover/lean4:v4.36.0
Mathlib tag v4.36.0 (commit fc4f59e577feb1a4956671bc04ac18aaaf8cd842)
Check date 2026-12-06

Mathlib is Lean's large community library of mathematics. Each chapter header repeats the versions it was tested on. Lean and Mathlib change often, and names in Mathlib get renamed or deprecated. If an example stops working on a newer version, the next edition fixes it.

Conventions: how to read the examples

Lean blocks are complete files. You can paste any block into the online editor at live.lean-lang.org or into a file in the book's labs/ project. When a block does not show an import line, it starts with import Mathlib, which we leave out to save space. Add that line yourself when you paste.

Pitfall: the missing first line. An example printed without an import line still needs import Mathlib at the top of your file. Without it, the example will not compile as shown.

Three kinds of Lean block:

  • A normal block compiles with no errors and no sorry. (sorry is Lean's placeholder for a missing proof.)
  • A block introduced as an exercise compiles, but contains sorry where your proof goes. Solutions are in labs/QedFolio/Solutions/.
  • A block introduced with "this does not compile" fails on purpose, to show an error. The checking script confirms that it fails.

Goal states are shown the way Lean's infoview shows them. The infoview is the panel next to the editor. The facts you may use (the hypotheses) are above, and what you still have to prove (the goal) comes after ⊢. Here, you know x = y and must prove y = x:

x y : ℕ
h : x = y
⊢ y = x

Lean output (from #eval, #check, #print axioms or an error) is copied from a real run on the versions above. Where we shorten it, we say so.

Claim labels: how sure each news claim is

Factual statements about events, tools and other people's work carry a source. In the chapters about the news (15 and 16), claims carry a label. The table tells you how much weight each label can bear:

Label Meaning
Sourced A primary source says so: the author's own page, the official project repository or blog, or the tool's own help text. The chapter lists the URL and the date we read it.
Reported Only secondary sources (news, blogs) were available. Treat it as likely, not settled.
Ran We ran it ourselves on the versions above.

How this book was written (AI disclosure)

This book was written with AI assistance (Claude, by Anthropic) and checked: every Lean example compiles against a pinned Lean and Mathlib version, and every factual claim links to a dated source. We think you should know that, especially in a book that is partly about AI.

What we did to keep it honest:

  • Every Lean example was compiled by the checking script. The AI's Lean code was not trusted until the compiler accepted it.
  • Every factual claim was checked against a source, recorded in the project's fact file with the date it was read.
  • Outputs shown in the book were copied from real runs, not written from memory.
  • The illustration at the start of each chapter was made with an AI image model (ChatGPT). The diagrams that explain ideas were drawn by hand from the book's own examples.

The byline is the imprint, not a person. No reviewer quotes or testimonials appear in this book or its store pages.

Not affiliated

Lean is a trademark of the Lean FRO. This book is independent. It is not affiliated with, sponsored by or endorsed by the Lean FRO, the Mathlib Initiative, the Lean community, or Anthropic. "Lean" is used here only to name the software the book teaches.

Code adapted from Mathlib and from Theorem Proving in Lean 4 and Mathematics in Lean (Apache-2.0) is marked where it appears.

Contents

The book has six parts and two appendices. Part I teaches the basics, and each later part builds on it.

  • Part I — First proofs: 1 Your first machine-checked proof · 2 Goals, hypotheses and the logic tactics · 3 Tactic cards · 4 Induction, recursion and computation
  • Part II — Mathematics with Mathlib: 5 Finding what you need in Mathlib · 6 Algebra and inequalities · 7 Number theory · 8 Sets, functions and structures · 9 Analysis, and reading a real statement
  • Part III — Proof engineering: 10 Projects, pinning and CI · 11 Style, maintenance and performance
  • Part IV — AI-assisted proving: 12 Working with an AI prover · 13 Autoformalization and how it goes wrong
  • Part V — Trust: 14 Checking a proof you did not write · 15 What was checked in the Riemann Hypothesis proof
  • Part VI — Further: 16 Case studies: AI-found results, formalized · 17 Where to go next
  • Appendices: A Tactic cheat-sheet (with a plain-words glossary) · B Error message decoder

Key takeaways

  • Every Lean example in this book was compiled against Lean v4.36.0 and Mathlib v4.36.0.
  • Blocks marked "exercise" hold a sorry for you to replace; blocks marked "this does not compile" fail on purpose.
  • News claims carry a label: [Sourced], [Reported] or [Ran].
  • The book was drafted with AI help, and nothing the AI wrote was trusted until it was checked.

Copyright © 2026 ATLAS KITS. All rights reserved, except the Lean code in this book and its labs/ project, which may be reused under the Apache License 2.0.