Three options, in increasing order of effort. Start at the top. Genuinely: most people should do option 1 and stop.
None of this is required. Installing Lean, or running it anywhere at all outside the two Lean class meetings, is entirely up to you and is never graded.
Two things to do before Wednesday, October 28.
1. Make a free GitHub account if you do not already have one: github.com/signup. Two minutes, no cost, any email. You need one to open the Lean package in a browser tab, which is what we will be doing in the room, and the sign-up is not something to be doing for the first time during class.
2. Bring a laptop that day if you have one, and use Chrome or Edge rather than Safari or Firefox. If you do not have a laptop, come anyway and share with a neighbour — working in pairs is better anyway — but the more laptops in the room, the better the day goes.
There is nothing to install beforehand. Option 2 below is what we will use in class, and you can read it ahead of time if you like, but you do not have to.
adam.math.hhu.de/#/g/djvelleman/stg4
Open the link. That is the setup. No account, no download, no install, no configuration. It works on a phone, though a laptop is much nicer.
The game is by Velleman, the same person who wrote our textbook, and its eight worlds are Chapter 3:
Start with Subset World. Work left to right. The game will not let you into a world until you have the tools for it.
Your progress lives in your browser, and only in your browser. The game saves to local storage on the machine you are using. Clearing cookies or site data will delete it, and it does not follow you to another computer. There is a download-your-progress option in the menu if you care. Mostly, do not care — if you lose it, replaying is fast and is not a waste of time.
A dialect warning, so it does not surprise you later. The Set Theory Game's tactics are close to, but not identical to, the ones in Velleman's book. The game is a warm-up for the ideas, not a syntax reference for the package. Do not spend energy memorizing exact spellings there.
This runs the actual HTPI Lean Package, with the real numbered exercise files, on a computer that Microsoft rents you for free, displayed in your browser. It is what I would use if I did not want to install anything.
The one thing you must not skip: stop your codespace when you finish.
The package's configuration file asks GitHub for a machine with 4 CPUs and 8 GB of memory. A free GitHub account includes 120 core-hours per month. Core-hours, not hours. A 4-CPU machine consumes them at four times the wall clock, so your free tier is really about 30 hours of sitting in front of it per month.
And a codespace does not stop because you closed the tab. It keeps running, and keeps billing, until it idles out or you stop it. Close the laptop lid on Tuesday and you can burn the month by Thursday without touching a key. There is no warning and no error message; things simply stop working and you will not know why.
When you are done for the day: go to github.com/codespaces, find your codespace in the list, click the … menu on its row, and choose Stop codespace. Do this every single time. Make it a reflex. Thirty hours is plenty for this course if you stop it, and nowhere near enough if you do not.
lake exe cache get! and lake build, which download and compile
the library. This takes several minutes — possibly ten. It is not stuck. Let it
finish before you touch anything; a half-built library produces error messages that
make no sense.
Chap3Ex.lean. This is the file whose theorems are numbered to match the
exercises in How To Prove It.
Ctrl-Shift-P (Cmd-Shift-P on a Mac), type
Lean 4: Infoview: Display Goal, and press Enter. Without this pane you
are working blind. It is the entire point.
You type \ followed by a short name, then space or tab. The Lean extension
replaces it.
\to or \r → \and or \an ∧
\forall or \all ∀ \or ∨
\exists or \ex ∃ \not or \n ¬
\in ∈ \iff or \lr ↔
\notin ∉ \sub ⊆
\cup ∪ \cap ∩
\bigcup ⋃₀ \bigcap ⋂₀
\comp ∘ \powerset 𝒫
\ne ≠ \le ≤Abbreviations follow the Lean 4 VS Code extension's standard table; the book's appendix has a "Typing Symbols" section with the full list.
If you forget one, hover the mouse over a symbol already on the screen and the tooltip tells you how to type it.
Nicer if you are going to do this more than twice: faster, offline, no quota, and your files are yours. Budget half an hour, most of it waiting.
lean4, install the one published by leanprover. When it starts, it
will offer to install elan, the Lean version manager, for you. Say yes.
(elan is to Lean what pyenv is to Python: it reads the
lean-toolchain file in a project and fetches exactly that compiler version.
You never pick a version by hand.)
git clone https://github.com/djvelleman/HTPILeanPackage.gitlakefile.toml. Not a single file. Lean needs the project root to find the
library.
lake exe cache get!
lake buildChap3Ex.lean and check that the Infoview pane appears when your
cursor is inside a proof.
Official instructions, if you want the canonical source: lean-lang.org quickstart and leanprover-community.github.io/get_started.
Do not use Gitpod.
You will find instructions online — including in the repository's own leftover config files, and in the README of Heather Macbeth's math2001, which is otherwise an excellent course — telling you to open a Lean project in Gitpod. These are stale. Gitpod Classic has been sunset. Ignore every Gitpod button you see. Use Codespaces or install locally.
This is the single largest source of misery for beginners, so it goes first. Lean 4 uses indentation to decide what belongs to what. Two spaces of indentation inside a proof, consistently. If you paste code and the indentation shifts, the proof breaks in a way whose error message will not mention indentation.
In particular, the bullet · (typed \.) opens a subproof, and
everything belonging to that subproof must be indented further than the bullet:
apply And.intro
· -- Proof that x ∈ B.
show x ∈ B from h1 h3.left
done
· -- Proof that x ∉ D.
contradict h2 with h4
apply Exists.intro x
show x ∈ C ∩ D from And.intro h3.right h4
done
doneVerbatim excerpt from Like_Example_3_4_1 in HTPILib/Chap3.lean (Velleman).
Note also that done appears once at the end of each bullet's block and once
more at the end of the whole proof. done means "I claim there is nothing left
to prove here." If Lean disagrees it will tell you, and that is useful information rather
than an annoyance.
Lean's errors are written for people who already know Lean. Three rules make them usable:
unknown identifier means you referred to a hypothesis name that does
not exist — usually a typo, or a name that a previous tactic consumed or renamed.
Look at the pane: it lists every name you actually have.
A specific one worth naming: if every line is red and the errors mention
assume, fix, or obtain being unknown, you are not
in the HTPI package. Either the build did not finish, or you opened a lone file instead of
the project folder, or you are on one of the public web editors described below.
live.lean-lang.org and lean.math.hhu.de cannot run these exercises.
Both ship Lean plus Mathlib. Neither has HTPILib, which is the library
Velleman wrote for the book and where assume, fix,
obtain, define, by_induc and the rest are defined.
Paste an exercise into either one and you will get a wall of "unknown tactic" errors that
have nothing to do with your proof. There is no way around this and no setting to change.
If you want the numbered exercises you need Codespaces or a local install. Full stop.
Codespaces misbehaves in Safari and Firefox — typically the editor loads but the Infoview never appears, or keyboard shortcuts do nothing. Use Chrome or Edge. This is not a preference, it is what the tooling supports.
This is a good place to be and it means the tool is working. In order:
And one thing not to do: do not have an AI write the proof for you and then read the green checkmark as evidence you learned something. It will work, instantly, every time, and you will get nothing out of it. That is why the badge is a conversation and not a file.