Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 44 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
44
Dung lượng
478,71 KB
Nội dung
Logics (cont.) Huynh Tuong Nguyen, Nguyen An Khuong Chapter Logics (cont.) Discrete Structures for Computer Science (CO1007) on October 09, 2015 Contents Predicate Logic Proof Methods Some problems for discussion Huynh Tuong Nguyen, Nguyen An Khuong Faculty of Computer Science and Engineering University of Technology, VNU-HCM 2.1 Contents Logics (cont.) Huynh Tuong Nguyen, Nguyen An Khuong Predicate Logic Contents Predicate Logic Proof Methods Proof Methods Some problems for discussion Some problems for discussion 2.2 Limitations of Propositional Logic Logics (cont.) Huynh Tuong Nguyen, Nguyen An Khuong Contents • x > 3: not a proposition • All square numbers are not prime numbers 100 is a square number Therefore 100 is not a prime number: not able to infer in propositional logic Predicate Logic Proof Methods Some problems for discussion 2.3 Predicates Definition Logics (cont.) Huynh Tuong Nguyen, Nguyen An Khuong • A predicate (vị từ) is a statement containing one or more variables • If values are assigned to all the variables in a predicate, the resulting statement is a proposition (mệnh đề ) Contents Predicate Logic Examples: • x > (predicate) • > (proposition) • > (proposition) Etymology: predicate (n.) from Latin praedicatum “that which is said of the subject.” Contexts: properties, relations, characteristics, features, Notations: • x > → P (x) • > → P (5) • > → P (2) • A predicate with n variables P (x1 , x2 , , xn ) Proof Methods Some problems for discussion 2.4 Truth value and Quantifiers Logics (cont.) Huynh Tuong Nguyen, Nguyen An Khuong • x > is true or false? • 5>3 Contents • For every number x, x > holds • There is a number x such that x > Quantifiers: • ∀: Universal – Với Predicate Logic Proof Methods Some problems for discussion • ∀xP (x) = P (x) is T for all x • ∃: Existential – Tồn • ∃xP (x) = There exists an element x such that P (x) is T • We need a domain of discourse for variable: Universe 2.5 Logics (cont.) Huynh Tuong Nguyen, Nguyen An Khuong Example Let P (x) be the statement “x < 2” What is the truth value of the quantification ∀xP (x), where the domain consists of all real number? Contents • P (3) = < is false • ⇒ ∀xP (x) is false Predicate Logic Proof Methods Some problems for discussion • is a counterexample (phản ví dụ) of ∀xP (x) Example What is the truth value of the quantification ∃xP (x), where the domain consists of all real number? 2.6 Logics (cont.) Huynh Tuong Nguyen, Nguyen An Khuong Example Express the statement “Some student in this class comes from Central Vietnam.” Solution Contents Predicate Logic • M (x) = x comes from Central Vietnam Proof Methods • Domain for x is the students in the class Some problems for discussion • ∃xM (x) Solution • Domain for x is all people • 2.7 Logics (cont.) Negation of Quantifiers Huynh Tuong Nguyen, Nguyen An Khuong Statement Negation Equivalent form ∀xP (x) ¬(∀xP (x)) ∃x¬P (x) ∃xP (x) ¬(∃xP (x)) ∀x¬P (x) Contents Predicate Logic Proof Methods Example Some problems for discussion • All CSE students study Discrete Math • Let C(x) denote “x is a CSE student” • Let S(x) denote “x studies Discrete Math 1” • ∀x : C(x) → S(x) • ∃x : ¬(C(x) → S(x)) ≡ ∃x : C(x) ∧ ¬S(x) • There is a CSE student who does not study Discrete Math 2.8 Another Example Logics (cont.) Huynh Tuong Nguyen, Nguyen An Khuong Example Translate these: • All lions are fierce • Some lions not drink coffee • Some fierce creatures not drink coffee Contents Predicate Logic Proof Methods Some problems for discussion Solution Let P (x), Q(x) and R(x) be the statements “x is a lion”, “x is fierce” and “x drinks coffee”, respectively • ∀x(P (x) → Q(x)) • ∃x(P (x) ∧ ¬R(x)) • ∃x(Q(x) ∧ ¬R(x)) 2.9 The Order of Quantifiers Logics (cont.) Huynh Tuong Nguyen, Nguyen An Khuong • The order of quantifiers is important, unless all the quantifiers are universal quantifiers or all are existential quantifiers • Read from left to right, apply from inner to outer Contents Predicate Logic Example Proof Methods ∀x ∀y (x + y = y + x) T for all x, y ∈ R Some problems for discussion Example ∀x ∃y (x + y = 0) is T, while ∃y ∀x (x + y = 0) is F 2.10 Proving a Theorem Logics (cont.) Huynh Tuong Nguyen, Nguyen An Khuong Many theorem has the form ∀xP (x) → Q(x) Contents Predicate Logic Goal: • Show that P (c) → Q(c) is true with arbitrary c of the domain Proof Methods Some problems for discussion • Apply universal generalization ⇒ How to show that conditional statement p → q is true 2.30 Methods of Proof Logics (cont.) Huynh Tuong Nguyen, Nguyen An Khuong Contents • Direct proofs (chứng minh trực tiếp) Predicate Logic • Proof by contraposition (chứng minh phản đảo) Proof Methods • Proof by contradiction (chứng minh phản chứng ) Some problems for discussion • Mathematical induction (quy nạp toán học) 2.31 Direct Proofs Logics (cont.) Huynh Tuong Nguyen, Nguyen An Khuong Definition A direct proof shows that p → q is true by showing that if p is true, then q must also be true Contents Predicate Logic Proof Methods Example Some problems for discussion Ex.: If n is an odd integer, then n2 is odd Pr.: Assume that n is odd By the definition, n = 2k + 1, k ∈ Z n2 = (2k + 1)2 = 4k + 4k + = 2(2k + 2k) + is an odd number 2.32 Proof by Contraposition Logics (cont.) Huynh Tuong Nguyen, Nguyen An Khuong Definition p → q can be proved by showing (directly) that its contrapositive, ¬q → ¬p, is true Contents Predicate Logic Example Ex.: If n is an integer and 3n + is odd, then n is odd Proof Methods Some problems for discussion Pr.: Assume that “If 3n + is odd, then n is odd” is false; or n is even, so n = 2k, k ∈ Z Substituting 3n + = 3(2k) + = 6k + = 2(3k + 1) is even Because the negation of the conclusion of the conditional statement implies that the hypothesis is false, Q.E.D 2.33 Proofs by Contradiction Logics (cont.) Huynh Tuong Nguyen, Nguyen An Khuong Definition p is true if if can show that ¬p → (r ∧ ¬r) is true for some proposition r Contents Predicate Logic Example √ Ex.: Prove that is irrational √ Pr.: Let p is the proposition “ is irrational” Suppose ¬p is true, √ √ which means is rational If so, ∃a, b ∈ Z, = a/b, a, b have no common factors Squared, = a2 /b2 , 2b2 = a2 , so a2 is even, and a is even, too Because of that a = 2c, c ∈ Z Thus, 2b2 = 4c2 , or b2 = 2c2 , which means b2 is even and so is b That means divides both a and b, contradict with the assumption Proof Methods Some problems for discussion 2.34 Problem Logics (cont.) Huynh Tuong Nguyen, Nguyen An Khuong Contents Predicate Logic Proof Methods Some problems for discussion Assume that we have an infinite domino string, we want to know whether every dominoes will fall, if we only know two things: We can push the first domino to fall If a domino falls, the next one will be fall We can! Mathematical induction 2.35 Mathematical Induction Logics (cont.) Huynh Tuong Nguyen, Nguyen An Khuong Definition (Induction) To prove that P (n) is true for all positive integers n, where P (n) is a propositional function, we complete two steps: • Basis Step: Verify that P (1) is true • Inductive Step: Show that the conditional statement Contents Predicate Logic Proof Methods Some problems for discussion P (k) → P (k + 1) is true for all positive integers k Logic form: [P (1) ∧ ∀kP (k) → P (k + 1))] → ∀nP (n) What is P (n) in domino string case? 2.36 Logics (cont.) Example on Induction Huynh Tuong Nguyen, Nguyen An Khuong Example Show that if n is a positive integer, then + + + n = n(n + 1) Contents Predicate Logic Solution Proof Methods Let P (n) be the proposition that sum of first n is n(n + 1)/2 • Basis Step: P (1) is true, because = • Inductive Step: Assume that + + + k = Then: 1(1+1) Some problems for discussion k(k+1) + + + k + (k + 1) = = = k(k + 1) + (k + 1) k(k + 1) + 2(k + 1) (k + 1)(k + 2) shows that P (k + 1) is true under the assumption that P (k) is true 2.37 Example on Induction Logics (cont.) Huynh Tuong Nguyen, Nguyen An Khuong Example Prove that n < 2n for all positive integers n Solution Contents Let P (n) be the proposition that n > 2n Predicate Logic • Basis Step: P (1) is true, because > 21 = Proof Methods Some problems for discussion • Inductive Step: Assume that P (k) is true for the positive k, that is, k < 2k Add to both side of k < 2k , note that ≤ 2k k + < 2k + ≤ 2k + 2k = · 2k = 2k+1 shows that P (k + 1) is true, namely, that k + < 2k+1 , based on the assumption that P (k) is true 2.38 On drinking in pubs Logics (cont.) Huynh Tuong Nguyen, Nguyen An Khuong The drinker’s paradox In every non-empty pub there is somebody such that if he (or she) drinks then everybody drinks Contents Predicate Logic • Is this true? • Or more precisely: Is this a tautology in classical predicate Proof Methods Some problems for discussion logic? • I.e is it true independent of the domain (here pubs, people) and the meanings of pub and to drink? • Predicate formula: ∃x ∈ P, [D(x) −→ ∀y ∈ P, D(y)] • Law of excluded middle (LEM): p ∨ ¬p is a tautology 2.39 Some MCQs Logics (cont.) Huynh Tuong Nguyen, Nguyen An Khuong MCQ1 Which of the following has truth value T ? A ∀x ∈ R, (x > −→ x2 − 3x + > 0) B ∃x ∈ Q, (x2 = 2015) Contents Predicate Logic Proof Methods Some problems for discussion C ∃x ∈ R, (x > −→ x2 − 3x + < 0) D ∃x ∈ R, (x2 − x = −1) 2.40 Some MCQs (cont’d) Logics (cont.) Huynh Tuong Nguyen, Nguyen An Khuong MCQ2 Giả sử D(x, y) vị từ với ý nghĩa “số nguyên y ước số nguyên x.” Phát biểu tương đương diễn đạt ý nghĩa công thức ∀x, y(D(x, y) −→ ∃z(D(x, z) ∧ D(y, z)))? Contents Predicate Logic Proof Methods Some problems for discussion A Mọi cặp số tự nhiên (x, y) có ước chung B Nếu y ước x z ước y z ước x C Nếu y ước x chúng ước chung D Nếu x y ước chung y ước x 2.41 Some MCQs (cont’d) Logics (cont.) Huynh Tuong Nguyen, Nguyen An Khuong MCQ3 Contents Which of the following are semantically and syntactically correct translations of “No dog bites a child of its owner”? A ∀xDog(x) −→ ¬Bites(x, Child(Owner(x))) Predicate Logic Proof Methods Some problems for discussion B ¬∃x, yDog(x) ∧ Child(y, Owner(x)) ∧ Bites(x, y) C ∀xDog(x) −→ (∀yChild(y, Owner(x)) −→ ¬Bites(x, y)) D ¬∃xDog(x) −→ (∃yChild(y, Owner(x)) ∧ Bites(x, y)) 2.42 Convert Codes to English and Predicate Formula Logics (cont.) Huynh Tuong Nguyen, Nguyen An Khuong Example for (i=0; i