Chapter 2 · Logic

For all, there exists

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

Step 1 of 22 · Concept

A property is a function to propositions

In this lesson you prove facts about every number, and about some number.

A property of numbers turns each number into a proposition. (P : Nat → Prop) names one, as (p : Prop) named a proposition in lesson 5. P 3 is a call (lesson 3), and it is a proposition.

fun n => n < 5 is a property: given 3, it gives 3 < 5.

theorem add_zero_all : ∀ n : Nat, n + 0 = n := by
  intro n
  rfl
theorem at_two (P Q : Nat → Prop) (h : ∀ n, P n → Q n)
    (hp : P 2) : Q 2 := by
  specialize h 2
  exact h hp
theorem at_three (P : Nat → Prop) (h : ∀ n, P n) : P 3 := by
  exact h
theorem at_seven (P Q : Nat → Prop) (h1 : ∀ n, P n → Q n)
    (h2 : ∀ n, P n) : Q 7 := by
  sorry
theorem has_three : ∃ n : Nat, n + 2 = 5 := by
  exists 3
theorem has_three' : ∃ n : Nat, n + 2 = 5 := ⟨3, rfl⟩
theorem some_q (P Q : Nat → Prop)
    (h : ∃ n, P n ∧ Q n) : ∃ n, Q n := by
  obtain ⟨n, hn⟩ := h
  exists n
  exact hn.2
theorem pass_on (P Q : Nat → Prop) (h : ∃ n, P n) :
    ∃ n, P n ∨ Q n := by
  sorry
theorem next_one : ∀ n : Nat, ∃ m : Nat, m = n + 1 := by
  sorry
theorem all_imp (P Q : Nat → Prop) : (∀ n, P n → Q n) →
    (∀ n, P n) → ∀ n, Q n := by
  sorry
theorem two_numbers : ∃ a b : Nat, a + b = 5 ∧ a = 2 := by
  sorry
Terminal
Step 1 of 10See 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)