25
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 1 The Foundations: Logic and Proofs Predicates and Quantifiers

Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 1 The Foundations: Logic and Proofs Predicates and Quantifiers

Embed Size (px)

Citation preview

Page 1: Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 1 The Foundations: Logic and Proofs Predicates and Quantifiers

Fall 2008/2009

I. Arwa Linjawi & I. Asma’a Ashenkity1

The Foundations: Logic and Proofs

Predicates and Quantifiers

Page 2: Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 1 The Foundations: Logic and Proofs Predicates and Quantifiers

Fal

l 200

8/20

09

I. Arwa Linjawi & I. Asma’a Ashenkity2

Predicates

““x is greater than 3” x is greater than 3”

This statement is neither true nor false when the value of the variable is not specified

This statement has two parts:

The first part (subject) is the variable x. The second (predicate) is “is greater than 3”.

Page 3: Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 1 The Foundations: Logic and Proofs Predicates and Quantifiers

Fal

l 200

8/20

09

I. Arwa Linjawi & I. Asma’a Ashenkity3

Predicates

We can denote this statement by P(x), where P denotes the predicate “is greater than 3”. Once a value has been assigned to x, the statement P(x) becomes a proposition and has a truth values

P(x) is called Proposition function P at x

P(x1,x2,x3,………,xn). P is called n-place or (n-ary) predicate.

Page 4: Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 1 The Foundations: Logic and Proofs Predicates and Quantifiers

Fal

l 200

8/20

09

I. Arwa Linjawi & I. Asma’a Ashenkity4

Predicates

Examples: Let P(x) denote “ x is greater than 3”. What are the

truth values of P(4) and P(2)? Let Q(x, y) denote “x=y+3”. What are the truth

values of Q(1,2) and Q(3,0)? Let A(c, n) denote “computer c is connected to

network n”, suppose that the computer MATH1 is connected to network CAMPUS2, but not to network CAMPUS1, What are the truth values of A(MATH1, CAMPUS1) and A(MATH1, CAMPUS2)?

Page 5: Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 1 The Foundations: Logic and Proofs Predicates and Quantifiers

Fal

l 200

8/20

09

I. Arwa Linjawi & I. Asma’a Ashenkity5

Quantifiers

Universal quantification Universal quantification Which tell us that a predicate is true for every element under consideration( Domain / Discourse).

The universal quantification of P(x) is the statement “P(x) for all values of x in the domain”

x P(x) read as “for all x P(x)” or “for every x P(x)”

is called universal quantifier

Page 6: Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 1 The Foundations: Logic and Proofs Predicates and Quantifiers

Fal

l 200

8/20

09

I. Arwa Linjawi & I. Asma’a Ashenkity6

Quantifiers

Existential quantificationExistential quantification Which tell us that there is one or more element under consideration for which the predicate is true.

The existential quantification of P(x) is the statement “there exists an element x in the domain such that P(x)”

x P(x) read as “there is an x such that P(x)” or “there is at least one x such that P(x)” or “for some x P(x)”

is called existential quantifier

Page 7: Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 1 The Foundations: Logic and Proofs Predicates and Quantifiers

Fal

l 200

8/20

09

I. Arwa Linjawi & I. Asma’a Ashenkity7

Quantifiers The area of logic that deals with predicates and quantifiers is called predicate calculus.

x P(x) isx P(x) is True when: P(x) is true for every x False when: There is an x for which P(x) is false

x P(x) isx P(x) is True when: There is an x for which P(x) is true False when: P(x) is false for every x

Page 8: Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 1 The Foundations: Logic and Proofs Predicates and Quantifiers

Fal

l 200

8/20

09

I. Arwa Linjawi & I. Asma’a Ashenkity8

Quantifiers

Examples: Let Q(x) “x<2” . What is the truth value of x Q(x)

when the domain consists of all real numbers?

Q(x) is not true for every real number x, for example Q(3) is false

x =3 is a counterexample for the statement x Q(x) Thus x Q(x) is false

Page 9: Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 1 The Foundations: Logic and Proofs Predicates and Quantifiers

