<<

COMP 1002

Intro to Logic for Computer Scientists

Lecture 16

B 5 2 J Puzzle: Caesar cipher

• The Roman dictator Julius Caesar encrypted his personal correspondence using the following code. – letters of the alphabet: A=0, B=1,… Z=25. – To encode a message, replace every letter by a letter three positions before that (wrapping). • A letter numbered x by a letter numbered x-3 mod 26. • For example, F would be replaced by C, and A by X

• Suppose he sent the following message. – QOBXPROB FK QEB ZXSB • What does it say?

Proof by cases

• Use the tautology • If is ( ) ( ), 1 2 1 2 • prove 푝 ∨ 푝( ∧ 푝 → 푞 ∧). 푝 → 푞 → 푞 1 2 • Proof:∀푥 퐹 푥 ∀푥 퐺 푥 ∨ 퐺 푥 → 퐻 푥 1 2 – Universal퐺 푥 instantiation:→ 퐻 푥 ∧ 퐺“let푥 n be→ an퐻 arbitrary푥 element of the domain of ” – Case 1: ( ) – Case 2: 푆 ∀푥 ( ) 1 – Therefore,퐺 (푛 → 퐻 푛 ) ( ), 2 – Now use퐺 universal푛 → 퐻 generalization푛 to conclude that is true. 퐺1 푛 ∨ 퐺2 푛 → 퐻 푛 • This generalizes for any number of cases 2. ∀ 푥 퐹 푥

푘 ≥ (Done).

□ Proof by cases.

• Definition (of odd ): – An n is odd iff , = 2 + 1. • Theorem: Sum of an integer with a consecutive integer is odd. ∃푘 ∈ ℤ 푛 ⋅ 푘 – ( + + 1 ). • Proof: – Suppose∀푥 ∈ ℤ 푂푂푂n is an푥 arbitrary푥 integer. – Case 1: n is even. • So n=2k for some k (by definition). • Its consecutive integer is n+1 = 2k+1. Their sum is (n+(n+1))= 2k + (2k+1) = 4k+1. (axioms). • Let = . Then + 1 = + 1 is an odd number (by definition). So in this case, n+(n+1) is odd. – Case 2: 푙n is2푘 odd. 4푘 2푙 • So n=2k+1 for some k (by definition). • Its consecutive integer is n+1 = 2k+2. Their sum is (n+(n+1))= (2k+1) + (2k+2) = 2(2k+1)+1. (axioms). • Let = + 1. Then n+(n+1) = 2(2k+1)+1= 2 + 1, which is an odd number (by definition). So in this case, n+(n+1) is also odd. – Since in푙 both2푘 cases n+(n+1) is odd, it is odd 푙without additional assumptions. Therefore, by universal generalization, get ( + + 1 ). (Done). ∀푥 ∈ ℤ 푂푂푂 푥 푥 □ Proof by cases • Definition: an absolute value of a r is a non-negative real number |r| such that if | | = if 0, and = if < 0 – Claim 1: , = | | – Claim 2: , 푟 푟| |푟 ≥ 푟 −푟 푟 • Theorem: for∀ 푥any∈ ℝ two− 푥reals,푥 sum of their absolute values is at least the absolute value∀푥 of∈ ℝtheir− 푥 sum.≤ 푥 ≤ 푥 – , + + • Proof: ∀푥 푦 ∈ ℝ 푥 푦 ≤ 푥 푦 – Let r and s be arbitrary reals. (universal instantiation) – Case 1: Let + 0. • Then + = + (definition of ||) • Since 푟 푠and≥ (claim 2), r+ + (axioms), • so +푟 푠= r+푟 푠 + , which is what we need. – Case 2: Let푟 ≤ +푟 < 푠0≤. 푠 푠 ≤ 푟 푠 • Then푟 푠+ = 푠 ≤+푟 = 푠 + (definition of ||) • Since 푟 푠 = | | and | | (claims 1 and 2), • |r+ | =푟 ( 푠 ) +− 푟 푠 −+푟 (axioms),−푠 which is what we need. −푟 ≤ −푟 푟 −푠 ≤ −푠 ≤ 푠 – Since in both cases |r+ | + , and there are no more cases, |r+ | + 푠without−푟 additional−푠 ≤ assumptions.푟 푠 By universal generalization , can now get , + 푠+ ≤ . 푟 푠 푠 ≤ 푟 푠 (Done). ∀푥 푦 ∈ ℝ 푥 푦 ≤ 푥 푦 □ root of 2

• Is it possible to have a Pythagorean triple with a=b=1? • Not quite: 1 + 1 = 2, so the third side2 would2 have to be 2. • Is it at least possible to represent√ 2 as a of two integers?... – Pythagoras√ and others tried…

– To prove ( ), prove ¬ • Universal instantiation: “let n be an arbitrary element of the domain∀푥 퐹 of 푥 ” ∀푥 퐹 푥 → 퐹퐹퐹�퐹 • Suppose that ¬ ( ) is true. 푆 ∀푥 • Derive a contradiction. 퐹 푛 • Conclude that ( ) is true. • By universal generalization, is true. 퐹 푛

∀푥 퐹 푥

(Done).

□ Rational and irrational

