Chapter 3 · Numbers and induction

Automation you can check

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

Step 1 of 22 · Concept

Automation builds proofs too

In this lesson three tactics do arithmetic for you, and you see why their proofs are still checked.

tacticcloses
decidea yes-or-no fact about given numbers
omegalinear arithmetic on unknown numbers
simpa goal that library facts rewrite until it is true
example (a b : Nat) (h : a < b) : a + 1 ≤ b := by omega
example (n : Nat) : n / 2 ≤ n := by omega
example (a : Nat) (h : a ≠ 0) : a - 1 + 1 = a := by omega
example (a b : Nat) : a * b = b * a := by omega
theorem o1 (f : Nat → Nat) (h : ∀ n, f n ≤ n + 1) :
    f 3 < 5 := by
  sorry
theorem o2 (a b : Nat) (h1 : a ≤ b) (h2 : b ≤ a + 2) :
    b - a ≤ 2 := by
  sorry
theorem o3 (n : Nat) : 2 * n % 2 = 0 := by
  sorry
example (a b : Nat) (h : a = b) : a * 1 + 0 = b := by
  simp [h]
example (a b : Nat) (h : a = b) : a + 0 = b := by
  simp only [h, Nat.add_zero]
theorem from_h (a b : Nat) (h : a * 1 + 0 = b) : a = b := by
  sorry
theorem t_decide : 10 < 20 := by decide
theorem t_omega (a b : Nat) (h : a < b) : a + 1 ≤ b := by omega
theorem t_simp (a : Nat) : a * 1 + 0 = a := by simp
#print axioms t_decide
#print axioms t_omega
#print axioms t_simp
theorem big : 2 ^ 20 = 1048576 := by native_decide
#print axioms big
theorem t1 : 12 * 12 = 144 := by
  sorry
theorem t2 (a b : Nat) (h : a + 2 = b) : a < b := by
  sorry
theorem t3 (f : Nat → Nat) (a : Nat) :
    f (a * 1 + 0) = f a := by
  sorry
theorem below_five : ∀ n, n < 5 → n * n < 25 := by
  sorry
Terminal
Step 1 of 9See omega work

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)