0% found this document useful (0 votes)
22 views43 pages

CS202 - L06 - Logic and Proofs - Part-2 - Predicates and Quantifiers

The document discusses predicates and quantifiers in logic, explaining how predicates can represent statements about variables and how their truth values can be evaluated. It introduces universal and existential quantification, detailing their meanings and implications in logical expressions. Additionally, it covers negation of quantified expressions and provides examples of translating English statements into logical expressions using predicates and quantifiers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views43 pages

CS202 - L06 - Logic and Proofs - Part-2 - Predicates and Quantifiers

The document discusses predicates and quantifiers in logic, explaining how predicates can represent statements about variables and how their truth values can be evaluated. It introduces universal and existential quantification, detailing their meanings and implications in logical expressions. Additionally, it covers negation of quantified expressions and provides examples of translating English statements into logical expressions using predicates and quantifiers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Discrete Structures

Logic and Proofs


Predicates and Quantifiers

1
Predicates and Quantifiers
Predicates
“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 pats
The fist part (subject) is the variable x
The second (predicate) is “is greater than 3”
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 value. P is called Proposition function. 2
Predicates and Quantifiers
Predicates

let P(x) denote “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 R(x,y,z) denote “x+y=z”
What are the truth values of R(1,2,3) and R(0,0,1)?

P(x1,x2,x3,………,xn)
P is called n-place(n-ary) predicate.
3
Predicates and Quantifiers
Predicates

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) ?
4
Predicates and Quantifiers
Predicates
Proposition functions (Predicates) occur in
computer programs.
If x>0 then x:=x+1
P(x) : “x>0”
If P(x) is true the assignment is executed
If P(x) is false the assignment is not executed

5
Predicates and Quantifiers
Universal quantification
Which tell us that a predicate is true for every
element under consideration.

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

The area of logic that deals with predicates and


quantifiers is called predicate calculus.

6
Predicates and Quantifiers
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)”
“for every x P(x)”
∀ is called universal quantifier

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)”
“there is at least one x such that P(x)”
“for some x P(x)”
∃ is called existential quantifier 7
Predicates and Quantifiers

∀x P(x)
When true P(x) is true for every x.
When false there is an x for which P(x) is false.

∃x P(x)
When true there is an x for which P(x) is true.
When false P(x) is false for every x.

8
Predicates and Quantifiers
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.

9
Predicates and Quantifiers
Let Q(x) “x2>0”
What is the truth value of ∀x Q(x) when the
domain consists of all integers?

Q(x) is not true for every integer number x, for


example Q(0) is false.

x=0 is a counterexample for the statement


∀x Q(x)

Thus ∀x Q(x) is false.

10
Predicates and Quantifiers
What is the truth value of ∀x (x2≥ x) when the
domain
a) consists of all real number?
b) consists of 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

11
Predicates and Quantifiers
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.

∃x Q(x) is false iif there is no elements in the


domain for which Q(x) is true.

12
Predicates and Quantifiers
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.

∃x Q(x) is false iif there is no elements in the


domain for which Q(x) is true or the domain is
empty.

13
Predicates and Quantifiers
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)

14
Predicates and Quantifiers
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.

15
Predicates and Quantifiers
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 true
Thus ∃x Q(x) is true.

16
Predicates and Quantifiers
If domain consists of n (finite) object and we
need to determine the truth value of
∀x Q(x)
▪ Loop through all n values of x to see if Q(x) is always
true
▪ If 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)
▪ Loop through all n values of x to see if Q(x) is true
▪ If you encounter a value x for which Q(x) is
true, exit the loop with ∃x Q(x) is true
▪ Otherwise ∃x Q(x) is false 17
Predicates and Quantifiers
You can define other quantifiers, for example
“there are exactly two”
“there are at least 100”

Uniqueness quantifier ∃! ∃1
“there exists a unique x such that P(x) is true”
“there is exactly one”
“there is one and only one”

Precedence of quantifiers
∀ ∃ have higher precedence than all logical
operators ¬ ∧ ∨ → ↔
18
Quantifiers with restricted domain
What do these statements mean (domain real)

• ∀x<0 (x2>0) same as ∀x (x<0 → x2>0)


“the square of a negative real number is positive”

• ∀y≠0 (y3 ≠ 0) same as ∀y(y≠0 → y3 ≠ 0)


“the cube of every nonzero real number is
nonzero”

• ∃z >0 (z2=2) same as ∃z(z>0 ∧ z2=2)


“there is a positive square root of 2”

19
Binding variables
• ∃x (x+y=1)
The variable x is bounded by the existential
quantification ∃x and the variable y is free

• ∃x (P(x) ∧ Q(x)) ∨ ∀x R(x)


