<<

Predicate Logic: Peano

Alice Gao

Lecture 20

CS 245 Logic and Computation Fall 2019 1 / 22 Outline

The Learning Goals

Properties of

Using Logic to Model Theory

Revisiting the Learning Goals

CS 245 Logic and Computation Fall 2019 2 / 22 Learning goals

By the end of this lecture, you should be able to: ▶ Write a formal deduction proof using rules for equality. ▶ Write a formal deduction proof for properties of natural using formal deduction rules and Peano .

CS 245 Logic and Computation Fall 2019 3 / 22 Formal Deduction Rules for Equality

(≈ −) If Σ ⊢ 퐴(푡1) and Σ ⊢ 푡1 ≈ 푡2 then ′ Σ ⊢ 퐴 (푡2), ′ where 퐴 (푡2) results from 퐴(푡1) by replacing some (not necessarily all) occurrences

of 푡1 by 푡2.

(≈ +) ∅ ⊢ 푢 ≈ 푢.

CS 245 Logic and Computation Fall 2019 4 / 22 Proving Properties of Equality

(Reflexivity) ∀푥 (푥 ≈ 푥)

(Symmetry) ∀푥 ∀푦 ((푥 ≈ 푦) → (푦 ≈ 푥))

(Transitivity) ∀푥 ∀푦 ∀푧 ((푥 ≈ 푦) ∧ (푦 ≈ 푧) → (푥 ≈ 푧))

CS 245 Logic and Computation Fall 2019 5 / 22 Proving Reflexivity

Reflexivity: ∅ ⊢ ∀푥(푥 ≈ 푥)

CS 245 Logic and Computation Fall 2019 6 / 22 Proving Symmetry

Symmetry: ∅ ⊢ ∀푥 ∀푦 (푥 ≈ 푦) → (푦 ≈ 푥)

CS 245 Logic and Computation Fall 2019 7 / 22 Proving Transitivity

Transitivity: ∅ ⊢ ∀푥 ∀푦 ∀푧 (푥 ≈ 푦) ∧ (푦 ≈ 푧) → (푥 ≈ 푧)

CS 245 Logic and Computation Fall 2019 8 / 22 Outline

The Learning Goals

Properties of Equality

Using Logic to Model

Revisiting the Learning Goals

CS 245 Logic and Computation Fall 2019 9 / 22 Using Logic to Model Mathematics

We want to use predicate logic to model mathematics. ▶ Number theory, with 0, +, and ⋅ ▶ theory, with ∈ and ∅ ▶ theory ▶ Graph theory ▶ Geometry For each domain, ▶ Define axioms that describe the functions, predicates/relations and individuals/constants. ▶ Prove theorems in that domain using predicate logic.

CS 245 Logic and Computation Fall 2019 10 / 22 Number Theory

We would like to formalize the properties of natural numbers. ▶ The domain is the set of natural numbers, 0, 1, 2, 3, … . ▶ Functions: + and ⋅. ▶ Relations: ordering <. The axioms should be a small set of true statements from which we can derive theorems about natural numbers.

CS 245 Logic and Computation Fall 2019 11 / 22 Symbols for Number Theory

▶ Individual/constant: 0 ▶ Functions: addition + multiplication ⋅ successor 푠(푥)

CS 245 Logic and Computation Fall 2019 12 / 22 Peano Axioms (1/2)

Axioms for successor PA1 Zero is not a successor of any .

PA2 If two numbers are the same, they must have the same predecessor.

Axioms for addition PA3 Adding zero to any number yields the same number.

PA4 Adding the successor of a number yields the successor of adding the number.

CS 245 Logic and Computation Fall 2019 13 / 22 Peano Axioms (2/2)

Axioms for multiplication PA5 Multiplying a number by zero yields zero.

PA6 Multiplying one number and the successor of another number equals the product of the two numbers plus the first number.

CS 245 Logic and Computation Fall 2019 14 / 22 for Induction

