ics 253: discrete structures i dr. nasir al-darwish computer science department king fahd university...

22
ICS 253: Discrete Structures I ICS 253: Discrete Structures I Dr. Nasir Al-Darwish Computer Science Department King Fahd University of Petroleum and Minerals [email protected] Spring Semester 2014 (2013-2) Predicates and Quantifiers

Upload: darrion-pelly

Post on 14-Dec-2015

221 views

Category:

Documents


1 download

TRANSCRIPT

ICS 253: Discrete Structures I ICS 253: Discrete Structures I

Dr. Nasir Al-DarwishComputer Science Department King Fahd University of Petroleum and [email protected]

Spring Semester 2014 (2013-2)

Predicates and Quantifiers

KFUPM: Dr. Al-Darwish © 2014 2

Propositional Predicate Definition: A propositional predicate P(x) is a

statement that has a variable x.

Examples of P(x)

P(x) = “The Course x is difficult”

P(x) = “x+2 < 5”

Note: a propositional predicate is not a proposition because it depends on the value of x.

Example: If P(x) = “x > 3”, then P(4) is true but not P(1).

A propositional predicate is also called a propositional function

KFUPM: Dr. Al-Darwish © 2014 3

Propositional Predicate – cont.

It also possible to have more than one variable in one predicate, e.g., Q(x,y) =“x > y-2”

P(x) is a function (a mapping) that takes a value for x and produce either true or false.

Example: P(x) = “x2 > 2” , P: Some Domain {T, F}

Domain of x is called the domain (universe) of discourse

KFUPM: Dr. Al-Darwish © 2014 4

Quantification

A predicate (propositional function) could be made a proposition by either assigning values to the variables or by quantification.

Predicate Calculus: Is the area of logic concerned with predicates and quantifiers.

KFUPM: Dr. Al-Darwish © 2014 5

Quantifiers

1. Universal quantifier: P(x) is true for all (every) x in the domain. We write x P(x)

2. Existential quantifier: there exists at least one x

in the domain such that P(x) is true. We write x P(x)

3. Others: there exists a unique x such that P(x) is true.

We write !x P(x)

KFUPM: Dr. Al-Darwish © 2014 6

Universal Quantification

Uses the universal quantifier (for all)

x P(x) corresponds to “p(x) is true for all values of x (in some domain)”

Read it as “for all x p(x)” or “for every x p(x)”

Other expressions include “for each” , “all of”, “for arbitrary” , and “for any” (avoid this!)

A statement x P(x) is false if and only if p(x) is not always true (i.e., P(x) is false for at least one value of x)

An element for which p(x) is false is called a counterexample of x P(x); one counterexample is all we need to establish that x P(x) is false

KFUPM: Dr. Al-Darwish © 2014 7

Universal Quantification - Examples Example 1: Let P(x) be the statement “x + 1 > x” . What is

the truth value of ∀x P(x), where the domain for x consists of all real numbers?

Solution: Because P(x) is true for all real numbers x, the universal quantification ∀x P(x) is true.

Example 2: Suppose that P(x) is “x2 > 0” . What is the truth value of ∀x P(x), where the domain consists of all integers.

Solution: We show ∀x P(x) is false by a counterexample. We see that x = 0 is a counterexample because for x = 0, x2 = 0, thus there is some integer x for which P(x) is false.

KFUPM: Dr. Al-Darwish © 2014 8

Existential Quantification

Uses the existential quantifier (there exists)

x P(x) corresponds to “There exists an element x (in some domain) such that p(x) is true”

In English, “there is”, “for at least one”, or “for some”

Read as “There is an x such that p(x)”, “There is at least one x such that p(x)”, or “For some x, p(x)”

A statement x P(x) is false if and only if “for all x, P(x) is false”

KFUPM: Dr. Al-Darwish © 2014 9

Existential Quantification - Examples Example 1: Let P(x) denote the statement “x > 3”. What is

the truth value of ∃x P(x), where the domain for x consists of all real numbers?

Solution: Because “x > 3” is true for some values of x , for example, x = 4, the existential quantification ∃x P(x) is true.

Example 2: Let Q(x) denote the statement “x = x + 1” . What is the truth value of ∃x Q(x), where the domain consists of all real numbers?

Solution: Because Q(x) is false for every real number x, the existential quantification ∃x Q(x) is false.

