A word, a tactic, a new idea

What are you curious about?

152 results

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.

Library

From tally marks to Lean

A short illustrated history of math and proof.

Example 1

Meet your new calculator

A calculator follows rules in a fixed order. Lean does too.

Example 2

Everything has a type

A label on a box tells you what belongs inside. A type plays a similar role.

Example 3

Make a function

A recipe takes ingredients and produces something. A function takes an input and returns an output.

Example 4

Words and collections

A word can join another word. A row of items can join another row.

Example 5

Make a decision

A signpost sends you one way or another. A conditional chooses between two results.

Example 6

Your first proof

Write your first Lean proof with rfl, then watch the goal disappear.

Example 7

Prove a difference

Some questions have a finite checking procedure. Lean can run such a procedure and turn its verified result into a proof.

Example 8

Give a proof a name

A saved recipe saves you work next time. A named theorem does the same for a proof.

Example 9

Swap equal things

If two labels name the same box, you can swap the labels. Rewriting replaces an expression using a proved equality.

Example 10

Use what you know

Sometimes the key you need is already in your pocket. A hypothesis can already prove the goal.

Example 11

If this, then that

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

Prove both halves

A two-item checklist needs two ticks. To prove an “and” statement, prove both parts.

Example 13

Unpack an and

A packed lunch contains both a drink and a sandwich. You can unpack the pair and use either part.

Example 14

Choose a side

A pass may accept a student card or a library card. One valid option is enough.

Example 15

Follow both possibilities

A parcel can arrive by bike or by van. A plan for either arrival method covers the possibilities.

Example 16

What not means

A “no entry” rule promises that any entry attempt leads to a contradiction. Negation has a similar shape.

Example 17

Proof by contradiction

Suppose every attempt to deny a claim leads to a contradiction. Classical reasoning lets you conclude the claim.

Example 18

A two-way promise

A two-way bridge needs a route in both directions. “If and only if” also makes two promises.

Example 19

For every input

A rule for every locker applies to locker three too. A universally quantified claim must cover every input.

Example 20

Find one witness

To show that a treasure exists, showing one treasure is enough. An existence proof supplies a witness.

Example 21

Numbers from zero and steps

A staircase starts at the ground and adds one step at a time. Natural numbers have the same structure.

Example 22

Your first induction

If the first domino falls, and each falling domino knocks down the next, the whole chain falls. Induction follows this pattern.

Example 23

Addition in either order

You can build a bridge using sections already checked. A proof can also reuse earlier lemmas.

Example 24

Add a whole staircase

Stack blocks in rows of lengths zero, one, two, and so on. Two copies fit into a rectangle.

Example 25

Let omega handle the arithmetic

A calculator is good at routine arithmetic. A specialized proof procedure can handle routine inequalities too.

Example 26

A library of mathematics

A workshop is more useful with a well-stocked toolbox. Mathlib supplies a large collection of mathematical definitions, theorems, and tactics.

Example 27

Numbers, checked

A number written as a fraction still has an exact value. Lean can check concrete calculations without decimal rounding.

Example 28

Follow the inequalities

Two short routes can make one longer route. Inequalities can chain in the same way.

Example 29

Write a chain of reasons

A clear explanation leaves a trail of reasons. A calc proof does the same.

Example 30

A square is never negative

A squared distance cannot be negative. That single fact can unlock a useful inequality.

Example 31

Functions that call themselves

A recipe can tell you to make a smaller version first. Recursive functions do that too.

Example 32

Induction on a list

A train is empty or has a first carriage followed by the rest. A list has the same two possibilities.

Example 33

Keep related data together

A coordinate card keeps an x-value beside a y-value. A structure packages named fields in the same way.

Example 34

Make your own type

A menu gives a fixed set of choices. An inductive type can name those choices directly.

Example 35

Different inputs stay different

A numbered ticket machine should never give the same new ticket to two different old tickets. An injective function has that property.

Example 36

Even plus even

Two even piles can each be split into matching halves. Put the piles together, and the halves combine too.

Example 37

Odd squared stays odd

An odd row has pairs plus one extra item. Squaring such a row still leaves one extra after pairing.

Example 38

Neighbors make an even product

Two neighboring whole numbers cannot both be odd. One has an even half-size witness.

Example 39

Primes never run out

A road with a sign beyond every distance cannot end at a last sign. Primes have a similar property.

Example 40

Capstone: reverse, then reverse again

Turn a row of cards around, then turn it around again. You get the original order.

Example 41

Reason from a missing badge

If P implies Q and Q is impossible, then P is impossible.

Example 42

Rule out one possibility

Given P or Q, ruling out P leaves Q.

Example 43

Keep a clue in both cases

P and (Q or R) implies (P and Q) or (P and R).

Example 44

Connect two two-way rules

