Chapter 3 · Numbers and induction

Chains of steps

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

Step 1 of 19 · Concept

calc writes a proof as a chain

In this lesson you prove a statement as a chain of small steps. You also prove ≤ and <.

calc writes the chain, one step per line, each with its own proof after :=:

theorem chain (a b : Nat) (h : a = b) : a + 0 = b := by
  calc a + 0 = a := by rw [Nat.add_zero]
    _ = b := h

Each _ stands for the right side of the step before. The first left side and the last right side must be the goal's.

theorem chain (a b : Nat) (h : a = b) : a + 0 = b := by
  calc a + 0 = a := by rw [Nat.add_zero]
    _ = b := h
theorem calc_two (a b c : Nat) (h1 : a = b) (h2 : b = c + 0) :
    a = c := by
  sorry
#check Nat.le_refl
#check Nat.le_succ
#check Nat.le_add_right
#check Nat.le_trans
example (n : Nat) : n ≤ n + 1 := Nat.le_succ n
example (a b : Nat) (h : a ≤ b) : a ≤ b + 5 := Nat.le_trans h
    (Nat.le_add_right b 5)
example (n : Nat) : n ≤ n := Nat.le_refl n
theorem le_three (a b c : Nat) (h1 : a ≤ b) (h2 : b ≤ c) :
    a ≤ c := by
  sorry
theorem chain_le (a b c : Nat) (h1 : a = b + 0) (h2 : b ≤ c) :
    a ≤ c + 1 := by
  sorry
example (a b c : Nat) (h1 : a ≤ b) (h2 : b ≤ c) :
    a ≤ c + 1 := by
  have h3 : a ≤ c := Nat.le_trans h1 h2
  exact Nat.le_trans h3 (Nat.le_succ c)
example (x : Nat) (h : 4 ≤ x) : 3 < x := by
  show 4 ≤ x
  exact h
theorem bound (a b c : Nat) (h1 : a < b) (h2 : b = c) :
    a + 1 ≤ c + 5 := by
  sorry
theorem lt_chain (a b c : Nat) (h1 : a < b) (h2 : b ≤ c) :
    a < c + 1 := by
  sorry
Terminal
Step 1 of 8See the chain checked

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)