25
1 Sections 1.3 and 1.4 Predicates & Quantifiers

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,

Embed Size (px)

Citation preview

Page 1: 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,

1

Sections 1.3 and 1.4

Predicates & Quantifiers

Page 2: 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,

2

Propositional Functions

• In a mathematical assertion, such as x < 3, there are two parts:– the subject, which is the variable (x in this case)– the predicate, which is the property the subject

may (or may not) have (< 3 in the example)

• We can denote such a predicate as a propositional function on x, or P(x)

• When x has a value, P(x) is a proposition

Page 3: 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,

3

Propositional Functions

Let Q(x,y) denote the statement “x is the capital of y”What are the truth values of:

Q(Denver, Colorado)Q(Detroit, Michigan)Q(Massachusetts, Boston)Q(New York, New York)

A propositional function can include more than one variable; forexample:

Page 4: 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,

4

Propositional Functions and Programs

• In a program, a selection structure involves evaluating a propositional function

• For example:if (x > 0) x++;

Means let P(x) = x > 0if P(x) is true, increment xotherwise, do nothing

Page 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,

5

Quantifiers

• As we have seen, we can create a proposition from a propositional function by assigning a value to its subject(s)

• We can also create a proposition by quantifying the propositional function

• There are two types of quantifiers:– universal– existential

Page 6: 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,

6

Universal Quantification

• The domain of a problem is called its universe of discourse

• The universal quantification of P(x) is the assertion that P(x) is true for all values of x in the universe of discourse

• Universal quantification is denoted xP(x) which may be read “for all (or every) value of x, P(x) is true”

Page 7: 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,

7

Universal Quantification

• Suppose P(x) is the statement “x spends more than 3 hours every day in class” and the universe of discourse is the set of all students

• Then xP(x) would be the statement “All students spend more than 3 hours every day in class”

• This could also be expressed: x(S(x) P(x)) where S(x) = “x is a student”

Page 8: 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,

8

Universal Quantification & Conjunction

When all elements in a universe of discourse can be listed, e.g.(x1, x2, … , xn) then xP(x) can be written as:

P(x1) P(x2) … P(xn)

For example, suppose P(x) = x < x2 where the universe ofdiscourse is the positive integers less than 5

For xP(x) to be true, P(0) P(1) P(2) P(3) P(4) wouldhave to be true; since 0 < 0 and 1 < 1 are untrue, xP(x) is false

Page 9: 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,

9

Existential Quantification

• The assertion that there is an element with a certain property

• The notation xP(x) means there exists at least one element x in the universe of discourse for which P(x) is true

Page 10: 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,

10

Existential Quantification & Disjunction

When all elements in a universe of discourse can be listed, e.g.(x1, x2, … , xn) then xP(x) can be written as:

P(x1) P(x2) … P(xn)

For example, suppose P(x) = x < x2 where the universe ofdiscourse is the positive integers less than 5

For xP(x) to be true, P(0) P(1) P(2) P(3) P(4) wouldhave to be true; since 2 < 4, xP(x) is true

Page 11: 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,

11

Universal vs. Existential Quantification

xP(x) True if P(x) is true False if therefor all values of x is at least onein universe of value x wherediscourse P(x) is false

xP(x) True if there exists False if P(x) isat least one value x false for every xfor which P(x) in the universeis true of discourse

Page 12: 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,

12

Quantifiers & Looping

• Can be helpful to think in terms of looping and searching when seeking truth value of a quantification

• For xP(x), loop through all N values in universe of discourse; if all are true, xP(x) is true

• For xP(x), loop through all N values; if any are true, xP(x) is true

Page 13: 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,

13

Binding Variables

• A variable is said to be bound if it has a value assigned to it or if a quantifier is used on it

• A variable is free if neither of these conditions applies

Page 14: 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,

14

Binding Variables

• In order to turn a propositional function into a proposition, all variables in the function must be bound

• Can have multiple quantifications for propositional functions involving more than one variable

• The order of quantifiers is important unless all are of the same type (all existential or all universal)

Page 15: 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,

15

ExampleAre these quantifications logically equivalent?

x y P(x,y) y x P(x,y)

x y P(x,y) y x P(x,y)There exists an x for For every value of y therewhich P(x,y) is true is a value of x for whichfor every value of y P(x,y) is true

So there must be an x So x can depend on yfor which the function istrue regardless of y - x isan independent constant

If the first is true, the second is true - but not vice-versa

Page 16: 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,

16

Translating Quantified Expressions

Suppose W(x,y) is the propositional function “student x has takenclass y” and the universe of discourse for x is students in thisclass, while the universe of discourse for y is classes at Kirkwood

Then the quantification y(W(Tim,y) W(Dan,y)) meansthere exists a class at Kirkwood for which the statements“Tim has taken this class” and “Dan has taken this class” is true

What does yx(W(x,y)) mean?

Page 17: 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,

17

Translating Quantified Statements

Suppose the universe of discourse for x, y and z is the set ofreal numbers. What is the meaning of the following quantification?

x y z (z * (x + y) = (z * x) + (z * y))

This is the distributive law for multiplication:For all real numbers x, y and z, the product of z and the sum ofx and y is equal to the sum of the products of z and x and z and y

Page 18: 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,

18

Translating Quantified Statements

Can translate from English into logical expressions, as well asvice versa

For example, suppose L(x,y) is the propositional functionx loves y, and the universe of discourse for x and y is all thepeople in the world

The quantification “Everybody loves me” can be denoted as:x L(x, me)

How would you denote “I love everybody” and “Somebodyloves me?”

Page 19: 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,

19

More “love” examplesThere is somebody whom everybody loves:

y x L(x,y)

Everybody loves somebody:x y L(x,y)

There is somebody whom nobody loves: y x (L(x,y))

Page 20: 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,

20

Nested Loops & Multiple Quantifications

x y P(x,y): loop through all values of x; in each x loop, loop through all values of y; true if no false values found

x y P(x,y): loop through all values of x; loop through all y values at each x until a y is found for which P(x,y) is true - proposition is true if there is such a y for every x

Page 21: 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,

21

Nested Loops & Multiple Quantifications

x y P(x,y): loop through all values of x until we find an x for which P(x,y) is true for all values of y

x y P(x,y): start looping through x values; at each x, loop through y values - if we hit at least one x,y where P(x,y) is true, then the proposition is true

Page 22: 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,

22

Summary of truth values for multiple quantifications

x y P(x,y) True if P(x,y) is False if there is at least oney x P(x,y) true for every x,y pair for which P(x,y)

x,y pair is falsex y P(x,y) True if there is a False if there is an x for

y that makes P(x,y) which P(x,y) is false fortrue for every x every y

x y P(x,y) True if there is an False if for every x therex for which P(x,y) is a y for which P(x,y)true for every y is false

x y P(x,y) True if there is at False if P(x,y) is falsey x P(x,y) least 1 x,y pair for for every x,y pair

which P(x,y) is true

Page 23: 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,

23

Negations of quantified expressions

• The negation of a universal quantification is the existential quantification of the negation

• The negation of an existential quantification is the universal quantification of the negation

Page 24: 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,

24

Negations of quantified expressions

x P(x) x P(x)True if P(x) is false False if there is an x forfor every value of x which P(x) is true

x P(x) x P(x)True if there exists False if P(x) is true foran x for which P(x) every xis false

Page 25: 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,

25

Section 1.3

Predicates & Quantifiers

- ends -