3 28 16
play

3/28/16 Predicate Logic n Some statements cannot be expressed in - PDF document

3/28/16 Predicate Logic n Some statements cannot be expressed in propositional logic, such as: Predicate Logic n All men are mortal. (Rosen, Sections 1.4, 1.5) n Some trees have needles. TOPICS n X > 3. Universal Quantifiers n Predicate


  1. 3/28/16 Predicate Logic n Some statements cannot be expressed in propositional logic, such as: Predicate Logic n All men are mortal. (Rosen, Sections 1.4, 1.5) n Some trees have needles. TOPICS n X > 3. • Universal Quantifiers n Predicate logic can express these • Existential Quantifiers statements and make inferences on them. • Predicate Equivalences CS160 - Spring Semester 2016 2 Statements in Predicate Logic Example n Let Q(x,y) denote “ x=y+3 ” . P(x,y) n What are truth values of: n Two parts: n Q(1,2) false n A predicate P describes a relation or property. n Q(3,0) true n V ariables (x,y) can take arbitrary values from some domain. n Let R(x,y) denote x beats y in n Still have two truth values for statements Rock/Paper/Scissors with 2 players with following rules: (T and F) n Rock smashes scissors, Scissors cuts paper, n When we assign values to x and y , then Paper covers rock. P has a truth value. n What are the truth values of: false n R(rock, paper) true n R(scissors, paper) CS160 - Spring Semester 2016 3 CS160 - Spring Semester 2016 4 1

  2. 3/28/16 Quantifiers Universal Quantifier n P(x) is true for all values in the domain n Quantification expresses the extent to which a predicate is true over a set of ∀ x ∈ D, P(x) elements. n For every x in D , P(x) is true. n Two forms: n An element x for which P(x) is false is called a counterexample . n Universal ∀ n Given P(x) as “ x+1>x ” and the domain n Existential ∃ of R , what is the truth value of: ∀ x P(x) true CS160 - Spring Semester 2016 5 CS160 - Spring Semester 2016 6 Example Existential Quantifier n P(x) is true for at least one value in the n Let P(x) be that x>0 and x is in domain domain. of R . ∃ x ∈ D, P(x) n Give a counterexample for: ∀ x P(x) n For some x in D , P(x) is true. n Let the domain of x be “ animals ” , M(x) be “ x is a mammal ” and x = -5 E(x) be “ x lays eggs ” , what is the truth value of: true Platypuses ∃ x (M(x) ∧ E(x)) echidnas CS160 - Spring Semester 2016 7 CS160 - Spring Semester 2016 8 2

  3. 3/28/16 English to Logic English to Logic n Some person in this class has visited the n For every one there is someone to love. Grand Canyon. n Domain of x and y is the set of all persons n Domain of x is the set of all persons n L(x, y): x loves y n C(x): x is a person in this class n ∀ x ∃ y L(x,y) n V(x): x has visited the Grand Canyon n Is it necessary to explicitly include that x n ∃ x(C(x) ∧ V(x)) and y must be different people (i.e. x ≠ y)? n Just because x and y are different variable names doesn ’ t mean that they can ’ t take the same values CS160 - Spring Semester 2016 9 CS160 - Spring Semester 2016 10 Evaluating Expressions: English to Logic Precedence and Variable Bindings n No one in this class is wearing shorts and a ski n Precedence: parka. n Quantifiers and negation are evaluated n Domain of x is persons in this class before operators n S(x): x is wearing shorts n Otherwise left to right n P(x): x is wearing a ski parka n Bound: n ¬ ∃ x(S(x) ∧ P(x)) n Variables can be given specific values or n Domain of x is all persons n Can be constrained by quantifiers n C(x): x belongs to the class n ¬ ∃ x(C(x) ∧ S(x) ∧ P(x)) CS160 - Spring Semester 2016 11 CS160 - Spring Semester 2016 12 3

  4. 3/28/16 Predicate Logic Equivalences Other Equivalences • Someone likes skiing (P) or likes swimming (Q); hence, Statements are logically equivalent iff they have the there exists someone who likes skiing or there exists same truth value under all possible bindings. someone who likes skiing. For example: ( ( ) ∨ Q x ( ) ) ≡ ∃ xP x ( ) ∨∃ xQ x ( ) ∃ x P x ( ( ) ∧ Q x ( ) ) ≡ ∀ xP x ( ) ∧∀ xQ x ( ) ∀ x P x • Not everyone likes to go to the dentist; hence there is someone who does not like to go to the dentist. In English: “Given the domain of students in CS160, all ( ) ≡ ∃ x ¬ P x ( ) ¬ ∀ xP x students have passed M124 course (P) and are • There does not exist someone who likes to go to the registered at CSU (Q); hence, all students have passed dentist; hence everyone does not like to go to the dentist. M124 and all students are registered at CSU. ( ) ≡ ∀ x ¬ P x ( ) ¬ ∃ xP x CS160 - Spring Semester 2016 13 CS160 - Spring Semester 2016 14 4

Recommend


More recommend