Chapter 2 · Logic

If, then

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

Step 1 of 21 · Concept

p and q can be any propositions

Until now every goal computed, like 2 + 2 = 4. In this lesson you prove facts about any propositions with exact, intro and apply. You read the goal after each one.

A proposition is a statement: (p q : Prop) names any two. A hypothesis (hp : p) is a proof of p you are given. The goal panel lists the hypotheses, then ⊢ and the goal.

theorem same (p : Prop) (hp : p) : p := by
  exact hp
theorem give_both (p q r : Prop) (hp : p) (hq : q)
    (h : p → q → r) : r := by
  exact h hp
theorem backwards (p q : Prop) (hp : p) (hpq : p → q) : q := by
  apply hpq
  exact hp
theorem first' (p q : Prop) : p → q → p := by
  intro hp hq
  exact hp
theorem two_back (p q r : Prop) (hp : p) (hpq : p → q)
    (hqr : q → r) : r := by
  sorry
theorem swap_args (p q r : Prop) : (p → q → r) → q → p → r := by
  sorry
theorem chain (p q r : Prop) : (p → q) → (q → r) → p → r := by
  sorry
theorem chain' (p q r : Prop) : (p → q) → (q → r) → p → r :=
  sorry
Terminal
Step 1 of 7See it 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)