Step 0
Base Camp Gym
What a proof is, a short history of math, why proofs need checking, where Lean came from, and how to read Lean 4.
A word, a tactic, a new idea
153 results
Step 0
What a proof is, a short history of math, why proofs need checking, where Lean came from, and how to read Lean 4.
Step 0
Six classic proofs with pictures: triangle angles, Pythagoras, pigeonhole, a broken chessboard, why √2 is not a fraction, and why the primes never run out.
Library
A short illustrated history of math and proof.
Example 1
A calculator follows rules in a fixed order. Lean does too.
Example 2
A label on a box tells you what belongs inside. A type plays a similar role.
Example 3
A recipe takes ingredients and produces something. A function takes an input and returns an output.
Example 4
A word can join another word. A row of items can join another row.
Example 5
A signpost sends you one way or another. A conditional chooses between two results.
Example 6
Write your first Lean proof with rfl, then watch the goal disappear.
Example 7
Some questions have a finite checking procedure. Lean can run such a procedure and turn its verified result into a proof.
Example 8
A saved recipe saves you work next time. A named theorem does the same for a proof.
Example 9
If two labels name the same box, you can swap the labels. Rewriting replaces an expression using a proved equality.
Example 10
Sometimes the key you need is already in your pocket. A hypothesis can already prove the goal.
Example 11
A promise can say, “Give me a ticket, and I will let you in.” An implication describes what follows from an assumption. To prove one, temporarily accept its premise.
Example 12
A two-item checklist needs two ticks. To prove an “and” statement, prove both parts.
Example 13
A packed lunch contains both a drink and a sandwich. You can unpack the pair and use either part.
Example 14
A pass may accept a student card or a library card. One valid option is enough.
Example 15
A parcel can arrive by bike or by van. A plan for either arrival method covers the possibilities.
Example 16
A “no entry” rule promises that any entry attempt leads to a contradiction. Negation has a similar shape.
Example 17
Suppose every attempt to deny a claim leads to a contradiction. Classical reasoning lets you conclude the claim.
Example 18
A two-way bridge needs a route in both directions. “If and only if” also makes two promises.
Example 19
A rule for every locker applies to locker three too. A universally quantified claim must cover every input.
Example 20
To show that a treasure exists, showing one treasure is enough. An existence proof supplies a witness.
Example 21
A staircase starts at the ground and adds one step at a time. Natural numbers have the same structure.
Example 22
If the first domino falls, and each falling domino knocks down the next, the whole chain falls. Induction follows this pattern.
Example 23
You can build a bridge using sections already checked. A proof can also reuse earlier lemmas.
Example 24
Stack blocks in rows of lengths zero, one, two, and so on. Two copies fit into a rectangle.
Example 25
A calculator is good at routine arithmetic. A specialized proof procedure can handle routine inequalities too.
Example 26
A workshop is more useful with a well-stocked toolbox. Mathlib supplies a large collection of mathematical definitions, theorems, and tactics.
Example 27
A number written as a fraction still has an exact value. Lean can check concrete calculations without decimal rounding.
Example 28
Two short routes can make one longer route. Inequalities can chain in the same way.
Example 29
A clear explanation leaves a trail of reasons. A calc proof does the same.
Example 30
A squared distance cannot be negative. That single fact can unlock a useful inequality.
Example 31
A recipe can tell you to make a smaller version first. Recursive functions do that too.
Example 32
A train is empty or has a first carriage followed by the rest. A list has the same two possibilities.
Example 33
A coordinate card keeps an x-value beside a y-value. A structure packages named fields in the same way.
Example 34
A menu gives a fixed set of choices. An inductive type can name those choices directly.
Example 35
A numbered ticket machine should never give the same new ticket to two different old tickets. An injective function has that property.
Example 36
Two even piles can each be split into matching halves. Put the piles together, and the halves combine too.
Example 37
An odd row has pairs plus one extra item. Squaring such a row still leaves one extra after pairing.
Example 38
Two neighboring whole numbers cannot both be odd. One has an even half-size witness.
Example 39
A road with a sign beyond every distance cannot end at a last sign. Primes have a similar property.
Example 40
Turn a row of cards around, then turn it around again. You get the original order.
Example 41
If P implies Q and Q is impossible, then P is impossible.
Example 42
Given P or Q, ruling out P leaves Q.
Example 43
P and (Q or R) implies (P and Q) or (P and R).
Example 44
If P is equivalent to Q and Q is equivalent to R, then P is equivalent to R.
Example 45
If at least one n fails a test, it is false that every n passes.
Example 46
For every Boolean b, negating b twice returns b.
Example 47
For every pair p, swapping its two entries twice gives p.
Example 48
For every function f and list xs, mapping f over xs preserves its length.
Example 49
Mapping f and then g gives the same list as mapping the combined rule x ↦ g (f x).
Example 50
The total of xs followed by ys equals the total of xs plus the total of ys.
Tactic
For our equality goals, close a goal by definitional equality.
Tactic
Run a decision procedure and turn its successful result into a proof.
Tactic
Supply a term whose type is the current goal.
Tactic
Rewrite with named equalities or supported equivalences.
Tactic
Introduce a function input, implication premise, or universally quantified variable.
Tactic
Apply a constructor for the goal’s type, leaving goals for its required arguments.
Tactic
Split a value into all its constructor cases.
Tactic
Choose the left constructor of an or goal.
Tactic
Choose the right constructor of an or goal.
Tactic
Use a theorem with a matching conclusion, leaving its missing premises as goals.
Tactic
Apply a local hypothesis to arguments and replace it with the result.
Tactic
Supply an existence witness, then try to finish by reflexivity.
Tactic
Follow constructors, obtaining hypotheses for smaller recursive inputs.
Tactic
Replace a goal with a definitionally equal expression.
Tactic
Simplify using rewrite rules and the configured simplifier lemmas.
Tactic
Prove supported arithmetic claims over Nat and Int.
Tactic
Normalize polynomial expressions to prove supported identities.
Tactic
Prove supported concrete numerical facts.
Tactic
Derive a linear arithmetic consequence of the available facts.
Tactic
Write a chain of relations, with a justification for every link.
Tactic
Introduce a local proved fact inside a tactic proof.
Tactic
Use arithmetic reasoning with nonlinear preprocessing.
Tactic
Replace a named definition by its defining expression.
Tactic
Unpack a fact into named components, such as a witness and its property.
Tactic
Supply a term with holes that become new goals.
Tactic
Split and name components using a case pattern.
Tactic
Run the right-hand tactic on every goal produced by the left-hand tactic.
Glossary
Join a second list after the first, keeping the order of both.
Glossary
The starting case of an induction or recursive definition, such as zero or an empty list.
Glossary
A value of type Bool: true or false. These are values, distinct from propositions and their proofs.
Glossary
One possibility determined by the constructor that built a value. A proof by cases handles every possibility.
Glossary
Reasoning that includes excluded middle: every proposition holds or its negation holds.
Glossary
An operation is commutative when swapping its two inputs leaves the result unchanged.
Glossary
An expression that chooses one branch when a condition holds and another when it does not.
Glossary
An and statement. Its proof contains a proof of each component proposition.
Glossary
A specified way to build a value of an inductive type. Nat has zero and successor constructors.
Glossary
A situation where the available assumptions produce a proof of False. A compiler error is not such a proof.
Glossary
A command that introduces something into Lean, such as a definition or theorem.
Glossary
A proposition is decidable when a procedure provides either a proof of it or a proof of its negation.
Glossary
A named expression. Lean checks its declared type and its defining value.
Glossary
Equality that Lean recognizes using its computation rules, without requiring a separate equality proof.
Glossary
An inclusive or statement. A proof supplies one side; both sides may also be true.
Glossary
For natural numbers, a divides b when b equals a times some natural-number witness.
Glossary
One item in a list or other collection. Every element in a Lean list has the same element type.
Glossary
A proposition identifying two expressions of the same type. It may need more than computation to prove.
Glossary
An if-and-only-if statement, proved by an implication in each direction.
Glossary
Computing the value described by an expression. Evaluation alone is different from stating a theorem.
Glossary
A natural number is even when it is the sum of some natural number with itself. Zero is even.
Glossary
The phrase there exists. A proof supplies a witness and a proof of its required property.
Glossary
A piece of code that describes a term. Well-typed expressions have types.
Glossary
A proposition with no constructors. It is different from the Boolean value false.
Glossary
The product of the positive whole numbers through n. By definition, the factorial of zero is one.
Glossary
The sequence beginning with zero and one, in which each later value is the sum of the preceding two values.
Glossary
A named component of a structure record. This use of field differs from the algebraic meaning of a number field.
Glossary
A rule taking an input of a specified type and producing an output of a specified type.
Glossary
The type or proposition for which a proof still needs to supply a term.
Glossary
A named assumption or available fact in the local proof context.
Glossary
A proposition saying that a proof of a premise can be turned into a proof of a conclusion.
Glossary
A proof method following the constructors of an inductive type, with hypotheses for recursive constructor arguments.
Glossary
The claim already available for the smaller recursive input in an induction case.
Glossary
A type specified by constructors that build its values, sometimes from smaller values of the same type.
Glossary
A registered implementation that Lean can find automatically. A Decidable instance supplies a decision procedure for a proposition.
Glossary
A function is injective when equal outputs force equal inputs. Different inputs cannot share an output.
Glossary
A whole number, including zero, positive whole numbers, and negative whole numbers. Lean’s Int type represents integers.
Glossary
A theorem used as a supporting fact. Lean checks lemmas and theorems by the same proof rules.
Glossary
Arithmetic with sums, order comparisons, and fixed-number multiples of unknowns. General products of unknowns are nonlinear.
Glossary
An ordered sequence of elements of a single type. A list is empty or has a head and a tail.
Glossary
A community-maintained mathematical library for Lean, containing definitions, checked theorems, and tactics.
Glossary
A source-file unit that controls imported and exported declarations. This course pins the module behavior of Lean 4.36.0.
Glossary
Zero or a positive whole number. Lean’s Nat type does not contain negative integers or fractions.
Glossary
A not statement. In Lean, a proof of not P turns a proof of P into a proof of False.
Glossary
A natural number of the form twice a natural number plus one.
Glossary
A named input used while describing a function, definition, or theorem.
Glossary
Inspecting a value’s constructor and providing a result for each possible constructor pattern.
Glossary
An expression formed from variables and coefficients using addition, multiplication, and natural-number powers.
Glossary
The assumption on the left side of an implication. A proof of the implication must work for any proof of this assumption.
Glossary
A natural number at least two whose only positive divisors are one and itself.
Glossary
A prime number that divides another natural number. The least prime factor is the smallest such prime.
Glossary
A term whose type is the proposition being established. Lean’s kernel checks that term against its type.
Glossary
A statement that can have a proof. Propositions have type Prop in Lean.
Glossary
A number expressible as an integer divided by a nonzero integer. Lean’s rational arithmetic is exact.
Glossary
A number on the usual continuous number line. Real numbers include rational and irrational numbers.
Glossary
Defining a function using its own values at smaller inputs. Lean checks that ordinary recursive definitions terminate.
Glossary
What is left after whole-number division. For a positive divisor, a natural-number remainder is smaller than the divisor.
Glossary
Replace an occurrence using a proved equality or a supported logical equivalence.
Glossary
A placeholder for unfinished work. Lean warns about it. It is forbidden in this course’s finished examples and solutions.
Glossary
The product of a number with itself. Every real square is nonnegative.
Glossary
Lean’s type for text values. String literals are surrounded by double quotation marks.
Glossary
A record type built from a collection of named fields and a constructor.
Glossary
A command that constructs proof terms by transforming or solving goals. Its result is still checked by Lean.
Glossary
A value or expression inhabiting a type. Functions, data values, and proofs can all be terms.
Glossary
A computation eventually reaching a result. Lean checks that the recursive calls in these examples decrease.
Glossary
A named proposition together with a checked proof. A theorem may use explicitly stated assumptions.
Glossary
A relation is transitive when a relation from a to b and from b to c imply the relation from a to c.
Glossary
A classification of terms. It tells Lean what kind of term is required in a position.
Glossary
Having an element beyond every proposed upper limit. The prime theorem lets you choose a larger bound each time.
Glossary
The phrase for all. A proof must work for every input of the indicated type.
Glossary
A named value that can vary over its declared type. An arbitrary variable cannot be assumed to be a particular number.
Glossary
The specific value supplied by an existence proof, together with a proof of its property.
Glossary
An order comparison such as less than or less than or equal to.