If P is equivalent to Q and Q is equivalent to R, then P is equivalent to R.

Example 45

Test a claim with one witness

If at least one n fails a test, it is false that every n passes.

Example 46

Flip a switch twice

For every Boolean b, negating b twice returns b.

Example 47

Swap a pair and swap back

For every pair p, swapping its two entries twice gives p.

Example 48

Change the values, keep the count

For every function f and list xs, mapping f over xs preserves its length.

Example 49

Combine two passes through a list

Mapping f and then g gives the same list as mapping the combined rule x ↦ g (f x).

Example 50

Capstone: combine two scoreboards

The total of xs followed by ys equals the total of xs plus the total of ys.

Tactic

rfl

For our equality goals, close a goal by definitional equality.

Tactic

decide

Run a decision procedure and turn its successful result into a proof.

Tactic

exact

Supply a term whose type is the current goal.

Tactic

rw

Rewrite with named equalities or supported equivalences.

Tactic

intro

Introduce a function input, implication premise, or universally quantified variable.

Tactic

constructor

Apply a constructor for the goal’s type, leaving goals for its required arguments.

Tactic

cases

Split a value into all its constructor cases.

Tactic

left

Choose the left constructor of an or goal.

Tactic

right

Choose the right constructor of an or goal.

Tactic

apply

Use a theorem with a matching conclusion, leaving its missing premises as goals.

Tactic

specialize

Apply a local hypothesis to arguments and replace it with the result.

Tactic

exists

Supply an existence witness, then try to finish by reflexivity.

Tactic

induction

Follow constructors, obtaining hypotheses for smaller recursive inputs.

Tactic

change

Replace a goal with a definitionally equal expression.

Tactic

simp

Simplify using rewrite rules and the configured simplifier lemmas.

Tactic

omega

Prove supported arithmetic claims over Nat and Int.

Tactic

ring

Normalize polynomial expressions to prove supported identities.

Tactic

norm_num

Prove supported concrete numerical facts.

Tactic

linarith

Derive a linear arithmetic consequence of the available facts.

Tactic

calc

Write a chain of relations, with a justification for every link.

Tactic

have

Introduce a local proved fact inside a tactic proof.

Tactic

nlinarith

Use arithmetic reasoning with nonlinear preprocessing.

Tactic

unfold

Replace a named definition by its defining expression.

Tactic

obtain

Unpack a fact into named components, such as a witness and its property.

Tactic

refine

Supply a term with holes that become new goals.

Tactic

rcases

Split and name components using a case pattern.

Tactic

<;>

Run the right-hand tactic on every goal produced by the left-hand tactic.

Glossary

Append

Join a second list after the first, keeping the order of both.

Glossary

Base case

The starting case of an induction or recursive definition, such as zero or an empty list.

Glossary

Boolean

A value of type Bool: true or false. These are values, distinct from propositions and their proofs.

Glossary

Case

One possibility determined by the constructor that built a value. A proof by cases handles every possibility.

Glossary

Classical logic

Reasoning that includes excluded middle: every proposition holds or its negation holds.

Glossary

Commutative

An operation is commutative when swapping its two inputs leaves the result unchanged.

Glossary

Conditional

An expression that chooses one branch when a condition holds and another when it does not.

Glossary

Conjunction

An and statement. Its proof contains a proof of each component proposition.

Glossary

Constructor

A specified way to build a value of an inductive type. Nat has zero and successor constructors.

Glossary

Contradiction

A situation where the available assumptions produce a proof of False. A compiler error is not such a proof.

Glossary

Declaration

A command that introduces something into Lean, such as a definition or theorem.

Glossary

Decidable

A proposition is decidable when a procedure provides either a proof of it or a proof of its negation.

Glossary

Definition

A named expression. Lean checks its declared type and its defining value.

Glossary

Definitional equality

Equality that Lean recognizes using its computation rules, without requiring a separate equality proof.

Glossary

Disjunction

An inclusive or statement. A proof supplies one side; both sides may also be true.

Glossary

Divisibility

For natural numbers, a divides b when b equals a times some natural-number witness.

Glossary

Element

One item in a list or other collection. Every element in a Lean list has the same element type.

Glossary

Equality

A proposition identifying two expressions of the same type. It may need more than computation to prove.

Glossary

Equivalence

An if-and-only-if statement, proved by an implication in each direction.

Glossary

Evaluation

Computing the value described by an expression. Evaluation alone is different from stating a theorem.

Glossary

Even

A natural number is even when it is the sum of some natural number with itself. Zero is even.

Glossary

Existential quantifier

The phrase there exists. A proof supplies a witness and a proof of its required property.

Glossary

Expression

A piece of code that describes a term. Well-typed expressions have types.

Glossary

False

A proposition with no constructors. It is different from the Boolean value false.

Glossary

Factorial

The product of the positive whole numbers through n. By definition, the factorial of zero is one.