• The numbers that are representable as a of two integers are rational numbers. Set of all rational numbers is . • Numbers that are not rational are irrational. – Pythagoras figured out that the diagonal of a square is not ℚ comparable to the sides, but did not think of it as a number. • More like something weird. – It seems that irrational numbers started being treated as numbers in 9th century in the Middle East. • Starting with a Persian mathematician and astronomer Abu-Abdullah Muhammad ibn Īsa Māhānī (Al-Mahani). • Rational and irrational numbers together form the set of all real numbers. – Any sequence of digits, potentially infinite after a point, is a real number. Any point on a line. • Irrationality of 2 is a classic proof by contradiction.

Proof by contradiction

– To prove ( ), prove ¬ • Universal instantiation: “let n be an arbitrary element of the domain∀푥 퐹 of 푥 ” ∀푥 퐹 푥 → 퐹퐹퐹�퐹 • Suppose that ¬ ( ) is true. 푆 ∀푥 • Derive a contradiction. 퐹 푛 • Conclude that ( ) is true. • By universal generalization, is true. 퐹 푛

∀푥 퐹 푥

(Done).

□ Definition of rational

• We need a slightly more precise definition of rational numbers for our proof that 2 is irrational. • Definition (of rational and irrational numbers): – A real number is rational iff , , 0 gcd , = 1 = . 푟 푚 ∃푚 푛 ∈ ℤ 푛 ≠ ∧ • Reminder: greatest common divisor gcd(m,n) is the largest푚 푛 integer which∧ 푟 divides푛 both m and n. When d=1, m and n are relatively prime. • Any fraction can be simplified until the numerator and denominator are relatively prime, so it is not a restriction – A real number which is not rational is called irrational.

Proof by contradiction • Theorem: of 2 is irrational. • Proof: – Suppose, for the sake of contradiction, that 2 is rational. Then there exist relatively prime m, n , 0 such that 2 = . 푚 – By algebra, squaring both sides we get 2 = . ∈ ℤ 푛 ≠ 푛 2 푚 – Thus is even, and by the theorem we just 2proved, 푛 then m 2is even. So = for some k. – 2 =푚4 , so = 2 , and by the same argument n is even.2 2 2 푚 2푘2 – This푛 contradicts푘 푛 our assumption푘 that and are relatively prime. Therefore, such and cannot exist, and so 2 is not rational. 푚 푛 푚 푛 (Done). □ Puzzle 9

• Susan is 28 years old, single, outspoken, and very bright. She majored in philosophy. As a student she was deeply concerned with issues of discrimination and social justice and also participated in anti-nuke demonstrations.

Please rank the following possibilities by how likely they are. List them from least likely to most likely. Susan is:

1. a kindergarden teacher 2. works in a bookstore and takes yoga classes 3. an active feminist Bank tellers Feminists 4. a psychiatric social worker 5. a member of an outdoors club 6. a bank teller

7. an insurance salesperson 8. a bank teller and an active feminist

Set inclusion.

• Let A and B be two sets.

PEOPLE – Such as A={2,3,4} and B= {1,2,3,4,5}

Bank • A is a subset of B: Feminists tellers – iff

• .

– A� is⊆ a퐵 strict∀ subset푥 푥 ∈ of� B:→ 푥 ∈ 퐵 iff � ⊆ 퐵 퐹퐹퐹퐹퐹퐹�퐹� ⊆ 푃𝑃푃𝑃 ( ) • . � ⊂ 퐵 – When∀푥 both푥 ∈ � → 푥 ∈ and퐵 ∧ ∃ 푦 , 푦 then∈ 퐵 ∧=푦 ∉ � � ⊂ 퐵 퐹퐹퐹퐹퐹퐹�퐹� ⊂ 푃𝑃푃𝑃 • A and B are disjoint iff ( ) – {1,5} and {2,3,6,9}� ⊆ 퐵 are disjoint.퐵 ⊆ � So are� BANKTELLERS퐵 and FEMINISTS in the diagram∀푥 above.푥 ∉ � ∨ 푥 ∉ 퐵

Operations on sets

• Let A and B be two sets. U – Such as A={1,2,3} and B={ 2,3,4} A B = } • Intersection U – The green part of the top right picture =�{2∩,3}퐵 푥 푥 ∈ � ∧ 푥 ∈ 퐵 –

� ∩ 퐵 • Union = } � ∩ 퐵 – The coloured part in the top picture. U – � ∪ =퐵 1,2,3푥,4푥 ∈ � ∨ 푥 ∈ 퐵

• Complement� ∪ 퐵 = } – The blue part on the Venn diagram to the right � ∪ 퐵 – If universe U� = , 푥 ∈=푈 푥 ∉ � 1,2,3 } U A ℕ � 푥 ∈ ℕ 푥 ∉ • Difference = } – The yellow part in the top picture. U A =� −1 퐵 푥 푥 ∈ � ∧ 푥 ∉ 퐵 – A-B • Symmetric− 퐵 Difference  = U – Both blue parts of the picture to the right. – A = 1,4 � 퐵 � − 퐵 ∪ 퐵 − � 

� 퐵

Puzzle: the barber

• In a certain village, there is a (male) barber who shaves all and only those men of the village who do not shave themselves.

• Question: who shaves the barber?