Chapter 1 · Foundations

Hello, Lean

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

Step 1 of 17 · Concept

Lean checks what you claim

Lean is a programming language and a proof checker. You write a claim, such as 2 + 2 = 4, and a proof of it. Lean checks the proof: it accepts the claim, or it says why not.

In this lesson you will:

  • check your first Lean file,
  • state facts and have Lean prove them,
  • read what is left to prove.
#eval 2 + 3
theorem two_plus_two : 2 + 2 = 4 := by rfl
theorem two_and_two : 2 + 2 = 5 := by rfl
-- ten_plus_five : 10 + 5 = 15
-- three_fours : 3 * 4 = 12
-- seven_eights : 7 * 8 = 56
theorem ten_plus_five : 10 + 5 = 15 := by
  sorry
#eval 3 < 5
theorem small : 3 < 5 := by decide
-- six_sevens : 6 * 7 = 42
-- twelve_thirty : 12 + 30 = 42
-- forty_less : 40 < 42
-- and print 6 * 7 with #eval
-- not_five : 2 + 2 ≠ 5
Terminal
Step 1 of 6Your first file

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)