Skip to content

Where to Find Official Lean 4 Resources ​

Halfway through learning, when you want to look something up, the most common frustration isn't "no materials" but not knowing which website to go to. Official Lean resources are spread across several places: the language itself, the math library, the online playground, the search engine for finding theorems—each has its own URL.

First, say what you want to do, and we'll tell you exactly where to go:

Look it upI want to...

Click one to see.

What You'll Be Able to Do After This Lesson ​

  • Know which official website to check when you run into problems
  • Use lake new to create a new Lean project and build it successfully
  • Know how to create a project that depends on Mathlib

Official Websites at a Glance ​

All of these are listed in the navigation and footer of lean-lang.org (descriptions taken from each site's own introduction):

NameURLWhat it's for
Installlean-lang.org/installOfficial installation instructions; recommends VS Code with the Lean 4 extension
Learnlean-lang.org/learnOfficial learning entry point
Language Referencelean-lang.org/doc/reference/latest/The authoritative description of syntax and semantics
Lean APIlean-lang.org/doc/api/Documentation for every definition in the standard library
Playgroundlive.lean-lang.orgWrite Lean directly in the browser
Mathlibleanprover-community.github.ioThe community-maintained math library
Reservoirreservoir.lean-lang.orgLake's package registry
Loogleloogle.lean-lang.orgSearch definitions and theorems in Lean and Mathlib
FAQlean-lang.org/faqOfficial frequently asked questions
  • I've bookmarked this table, or memorized the URLs of the Playground and the language reference

Creating a New Lean Project ​

The official guidance is: all Lean code should live inside a Lean project. A project is a folder containing a git repository, a lakefile.lean or lakefile.toml describing dependencies, and other necessary files. Generate one with a single lake command:

sh
lake new MyLeanProject
cd MyLeanProject && lake build

You should see: the last line is Build completed successfully. The folder contains files such as lakefile.toml, lean-toolchain, and Main.lean. We actually ran these two commands on Lean 4.35.0.

Then open this folder with VS Code (type code . in the terminal), and choose "Trust authors" when prompted.

Exercise: create a new projectOnly recognizes commands from this lesson, won't actually run them

$lake new MyLeanProject

$cd MyLeanProject && lake build

Build completed successfully (8 jobs).
  • My project lake build passed

Creating a Project That Depends on Mathlib ​

To use the math library, choose the Mathlib template directly when creating a new project (the command from the official manual installation instructions):

sh
lake +leanprover-community/mathlib4:lean-toolchain new MyMathlibProject math

The first time you create this kind of project, Mathlib has to be downloaded, so it takes quite a while.

After cloning someone else's project that depends on Mathlib, first run this command in the project folder to download the prebuilt cache and avoid compiling from scratch yourself:

sh
lake exe cache get

To upgrade Mathlib in a project, the official approach is:

sh
curl -L https://raw.githubusercontent.com/leanprover-community/mathlib4/master/lean-toolchain -o lean-toolchain
lake update

After upgrading, it's recommended to check again that all files still compile:

sh
lake exe mk_all && lake build
  • I know which command to use for creating a Mathlib project and for downloading the cache after cloning

FAQ ​

Where is the official Lean 4 documentation? ​

For the language itself, see the language reference at lean-lang.org/doc/reference/latest/; to look up a specific function, see the API docs at lean-lang.org/doc/api/. The entry point for systematic learning is lean-lang.org/learn.

How do I install Lean 4 on Windows? ​

The officially recommended setup is VS Code with the Lean 4 extension, which walks you through the remaining setup. If you only want the command line, you can install elan in PowerShell; the command is in Installing Lean 4.

Can I try Lean 4 online without installing anything? ​

Yes. The official online version is at live.lean-lang.org. It's good for trying things out before installing and for running small snippets; for big projects you should still install locally.

What if it says lake is an unknown command? ​

The official instructions say to first run source ~/.profile or source ~/.bash_profile so the newly installed command takes effect, then retry.

Checkpoints ​

  • I know where the language reference, API docs, Playground, and Mathlib each are
  • I created a project with lake new and lake build passed
  • I know how to create a project that depends on Mathlib and which command to run first after cloning

Next Section ​

With tools and resources ready, start learning reasoning: If... Then....

gaodong.aiAboutPrivacyContact

Independent tutorials, not affiliated with any product mentioned. Product names and trademarks belong to their owners. Check official pages for prices and policies.