All variables are bounded
The 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)
20
Logical equivalence involving quantifiers
Statements involving predicates and quantifier are
logically equivalent iff they have the same truth
value

Show that ∀x (P(x) ∧ Q(x)) ≡ ∀x P(x) ∧ ∀x


Q(x)

• Suppose that ∀x (P(x) ∧ Q(x)) is true, this


means that if a is in the domain then P(a) ∧
Q(a) is true
Hence, both P(a) and Q(a) are true for every
element in the domain
So ∀x P(x) and ∀x Q(x) are both true. 21
Logical equivalence involving quantifiers
Show that ∀x (P(x) ∧ Q(x)) ≡ ∀x P(x) ∧ ∀x
Q(x)

• suppose that ∀x P(x) ∧ ∀x Q(x) is true, it


follows that both ∀x P(x) and ∀x Q(x) are
true hence, if a is in the domain then P(a) is
true and Q(a) is true
This means that ∀x (P(x) ∧ Q(x)) is true.

Now we can conclude that


∀x (P(x) ∧ Q(x)) ≡ ∀x P(x) ∧ ∀x Q(x)

22
Logical equivalence involving quantifiers
∀x (P(x) ∧ Q(x)) ≡ ∀x P(x) ∧ ∀x Q(x)

The universal quantifier can be distributed over


the a conjunction (∧).

The universal quantifier can be distributed over


the a disjunction (∨).

The existential quantifier can not be distributed


over the a conjunction (∧) and disjunction (∨).

23
Negating quantified expression
“Every student in your class has taken a course in
calculus” ∀x P(x)
Where, P(x) is “x has taken a course in calculus”
and the domain consists of the student in your
class
Negation
“It is not the case that every student in your
class has taken a course in calculus”
or
“There is a student in your class who has not
taken a course in calculus” ∃x ¬ P(x)
¬ ∀x P(x) ≡ ∃x ¬ P(x)
24
Negating quantified expression
“There is a student in this class who has taken a
course in calculus” ∃x Q(x)
Where, Q(x) is “x has taken a course in calculus”
and the domain consists of the student in your
class
Negation
“It is not the case that there is a student in this
class who has taken a course in calculus”
or
“Every student in this class has not taken a
course in calculus” ∀x ¬Q(x)
“Not all students in this class have taken a course in calculus” is not
used. ¬∃x Q(x) ≡ ∀x ¬Q(x) 25
Negating quantified expression
Show that (homework)
▪¬∀x P(x) ≡ ∃x ¬P(x)
▪¬∃x P(x) ≡ ∀x ¬P(x)

26
Negating quantified expression
De Morgan’s laws for quantifiers
¬∃x P(x) ≡ ∀x ¬P(x)
The negation is true when for every x, P(x) is
false
The negation is false when there is an x for
which P(x) is true

¬∀x P(x) ≡ ∃x ¬P(x)


The negation is true when there is an x for which
P(x) is false
The negation is false when for every x, P(x) is
true
27
Negating quantified expression
De Morgan’s laws for quantifiers
When the domain of a predicate Q(x) consists of
n elements 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)

∃x Q(x) is the same as the disjunction


Q(x1) ∨ Q(x2) ∨…. ∨ Q(xn)
¬ ∃x Q(x) is the same as the conjunction
¬Q(x1) ∧ ¬Q(x2) ∧ …. ∧ ¬Q(xn) 28
Negating quantified expression
Examples: what are the negation of

▪∀x (x2>x)
▪∃x (x2=x)

▪∀x (x2>x)
¬∀x (x2>x) ≡ ∃x ¬(x2>x) ≡ ∃x (x2≤x)

▪∃x (x2=x)
¬∃x (x2=x) ≡ ∀x ¬(x2=x) ≡ ∀x (x2≠x)

29
Negating quantified expression
Show that
¬∀x [P(x) → Q(x)] ≡ ∃x [P(x) ∧ ¬Q(x)]

¬∀x [P(x) → Q(x)] ≡ ∃x ¬[P(x) → Q(x)]


≡ ∃x ¬[¬P(x) ∨ Q(x)]
≡ ∃x [¬ ¬P(x) ∧ ¬Q(x)]
≡ ∃x [P(x) ∧ ¬Q(x)]

30
Translating from English into Logical
Expressions
Express the statement “Every student in the class has
studied calculus” using predicates and quantifiers.

• Rewrite the statement to identify the appreciate


quantifiers to use
“For every student in the class,that student has studied
calculus”
• Introduce the variable x
“For every student x in the class,x has studied calculus”
• introduce C(x) “x has studied calculus”
∀x C(x)
The domain for x consists of the students in the class

