CS 220: Discrete Structures and their Applications

Slides:



Advertisements
Similar presentations
Nested Quantifiers Section 1.4.
Advertisements

1.3 Predicates and Quantifiers
Section 1.3. More Logical Equivalences Constructing New Logical Equivalences We can show that two expressions are logically equivalent by developing.
Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers.
Predicates and Quantifiers
Propositions and Connectives Conditionals and Bi-conditionals Quantifiers.
RMIT University; Taylor's College This is a story about four people named Everybody, Somebody, Anybody and Nobody. There was an important job to be done.
CSE 311 Foundations of Computing I Lecture 6 Predicate Logic Autumn 2011 CSE 3111.
CSE115/ENGR160 Discrete Mathematics 01/20/11 Ming-Hsuan Yang UC Merced 1.
Lecture # 21 Predicates & Quantifiers
1 Predicates and Quantifiers CS 202, Spring 2007 Epp, Sections 2.1 and 2.2 Aaron Bloomfield.
Predicates and Quantifiers
Section 1.3: Predicates and Quantifiers
Predicates & Quantifiers Goal: Introduce predicate logic, including existential & universal quantification Introduce translation between English sentences.
Predicates and Quantifiers
Chapter 1: The Foundations: Logic and Proofs
CSci 2011 Discrete Mathematics Lecture 3 CSci 2011.
The Foundations: Logic and Proofs
Logical Equivalence & Predicate Logic
CS 103 Discrete Structures Lecture 05
1 Predicates and Quantifiers CS/APMA 202, Spring 2005 Rosen, section 1.3 Aaron Bloomfield.
Chapter 1, Part II: Predicate Logic With Question/Answer Animations.
Chapter 1, Part II With Question/Answer Animations Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the.
Chapter 1, Part II: Predicate Logic With Question/Answer Animations.
Math 51/COEN 19 Day 3, 1.4 Quantifiers 1. 3 Predicates A lot like functions that return booleans Let P(x) denote x
Predicates and Quantified Statements
Nested Quantifiers Section 1.5.
1 Sections 1.3 and 1.4 Predicates & Quantifiers. 2 Propositional Functions In a mathematical assertion, such as x < 3, there are two parts: –the subject,
Chapter 2 Logic 2.1 Statements 2.2 The Negation of a Statement 2.3 The Disjunction and Conjunction of Statements 2.4 The Implication 2.5 More on Implications.
1 Introduction to Abstract Mathematics Predicate Logic Instructor: Hayk Melikya Purpose of Section: To introduce predicate logic (or.
1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Lecture 02: QUANTIFIERS Sections 1.3 and 1.4 Jarek Rossignac CS1050:
CSS342: Quantifiers1 Professor: Munehiro Fukuda. CSS342: Quantifiers2 Review of Propositions Proposition: a statement that is either true or false, but.
Lecture Predicates and Quantifiers 1.4 Nested Quantifiers.
Lecture 7 – Jan 28, Chapter 2 The Logic of Quantified Statements.
Discrete Mathematics CS 2610 August 22, Agenda Last class Propositional logic Logical equivalences This week Predicate logic & rules of inference.
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 1 The Foundations: Logic and Proofs Predicates and Quantifiers.
CS 285- Discrete Mathematics Lecture 4. Section 1.3 Predicate logic Predicate logic is an extension of propositional logic that permits concisely reasoning.
Copyright © Peter Cappello 2011 Predicates & Quantifiers.
Discrete Mathematics Mathematical reasoning: think logically; know how to prove Combinatorial analysis: know how to count Discrete structures: represent.
Section 1.5 and 1.6 Predicates and Quantifiers. Vocabulary Predicate Domain Universal Quantifier Existential Quantifier Counterexample Free variable Bound.
PREDICATES AND QUANTIFIERS COSC-1321 Discrete Structures 1.
Mathematics for Comter I Lecture 3: Logic (2) Propositional Equivalences Predicates and Quantifiers.
Section 1.4. Propositional Functions Propositional functions become propositions (and have truth values) when their variables are each replaced by a value.
رياضيات متقطعة لعلوم الحاسب MATH 226. Chapter 1 Predicates and Quantifiers 1.4.
Lecture 1.2: Equivalences, and Predicate Logic
3. The Logic of Quantified Statements Summary
CSE15 Discrete Mathematics 01/23/17
Chapter 3 The Logic of Quantified Statements
Predicates & Quantifiers
The Foundations: Logic and Proofs
CS203 Discrete Mathematical Structures
Chapter 1 The Foundations: Logic and Proofs
The Foundations: Logic and Proofs
CS201: Data Structures and Discrete Mathematics I
1.4 Predicates and Quantifiers
CHAPTER 1: LOGICS AND PROOF
Nested Quantifiers Nested quantifiers are often necessary to express the meaning of sentences in English as well as important concepts in computer science.
First Order Logic Rosen Lecture 3: Sept 11, 12.
Discrete Mathematics Lecture 4 & 5: Predicate and Quantifier
Negations of quantifiers
Discrete Mathematics Lecture 3: Predicate and Quantifier
Discrete Mathematics CMP-200 Propositional Equivalences, Predicates & Quantifiers, Negating Quantified Statements Abdul Hameed
Discrete Mathematics Lecture 4 & 5: Predicate and Quantifier
Predicates and Quantifiers
The Foundations: Logic and Proofs
CS201: Data Structures and Discrete Mathematics I
Predicates and Quantifiers
The Foundations: Logic and Proofs
Presentation transcript:

CS 220: Discrete Structures and their Applications Predicate Logic Section 1.6-1.10 in zybooks

From propositional to predicate logic Let’s consider the statement “x is an odd number” Its truth value depends on the the value of the variable x. Once we assign x a value, it becomes a proposition. Predicate logic will allow us to reason about statements with variables without having to assign values to them.

Predicates Predicate: A logical statement whose truth value is a function of one or more variables. Examples: x is an odd number Computer x is under attack The distance between cities x and y is less than z When the variables are assigned a value, the predicate becomes a proposition and can be assigned a truth value.

Predicates The truth value of a predicate can be expressed as a function of the variables, for example: “x is an odd number” can be expressed as P(x). So, the statement P(5) is the same as "5 is an odd number”. “The distance between cities x and y is less than z miles” Represented by a predicate function D(x, y, z) D(fort-collins, denver, 100) is true.

The domain of a predicate The domain of a variable in a predicate is the set of all possible values for the variable. Examples: The domain of the predicate "x is an odd number" is the set of all integers. In general, the domain of a predicate should be defined with the predicate. Compare domain to type. Compare predicate to a java method declaration. What about the predicate: The distance between cities x and y is less than z miles? Typed parameter

Predicates Consider the predicate S(x, y, z) which is the statement that “x + y = z” What is the domain of the variables in the predicate? What is the truth value of: S(1, -1, 0) S(1, 2, 5)

Predicates Let R(x, y) denote: x beats y in rock-paper-scissors with the standard rules. What are the truth values of: R(Rock, Paper) R(Scissors, Paper) image from http://en.wikipedia.org/wiki/Rock-paper-scissors

Uses of predicate logic Verifying program correctness Consider the following snippet of code: if (x < 0) x = -x; What is true before? (called precondition) x has some value What is true after? (called postcondition) greaterThan(x, 0)

Quantifiers Assigning values to variables is one way to provide them with a truth value. Alternative: Say that a predicate is satisfied for every value (universal quantification), or that it holds for some value (existential quantification) Example: Let P(x) be the statement x + 1 > x. This holds regardless of the value of x We express this as: x P(x)

Universal quantification Universal quantification is the statement “P(x) for all values of x in the domain of P” Notation: x P(x)  is called the universal quantifier If the domain of P contains a finite number of elements a1, a2,..., ak: ∀x P(x) ≡ P(a1)  P(a2)  ,...,  P(ak)

Universal quantification Universal quantification is the statement “P(x) for all values of x in the domain of P” Notation: x P(x)  is called the universal quantifier An element x for which P(x) is false is called a counterexample. Example: Let P be the predicate “x2 > x” with the domain of real numbers. Give a counterexample. What does the existence of a counterexample tell us about the truth value of x P(x) ?

Existential quantification Existential quantification of P(x) is the statement There exists an element x in the domain of P such that P(x) Notation: x P(x)  is called the existential quantifier Example: M(x) - “x is a mammal” and E(x) - “x lays eggs” (both with the domain of “animals”). What is the truth value of x (M(x)  E(x))? True (Platipus) Platipus, 4 species of echidna (spiny anteaters) from Australia, New Guinea

Existential quantification Existential quantification of P(x) is the statement There exists an element x in the domain of P such that P(x) Notation: x P(x)  is called the existential quantifier If the domain of P contains a finite number of elements a1, a2,..., ak: x P(x) ≡ P(a1)  P(a2) ,...,  P(ak)

Quantified statements Consider the following predicates: P(x): x is prime O(x): x is odd The proposition ∃x (P(x)  ¬O(x)) states that there exists a positive number that is prime and not odd. Is this true? What about∀x (P(x) → O(x)) ? Yes! 2 is a prime number that is not odd.

Precedence of quantifiers The quantifiers :  and  have higher precedence than the logical operators from propositional logic. Therefore: x P(x)  Q(x) means: (x P(x))  Q(x) rather than: x (P(x)  Q(x)) Image from: http://mrthinkyt.tumblr.com/

Binding variables When a quantifier is used on a variable x, we say that this occurrence of x is bound All variables that occur in a predicate must be bound or assigned a value to turn it into a proposition Example: x D(x, Denver, 60) D is the predicate that states that the distance between cities x and y is less than z

Examples In the statement x (x + y = 1) x is bound In the statement x P(x)  x R(x) all variables are bound Can also be written as: x P(x)  y R(y) What about x P(x)  Q(x) ? Better to express this as What about x P(x)  Q(y)

English to Logic Every student in CS220 has visited Mexico Every student in CS220 has visited Mexico or Canada show that there are several ways to express these statements

Negating quantified statements Suppose we want to negate the statement: “Every student in CS220 has taken Math160” Translation into logic: x P(x) where P is the predicate “x has taken Math160”, with the domain of CS220 students. The negation: “not every student in CS220 has taken Math160”, or “there exists a student in CS220 who hasn’t taken Math160” i.e.: x P(x) mention other way of specifying this other than thru domain

Note Alternative way of expressing the statement “Every student in CS220 has taken Math160” x (takes(x, CS220)  hasTaken(x, math160)) or x (takesCS220(x)  hasTakenMath160(x))

De Morgan’s laws for quantifiers We have illustrated the logical equivalence: ¬∀x P(x) ≡ ∃x ¬P(x) A similar equivalence holds for the existential quantifier: ¬∃x P(x) ≡ ∀x ¬P(x). Example: There does not exist someone who likes to go to the dentist. Same as: everyone does not like to go to the dentist

De Morgan’s laws for quantifiers Example: Each quantifier be expressed using the other x Likes(x,IceCream) x Likes(x,IceCream) x Likes(x,Broccoli) x Likes(x,Broccoli)

English to Logic No one in this class is wearing shorts and a ski parka. Some lions do not drink coffee show that there are several ways to express these statements the parka statement: equivalent to everyone in the class either doesn’t wear a park or doesn’t wear shorts

Nested quantifiers If a predicate has more than one variable, each variable must be bound by a separate quantifier. The logical expression is a proposition if all the variables are bound.

Nested quantifiers of the same type Example: M(x, y): x sent an email to y, with the domain of people. Consider the statement ∀x ∀y M(x, y) In English: Every person sent an email to everyone. This is a statement on all pairs x,y: For every pair of people, x,y it is true that x sent y a mail.

Nested quantifiers Example: M(x, y): x sent an email to y, with the domain of people. Consider the statement ∀x ∀y M(x, y) In English: Every person sent an email to everyone – including themselves. But what if we would like to exclude the self emails? ∀x ∀y ((x ≠ y) → M(x, y))

Nested quantifiers of the same type Example: M(x, y): x sent an email to y, with the domain of people. Express the following in English: ∃x ∃y M(x, y) Order does not matter: x y is the same as y x x y is the same as y x

Alternating nested quantifiers x y is not the same as y x: x y Likes(x, y) “There is a person who likes everyone” y x Likes(x, y) “Everyone is liked by at least one person”

Nested quantifiers as a two person game Two players: the Universal player, and the Existential player. Each selects values for their variables. Example: ∀x ∃y (x + y = 0) The Universal player selects a value. Given the value chosen, the Existential player chooses its value, making the statement true.

Nested quantifiers as a two person game Two players: the Universal player, and the Existential player. Each selects values for their variables. What happens in this situation: ∃x ∀y (x + y = 0) ?

Expressing uniqueness L(x): x was late How do we express the statement that exactly one person was late? What’s wrong with ∃x L(x) ?

Expressing uniqueness L(x): x was late How do we express the statement that exactly one person was late? What’s wrong with ∃x L(x) ? Instead: ∃x (L(x)  ∀y((x ≠ y) → ¬L(y) )

Moving quantifiers L(x): x was late How do we express the statement that exactly one person was late? ∃x (L(x)  ∀y((x ≠ y) → ¬L(y)) Equivalent to: ∃x ∀y (L(x)  ((x ≠ y) → ¬L(y))

De Morgan’s laws with nested quantifiers ¬∀x ∀y P(x, y) ≡ ∃x ∃y ¬P(x, y) ¬∀x ∃y P(x, y) ≡ ∃x ∀y ¬P(x, y) ¬∃x ∀y P(x, y) ≡ ∀x ∃y ¬P(x, y) ¬∃x ∃y P(x, y) ≡ ∀x ∀y ¬P(x, y) Example: ∃x ∀y Likes(x, y ) : There is a person who likes everyone Its negation: ¬∃x ∀y Likes(x, y ) : There is no person who likes everyone. ¬∃x ∀y Likes(x, y ) ≡ ∀x ∃y ¬Likes(x, y ) : Every person has someone that they do not like. Each time the negation sign moves past a quantifier, the quantifier changes type from universal to existential or from existential to universal: