1 / 57

CS 103 Discrete Structures Lecture 05 Logic and Proofs (5)

CS 103 Discrete Structures Lecture 05 Logic and Proofs (5). First Midterm Exam. Thursday, 30 October 2014 (same time as the lecture) 75 minute duration Will cover all lectures delivered before the exam date

Download Presentation

CS 103 Discrete Structures Lecture 05 Logic and Proofs (5)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 103Discrete StructuresLecture 05 Logic and Proofs (5)

  2. First Midterm Exam • Thursday, 30 October 2014 (same time as the lecture) • 75 minute duration • Will cover all lectures delivered before the exam date • Will consist of MCQ’s, fill-in-the-blanks, questions with short answers, writing of proofs, and drawing of diagrams • If you miss this exam for anyreason, you will have to appear for a makeup exam on the Thursday of the last week of teaching. That exam will cover alllectures delivered in the semester. It will consist of writing of proofs, drawing of diagrams and answering questions having 0.5-1 page answers.

  3. Chapter 1 The Foundations:Logic and Proofs1.4 Predicates and Quantifiers

  4. Limitation of Propositional Logic Propositional logic cannot always adequately express the meaning of statements in mathematics and in natural language. Example 1: Suppose that we know that: "Every computer connected to the university network is functioning properly." Propositional logic cannot conclude the truth of the statement: "MATH3 is functioning properly", where MATH3 is one of the computers connected to the university network. Example 2: If one computer is under attack such as: "CS2 is under attack by an intruder." We cannot conclude the truth of the statement: "There is a computer on the university network that is under attack by an intruder."

  5. Predicate Logic Predicate Logic is a more powerful type of logic It can be used to express the meaning of a wide range of statements in mathematics and computer science in ways that permit us to reason and explore relationships between objects To understand predicate logic, we need to define the concepts of predicate and quantifier

  6. Predicate Predicate refers to a property that the subjectof the statement can have Consider statements involving variables such as: • "x > 3" , "x = y + 3" , "x + y = z" • "computer x is under attack by an intruder" • "computer x is functioning properly" The statement "xis greater than 3" has two parts: • The first part is the subjectof the statement, x • The second part is the predicate,"is greater than 3"

  7. Propositional Function We can denote the statement "x is greater than 3" by P(x), where: • P denotes the predicate "is greater than 3" on x • The variable x is the subject of the statement • The statement P(x) is said to be the truth value of the propositional function P at x Example: Let P(x) denote the statement "x > 3". What are the truth values of P(4) and P(2)? Solution: We obtain the statement P(4) by settingx = 4 in the statement "x > 3“. Hence, P(4) is true, and similarly, P(2) is false. Remark: P(x) will become a proposition and have a truth value only when x is given a value.

  8. Predicates: Example Let A(x) denote the statement "Computer x is under attack by an intruder." • Suppose that of the computers on campus, only CS2 and MATH1 are currently under attack by intruders. • What are truth values of A(CSl), A(CS2), and A(MATHl)? Solution: We obtain the statement A(CSl) by setting x = CSI in the statement "Computer x is under attack by an intruder." As CS1 is not on the list of computers currently under attack, A(CSI) is false. As CS2 and MATH1 are on the list of computers under attack, A(CS2) & A(MATHl) are true.

  9. Predicates: Exercise Let P(x) = "x is a multiple of 5“. For what values of x is P(x) true?

  10. Multi-Variable Predicates We can also have statements (i.e. propositional functions) that involve more than one variable. • Consider the statement "x = y + 3." We can denote this statement by Q(x, y), where: • x and y are variables • Q is the predicate. • When values are assigned to the variables x and y, the statement Q(x, y) has a truth value

  11. Multi-Variable Predicates: Example Let Q(x, y) denote the statement "x = y + 3" What are the truth values of the propositions Q(1, 2) and Q(3, 0)? Solution: To obtain Q(I, 2), set x = 1 andy = 2 in the statement Q(x, y). Hence, Q(1, 2) is false. Similarly, the statement Q(3, 0) is true

  12. Multi-Variable Predicates: Example Let R(x, y, z) denote the statement "x+ y = z". Find the truth values of R(1, 2, 3) & R(0, 0, I)? Solution: The proposition R(1, 2, 3) is true.R(0, 0, 1) is false. In general: • A statement involving the n variables Xl, X2,…, Xncan be denoted by P(XI, X2, … , Xn) • P(XI, X2, … , Xn) is the value of propositional function P at the n-tuple(Xl, X2, … ,Xn) • P is also called a n-place predicate or a n-ary predicate.

  13. Propositional Functions in Programs Propositional functions occur in computer programs. Consider the statement: if x > 0 then x := x + 1 The value of x is inserted into P(x) = "x > 0" • If P(x) is true then x := x + 1 is executed • If P(x) is false the value of x is not changed

  14. Quantifiers Quantification expresses the extent to which a predicate is true over a range of elements. A quantifier is "an operator that limits the variables of a proposition" In English, the words all, some, many, none, and few are as quantifiers. We will focus on two types of quantification: Universal quantification tells us that a predicate is true for every element under consideration Existential quantification tells us that there are one or more elements under consideration for which the predicate is true

  15. Universal Quantification The universal quantification of P(x) is the statement: "P(x) for all values of x in the domain." The notation x P(x) denotes the universal quantification of P(x). • Here  is called the universal quantifier. • We read x P(x) as "for all x P(x)" or "for every x P(x)" An element for which P(x) is false is called a counterexampleof x P(x) Symbol name: Turned A

  16. Universal Quantification: Example Let P(x) be the statement "x + 1 > x". What is the truth value of the quantification x P(x), where the domainconsists of all real numbers? Solution: Because P(x) is true for all real numbers x, the quantification x P(x) is true

  17. Universal Quantification: Examples Let Q(x) be the statement "x < 2 ". What is the truth value of the quantification x Q(x), where the domain consists of all real numbers? Solution: Q(x) is not true for every real number x, because, for instance, Q(3) is false. Hence, x = 3 is a counterexample for the statement x Q(x). Therefore, x Q(x) is false Remark: Only a single counterexample is needed to prove that the universal quantification is false

  18. Universal Quantification: Example Let P(x) is "x/2 < x" What is the truth value of the quantification xP(x), where the domain consists of all real numbers? Solution: The statement x P(x) is falsebecause all negative values of x are counterexamples

  19. Universal Quantification: Example P(x) is the statement "x2 < 10" What is the truth value of x P(x), where the domain consists of positive integers not exceeding 4? Solution: The statement  x P(x) is the same as the conjunction P(l)  P(2)  P(3)  P(4), but P(4) is a counterexample, therefore  x P(x) is false Remarks: • In order to prove that a universal quantification is true, it must be shown for ALL cases • In order to prove that a universal quantification is false, it must be shown to be false for only ONEcase

  20. Existential Quantification The existential quantification of P(x) is the proposition "There exists an element x in the domain such that P(x)" • We use the notation x P(x) for the existential quantification of P(x).  is called the existential quantifier • A domain must always be specified when a statement x P(x) is used. • The meaning of x P(x) changes when the domain changes • Without specifying the domain, the statementx P(x) has no meaning Symbol name: Turned E

  21. Existential Quantification: Example Let P(x) denote the statement "x> 3". What is the truth value of the quantification x P(x), where the domain consists of all real numbers? Solution: Because "x > 3" is sometimes true, for example, for x = 4, therefore x P(x) is true Remark: The statement x P(x) is false if and only if there is no element x in the domain for which P(x) is true. • That is, x P(x) is false if and only P(x) is false for every element of the domain

  22. Existential Quantification: Example Let Q(x) denote the statement "x = x + I". What is the truth value of the quantification x Q(x), where the domain consists of all real numbers? Solution: As Q(x) is false for every real number x, therefore x Q(x) is false. Remarks: • In order to show an existential quantification is true, you only have to find ONE value. • In order to show an existential quantification is false, you have to show it’s false for ALL values

  23. Existential Quantification: Example What is the truth value of x P(x), where P(x) is the statement "x2 > 10" and the universe of discourse consists of the positive integers not exceeding 4? Solution: As the domain is {l , 2, 3, 4}, the proposition x P (x) is the same as the disjunctionP(l)  P(2)  P(3)  P(4). As P(4) is true, therefore x P(x) is true.

  24. Existential Quantification: Example What is the truth value of x P(x), where: a) P(x) denotes the statement x + 1 < x b) P(x) denotes the statement x + 1 > x and the domain consists of all real numbers Solution: a) There is no numerical value x for which x+1< x Thus, x P(x) is false b) There is a numerical value for which x + 1 > x In fact, it’s true for all of the values of x. Thus,x P(x) is true

  25. Some Notes on Quantifiers P(x) is not a proposition. P(x) is called a propositional function, e.g., let P(x) be "x = 0" There are two ways to convert a propositional function into a proposition: Supply it with a value Example:P(5) is false, P(0) is true Provide a quantification Example: x P(x) is false and x P(x) is true. You must determine universe of discourse (domain)

  26. Precedence of Quantifiers The quantifiers  and  have higher precedence then all logical operators from propositional calculus. Example: x P(x)  Q(x) is the disjunction of x P(x) and Q(x). It is the same as [x P(x)] Q(x), not x [P(x)  Q(x)]

  27. Binding Variables When a quantifier is used on the variable x, then we say that this occurrence of the variable is bound. • An occurrence of a variable that is not bound by a quantifier or set equal to a particular value is said to be free • All the variables that occur in a propositional function must be bound or set equal to a particular value to turn it into a proposition • The part of a logical expression to which a quantifier is applied is called the scope of this quantifier. • A variable is free if it is outside the scope of all quantifiers in the formula that specifies this variable.

  28. Binding Variables: Example In the statement x (x + y = 1), the variable x is bound by the existential quantification x, but the variable y is free, because it is not bound by a quantifier and no value is assigned to this variable.

  29. Binding Variables: Example Let P(x, y) be "x > y" Consider the propositional function x P(x, y) This is not a proposition, because y is free (not "bound" by a quantifier) If y is 5, then x P(x, y) is false If y is x - 1, then x P(x, y) is true

  30. Binding Variables: Example In the statement x [P(x)  Q(x)] x R(x), all variables are bound The scope of the first quantifier, x, is the expression P(x)  Q(x) because x is applied only toP(x)  Q(x) and not to the rest of the statement. Similarly, the scope of the second quantifier, x , is the expression R(x). • That is, the existential quantifier binds the variable x in P(x)  Q(x) and the universal quantifier x binds the variable x in R(x)

  31. Binding Variables: Examples [x P(x)]  Q(x) x in Q(x) is not bound, thus it is not a proposition [x P(x)]  [x Q(x)] Both x values are bound, thus it is a proposition x [P(x)  Q(x)]  [y R(y)] All variables are bound, thus it is a proposition [x P(x)  Q(y)]  [y R(y)] y in Q(y) is not bound, thus it is not a proposition

  32. Logical Equivalence Statements involving predicates and quantifiers are logically equivalent if and only if they have the same truth value no matter which • predicates are substituted into these statements • domain of discourse is used for the variables in these propositional functions We use the notation S  T to indicate that two statements S and T involving predicates and quantifiers are logically equivalent

  33. Logical Equivalences: Example Show that x [P(x)  Q(x)] and x P(x) x Q(x) are logically equivalent, when the same domain is used Solution: To show logical equivalence, we must show that they always take the same truth value, no matter • what the predicates P and Q are • which domain of discourse is used Suppose we have particular predicates P and Q, with a common domain. We can show logical equivalence between x [P(x)  Q(x)] and x P(x) x Q(x)by showing two things: • If x [P(x)  Q(x)] is true, then x P(x) x Q(x) is true • If x P(x) x Q(x) is true, then x [P(x)  Q(x)] is true

  34. Logical Equivalences: Example Solution (contd.) • If x [P(x)  Q(x)] is true,then x P(x) x Q(x) is true Suppose that x [P(x)  Q(x)] is true • This means that if a is in the domain, then P(a)  Q(a) is true. • Hence, P(a) is true and Q(a) is true. • Because P(a) is true and Q(a) is true for every element in the domain, we can conclude that x P(x) and x Q(x) are both true. • This means that x P(x) x Q(x) is true.

  35. Logical Equivalences: Example Solution (contd.) • If x P(x) x Q(x) is true,then x [P(x)  Q(x)] is true Suppose that x P(x) x Q(x) is true • Then x P(x) is true and x Q(x) is also true • If a is in the domain, then P(a) is true and Q(a) is true because P(x) and Q(x) are both true for all elements in the domain • It follows that for all a, P(a)  Q(a) is true • Then x [P(x)  Q(x)] is true

  36. Negating Universal Quantification "Every student in the class has taken calculus" • This statement is a universal quantification x P(x), • P(x) is "x has taken calculus" • The domain consists of the students in the class • Negation of statement is"It is not the case that every student in the class has taken calculus", i.e. ¬x P(x) • This is equivalent to"There is a student in the class who has not taken calculus." • This is the existential quantification of the negation of the original propositional function x ¬P(x) • This example illustrates the logical equivalence¬x P(x) x ¬P(x).

  37. CS 103Discrete StructuresLecture 06a Logic and Proofs (6)

  38. First Midterm Exam • Thursday, 30 October 2014 (same time as the lecture) • 75 minute duration • Will cover all lectures delivered before the exam date • Will consist of MCQ’s, fill-in-the-blanks, questions with short answers, writing of proofs, and drawing of diagrams • If you miss this exam for anyreason, you will have to appear for a makeup exam on the Thursday of the last week of teaching. That exam will cover alllectures delivered in the semester. It will consist of writing of proofs, drawing of diagrams and answering questions having 0.5-1 page answers.

  39. Negating Existential Quantification "There is a student in this class who has taken calculus" x Q(x), whereQ(x) is the statement "x has taken calculus" • The negation of this statement is the proposition"It is not the case that there is a student in this class who has taken calculus", i.e. ¬x Q(x) • This is equivalent to"Every student in this class has not taken calculus" • This is the universal quantification of the negation of the original propositional function, x ¬Q(x) • This example illustrates the logical equivalence¬x Q(x)  x ¬Q(x)

  40. De Morgan's Laws for Quantifiers The rules for negations for quantifiers are called De Morgan's Laws for Quantifiers. To negate a universal quantification: • Negate the propositional function • Change to an existential quantification To negate an existential quantification: • Negate the propositional function • Change to a universal quantification

  41. De Morgan's Laws for Quantifiers What is the negation of the statement "There is an excellent student"? Solution: Let P(x) denote "x is excellent“. Then the statement "There is an excellent student" is represented by x P(x), where the domain consists of all students. The negation of this statement is ¬x P(x), which is equivalent to x ¬P(x) This negation can be expressed in English as "Every student is not excellent"

  42. De Morgan's Laws for Quantifiers Find the negation of the statement "All teachers explain lessons seriously" Solution: Let L(x) denote "x explains lessons seriously" Then the statement "All teachers explain lessons seriously" is represented by x L (x), where the domain consists of all teachers. The negation of this statement is ¬x L(x), which is equivalent to x ¬L(x). This negation can be expressed in several different ways, including: • "Some teachers do not explain lessons seriously" • "There is a teacher who does not explain lessons seriously"

  43. De Morgan's Laws for Quantifiers Find the negation of the statement x (x2 > x) Negation of x (x2 > x) is the statement,¬x (x2 > x), which is equivalent to x ¬(x2 > x) This can be rewritten as x (x2 ≤ x) Remark: The truth values of this statement depends on the domain

  44. De Morgan's Laws for Quantifiers Find the negation of the statement x (x2 = 2) Negation of x (x2 = 2) is the statement,¬x (x2 = 2), which is equivalent to x ¬(x2 = 2) This can be rewritten as x (x2 ≠ 2) Remark: The truth values of this statement depends on the domain

  45. De Morgan's Laws for Quantifiers Show that ¬x [P(x) → Q(x)] and x [P(x)  ¬Q(x)] are logically equivalent ¬x [P(x) → Q(x)]  x (¬[P(x) → Q(x)])De Morgan's  x (¬[¬P(x)  Q(x)]) De Morgan's  x [P(x)  ¬Q(x)]

  46. Translating English into Logical Expressions Translating sentences in English (or other natural languages) into logical expressions is a crucial task in Mathematics, Logic Programming, Artificial Intelligence, Software Engineering, and many other disciplines The goal in this translation is to produce simple and useful logical expressions Here, we restrict ourselves to sentences that can be translated into logical expressions using a single quantifier

  47. Translating English into Logical Expressions Express the statement "Every student in this class has studied calculus" using predicates and a quantifier Solution: We can introduce the following two: • A variable x to represent student (object) • Predicates to represent each property in the statement Now let: S(x) be "x is in this class" C(x) be "x has studied calculus" Then the required expression isx [S(x) → C(x)]

  48. Translating English into Logical Expressions Express the statements "Some student in this class has visited Egypt" and "Every student in this class has visited either Jordan or Egypt" using predicates and quantifier Solution: Let, x represent a student S(x) is "x is in this class" E(x) is "x has visited Egypt" J(x) is "x has visited Jordan ", then our 1st statement is expressed asx [S(x)  E(x)] 2nd one is expressed asx (S(x) → [E(x)  J(x)])

  49. Exercises 1. Let P(x) denote the statement "x ≤ 4" What are the truth values? a) P(0) b) P(4) c) P(6) 2. Let P(x) be the statement "the word x contains the letter a" What are the truth values? a) P(orange) b) P(lemon) c) P(true) d) P(false) 3. Let Q(x, y) denote the statement "x is the capital of y." What are these truth values? a) Q(Riyad, Saudi Arabia) b) Q(Riyad, Egypt) c) Q(Cairo, Saudi Arabia) d) Q(Cairo, Egypt)

  50. Exercises 4. Let P(x) be the statement "x spends more than five hours every weekday in class," where the domain for x consists of all students. Express each of these quantifications in English. a) x P(x) b) x P(x) c) x ¬P(x) d) x ¬P(x) 5. Translate these statements into English, where C(x) is "x is a comedian" and F(x) is "x is funny" and the domain consists of all people. a) x (C(x) → F(x)) b) x (C(x) → F(x)) c) x (C(x)  F(x)) d) x (C(x)  F(x)) 6. Translate these statements into English, where R(x) is "x is a rabbit" and H (x) is "x hops" and the domain consists of all animals. a) x (R(x) → H(x)) b) x (R(x) → H(x)) c) x (R(x)  H(x)) d) x (R(x)  H(x))

More Related