Get started
From nothing to your first proof
Three steps, each a command you paste into a terminal. Nothing here assumes you have used Lean before.
-
Install flash
Open a terminal and paste this line:
curl -fsSL https://r7n.solutions/install.sh | sh… lens-flash 9.0.0 is installed. Next: open a new terminal (so it finds flash), then run: flash startIt takes a few seconds. It downloads Lens Flash 9.0.0 from this site, checks its SHA-256, installs it, and puts the
flashcommand on your PATH. Then do what its last line says: open a new terminal, so the command is found.You can read the installer before you run it. If you prefer to install by hand, the Download page has the files and the steps.
-
Set up
In the new terminal, run:
flash startflash start: setting up - Lean, installed with elan, Lean's installer (into /home/you/.elan; about 3 GB) - a new Lean project with Mathlib in my-proofs - Mathlib's prebuilt files, downloaded (about 7 GB on disk; ten minutes or so on a good connection) - flash for the project, and a first check of its example file Continue? [Y/n]
It shows its plan first and asks once, before it installs or downloads anything. Press Enter to go ahead. What it sets up depends on what you already have:
- If Lean is not installed, it installs it with elan, Lean’s own installer.
- If you run it inside a Lean project, it sets flash up there.
- If not, it makes a new project,
my-proofs, with Mathlib, the library most Lean work uses. For plain Lean without Mathlib, runflash start --leaninstead. - It builds the project, downloading Mathlib’s prebuilt files once, then sets flash up and checks the example file it wrote.
As it works, it says which step it is on. Mathlib takes longest, and for its first few minutes there is little to see:
flash start: installing Lean (elan) … flash start: downloading Lean (leanprover/lean4:v4.35.0; about 600 MB, once) … flash start: downloading Mathlib: first its source, from GitHub (a few minutes, with little to show), then its prebuilt files (about 9,000; a file that fails is tried again by itself, so a transfer error on the way is no cause to stop) … flash start: building the project (lake build) …
When it is done, it says so and tells you what to run next:
flash start: ready. Your project is /home/you/my-proofs Next: cd my-proofs flash prove MyProofs/Basic.lean prove its sorry (--write puts the proof in the file) Edit with VS Code and its Lean 4 extension, or any editor; flash help shows the rest.
-
Your first proof
The project comes with an example,
MyProofs/Basic.lean. Its theorem has asorry, Lean’s placeholder for a missing proof, where the proof should be:MyProofs/Basic.lean import Mathlib /-! Your first file. `flash prove MyProofs/Basic.lean` finds a proof for the sorry below and shows it; add --write to put it in the file. -/ theorem two_mul_le_sq_add_sq (a b : ℝ) : 2 * a * b ≤ a ^ 2 + b ^ 2 := by sorry
Go into the project and ask flash to prove it:
cd my-proofsflash prove MyProofs/Basic.leanproved MyProofs/Basic.lean two_mul_le_sq_add_sq: 2 Lean checks, … s MyProofs/Basic.lean:7:2: proof for this sorry (checked; --write saves it): apply two_mul_le_add_pow_twoflash proved it, and Lean checked it, before showing it to you. To put it into the file in place of the
sorry, run the same with--write:flash prove MyProofs/Basic.lean --writeMyProofs/Basic.lean, as written theorem two_mul_le_sq_add_sq (a b : ℝ) : 2 * a * b ≤ a ^ 2 + b ^ 2 := by apply two_mul_le_add_pow_two
Write your own theorems the same way, with
sorrywhere a proof is missing, and let flash look for them. The docs → show how to check files as you write, read every result, and work in a larger project.To type the symbols in VS Code with the Lean 4 extension:
\natgives ℕ,\Rgives ℝ,\legives ≤, and\midgives ∣, “divides” (the plain|is not divides).
If something goes wrong
Each of these is a line you might see, and what to do about it.
flash: command not found- The terminal was opened before the install. Open a new one; the installer says so in its last line.
flash: nothing is set up here yet: run flash start to make a project with Mathlib, or flash init in a Lean project you have- A command was run outside a project flash knows. If you have not run
flash startyet, run it. If you have, go into the project it made first:cd my-proofs. flash start: Downloading Mathlib did not finish (its messages are above).- A step stopped part way; the name changes with the step (Installing Lean, Downloading Lean, Downloading Mathlib, Building the project, Setting flash up). Run
flash startagain: it continues from where it stopped. If it stops at the same place, the last lines above it say why. While Mathlib downloads, a file that fails is tried again by itself (three tries in all), and between tries it sayssome of Mathlib's files did not download; trying again (2 of 3). It downloads elan, Lean's installer, from raw.githubusercontent.com and github.com: if the lines above name a connection or a proxy, that is where it stopped.- This follows
Installing Lean did not finish: elan could not be downloaded. Check your connection, or your proxy if you are behind one, then runflash startagain. flash start: nothing was changed. Without a terminal to ask at, run flash start --yes- It was run where it cannot ask you, from a script for example.
flash start --yesgoes ahead without asking. flash start: cannot make a project in / (you cannot write there). Go to a folder of yours first (cd ~), or name one: flash start ~/my-proofsflash startmakes its project in the folder you are in, and you cannot write in this one. Runcd ~first, or name a folder as it says.Note: this disk has 6.2 GB free, and this needs about 11 GB.- Not an error, but a warning under the plan: Lean and Mathlib will not fit. Free some space before you continue, or set up plain Lean with
flash start --lean. flash init: /home/you is not a Lean project (it has no lakefile).flash initsets up a project you already have, so it has to run in that project’s folder. To make a new project with Mathlib, runflash startinstead.lens-flash install: lens-flash runs on Linux (x86_64), including WSL on Windows; this machine is Darwin arm64- Lens Flash runs on Linux only. On Windows, install WSL with Ubuntu, and run the installer inside it.
lens-flash install: the download is damaged (its SHA-256 does not match); run this again. If it says this again, the copy at https://r7n.solutions/download is damaged: nothing was installed- The download was cut short or damaged on the way, and nothing was installed. Run the same line again. If the same message comes back, the file on this site is damaged, not your copy: try again later.
Rarer messages, about a folder in the way, a project that is not ready, or the installer, are in Setting up a project →