Chapter 1. Core Language and Environment
- Installation and toolchain
- Project structure with Lean and Lake
- Files, namespaces, and modules
- Basic syntax and expressions
- Definitions with
def - Theorems with
theoremandlemma - Types and universes
- Functions and lambda abstraction
- Implicit and explicit arguments
- Notation and infix operators
- Comments and documentation
- Evaluation with
#eval - Checking types with
#check - Simple rewriting
- Pattern matching basics
- Inductive types introduction
- Structures and records
- Basic tactic mode
- Term mode vs tactic mode
- Holes and goals
- Error messages and debugging
- Imports and dependencies
- Interactive development workflow
- Editor integration (VSCode)
- Minimal working examples
Chapter 2. Propositions and Proofs
- Propositions as types
- Implication and functions
- Conjunction
- Disjunction
- Negation
- False and contradiction
- True and trivial proofs
- Equality basics
- Rewriting with equality
- Symmetry and transitivity
- Existential quantifiers
- Universal quantifiers
- Classical vs constructive logic
- Proof by contradiction
- Case analysis
- Introduction and elimination rules
- Proof structuring patterns
- Naming conventions
- Local context management
- Using assumptions effectively
- Forward reasoning
- Backward reasoning
- Combining tactics and terms
- Small proof refactoring
- Proof readability patterns
Chapter 3. Tactic Framework
- The
introtactic - The
applytactic - The
exacttactic - The
assumptiontactic - The
rwtactic - The
simptactic - The
simpset control - The
casestactic - The
inductiontactic - The
constructortactic - The
havetactic - The
lettactic - The
showtactic - The
refinetactic - The
calcblock - The
convtactic - The
changetactic - The
generalizetactic - The
reverttactic - The
cleartactic - The
renametactic - The
simp_alltactic - The
aesoptactic - Combining tactics
- Debugging tactic scripts
Chapter 4. Equality and Rewriting
- Definitional equality
- Propositional equality
- The
rflproof - Congruence lemmas
- Rewriting direction control
- Chained rewriting
- Rewriting under binders
- Rewriting with hypotheses
- Dependent rewriting
- Substitution patterns
- Transport across equality
- Heterogeneous equality
simpnormalization- Custom simp lemmas
- Avoiding rewrite loops
- Controlled rewriting strategies
- Equality in inductive types
- Equality of functions
- Extensionality
- Proof irrelevance
- Decidable equality
- Boolean equality bridges
- Rewriting with equivalences
- Rewriting in structures
- Common pitfalls
Chapter 5. Inductive Types
- Defining inductive types
- Constructors and recursion
- Pattern matching deep dive
- Structural recursion
- Well-founded recursion
- Induction principles
- Custom induction schemes
- Mutual inductive types
- Nested inductive types
- Indexed families
- Finite types
- Enumerations
- Trees and recursion
- Lists and sequences
- Options and sums
- Products and pairs
- Proofs by induction
- Eliminators
- Recursors
- Dependent pattern matching
- Inductive propositions
- Encoding logical rules
- Proof objects
- Design patterns
- Performance considerations
Chapter 6. Structures and Typeclasses
- Structures definition
- Field access
- Instances
- Typeclass basics
- Instance search
- Coercions
- Inheritance patterns
- Bundled vs unbundled
- Algebraic structures
- Custom instances
- Overlapping instances
- Priority control
- Local instances
- Deriving mechanisms
- Reusable interfaces
- Notation with structures
- Canonical structures
- Class inference debugging
- Mixins
- Parametric structures
- Typeclass design patterns
- Automation via classes
- Interoperability
- Extending libraries
- Pitfalls
Chapter 7. Functions and Recursion
- Function definitions
- Higher-order functions
- Currying and uncurrying
- Recursion basics
- Tail recursion
- Termination checking
- Measure functions
- Structural recursion patterns
- Partial functions
- Option-returning functions
- Error handling
- Monadic style
- Dependent functions
- Function extensionality
- Mapping and folding
- Composition patterns
- Lazy evaluation patterns
- Efficiency concerns
- Memoization ideas
- Rewriting recursive definitions
- Equational reasoning
- Proofs about functions
- Parametricity
- Abstraction patterns
- Refactoring functions
Chapter 8. Lists and Collections
- Lists basics
- List recursion
- Mapping
- Filtering
- Folding
- Zipping
- Concatenation
- Membership
- Sublist relations
- Permutations
- Sorting
- Multisets
- Arrays
- Finite sets
- Maps and dictionaries
- Indexing
- Iterators
- Collection proofs
- Algebraic properties
- Complexity reasoning
- Efficient representations
- Custom containers
- Interoperability
- Common lemmas
- Design patterns
Chapter 9. Arithmetic and Algebra
- Natural numbers
- Integers
- Rational numbers
- Real numbers interface
- Arithmetic tactics
- Ring reasoning
- Linear arithmetic
- Inequalities
- Divisibility
- Modular arithmetic
- Algebraic identities
- Polynomial reasoning
- Structures (semigroup, monoid)
- Groups
- Rings
- Fields
- Homomorphisms
- Algebraic rewriting
- Canonical forms
- Decision procedures
- Automation
- Custom algebraic tactics
- Proof patterns
- Optimization
- Integration with libraries
Chapter 10. Logic Engineering
- Encoding syntax
- Encoding semantics
- Abstract syntax trees
- Evaluation functions
- Substitution
- Variable binding
- De Bruijn indices
- Alpha equivalence
- Beta reduction
- Small-step semantics
- Big-step semantics
- Proof systems
- Soundness
- Completeness
- Decidability
- Normalization
- Encoding inference rules
- Automated reasoning
- Reflection
- Verified interpreters
- Verified compilers
- Logical frameworks
- DSL design
- Meta-theory proofs
- Case studies
Chapter 11. Metaprogramming
- The
Leanmetaprogramming model - Syntax trees
- Elaborator basics
- Tactic writing
- Custom tactics
- Macros
- Attributes
- Environment inspection
- Quotation
- Anti-quotation
- Reflection
- Code generation
- Custom commands
- Interactive tools
- Debugging meta code
- Performance tuning
- Automation pipelines
- Proof search
- Custom simplifiers
- Domain-specific tactics
- Integrating with libraries
- Tooling extensions
- Safe metaprogramming
- Testing meta code
- Design patterns
Chapter 12. Automation
- Simplification strategies
- Rewriting automation
- Decision procedures
- Search-based tactics
- Heuristic design
- Controlling search
- Custom simp sets
- Combining automation
- Proof reconstruction
- External solvers
- SMT integration
- Arithmetic automation
- Logic automation
- Rewriting engines
- Performance tuning
- Debugging automation
- Domain-specific automation
- Automation boundaries
- Proof minimization
- Trusted kernels
- Reliability concerns
- Incremental automation
- Benchmarking
- Scaling automation
- Case studies
Chapter 13. Formalizing Mathematics
- Sets and functions
- Relations
- Orders
- Topology basics
- Analysis basics
- Algebra formalization
- Category theory basics
- Combinatorics formalization
- Graph theory
- Probability basics
- Number theory
- Linear algebra
- Abstract structures
- Reusable lemmas
- Naming conventions
- Library navigation
- Documentation patterns
- Bridging informal to formal
- Formal proof strategies
- Refactoring libraries
- Dependency management
- Cross-domain reuse
- Collaboration workflows
- Review processes
- Case studies
Chapter 14. Large Projects
- Project architecture
- Module boundaries
- Naming systems
- Dependency graphs
- Build performance
- Incremental compilation
- Testing strategies
- Continuous integration
- Documentation systems
- Versioning
- Refactoring large codebases
- Code review practices
- Style guides
- Collaboration models
- Packaging
- Distribution
- Benchmarking
- Profiling
- Debugging large systems
- Error isolation
- Scaling proofs
- Automation pipelines
- Library evolution
- Migration strategies
- Case studies
Chapter 15. Interoperability
- Calling external code
- FFI basics
- Data exchange
- Serialization
- JSON handling
- Interfacing with C
- Interfacing with Rust
- Interfacing with Python
- Command line tools
- File IO
- Network IO
- External solvers
- Database interaction
- Embedding Lean
- Extracting programs
- Verified pipelines
- Toolchain integration
- Build system bridges
- Testing interoperability
- Performance concerns
- Security considerations
- Sandboxing
- Deployment
- Monitoring
- Case studies
Chapter 16. Performance and Optimization
- Evaluation model
- Memory usage
- Lazy vs strict
- Profiling tools
- Bottleneck analysis
- Optimizing recursion
- Efficient data structures
- Avoiding recomputation
- Caching
- Parallelism concepts
- Compilation strategies
- Kernel performance
- Tactic performance
- Simplifier tuning
- Instance search tuning
- Reducing proof size
- Code generation efficiency
- Benchmarking
- Micro-optimizations
- Macro-optimizations
- Trade-offs
- Regression testing
- Performance metrics
- Scaling strategies
- Case studies
Chapter 17. Debugging and Diagnostics
- Reading error messages
- Type mismatch diagnosis
- Unification failures
- Missing instances
- Infinite loops
- Tactic failures
- Simplifier issues
- Trace tools
- Logging
- Inspecting goals
- Context inspection
- Stepwise debugging
- Binary search debugging
- Minimizing examples
- Reproducing bugs
- Fix strategies
- Testing fixes
- Debugging meta code
- Debugging automation
- Performance debugging
- Tooling support
- Editor features
- Reporting issues
- Common pitfalls
- Debugging checklist
Chapter 18. Proof Patterns
- Direct proofs
- Contradiction
- Contrapositive
- Induction patterns
- Case splits
- Invariants
- Structural recursion proofs
- Algebraic proofs
- Combinatorial proofs
- Constructive proofs
- Classical proofs
- Equational reasoning
- Diagram chasing
- Reduction arguments
- Encoding arguments
- Abstraction patterns
- Layered proofs
- Reusable lemmas
- Proof compression
- Proof expansion
- Readability patterns
- Naming patterns
- Refactoring proofs
- Anti-patterns
- Case studies
Chapter 19. Domain-Specific Libraries
- Mathlib overview
- Navigating mathlib
- Extending mathlib
- Custom libraries
- DSL construction
- Domain modeling
- Interfaces
- Reuse strategies
- Version compatibility
- Documentation
- Testing
- Benchmarking
- Distribution
- Collaboration
- Review processes
- Stability
- Deprecation
- Migration
- Tooling
- Packaging
- Publication
- Community standards
- Maintenance
- Governance
- Case studies
Chapter 20. End-to-End Case Studies
- Verified arithmetic library
- Verified data structure
- Verified parser
- Verified interpreter
- Verified compiler
- Verified algorithm
- Formal combinatorics project
- Formal algebra project
- Formal logic system
- DSL implementation
- Automation pipeline
- Custom tactic suite
- Large proof development
- Library extension
- Interoperability project
- Performance optimization
- Debugging case study
- Refactoring case study
- Collaboration case study
- Teaching example
- Research prototype
- Industrial application
- Deployment scenario
- Maintenance workflow
- Lessons learned
Chapter 1. Core Language and EnvironmentThis chapter establishes the operational model of the Lean system.
Chapter 2. Propositions and ProofsThis chapter introduces the proof layer of Lean.
Chapter 4. Equality and RewritingThis chapter isolates the operational core of reasoning in Type Theory as implemented by Lean: equality and its use as a transport mechanism.
PrefaceThis book is a working manual for the Lean proof assistant.