This document explains how to get started with Lean and mathlib.
If you get stuck, please come to the chat room to ask for assistance. If you prefer, you can watch a short video tutorial
We'll need to set up Lean, an editor that knows about Lean, and mathlib (the standard library).
Rather than installing Lean directly, we'll install a small program called elan which
automatically provides the correct version of Lean on a per-project basis. This is recommended for
all users.
-
We'll need a terminal, along with some basic prerequisites.
We recommend that you use
git bashand notmsys2, since installing the supporting tools (below) causes issues inmsys2.Install Git for Windows (you can accept all default answers during installation). Then open a terminal by typing
git bashin the Windows search bar. -
In terminal, run the command
curl https://raw.githubusercontent.com/Kha/elan/master/elan-init.sh -sSf | shand hit enter when a question is asked. To make sure the terminal will find the installed files, run
echo 'PATH="$HOME/.elan/bin:$PATH"' >> $HOME/.profile.
Then close and reopen Git Bash.
In order to use mathlib supporting tools, you need to get python first.
- Download the latest version of python here.
- Run the downloaded file (
python-3.x.x.exe) - Check
Add Python 3.x to PATH. - Choose the default installation.
- Navigate to the folder where Python was installed. A reliable way to do this is to search for
pythonin the Start Menu -> right clickPython 3.x (xx-bit)-> open file location -> right clickPython 3.x (xx-bit)-> open file location. The default location is something likeC:\Users\<user>\AppData\Local\Programs\Python\Python37-32. - Copy the file
python.exetopython3.exe. - Open Git Bash (type
git bashin the Start Menu) - Test whether everything is working by typing
python3 --versionandpip3 --version. If both commands give a short output and no error, everything is set up correctly. - If
pip3 --versiondoesn't give any output, run the commandpython3 -m pip install --upgrade pip, which should fix it.
- Run
git config --global core.autocrlf inputin Git Bash- Alternatively, you can set it to
false. If it is set totrue, you might run into issues when runningupdate-mathliborcache-olean --fetch.
- Alternatively, you can set it to
Then, at a terminal, run the command
curl https://raw.githubusercontent.com/leanprover-community/mathlib-tools/master/scripts/remote-install-update-mathlib.sh -sSf | bashRun source ~/.profile or close and reopen Git Bash.
There are two Lean-aware editors, VS Code and emacs. This document describes using VS Code (for emacs, look at https://github.com/leanprover/lean-mode).
- Install VS Code.
- Launch VS Code.
- Click on the extension icon
(or
in older versions) in the side bar on the left edge of
the screen (or press ShiftCtrlX) and search for leanprover. - Click "install" (In old versions of VSCode, you might need to click "reload" afterwards)
- Setup the default shell:
- If you're using
git bash, pressctrl-shift-pto open the command palette, and typeSelect Default Shell, then selectgit bashfrom the menu. - If you're using
msys2, pressctrl-commaagain to open the settings, and add two settings:
"terminal.integrated.shell.windows": "C:\\msys64\\usr\\bin\\bash.exe",
"terminal.integrated.shellArgs.windows": ["--login", "-i"]
- Verify Lean is working, for example by saving a file
test.leanand entering#eval 1+1. A green line should appear underneath#eval 1+1, and hovering the mouse over it you should see2displayed.
You can now read instructions about creating and working on Lean projects