Chapter 1 · Foundations

Inside the checker

You are reading the whole lesson on one page. Back to one step at a time

Step 1 of 19 · Concept

Lean reads your file from the top

This lesson shows what reads your file, which part you must trust, and what a proof is.

Lean reads a file one declaration at a time, from the top: a theorem, an #eval, a #check. The last two are really commands; this lesson calls them declarations for short. A name exists only after its declaration.

Line 2 proves again with := four, the theorem of line 1. The step A proof is a term of its statement's type says why.

#check 2 + 2 = 5
theorem four : 2 + 2 = 4 := by rfl
theorem again : 2 + 2 = 4 := four
#check again
#print four
theorem four : 2 + 2 = 4 := by rfl
theorem later : 3 + 3 = 6 := by sorry
#print axioms four
#print axioms later
theorem again : 3 + 3 = 6 := six
theorem six : 3 + 3 = 6 := by
  sorry
#print again
#print axioms again
Terminal
Step 1 of 4See it run

Keyboard shortcuts

The step

ContinueEnter
Previous / next stepAlt+[ · Alt+]
Move along the steps bar← → Home End, then Enter
From a quiz's title to its answers↓
Skip to the stepTab, then Enter (first on the page)
Course outlineAlt+O
These shortcuts?

The workspace

Run the stepCtrl+Enter (⌘↵ on a Mac)
Lesson → editor → consoleF6 (Shift+F6 back)
Output ↔ TerminalCtrl+`
Focus the editorCtrl+. (⌘. on a Mac)
Hide or show the lessonAlt+L
Restore, close a messageEsc (outside the editor and the terminal)

The editor

Leave the editorF6 (Shift+F6 back); or Ctrl+M (⌃⇧M on a Mac), then Tab moves the focus (not in the vim mode)
Open a file by nameCtrl+P (⌘P on a Mac)
All commandsCtrl+Shift+P (⌘⇧P on a Mac) or F1
Go to a lineCtrl+G (⌃G on a Mac)
Show or hide the filesCtrl+B (⌘B on a Mac)
Previous / next file tabCtrl+Shift+[ · Ctrl+Shift+] (⌘⇧[ · ⌘⇧] on a Mac)
The file tabs← → Home End on a tab; Delete closes it
Save the files nowCtrl+S (⌘S on a Mac)
Go to a symbol in the fileCtrl+Shift+O (⌘⇧O on a Mac)
Go to the definitionF12
Format the fileCtrl+Shift+F (⌘⇧F on a Mac), or Shift+Alt+F
Go back / forward after a jumpAlt+← · Alt+→ (⌃- · ⌃⇧- on a Mac)