You are on page 1of 20

Department Of Computer Science, CUI

Lahore Campus
CSC102 - Discrete Structures
By
Mahwish Waqas
3/6/2021 CSC102 - Discrete Structures 2

Course Outline

• Nested Quantifiers
3/6/2021 CSC102 - Discrete Structures 3

Nested Quantifiers
• Two quantifiers are nested if one is within scope of other,
such as
∀x∃y(x + y = 0).

• Everything within the scope of a quantifier can be thought


of as a propositional function.
• For example,
∀x∃y(x + y = 0)
is the same thing as ∀xQ(x), where Q(x) is ∃yP(x, y), where P(x, y) is
x + y = 0.
3/6/2021 CSC102 - Discrete Structures 4

Nested Quantifiers
• ∀𝑥∃𝑦 𝑃(𝑥, 𝑦)
• “For all 𝑥, there exists a 𝑦 such that 𝑃(𝑥, 𝑦)”.
• Example:
• ∀𝑥∃𝑦 (𝑥 + 𝑦 = 0) where 𝑥 and 𝑦 are integers

• 𝑥𝑦 𝑃(𝑥, 𝑦)
• There exists an x such that for all 𝑦, 𝑃(𝑥, 𝑦) is true”
• Example: 𝑥𝑦 𝑥 × 𝑦 = 0

• ∀𝑥∀𝑦∀𝑧 𝑥 + 𝑦 + 𝑧 = 𝑥 + 𝑦 + 𝑧

• THINK QUANTIFICATION AS LOOPS


3/6/2021 CSC102 - Discrete Structures 5

Nested Quantifiers Example


• Let Domain of 𝑥 is the students in this class
Doamin of 𝑦 is the courses in software engineering
𝑄 𝑥, 𝑦 = “𝑥 takes course 𝑦”, true when 𝑥 takes course
𝑦, otherwise false.
Translate the following logical expression:

• ∀𝑥∀𝑦𝑄 𝑥, 𝑦
• ∃𝑥∃𝑦𝑄(𝑥, 𝑦)
• ∀𝑥∃𝑦𝑄 𝑥, 𝑦
• ∃𝑥∀𝑦𝑄(𝑥, 𝑦)
3/6/2021 CSC102 - Discrete Structures 6

Meaning of Multiple Quantifiers


Suppose 𝑃(𝑥, 𝑦) = “x likes y.”
Domain of x: {St1, St2}; Domain of y: {Cricket, Hockey}

• 𝒙𝒚 𝑷(𝒙, 𝒚)
• 𝑃(𝑥, 𝑦) true for all x, y pairs.

• 𝒙𝒚 𝑷(𝒙, 𝒚)
• 𝑃(𝑥, 𝑦) true for at least one x, y pair.

• 𝒙𝒚 𝑷(𝒙, 𝒚)
• For every value of x we can find a (possibly different) y so that P(x,y) is
true.
• 𝒙𝒚 𝑷(𝒙, 𝒚)
• There is at least one x for which P(x,y) is always true.
3/6/2021 CSC102 - Discrete Structures 7

Predicates - the meaning of multiple quantifiers

Statement When True? When False?


∀x∀yP(x, y) P(x, y) is true for every There is a pair x, y for
∀y∀xP(x, y) pair x, y. which P(x, y) is false.
∀x∃yP(x, y) For every x there is a y There is an x such that
for which P(x, y) is true. P(x, y) is false for every
y.
∃x∀yP(x, y) There is an x for which For every x there is a y
P(x, y) is true for every y. for which P(x, y) is false.
∃x∃yP(x, y) There is a pair x, y for P(x, y) is false for every
∃y∃xP(x, y) which P(x, y) is true. pair x, y.
3/6/2021 CSC102 - Discrete Structures 8

Example

• Let Q(x, y): “x + y = 0”

What are the truth values of the quantifications ∃y∀xQ(x, y)


and ∀x∃yQ(x,y), where the domain for all variables consists
of all real numbers?
3/6/2021 CSC102 - Discrete Structures 9

Example
• Let Q(x, y) denote “x + y = 0.” What are the truth values of
the quantifications ∃y∀xQ(x, y) and ∀x∃yQ(x, y), where
the domain for all variables consists of all real numbers?