KFUPM: Dr. Al-Darwish © 2014 10

Predicates and Negations

Predicate When true When false Negation

x P(x) For all x, P(x) is true There is at least one x s.t. P(x) is false

x P(x)

x P(x) There is at least one x s.t. P(x) is true

For all x, P(x) is false

x P(x)

KFUPM: Dr. Al-Darwish © 2014 11

Domain (or Universe) of Discourse

Cannot tell if a quantified predicate P(x) is true (or false) if the domain of x is not known.

The meaning of the quantified P(x) changes when we change the domain.

The domain must always be specified when universal or existential quantifiers are used; otherwise, the statement is ambiguous.

KFUPM: Dr. Al-Darwish © 2014 12

Quantification Examples

P(x) = “x+1 = 2” Domain is R (set of real numbers)

Proposition Truth Value

x P(x)

x P(x)

x P(x)

x P(x)

!x P(x)

!x P(x)

FFTTTF

KFUPM: Dr. Al-Darwish © 2014 13

Quantification Examples P(x) = “x2 > 0”

Domain Proposition Truth Value

R x P(x)

Z x P(x)

Z - {0} x P(x)

Z !x P(x)

N={1,2, ..} x P(x)

FFTTF

KFUPM: Dr. Al-Darwish © 2014 14

Quantification Examples

Proposition Truth Value

xR (x2 x)

!xR (x2 < x)

x(0,1) (x2 < x)

x{0,1} (x2 = x)

x P(x)

FT

F

T

T

KFUPM: Dr. Al-Darwish © 2014 15

Logically Equivalence

Definition: Two statements involving predicates & quantifiers are logically equivalent

if and only if

they have the same truth values independent of the domains and the predicates.

Examples:

( x P(x) ) x P(x)

( x P(x) ) x P(x)

KFUPM: Dr. Al-Darwish © 2014 16

Theorem

If the domain of discourse is finite, say Domain = {x1, x2, …, xn}, then

x P(x)

x P(x)

P(x1) P(x2) ... P(xn)

P(x1) P(x2) ... P(xn)

KFUPM: Dr. Al-Darwish © 2014 17

Precedence

, , , , ,

Example:

((x P(x) ) ((!x Q(x) ) (x P(x) )))

KFUPM: Dr. Al-Darwish © 2014 18

Correct Equivalences

x ( P(x) Q(x) ) x P(x) x Q(x)

This says that we can distribute a universal quantifier over a conjunction

x ( P(x) Q(x) ) x P(x) x Q(x)

This says that we can distribute an existential quantifier over a disjunction

The preceding equivalences can be easily proven if we assume a finite domain for x = {x1, x2, …, xn}

Note: we cannot distribute a universal quantifier over a disjunction, nor can we distribute an existential quantifier over a conjunction.

KFUPM: Dr. Al-Darwish © 2014 19

Wrong Equivalences

x ( P(x) Q(x) ) x P(x) x Q(x) Read as “there exists an x for which both P(x) and Q(x) are

true is equivalent to there exists an x for which P(x) is true and there exists an x for which Q(x) is true”. One can construct an example that makes the above equivalence false. Consider the following

x ( P(x) Q(x) ) = F but

x P(x) x Q(x) = T, since P(1) is true and Q(2) is true

x 1 2

P(x) T F

Q(x) F T

KFUPM: Dr. Al-Darwish © 2014 20

Wrong Equivalences

x ( P(x) Q(x) ) x P(x) x Q(x) One can construct an example that makes the

above equivalence false. Consider the following

x ( P(x) Q(x) ) = T but

x P(x) x Q(x) = F F = F

x 1 2

P(x) T F

Q(x) F T

KFUPM: Dr. Al-Darwish © 2014 21

Wrong Equivalences

( x P(x) ) Q(x) x ( P(x) Q(x) )

Notice that the LHS = ( x P(x) ) Q(x) is not fully quantified. So it cannot be equivalent to RHS.

KFUPM: Dr. Al-Darwish © 2014 22

Quantifiers with restricted domains

What do the following statements mean for the domain of real numbers?

)20( as same 2,0

)00( as same0,0

)00( as same0,0

22

33

22

zzzzz

yyyyy

xxxxx

Be careful about → and ˄ in these statements