Fal

l 200

8/20

09

I. Arwa Linjawi & I. Asma’a Ashenkity9

Quantifiers

Examples: What is the truth value of x (x2 x) when the

domain consists of: a) all real number? B) all integers?

a ) is false because (0.5)2 0.5 , x2 x is false for all real numbers in the range 0<x<1

b) is true because there are no integer x with 0<x<1

Page 10: Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 1 The Foundations: Logic and Proofs Predicates and Quantifiers

Fal

l 200

8/20

09

I. Arwa Linjawi & I. Asma’a Ashenkity10

Quantifiers

Examples: Let Q(x) “x>3”. What is the truth value of x Q(x)

when the domain consists of all real numbers?

Q(x) is sometimes true , for example Q(4) is true Thus x Q(x) is true

Page 11: Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 1 The Foundations: Logic and Proofs Predicates and Quantifiers

Fal

l 200

8/20

09

I. Arwa Linjawi & I. Asma’a Ashenkity11

Quantifiers

Examples: Let Q(x) “x=x+1”. What is the truth value of x Q(x)

when the domain consists of all real numbers?

Q(x) is false for every real number Thus x Q(x) is false

Page 12: Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 1 The Foundations: Logic and Proofs Predicates and Quantifiers

Fal

l 200

8/20

09

I. Arwa Linjawi & I. Asma’a Ashenkity12

Quantifiers Note that : x Q(x) is false if there is no elements in the domain for which Q(x) is true or the domain is empty.

When all the elements in the domain can be listed x1, x2, x3, x4, ……., xn :

x Q(x) is the same as the conjunction Q(x1) Q(x2) …. Q(xn)

x Q(x) is the same as the disjunction Q(x1) Q(x2) …. Q(xn)

Precedence of quantifiers and have higher precedence than all logical

operators

Page 13: Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 1 The Foundations: Logic and Proofs Predicates and Quantifiers

Fal

l 200

8/20

09

I. Arwa Linjawi & I. Asma’a Ashenkity13

Quantifiers

Examples: Let Q(x) “x2<10”. What is the truth value of x Q(x)

when the domain consists of the positive integers not exceeding 4?

x Q(x) is the same as the conjunction Q(1) Q(2) Q(3) Q(4). Q(4) is false. Thus x Q(x) is false.

Page 14: Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 1 The Foundations: Logic and Proofs Predicates and Quantifiers

Fal

l 200

8/20

09

I. Arwa Linjawi & I. Asma’a Ashenkity14

Quantifiers

Examples: Let Q(x) “x2<10”. What is the truth value of x Q(x)

when the domain consists of the positive integers not exceeding 4?

x Q(x) is the same as the disjunction Q(1) Q(2) Q(3) Q(4). Q(4) is false. Thus x Q(x) is false

Page 15: Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 1 The Foundations: Logic and Proofs Predicates and Quantifiers

Fal

l 200

8/20

09

I. Arwa Linjawi & I. Asma’a Ashenkity15

Quantifiers If domain consists of n (finite) object and we need to determine the truth value of.

x Q(x)x Q(x) Loop through all n values of x to see if Q(x) is always trueIf you encounter a value x for which Q(x) is false, exit the loop with x Q(x) is false Otherwise x Q(x) is true 

 x Q(x)x Q(x)Loop through all n values of x to see if Q(x) is trueIf you encounter a value x for which Q(x) is true, exit the loop with x Q(x) is trueOtherwise x Q(x) is false

Page 16: Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 1 The Foundations: Logic and Proofs Predicates and Quantifiers

Fal

l 200

8/20

09

I. Arwa Linjawi & I. Asma’a Ashenkity16

Quantifiers with restricted domain  The restriction of a universal quantification is the same as the universal quantification of a conditional statement

x<0 (x2>0) same as x (x<0 x2>0) “The square of a negative real number is positive”

The restriction of a existential quantification is the same as the existential quantification of a conjunction

z >0 (z2=2) same as z(z>0 z2=2) “There is a positive square root of 2”