• Solution:
The quantification ∃y∀xQ(x,y) denotes the
proposition
“There is a real number y such that for every real number
x, Q(x, y).”
• No matter what value of y is chosen, there is only one
value of x for which x + y = 0. Because there is no real
number y such that x + y = 0 for all real numbers x, the
statement ∃y∀xQ(x, y) is false.
3/6/2021 CSC102 - Discrete Structures 10

Example
• The quantification ∀x∃yQ(x, y) denotes the proposition
“For every real number x there is a real number y
such that Q(x, y).”

• Given a real number x, there is a real number y such that


x + y = 0; namely, y = −x.
• Hence, the statement ∀x∃yQ(x, y) is true.
3/6/2021 CSC102 - Discrete Structures 11

Order of Quantifiers

• xy and xy are not equivalent!


• xy P(x,y)
• P(x,y) = (x+y == 0) is false

• xy P(x,y)
• P(x,y) = (x+y == 0) is true
3/6/2021 CSC102 - Discrete Structures 12

Example
𝑄 (𝑥 , 𝑦, 𝑧): x + y = z
Domain: Real numbers

• ∀𝑥∀𝑦∃𝑧 𝑄(𝑥, 𝑦, 𝑧) True/False???


• For all real numbers x and for all real numbers y there is a
real number z such that 𝑥 + 𝑦 = 𝑧.
• True
• ∃𝑧∀𝑥∀𝑦 𝑄(𝑥, 𝑦, 𝑧) True/False???
• There is a real number z such that for all real numbers x
and for all real numbers y that 𝑥 + 𝑦 = 𝑧.
• False
3/6/2021 CSC102 - Discrete Structures 13

Translating between English and Quantifiers


• Translate the statement “The sum of two positive integers
is always positive” into a logical expression.
3/6/2021 CSC102 - Discrete Structures 14

Translating between English and Quantifiers


• Translate the statement “The sum of two positive integers
is always positive” into a logical expression.
• Solution:
• First rewrite it so that the implied quantifiers and a domain
are shown: “For every two integers, if these integers are
both positive, then the sum of these integers is positive.”
• Next, introduce the variables x and y to obtain “For all
positive integers x and y, x + y is positive.”
• Statement is ∀x∀y((x > 0) ∧ (y > 0) → (x +y > 0)),
• where the domain for both variables consists positive
integers.
3/6/2021 CSC102 - Discrete Structures 15

Translating between English and Quantifiers

• Translate the following statement into English


∀x(C(x) ∨ ∃y(C(y) ∧ F(x, y)))
where
C(x): “x has a computer,”
F(x, y): “x and y are friends,”
The domain for both x and y consists of all students in your
school.
3/6/2021 CSC102 - Discrete Structures 16

Translating between English and Quantifiers


• Translate the following statement into English
∀x(C(x) ∨ ∃y(C(y) ∧ F(x, y)))
where
C(x): “x has a computer,”
F(x, y): “x and y are friends,”
The domain for both x and y consists of all students in your
school.
• Solution:
• The statement says that 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.
• In other words, every student in your school has a computer or
has a friend who has a computer.
3/6/2021 CSC102 - Discrete Structures 17

Negating Multiple Quantifiers


• Recall negation rules for single quantifiers:
• ¬x P(x) = x ¬P(x)
• ¬x P(x) = x ¬P(x)
• Essentially, you change the quantifier(s), and negate
what it’s quantifying

• Examples:
• ¬(xy P(x,y)) = x ¬y P(x,y) = xy ¬P(x,y)
• ¬(xyz P(x,y,z)) = x¬yz P(x,y,z)
= xy ¬ z P(x,y,z) = xyz ¬P(x,y,z)
3/6/2021 CSC102 - Discrete Structures 18

Negating Multiple Quantifiers

• Consider ¬(xy P(x,y)) = xy ¬P(x,y)


• The left side is saying “for all x, there exists a y such
that P is true”
• To negate it, you need to show that “there exists an x
such that for all y, P is false”
• Consider ¬(xy P(x,y)) = xy ¬P(x,y)
• The left side is saying “there exists an x such that for all
y, P is true”
• To negate it, you need to show that “for all x, there
exists a y such that P is false”
3/6/2021 CSC102 - Discrete Structures 19

Chapter Reading
• Chapter 1, Kenneth H. Rosen, Discrete Mathematics and
Its Applications, Section 1.5
3/6/2021 CSC102 - Discrete Structures 20

Chapter Exercise (For Practice)


• Question # 1, 2, 3, 4, 8, 23, 24, 25, 26, 27, 30, 31, 39, 41

You might also like