31
Translating from English into Logical
Expressions
If we change the domain to consists of people

“For every person x, if person x is a student in the


class,then x has studied calculus”

C(x) “x has studied calculus”


S(x) “person x is a student in the class”

∀x (S(x) → C(x))

Note ∀x (S(x) ∧ C(x)) is wrong


All people are students in this class and have
studied calculus 32
Translating from English into Logical
Expressions
Express the statements “some students in the class has
visited Cairo” , “every student in the class has visited
either Aswan or Cairo ” using predicates and quantifiers.

▪ “some students in the class has visited Cairo”


some students ~ there is a student
C(x) “x has visited Cairo”
∃x C(x)

▪ “every student in the class has visited either Aswan or


Cairo ”
A(x) “x has visited Aswan ”
∀x (C(x) ∨ A(x))
33
Translating from English into Logical
Expressions
System specifications
Express the statement “Every mail message larger than
one megabyte will be compressed” using predicates and
quantifiers.

S(m,y) “Mail message m is larger than y megabyte”


Where m has the domain of all mail message
y is a positive real number
C(m) “Mail message m will be compressed”
∀m (S(m,1) → C(m))

34
Translating from English into Logical
Expressions
System specifications
Express the statement “If a user is active, at least one
network link will be available” using predicates and
quantifiers.

A(u) “user u is active”


Where u has the domain of all users
S(n,x) “network link n is in state x”
Where n has the domain of all network links
x has the domain of all possible states
for a network link

∃u A(u) → ∃n S(n, available)


35
Nested Quantifiers
Two quantifiers are nested if one is within the
scope of the other.

∀x∃y (x+y=0)

Every thing within the scope of a quantifier can


be thought as a propositional function.
For example
∀x Q(x)
Q(x) is ∃y P(x,y)
P(x,y) is (x+y=0)

36
Nested Quantifiers
Translate into English
∀x∀y( (x>0) ∧ (y<0) → (xy<0))
The domain of both x and y are real number.

Thinking of quantification as a loops


∀x∀y P(x,y) ∀x ∃y P(x,y)
For all x
For all y
P(x,y) all are true at least one is true
End for all y for all x and y in y loop and all x
End for all x

37
Nested Quantifiers
Thinking of quantification as a loops
∃x ∀y P(x,y)
For all y
For all x
P(x,y) at least one is true in x loop and all y
End for all x
End for all y

∃x∃y P(x,y)
For all x
For all y
P(x,y) at least one is true
End for all y
End for all x
38
Nested Quantifiers
The order of quantifiers
Suppose that the universe for x and y is {1, 2, 3}.
Also, assume that P(x, y) is a predicate that is
true in the following cases, and false otherwise: P(1, 3),
P(2, 1), P(2, 2), P(3, 1), P(3, 2), P(3, 3). Determine
whether each of the following is true or false:
(a) ∀y∃x (x≠y ∧ P(x, y)).
(b) ∀x∃y (x≠y ∧ ¬P(x, y)).
(c) ∀y∃x (x≠y ∧¬P(x, y)).

True.
False.
False.
39
Nested Quantifiers
Translate the following statements into logical
expression
▪ “the sum of two positive integers is always positive”
∀x∀y( (x>0) ∧ (y>0) → (x+y>0))
Or
∀x∀y(x+y>0),
where the domain of both x and y consists of all positive
integers.

▪“every real number except zero has a multiplicative


inverse”
∀x ( (x ≠ 0) → ∃y(xy=1))

40
Nested Quantifiers
Translate the statements into English
▪ ∀x(C(x) ∨ ∃y(C(y) ∧ F(x,y) ))
where C(x) is “x has a computer”
F(x,y) is “x and y are friends”
the domain for both x and y consists of
all student in your school.

“for every student x in your school, x has a computer or


there is a student y such that y has a computer and x
and y are friends ”

“every student in your school has a computer or has a


friend who has a computer”
41
Nested Quantifiers
Express the statement as logical expression (quantifiers,
predicates, logical connectives) the domain consists of all
people.
▪ “ if a person is male and is a parent, then this person is
someone’s father”
∀x( (M(x) ∧ P(x)) → ∃y F(x,y) )
where M(x) is “x is male ”
P(x) is “x is a parent”
F(x,y) is “x is the father of y”

Or ∀x ∃y ( (M(x) ∧ P(x)) → F(x,y) )

42
Negating Nested Quantifiers
Negate this statement( no negation precedes a
quantifier)
∀x ∃y (xy=1)
¬(∀x ∃y (xy=1))
∃x ¬∃y (xy=1)
∃x ∀y ¬(xy=1)
∃x ∀y (xy≠1)

43

You might also like