Glossary

Fibonacci sequence

The sequence beginning with zero and one, in which each later value is the sum of the preceding two values.

Glossary

Field of a structure

A named component of a structure record. This use of field differs from the algebraic meaning of a number field.

Glossary

Function

A rule taking an input of a specified type and producing an output of a specified type.

Glossary

Goal

The type or proposition for which a proof still needs to supply a term.

Glossary

Hypothesis

A named assumption or available fact in the local proof context.

Glossary

Implication

A proposition saying that a proof of a premise can be turned into a proof of a conclusion.

Glossary

Induction

A proof method following the constructors of an inductive type, with hypotheses for recursive constructor arguments.

Glossary

Induction hypothesis

The claim already available for the smaller recursive input in an induction case.

Glossary

Inductive type

A type specified by constructors that build its values, sometimes from smaller values of the same type.

Glossary

Instance

A registered implementation that Lean can find automatically. A Decidable instance supplies a decision procedure for a proposition.

Glossary

Injective

A function is injective when equal outputs force equal inputs. Different inputs cannot share an output.

Glossary

Integer

A whole number, including zero, positive whole numbers, and negative whole numbers. Lean’s Int type represents integers.

Glossary

Lemma

A theorem used as a supporting fact. Lean checks lemmas and theorems by the same proof rules.

Glossary

Linear arithmetic

Arithmetic with sums, order comparisons, and fixed-number multiples of unknowns. General products of unknowns are nonlinear.

Glossary

List

An ordered sequence of elements of a single type. A list is empty or has a head and a tail.

Glossary

Mathlib

A community-maintained mathematical library for Lean, containing definitions, checked theorems, and tactics.

Glossary

Module

A source-file unit that controls imported and exported declarations. This course pins the module behavior of Lean 4.36.0.

Glossary

Natural number

Zero or a positive whole number. Lean’s Nat type does not contain negative integers or fractions.

Glossary

Negation

A not statement. In Lean, a proof of not P turns a proof of P into a proof of False.

Glossary

Odd

A natural number of the form twice a natural number plus one.

Glossary

Parameter

A named input used while describing a function, definition, or theorem.

Glossary

Pattern matching

Inspecting a value’s constructor and providing a result for each possible constructor pattern.

Glossary

Polynomial

An expression formed from variables and coefficients using addition, multiplication, and natural-number powers.

Glossary

Premise

The assumption on the left side of an implication. A proof of the implication must work for any proof of this assumption.

Glossary

Prime

A natural number at least two whose only positive divisors are one and itself.

Glossary

Prime factor

A prime number that divides another natural number. The least prime factor is the smallest such prime.

Glossary

Proof

A term whose type is the proposition being established. Lean’s kernel checks that term against its type.

Glossary

Proposition

A statement that can have a proof. Propositions have type Prop in Lean.

Glossary

Rational number

A number expressible as an integer divided by a nonzero integer. Lean’s rational arithmetic is exact.

Glossary

Real number

A number on the usual continuous number line. Real numbers include rational and irrational numbers.

Glossary

Recursion

Defining a function using its own values at smaller inputs. Lean checks that ordinary recursive definitions terminate.

Glossary

Remainder

What is left after whole-number division. For a positive divisor, a natural-number remainder is smaller than the divisor.

Glossary

Rewrite

Replace an occurrence using a proved equality or a supported logical equivalence.

Glossary

sorry

A placeholder for unfinished work. Lean warns about it. It is forbidden in this course’s finished examples and solutions.

Glossary

Square

The product of a number with itself. Every real square is nonnegative.

Glossary

String

Lean’s type for text values. String literals are surrounded by double quotation marks.

Glossary

Structure

A record type built from a collection of named fields and a constructor.

Glossary

Tactic

A command that constructs proof terms by transforming or solving goals. Its result is still checked by Lean.

Glossary

Term

A value or expression inhabiting a type. Functions, data values, and proofs can all be terms.

Glossary

Termination

A computation eventually reaching a result. Lean checks that the recursive calls in these examples decrease.

Glossary

Theorem

A named proposition together with a checked proof. A theorem may use explicitly stated assumptions.

Glossary

Transitive

A relation is transitive when a relation from a to b and from b to c imply the relation from a to c.

Glossary

Type

A classification of terms. It tells Lean what kind of term is required in a position.

Glossary

Unbounded above

Having an element beyond every proposed upper limit. The prime theorem lets you choose a larger bound each time.

Glossary

Universal quantifier

The phrase for all. A proof must work for every input of the indicated type.

Glossary

Variable

A named value that can vary over its declared type. An arbitrary variable cannot be assumed to be a particular number.

Glossary

Witness

The specific value supplied by an existence proof, together with a proof of its property.

Glossary

Inequality

An order comparison such as less than or less than or equal to.