For 푛 ∈ ℕ, let 푃 (푛) denote that 푛 has the property 푃 . ▶ (Base Case) Prove that 푃 (0) is true. ▶ (Inductive Step) Assume that 푃 (푘) is true for some 푘 ∈ ℕ. Prove that 푃 (푘 + 1) is true. By the principle of , 푃 (푛) is true for every 푛 ∈ ℕ. Expressing this in predicate logic:

(푃 (0) ∧ ∀푥 (푃 (푥) → 푃 (푠(푥)))) → ∀푥 푃 (푥)

CS 245 Logic and Computation Fall 2019 15 / 22 Axiom for Induction

Axiom for induction PA7 For each predicate formula 퐴(푥) with free variable 푥 [퐴(0) ∧ ∀푥(퐴(푥) → 퐴(푠(푥))] → ∀푥퐴(푥)

CS 245 Logic and Computation Fall 2019 16 / 22 Example 1: Every number is not equal to its successor

Every natural number is not equal to its successor. Prove that ∀푥 (¬(푠(푥) ≈ 푥)). ▶ Base Case: Prove that ¬(푠(0) ≈ 0) Which Peano Axiom can we use to prove this? ▶ Induction Step: Consider some 푘 ∈ ℕ. Assume that ¬(푠(푘) ≈ 푘). Prove that ¬(푠(푠(푘)) ≈ 푠(푘)). Which Peano Axiom can we use to prove this?

CS 245 Logic and Computation Fall 2019 17 / 22 Example 1: Every number is not equal to its successor Every natural number is not equal to its successor. Prove that ∀푥 (¬(푠(푥) ≈ 푥)).

1.∅ ⊢ ∀푥 ¬(푠(푥) ≈ 0) (푃 퐴1) 2.∅ ⊢ ¬(푠(0) ≈ 0) (∀−, 1) 3.¬(푠(푢) ≈ 푢), 푠(푠(푢)) ≈ 푠(푢) ⊢ 푠(푠(푢)) ≈ 푠(푢) (∈) 4.∅ ⊢ ∀푥 ∀푦 (푠(푥) ≈ 푠(푦) → 푥 ≈ 푦) (푃 퐴2) 5.∅ ⊢ 푠(푠(푢)) ≈ 푠(푢) → 푠(푢) ≈ 푢 (∀−, 4) 6.¬(푠(푢) ≈ 푢), 푠(푠(푢)) ≈ 푠(푢) ⊢ 푠(푠(푢)) ≈ 푠(푢) → 푠(푢) ≈ 푢 (+, 5) 7.¬(푠(푢) ≈ 푢), 푠(푠(푢)) ≈ 푠(푢) ⊢ 푠(푢) ≈ 푢 (→ −, 6, 3) 8.¬(푠(푢) ≈ 푢), 푠(푠(푢)) ≈ 푠(푢) ⊢ ¬(푠(푢) ≈ 푢) (∈) 9.¬(푠(푢) ≈ 푢) ⊢ ¬(푠(푠(푢)) ≈ 푠(푢)) (¬+, 7, 8) 10.∅ ⊢ ¬(푠(푢) ≈ 푢) → ¬(푠(푠(푢)) ≈ 푠(푢)) (→ +, 9) 11.∅ ⊢ ∀푥(¬(푠(푢) ≈ 푢) → ¬(푠(푠(푢)) ≈ 푠(푢))) (10, ∀+, no 푢 elsewhere)

CS 245 Logic and Computation Fall 2019 18 / 22 Example 1: Every number is not equal to its successor

Every natural number is not equal to its successor. Prove that ∀푥(¬(푠(푥) ≈ 푥)). (continued)

12.∅ ⊢ ¬(푠(푢) ≈ 푢) ∧ ∀푥(¬(푠(푢) ≈ 푢) → ¬(푠(푠(푢)) ≈ 푠(푢))) (∧+, 2, 11) 13.∅ ⊢ ¬(푠(푢) ≈ 푢) ∧ ∀푥(¬(푠(푢) ≈ 푢) → ¬(푠(푠(푢)) ≈ 푠(푢))) → ∀푥 ¬(푠(푥) ≈ 푥) (푃 퐴7, with 퐴(푥) ∶‶ ¬(푠(푥) ≈ 푥)″) 14.∅ ⊢ ∀푥 ¬(푠(푥) ≈ 푥) (→ −, 12, 13)

CS 245 Logic and Computation Fall 2019 19 / 22 Example 2: Every non-zero natural number has a predecessor

Every non-zero natural number has a predecessor. Prove that ∀푥(푥 ≈ 0 ∨ ∃푦 (푠(푦) ≈ 푥))

Base case: 1.∅ ⊢ 0 ≈ 0 (≈ +) 2.∅ ⊢ 0 ≈ 0 ∨ ∃푦(푠(푦) ≈ 0) (∨+, 1) Induction step: 3.푘 ≈ 0 ⊢ 푘 ≈ 0 (∈) 4.∅ ⊢ 푠(푘) ≈ 푠(푘) (prove separately using (≈ +)) 5.푘 ≈ 0 ⊢ 푠(푘) ≈ 푠(푘) (+, 4) 6.푘 ≈ 0 ⊢ 푠(0) ≈ 푠(푘) (≈ −) with 퐴(푥) ∶‶ 푠(푥) ≈ 푠(푘)″ 7.푘 ≈ 0 ⊢ ∃푦(푠(푦) ≈ 푠(푘)) ((∃+), 6) 8.푘 ≈ 0 ⊢ (푠(푘) ≈ 0) ∨ ∃푦(푠(푦) ≈ 푠(푘)) (∨+, 8)

CS 245 Logic and Computation Fall 2019 20 / 22 Example 2:

Inductive step, second case of (∨−) 9.푠(푢) ≈ 푘 ⊢ 푠(푢) ≈ 푘 (∈) 10.푠(푢) ≈ 푘 ⊢ 푘 ≈ 푠(푢) (9, symmetry of ≈) 11.푠(푢) ≈ 푘 ⊢ 푠(푘) ≈ 푠(푘) (4, +) 12.푠(푢) ≈ 푘 ⊢ 푠(푠(푢)) ≈ 푠(푘) (11, 10, (≈ −), 퐴(푥) ∶ 푠(푥) ≈ 푠(푘)) 13.푠(푢) ≈ 푘 ⊢ ∃푦(푠(푦) ≈ 푠(푘)) (12, ∃+) 14.푠(푢) ≈ 푘 ⊢ 푠(푘) ≈ 0 ∨ ∃푦(푠(푦) ≈ 푠(푘)) (13, ∨+) 15.∃푦(푠(푦) ≈ 푘) ⊢ 푠(푘) ≈ 0 ∨ ∃푦(푠(푦) ≈ 푠(푘)) (14, ∃−), no 푢 elsewhere) 16.푘 ≈ 0 ∨ ∃푦(푠(푦) ≈ 푘) ⊢ 푠(푘) ≈ 0 ∨ ∃푦(푠(푦) ≈ 푠(푘)) (8, 15, ∨−) 17.∅ ⊢ 푘 ≈ 0 ∨ ∃푦(푠(푦) ≈ 푘) → 푠(푘) ≈ 0 ∨ ∃푦(푠(푦) ≈ 푠(푘))(16, → +) 18.∅ ⊢ ∀푥(푃 (푥) → 푃 (푠(푥))) (17, ∀+, no 푘 elsewhere) 19.∅ ⊢ 푃 (0) ∧ ∀푥(푃 (푥) → 푃 (푠(푥))) (18, 2, ∧+) 20.∅ ⊢ 푃 (0) ∧ ∀푥(푃 (푥) → 푃 (푠(푥))) → ∀푥푃 (푥) (푃 퐴7) 21.∅ ⊢ ∀푥(푥 ≈ 0 ∨ ∃푦(푠(푦) ≈ 푥)) (20, 19, → −)

CS 245 Logic and Computation Fall 2019 21 / 22 Revisiting the learning goals

By the end of this lecture, you should be able to: ▶ Write a formal deduction proof using rules for equality. ▶ Write a formal deduction proof for properties of natural numbers using formal deduction rules and Peano axioms.

CS 245 Logic and Computation Fall 2019 22 / 22