Page 17: Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 1 The Foundations: Logic and Proofs Predicates and Quantifiers

Fal

l 200

8/20

09

I. Arwa Linjawi & I. Asma’a Ashenkity17

Binding variables  When a quantifier is used on the variable x , we say that this occurrence of the variable is bound.

x (x+y=1) The variable x is bounded by the existential

quantification x and the variable y is free

All variable that occur in a propositional function must be bound or equal to particular value to turn it into proposition.

Page 18: Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 1 The Foundations: Logic and Proofs Predicates and Quantifiers

Fal

l 200

8/20

09

I. Arwa Linjawi & I. Asma’a Ashenkity18

Binding variables   Examples:

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

All variables are boundedThe scope of the first quantifier x is the expression P(x)Q(x), second quantifier x is the expression R(x) Existential quantifier binds the variable x in P(x)Q(x) Universal quantifier binds the variable x in R(x)

Page 19: Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 1 The Foundations: Logic and Proofs Predicates and Quantifiers

Fal

l 200

8/20

09

I. Arwa Linjawi & I. Asma’a Ashenkity1919

Quantifiers

Other QuantifiersUniqueness Quantifier ! or 1

“! x P(x)” = “There exists a unique x such that P(x) is true”

Page 20: Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 1 The Foundations: Logic and Proofs Predicates and Quantifiers

Fal

l 200

8/20

09

I. Arwa Linjawi & I. Asma’a Ashenkity20

Negating Quantified Expressions

“Every student in this class has taken a calculus course”

xP(x) where P(x) is “x has taken a calculus course” Domain = “Students in class”

Negation is “There is a student that has not taken a calculus course”

x P(x)

xP(x) xP(x) xxP(x)P(x)

Page 21: Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 1 The Foundations: Logic and Proofs Predicates and Quantifiers

Fal

l 200

8/20

09

I. Arwa Linjawi & I. Asma’a Ashenkity21

Negating Quantified Expressions

If domain of P(x) consists of n elements

“x1,x2,x3,…,xn” then

xP(x)

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

by DeMorgan’s laws

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

xP(x) De Morgan’s Lwas for Quantifiers

xP(x) xP(x) xxP(x)P(x)

xP(x) xP(x) xxP(x) P(x)

Page 22: Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 1 The Foundations: Logic and Proofs Predicates and Quantifiers

Fal

l 200

8/20

09

I. Arwa Linjawi & I. Asma’a Ashenkity22

Nested Quantifiers

Two quantifiers are nested if one is within the scope of another

e.g.x y (x+y=0)

Examples: xy(x+y=y+x) xy((x>0)(y<0)(xy<0))

Page 23: Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 1 The Foundations: Logic and Proofs Predicates and Quantifiers

Fal

l 200

8/20

09

I. Arwa Linjawi & I. Asma’a Ashenkity23

Order of Nested Quantifiers

Order of nested quantifiers is important if they are different.

Example: If Q(x,y) denotes x+y=0, what are the truth

values of quantifications xxy Q(x,y)y Q(x,y) yyx Q(x,y)x Q(x,y)

Page 24: Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 1 The Foundations: Logic and Proofs Predicates and Quantifiers

Fal

l 200

8/20

09

I. Arwa Linjawi & I. Asma’a Ashenkity24

Negating Nested Quantifiers

Example:

Express the negation of xy(xy=1)

xy(xy=1) by DeMorgan’s laws

xy(xy=1)

xy(xy=1)

xy(xy1)

Page 25: Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 1 The Foundations: Logic and Proofs Predicates and Quantifiers

Fal

l 200

8/20

09

I. Arwa Linjawi & I. Asma’a Ashenkity25

Negating Nested Quantifiers Example:

Express the statement (There does not exist a woman who has taken a flight on every airline in the world)Let P(w,f) be “w has taken f” and Q(f,a) be “f is a flight on a”, thenw a f(P(w,f)Q(f,a)) w a f(P(w,f)Q(f,a))w a f(P(w,f)Q(f,a))w a f (P(w,f)Q(f,a))w a f ( P(w,f)Q(f,a))