PREDICATES AND QUANTIFIERS Lecture # 4 1 TERMINOLOGY REVIEW Proposition: - A statement that is either true or false - Must always be one or the other! Example: “The sky is red” Not a proposition: x + 3 > 4 Boolean variable: - A variable (usually p, q, r, etc.) that represents a proposition. 2 Consider the following statements: x > 3, x = y +3, x + y = z We can make propositions out of such statements A predicate is a property that is affirmed or denied about the subject (in logic: we say “variables” or “arguments”) of a statement. “ x subject 3 is greater than 3” predicate To write in a predicate logic: “ x is greater then 3” subject predicate We introduce a (functional) symbol for the predicate, and put the subject as an argument (to the functional symbol): P(x). The statement P(x) is also said to be propositional function. Examples: • • • • 4 Father(x): unary predicate Brother(x, y): binary predicate Sum(x, y, z): ternary predicate P(x, y, z, …t): n-ary predicate PROPOSITIONAL FUNCTIONS Consider P(x) = x < 5 P(x) has no truth values (x is not given a value) P(1) is true The proposition 1 < 5 is true P(10) is false The proposition 10 < 5 is false Thus, P(x) will create a proposition when given a value. 5 EXAMPLE Let P(x) denote the statement “x > 3”. What are truth values of P(4) and P(2)? SOLUTION: P(x) = x > 3 P(4) = 4 > 3 P(4) = True P(x) = x > 3 P(2) = 2 > 3 P(2) = False 6 EXAMPLES Let P(x) = “x is a multiple of 5” For what values of x is P(x) true? Let P(x) = x+1 > x 7 For what values of x is P(x) true? PROPOSITIONAL FUNCTIONS INVOLVING MULTIPLE VARIABLES Functions with multiple variables: P(x,y) = x + y == 0 P(x,y,z) = x + y == z 9 P(1,2) is false, P(1,-1) is true P(3,4,5) is false, P(1,2,3) is true DEFINITION A predicate is a sentence that contains a finite number of variables and becomes a statement when specific values are substituted for the variables. The domain of a predicate variable is the set of all values that may be substituted in place of the variable. 10 UNIVERSE OF DISCOURSE Consider the statement ‘x > 3’, does it make sense to assign to x the value ‘blue’? Intuitively, the universe of discourse is the set of all things we wish to talk about; that is the set of all objects that we can sensibly assign to a variable in a propositional function. Referred to as Domain. What would be the universe of discourse for the propositional function below be: EnrolledCSE235(x)=‘x is enrolled in CSE235’ 11 QUANTIFIERS When the variables in a propositional function are assigned values, the resulting statement becomes a proposition with a certain truth values. However, there is another important way, called quantification, to create a proposition from a propositional function. Quantification expresses the extent to which a predicate is true over a range of elements. 12 In English, the words all, some, many, none and few are used in quantification. We will focus on two types of quantification here Universal Quantification Existential Quantification 13 The statement ‘x > 3’ is not a proposition It becomes a proposition When we assign values to the argument: ‘4>3’ is false, ‘2<3’ is true, or When we quantify the statement Two quantifiers Universal quantifier \for all the proposition is true for all possible values in the universe of discourse Existential quantifier \exists the proposition is true for some value(s) in the universe of discourse 14 UNIVERSAL QUANTIFIER Definition: The universal quantification of a predicate P(x) is the proposition ‘P(x) is true for all values of x in the universe of discourse.’ Notation: We use the notation: x P(x), which is read ‘for all x’. If the universe of discourse is finite, say {n1,n2,…,nk}, then the universal quantifier is simply the conjunction of the propositions over all the elements x P(x) P(n1) P(n2) … P(nk) 15 UNIVERSAL QUANTIFIER Represented by an upside-down A: It means “for all” Let P(x) = x+1 > x We can state the following: 16 x P(x) English translation: “for all values of x, P(x) is true” English translation: “for all values of x, x+1>x is true” EXAMPLE Let the universe be the real numbers. Then, x P(x) is true Let P(x) = x/2 < x Not true for the negative numbers! Thus, x P(x) is false When the domain is all the real numbers 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 ONE case 17 LOOP Think of as a for loop: x P(x), where 1 ≤ x ≤ 10 … can be translated as … for ( x = 1; x <= 10; x++ ) is P(x) true? If P(x) is true for all parts of the for loop, then x P(x) 18 Consequently, if P(x) is false for any one value of the for loop, then x P(x) is false REMEMBER The truth value of x P(x) depends on the domain/universe of discourse! A statement x P(x) is false. If and only If P(x) is not always true when x is in the domain. One way to show that P(x) is not always true when x is in the domain is to find a counterexample. A single counter example is all we need to establish that x P(x) is false. 19 EXAMPLE 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 Counter Example: Let x = 3 Q(3) is false Thus, x Q(x) is false. 20 EXAMPLE What is the truth value of x P(x), where P(x) is the statement “x2 < 10” and the domain consists of the positive integers not exceeding 4? Solution: The statement x P(x) is the same as the conjunction P(1) P(2) P(3) P(4) P(1) is true P(2) is true P(3) is true P(4) is false P(4), which is the statement “42 < 10” is false, Thus, x P(x) is false. 21 EXAMPLE a) What is the truth value of x (x2 ≥ x), if the domain consists of all real numbers? b) What is the truth value of x (x2 ≥ x), if the domain consists of all integers? a) Solution: The universal quantification (x2 ≥ x) is not true for every real number x Counter Example: Let x = ½ (1/2)2 ≥ (1/2) is false 22 b) Solution: The universal quantification (x2 ≥ x) is true for all integers. The universal quantification (x2 ≥ x) is true for all 0 < x < 1. 23 EXISTENTIAL QUANTIFICATION Definition: The existential quantification of a predicate P(x) is the proposition ‘There exists a value x in the universe of discourse such that P(x) is true.’ Notation: We use the notation: x P(x), which is read ‘there exists x’. If the universe of discourse is finite, say {n1,n2,…,nk}, then the existential quantifier is simply the disjunction of the propositions over all the elements x P(x) P(n1) P(n2) … P(nk) 24 Represented by an backwards E: It means “there exists” Let P(x) = x+1 > x We can state the following: 25 x P(x) English translation: “there exists (a value of) x such that P(x) is true” English translation: “for at least one value of x, x+1>x is true” EXAMPLE Let P(x) = x+1 > x 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 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 26 EXAMPLE Let P(x) be the statement “x > 3.” What is the truth value of the quantification x P(x), where the domain consists of all real numbers? Solution: P(x) is true for some values in domain Counter Example: Let x = 4 P(4) is true Thus, x P(x) is true. 27 EXAMPLE Let Q(x) be the statement “x = x + 1.” What is the truth value of the quantification x Q(x), where the domain consists of all real numbers? Solution: Q(x) is false for every real number x. Counter Example: Let x = 6 Q(6) = 6 = 6 + 1 is false Thus, x Q(x) is false. 28 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: The statement x P(x) is the same as the disjunction P(1) P(2) P(3) P(4) P(1) is false P(2) is false P(3) is false P(4) is true P(4), which is the statement “42 < 10” is true Thus, x P(x) is true 29 NOTE Recall that P(x) is a propositional function Recall that a proposition is a statement that is either true or false Let P(x) be “x == 0” P(x) is not a proposition There are two ways to make a propositional function into a proposition: Supply it with a value For example, P(5) is false, P(0) is true Provide a quantification For example, x P(x) is false and x P(x) is true 30 Let the universe of discourse be the real numbers QUANTIFIERS: Truth values In general, when are quantified statements true or false? Statement True when… x P(x) x P(x) False when... There is an x for which P(x) is true for every x P(x) is false There is an x for which P(x) is false for every x P(x) is true x P(x) is true when domain is empty. x P(x) is false when domain is empty. UNIQUENESS QUANTIFIER The Uniqueness quantifier, denoted by ! or 1. Notation: ! x P(x) [or 1 x P(x)] states “there exist a unique x such that P(x) is true” Other phrases for uniqueness quantification include “there is exactly one” and “there is one and only one.” 32 EXAMPLE ! x (x - 1 = 0), where the domain is the set of real Solution: (x - 1 = 0) is true for a unique real number. Counter Example: Let x = 1 (x - 1 = 0) is true Note: Generally, uniqueness quantifier is avoided. It is best to stick with existential and universal quantifier. numbers. 33 QUANTIFIERS WITH RESTRICTED DOMAINS EXAMPLE: What do statements x < 0 (x2 > 0), y ≠ 0 (y3 ≠ 0) SOLUTION: The statement x < 0 (x2 > 0) states that for every real number x with x < 0, x2 > 0. That is, “the square of negative real number is positive.” The statement is the same as: x (x < 0 → x2 > 0). 34 The statement y ≠ 0 (y3 ≠ 0) states for every real number y with y ≠ 0, we have (y3 ≠ 0). That is, “the cube of every nonzero real number is nonzero.” This statement is equivalent to: y(y ≠ 0 → y3 ≠ 0) 35 NOTE: The restriction of a universal quantification is the same as the universal quantification of a conditional statement. Example: x < 0 (x2 > 0) is another way of expressing x (x < 0 → x2 > 0) The restriction of a existential quantification is the same as the existential quantification of a conjunctive statement. Example: False z > 0 (z2 = 2) is another way of expressing z (z > 0 ^ z2 = 2) 36 PRECEDENCE OF QUANTIFICATION The quantifiers and have higher precedence than all logical operators from propositional calculus. Example: x P(x) Q(x) is the disjunction of x P(x) and Q(x). In other words, It means ( x P(x)) Q(x) rather than x (P(x) Q(x)). 37 BINDING VARIABLES When a quantifier is used on the variable x, we say that the occurrence of the variable is bound. An occurrence of a variable that is not bound by a quantifier is said to be free. The part of a logical expression to which a quantifier is applied is called the scope of this quantifier. 38 EXAMPLE In the statement x (x + y =1), The variable x is bound to by the existential quantification x. The variable y is free because it is not bound by a quantifier. x (x + y =1), x is bound, but y is free. 39 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)) 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) Universal quantifier binds the variable x in R(x). 40 EXAMPLES (x P(x)) Q(x) (x P(x)) (x Q(x)) Both x values are bound; thus it is a proposition (x (P(x) Q(x))) (y R(y)) The x in Q(x) is not bound; thus not a proposition All variables are bound; thus it is a proposition (x P(x) Q(y) (y R(y)) 41 The y in Q(y) is not bound; this not a proposition BINDING VARIABLES Let P(x, y) be x > y Consider: x P(x, y) This is not a proposition! What is y? If it’s 5, then x P(x, y) is false If it’s x-1, then x P(x, y) is true Note that y is not “bound” by a quantifier 42 LOGICAL EQUIVALENCES INVOLVING QUANTIFIERS Two statements S and T involving predicates and quantifiers are logically equivalent if and only if they have the same truth value regardless of the interpretation, i.e. regardless of The meaning that is attributed to each propositional function. The domain of discourse. Notation: We use the notation S T to indicate that two statements S and T involving predicates and quantifiers are logically equivalent. 43 EXAMPLE Is x (P(x) Q(x)) logically equivalent to x P(x) x Q(x)? where the same domain is used throughout. Solution: Use two steps If x (P(x) Q(x)) is true, then x P(x) x Q(x) is true Proof: Suppose x (P(x) Q(x)) is true. Then if a is in the domain, P(a) Q(a) is true, So P(a) is true and Q(a) is true. So, if a is in the domain P(a) is true, which is the same as x P(x) is true; and similarly, we get that x P(x) is true 44 TRANSLATING FROM ENGLISH INTO LOGICAL EXPRESSIONS Example: Express the statement using predicates and quantifiers. “Every student in this class has studied calculus” Solution: Step 1: First we rephrase the statement so that we can clearly identify the appropriate quantifiers to use. “For every student in this class, that student has studied calculus.” Step 2: Introduce a variable x “For every student x in this class, x has studied calculus” 45 Step 3: Introduce C(x) C(x) = x has studied calculus. Domain = Students in the class. Step 4: x C(x) 46 EXAMPLE Express the statement using predicates and quantifiers. “For every person x, If person x is a student in this class then x has studied calculus.” Solution: Step 1: Step 2: Step 3: Introduce S(x) and C(x) S(x) = Person x is in the class. C(x) = x has studied Calculus. Domain = Students in the class. Step 4: x (S(x) → C(x)) 47 EXAMPLE Express the statement using predicates and quantifiers. “Some student in this class has visited Mexico” Solution: Step 1: First we rephrase the statement so that we can clearly identify the appropriate quantifiers to use. “There is a student in this class with the property that the student has visited Mexico” Step 2: Introduce a variable x “There is a student x in this class having the property that x has visited Mexico” 48 Step 3: Introduce M(x) M(x) = x has visited Mexico. Domain = Students in the class. Step 4: x M(x) 49 EXAMPLE Express the statement using predicates and quantifiers. “There is a person x having the properties that x is a student in this class and x has visited Mexico.” Solution: Step 1: Step 2: Step 3: Introduce S(x) and M(x) S(x) = x is a student in this class. M(x) = x has visited Mexico. Domain = All person. Step 4: x (S(x) M(x)) 50 EXAMPLE Express the statement using predicates and quantifiers. “For every x in this class, x has the property that x has visited Mexico or x has visited Canada.” Solution: Step 1: Step 2: Step 3: Introduce C(x) and M(x) C(x) = x has visited Canada. M(x) = x has visited Mexico. Domain = All people. Step 4: x (C(x) M(x)) 51 EXAMPLE Express the statement using predicates and quantifiers. “For every person x, if x is a student in this class, then x has visited Mexico or x has visited Canada.” Solution: Step 1: Step 2: Step 3: Introduce S(x) and M(x) S(x) = x is a student in this class. C(x) = x has visited Canada. M(x) = x has visited Mexico. Domain = student in the class. Step 4: x (S(x) → (C(x) M(x))). 52 EXAMPLES FROM LEWIS CARROL Consider these statements. The first two are called premises and the third is called the conclusion. The entire set is called an argument. “All lions are fierce.” “Some lions do not drink coffee.” Therefore, “Some fierce creatures do not drink coffee.” 53 SOLUTION Let P(x) = “x is a lion.” Q(x) = “x is fierce.” R(x) = “x drinks coffee.” Domain = Assume all creatures. We can express these statements as: “All lions are fierce.” x (P(x) → Q(x)). 54 “Some lions do not drink coffee.” x (P(x) ¬R(x)). “Some fierce creatures do not drink coffee.” x (Q(x) ¬R(x)). 55 MORE EXAMPLES Translate the statements: “All hummingbirds are richly colored” “No large birds live on honey” “Birds that do not live on honey are dull in color” “Hummingbirds are small” Solution: Assign propositional functions Let P(x) = “x is a hummingbird” Q(x) = “x is large” R(x) = “x lives on honey” S(x) = “x is richly colored” Let our universe of discourse be all birds 56 Translate the statements: Assume that “small” is the same as “not large” and that “dull in color” is the same as “not richly colored” “All hummingbirds are richly colored” x (P(x)→S(x)) “No large birds live on honey” ¬x (Q(x) R(x)) Alternatively: x (¬Q(x) ¬R(x)) “Birds that do not live on honey are dull in color” x (¬R(x) → ¬S(x)) “Hummingbirds are small” x (P(x) → ¬Q(x)) 57 NEGATING QUANTIFIED EXPRESSIONS Consider the statement: “Every student in your class has taken a course in calculus.” P(x) = x has taken a course in calculus. Domain = Students in your class. x P(x) 58 The negation of this statement is “It is not the case that every student in your class has taken a course in calculus.” This is equivalent to “There is a student in your class who has not taken a course in calculus.” x ¬P(x) 59 This example illustrate the following logical equivalence: ¬x P(x) x ¬P(x) 60 NOTE First note that ¬x P(x) is true if and only if x P(x) is false. Note that x P(x) is false if and only if there is an element x in domain for which P(x) is false. Finally, note that there is an element x in the domain for which ¬ P(x) is true if and only if x ¬P(x) is true. Putting these steps together, we can conclude that: ¬x P(x) is true if and only if x ¬P(x) is true. 61 It follows that ¬x P(x) and x ¬P(x) are logically equivalent. 62 Another example illustrate that following logical equivalence: ¬x Q(x) x ¬Q(x) 63 EXAMPLE What are the negations of the statements: “There is an honest politician” Solution: H(x) = x is an honest politician. Domain = all politician x H(x) The negation of this statement is ¬(x H(x)) = x ¬H(x) “Every politician is dishonest.” 64 EXAMPLE What are the negations of the statements: “All Americans eat cheeseburgers” Solution: C(x) = x eats cheeseburgers. Domain = all Americans x C(x) The negation of this statement is ¬(x C(x)) = x ¬C(x) “Some Americans does not eat cheeseburgers.” 65 EXAMPLE What are negations of the statement: x (x2 > x) Solution: The negation of x (x2 > x) is the statement ¬x (x2 > x) ¬x (x2 > x) = x ¬(x2 > x) This can be re-written as: x (x2 ≤ x) 66 EXAMPLE What are negations of the statement: x (x2 = 2) Solution: The negation of x (x2 = 2) is the statement ¬x (x2 = 2) ¬x (x2 = 2) = x ¬(x2 = 2) This can be re-written as: x (x2 ≠ 2) 67 EXMPLE Show that ¬x (P(x)→Q(x)) and x (P(x) ¬Q(x)) are logically equivalent. Solution: ¬x (P(x)→Q(x)) x ¬(P(x)→Q(x)) Given De Morgan’s law for universal quantifiers x ¬(¬P(x) Q(x)) As we know that p → q = ¬p q x (¬(¬P(x)) ¬Q(x)) De-Morgan’s law x (P(x) ¬Q(x)) Double Negation law R.H.S 68 EXMPLE Express the negation of xyP(x,y) xyQ(x,y). Solution: ¬(xyP(x,y) xyQ(x,y)) ¬(xyP(x,y)) ¬(xyQ(x,y)) x¬(yP(x,y)) x¬(yQ(x,y) ) xy ¬P(x,y) xy ¬Q(x,y) 69 Given De Morgan’s law De Morgan’s law De-Morgan’s law RULES OF INFERENCE FOR QUANTIFIED STATEMENTS 70 INTRODUCTION We have discussed rules of inference for propositions. We will now describe some important rules of inference for statements involving quantifiers, which are given below: 71 Universal Instantiation Universal Generalization Existential Instantiation Existential Generalization UNIVERSAL INSTANTIATION Assume that we know that x P(x) is true: Then we can conclude that P(c) is true Here c stands for some specific constant from the domain. This is called “universal instantiation” Given the premise x P(x). Example: We have a statement “All woman are wise.” We can conclude that “Sophia is wise” Where Sophia is member of the domain. 72 UNIVERSAL GENERALIZATION Assume that we know that P(c) is true for any value of c 73 Then we can conclude that x P(x) is true. This is called “universal generalization” EXISTENTIAL INSTANTIATION Assume that we know that x P(x) is true 74 Then we can conclude that P(c) is true for some value of c Here c stands for some specific constant from the domain. This is called “existential instantiation” Given the premise x P(x). EXISTENTIAL GENERALIZATION Assume we know that P(c) is true for some value of c 75 Then we can conclude that x P(x) is true This is called “existential generalization” 76 EXAMPLE Show that the premises: “Everyone in this discrete structures class has taken a course in computer science” and “John is a student in this class” imply the conclusion “John has taken a course in computer science.” Solution: D(x) = x is in discrete mathematics class. C(x) = x has taken a course in computer science. 77 Then the premises are: x (D(x) → C(x)) D(John) C(John) The following steps can be used to establish conclusion: 1. x (D(x) → C(x)) 2. D(John) → C(John) 3. D(John) 4. C(John) Premise Universal Instantiation Premise Modus Ponens Rule of inference pq p q q pq p pq qr Tautology Name [ p ( p q)] q Modus ponens [q ( p q)] p Modus tollen [( p q) (q r )] ( p r ) Hypothetic al syllogism pr pq p q p pq pq p p q pq pq p r q r (( p q) p) q Disjunctiv e syllogism p ( p q) Addition ( p q) p Simplifica tion (( p) (q)) ( p q) Conjunctio n [( p q) (p r )] ( p r ) Resolution EXAMPLE Show that the premises: “A student in this class has not read the book.” and “Everyone in this class passed the first exam” imply the conclusion “Someone who passed the first exam has not read the book.” Solution: C(x) = x is in this class. B(x) = x has read the book. P(x) = x passed the first exam. 79 Then the premises are: x (C(x) ¬B(x)) x (C(x) → P(x)) x (P(x) ¬B(x)) The following steps can be used to establish conclusion: Rule of inference 1. x (C(x) ¬B(x)) Premise pq p 2. C(a) ¬B(a) Existential Instantiation q q 3. C(a) Simplification pq p 4. x (C(x) → P(x)) Premise pq qr 5. C(a) → P(a) Universal Instantiation pr pq 6. P(a) Modus Ponens p 7. ¬B(a) C(a) Commutative on (2) q p 8. ¬B(a) Simplification pq pq 9. P(a) ¬B(a) Conjunction on (6) & (8) p p 10. x (P(x) ¬B(x)) Existential Generalization q pq pq p r q r Tautology Name [ p ( p q )] q Modus ponens [q ( p q )] p Modus tollen [( p q ) (q r )] ( p r ) Hypothetic al syllogism (( p q ) p ) q Disjunctiv e syllogism p ( p q) Addition ( p q) p Simplifica tion (( p ) (q )) ( p q ) Conjunctio n [( p q ) (p r )] ( p r ) Resolution COMBINING RULES OF INFERENCE FOR PROPOSITIONS & QUANTIFIED STATEMENTS A rule of inference for quantified statements, and modus ponens, a rule of inference for propositional logic. We will often need to use this combination of rules of inference. Because universal instantiation and modus ponens are used so often together. This combination of rules is sometimes called universal modus ponens. 81 UNIVERSAL MODUS PONENS This rule tells us that if x (P(x) → Q(x)) is true, and if P(a) is true for a particular element a in the domain of the universal quantifier, then Q(a) must also be true. To see this, note that by universal instantiation P(a) → Q(a) is true. x (P(x) → Q(x)) P(a), where a is a particular element in the domain. Q(a) 82 NOTE Universal modus ponens is commonly used in mathematical arguments. 83 UNIVERSAL MODUS TOLLENS Universal modus tollens combines universal instantiation and modus tollens and can be expressed in the following way: x (P(x) → Q(x)) ¬Q(a), where a is a particular element in the domain. ¬P(a) 84 EXERCISE Use rules of inference to show that if x (P(x) → (Q(x) S(x))) and x (P(x) R(x))) are true then x (R(x) S(x)) is true Solution: 85 The following steps can be used to establish conclusion: 01. x (P(x) R(x))) Premise 02. P(a) R(a) Universal Instantiation 03. P(a) Simplification 04. x (P(x) → (Q(x) S(x))) Premise 05. Q(a) S(a) Universal modus ponens 06. S(a) Q(a) Commutative 07. S(a) Simplification Rule of inference pq 08. R(a) P(a) 09. R(a) 10. R(a) S(a) 11. x (R(x) S(x)) Commutative on (2) Simplification Conjunction (9) & (7) Universal generalization p q q pq p pq qr Tautology Name [ p ( p q )] q Modus ponens [q ( p q )] p Modus tollen [( p q ) (q r )] ( p r ) Hypothetic al syllogism pr pq p q p pq pq p p q pq pq p r q r (( p q ) p ) q Disjunctiv e syllogism p ( p q) Addition ( p q) p Simplifica tion (( p ) (q )) ( p q ) Conjunctio n [( p q ) (p r )] ( p r ) Resolution