Lean is a programming language and a theorem prover. In this guide we
will use it mainly as a theorem prover: a system in which mathematical
statements and proofs are written in a language precise enough for a
computer to check them. If Lean accepts a proof, then the proof follows
from the definitions, lemmas, and axioms that were used to write it.
When we say that we are going to install Lean, we mean that we are
going to put the Lean tools on our own computer. This includes the
program that checks Lean files, the tools that manage Lean projects,
and the editor integration that lets us write Lean code comfortably.
After installation, Lean will be available locally, just like any other
program installed on the system.
There are also online ways to try Lean in a
browser. They are useful for testing
small examples, following a tutorial, or getting a first impression
without installing anything. They are not enough for our purposes,
however. We are going to use LLMs to write and modify Lean code
inside real projects. That workflow has to happen locally, on the
same machine where the project lives.
The official installation instructions can be found
here. They consist of three simple
steps. Even though they are quite straightforward, let us make some
further comments on them to better understand what is going on.
Install VS Code. Clicking the button Install VS Code will
redirect you to the official VS Code download
page. This website will try its best
to show you, by default, the download button corresponding to your
operating system (in my case, GNU/Linux). You have to download and
then install this program, following the standard procedure of your
operating system (usually this means just downloading the file and
clicking on it to start the installer).
Install the extension. Once VS Code is installed, we have to install
the Lean 4 extension, to have all the necessary tools to write Lean 4
available in VS Code. For this we just have to click the button Get
the extension. If we have VS Code properly installed, this will open
the program and show us the Lean 4 extension homepage. We just have
to click Install. Now VS Code is ready to handle Lean.
Complete the extension setup. Now we are going to truly install
Lean. As before, click the Open setup guide button. This will open a
VS Code guide that will walk you through the necessary VS Code setup.
The important point of the setup is Install Lean. Go there and
click Click to install. If everything goes smoothly, this should
install Lean on your system.
Most people need to reboot their computers at this point for Lean to
actually work.
At this point, we could start our own Lean project. Our goal, however,
is to contribute to an existing library to add the necessary
infrastructure (i.e., preliminary results) to be able to formalize the
theorems in our own research. Let's find out what such a library is,
and how to contribute to it.