You are on page 1of 41

DISCRETE STRUCTURES FOR

COMPUTER SCIENCE (DSCS)


 Faculty Name : Dr. ANITHA N
BITS Pilani Mail-Id : anithan@wilp.bits-pilani.ac.in
Pilani|Dubai|Goa|Hyderabad
BITS Pilani
Hyderabad Campus

Contact Sesion 2
Agenda

 Predicate

 Quantifiers
Limitations of proposition logic
Proposition logic cannot adequately express the meaning of
statements
Suppose we know
“Every computer connected to the university network is
functioning properly”
No rules of propositional logic allow us to conclude
“MATH3 is functioning properly”
where MATH3 is one of the computers connected to the
university network

4
Example
Cannot use the rules of propositional logic to conclude from
“CS2 is under attack by an intruder”
where CS2 is a computer on the university network

to conclude the truth

“There is a computer on the university network that is under


attack by an intruder”

5
1.4 Predicate and quantifiers
Can be used to express the meaning of a wide range of
statements
Allow us to reason and explore relationship between objects
Predicates: statements involving variables, e.g., “x > 3”,
“x=y+3”,
“x+y=z”,
“computer x is under attack by an intruder”,
“computer x is functioning property”

6
Example: x > 3
The variable x is the subject of the statement
Predicate “is greater than 3” refers to a property that
the subject of the statement can have
Can denote the statement by p(x) where p denotes the
predicate “is greater than 3” and x is the variable
p(x): also called the value of the propositional
function p at x
Once a value is assigned to the variable x, p(x)
becomes a proposition and has a truth value

7
Example
Let p(x) denote the statement “x > 3”
– p(4): setting x=4, thus p(4) is true
– p(2): setting x=2, thus p(2) is false
Let a(x) denote the statement “computer x is under
attack by an intruder”. Suppose that only CS2 and
MATH1 are currently under attack
– a(CS1)? : false
– a(CS2)? : true
– a(MATH1)?: true

8
Let Q(x,y) denote” x=y+3. What are the truth values of the
propositions Q(1,2) & Q(3,0)
Q(1,2) : x=1, y=2 which is False.
Q(3,0) : x=3, y=0, which is true.

9
N-ary Predicate
A statement involving n variables, x1, x2, …, xn, can be denoted
by p(x1, x2, …, xn)
p(x1, x2, …, xn) is the value of the propositional function p at
the n-tuple (x1, x2, …, xn)
p is also called n-ary predicate

10
Quantifiers
Express the extent to which a predicate is true
In English, all, some, many, none, few
Focus on two types:
– Universal: a predicate is true for every element under
consideration
– Existential: a predicate is true for there is one or more
elements under consideration
Predicate calculus: the area of logic that deals with predicates
and quantifiers

11
Universal quantifier 
“p(x) for all values of x in the domain”
x p(x)
Read it as “for all x p(x)” or “for every x p(x)”

A statement x p(x) is false if and only if p(x) is not always


true
An element for which p(x) is false is called a counterexample of
x p(x)

A single counterexample is all we need to establish that


x p(x) is not true
Example
Let p(x) be the statement “x+1>x”. What is the truth value of
x p(x) ? True
– Implicitly assume the domain of a predicate is not
empty
– Best to avoid “for any x” as it is ambiguous to whether
it means “every” or “some”
Let q(x) be the statement “x<2”. What is the truth value of
x q (x) where the domain consists of all real numbers?
False
q(3) is not true.
Example
Let p(x) be “x2>0”. To show that the statement
x p(x) is false where the domain consists of all integers

– Show a counterexample with x=0

When all the elements can be listed, e.g., x1, x2, …, xn, it follows
that the universal quantification x p (x) is the same as the
conjunction p(x1) ˄p(x2) ˄…˄ p(xn)
Example
What is the truth value of x p (x) where p(x) is the statement
“x2 < 10” and the domain consists of positive integers not
exceeding 4?

x p(x) is the same as p(1)˄p(2)˄p(3)


Universal Quantifier: Example 1
Let P(x): ‘x must take a discrete mathematics course’ and
Q(x): ‘x is a CS student.’
The universe of discourse for both P(x) and Q(x) is all UNL
students.
Express the statements:
– “Every CS student must take a discrete mathematics course.”
 x Q(x)  P(x)
– “Everybody must take a discrete mathematics course or be a CS
 x ( P(x)  Q(x) )
student.”
– “Everybody must take a discrete mathematics course and be a CS
student.”  x ( P(x)  Q(x) )
Universal Quantifier: Example 2
Express the statement: ‘for every x and every y, x+y>10’
Answer:
– Let P(x,y) be the statement x+y>10
– Where the universe of discourse for x, y is the set of
integers
– The statement is: x y P(x,y)
Shorthand: x,y P(x,y)
A note on quantifiers
• Recall that P(x) is a propositional function
– Let P(x) be “x == 0”
• Recall that a proposition is a statement that is either
true or false
– P(x) is not a proposition
• There are two ways to make a propositional function
into a proposition:
– Supply it with a value
• For example, P(5) is false, P(0) is true
– Provide a quantifiaction
• For example, x P(x) is false and x P(x) is true
– Let the universe of discourse be the real numbers
18
Existential quantification 
“There exists an element x in the domain such that p(x) (is true)”
Denoted that as x p (x) where  is the existential quantifier

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

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)”

19
Example
Let p(x) be the statement “x>3”.
Is x p (x) true for the domain of all real numbers? T

Let q(x) be the statement “x=x+1”.


Is x p (x) true for the domain of all real numbers? F

When all elements of the domain can be listed, , e.g., x1, x2, …,
xn,
it follows that the existential quantification is the same as
disjunction p(x1) ˅p(x2) ˅ … ˅ p(xn)

20
Example
What is the truth value of x p (x)
where p(x) is the statement “x2 > 10” and the domain consists of
positive integers not exceeding 4?

x p (x) is the same as p(1) ˅p(2) ˅p(3) ˅ p(4)

21
Quantifiers: Truth values
In general, when are quantified statements true or false?

Statement True when… False when...

x P(x) P(x) is true for every x There is an x for which


P(x) is false
There is an x for which P(x) is false for every x
x P(x) P(x) is true
Translating from English

• Consider “For every student in this class, that


student has studied calculus”
• Rephrased: “For every student x in this class, x
has studied calculus”
– Let C(x) be “x has studied calculus”
– Let S(x) be “x is a student”
• x C(x)
– True if the universe of discourse is all students in
this class

23
Translating from English 2

• What about if the universe of discourse is all


students (or all people?)
– x (S(x)C(x))
• This is wrong!
– x (S(x)→C(x))
• Another option:
– Let Q(x,y) be “x has stuided y”
– x (S(x)→Q(x, calculus))

24
Translating from English 3

• Consider:
– “Some students have visited Mexico”
– “Every student in this class has visited Canada or
Mexico”
• Let:
– S(x) be “x is a student in this class”
– M(x) be “x has visited Mexico”
– C(x) be “x has visited Canada”

25
Translating from English 4

• Consider: “Some students have visited Mexico”


– Rephrasing: “There exists a student who has visited
Mexico”
• x M(x)
– True if the universe of discourse is all students
• What about if the universe of discourse is all people?
– x (S(x) → M(x))
• This is wrong
x (S(x)  M(x))

26
Translating from English 5

• Consider: “Every student in this class has


visited Canada or Mexico”
• x (M(x)C(x)
– When the universe of discourse is all students
• x (S(x)→(M(x)C(x))
– When the universe of discourse is all people

27
Translating from English 6

• Note that it would be easier to define


V(x, y) as “x has visited y”
– x (S(x)  V(x,Mexico))
– x (S(x)→(V(x,Mexico)  V(x,Canada))

28
Translating from English 7
• Translate the statements:
– “All hummingbirds are richly colored”
– “No large birds live on honey”
– “Birds that do not live on honey are dull in color”
– “Hummingbirds are small”
• Assign our propositional functions
– Let P(x) be “x is a hummingbird”
– Let Q(x) be “x is large”
– Let R(x) be “x lives on honey”
– Let S(x) be “x is richly colored”
• Let our universe of discourse be all birds
29
Translating from English 8
• Our propositional functions
– Let P(x) be “x is a hummingbird”
– Let Q(x) be “x is large”
– Let R(x) be “x lives on honey”
– Let S(x) be “x is richly colored”
• Translate the statements:
– “All hummingbirds are richly colored”
• x (P(x)→S(x))
– “No large birds live on honey”
• ¬x (Q(x)  R(x))
• Alternatively: x (¬Q(x)  ¬R(x))
– “Birds that do not live on honey are dull in color”
• x (¬R(x) → ¬S(x))
– “Hummingbirds are small”
• x (P(x) → ¬Q(x))
30
Predicates - more examples
L(x) = “x is a lion.”
Universe of discourse
F(x) = “x is fierce.” is all creatures.
C(x) = “x drinks coffee.”
x (L(x)  F(x))
All lions are fierce.
Some lions don’t drink coffee. x (L(x)  C(x))

Some fierce creatures don’t drink coffee.

x (F(x)  C(x))
Binding Variables
When a quantifier is used on a variable x, we say that
x is bound
If no quantifier is used on a variable in a predicate
statement, the variable is called free
Examples
– In xyP(x,y), both x and y are bound
– In xP(x,y), x is bound but y is free
A statement is called a well-formed formula, when all
variables are properly quantified
Binding Variables: Scope
The set of all variables bound by a common quantifier is called
the scope of the quantifier
For example, in the expression x,yzP(x,y,z,c)
– What is the scope of existential quantifier?
– What is the scope of universal quantifier?
– What are the bound variables?
– What are the free variables?
– Is the expression a well-formed formula?
Binding variables

• Let P(x,y) be x > y


• Consider: x P(x,y)
– This is not a proposition!
– What is y?
• If it’s 5, then x P(x,y) is false
• If it’s x-1, then x P(x,y) is true
• Note that y is not “bound” by a quantifier

34
Binding variables 2

• (x P(x))  Q(x)


– The x in Q(x) is not bound; thus not a proposition
• (x P(x))  (x Q(x))
– Both x values are bound; thus it is a proposition
• x (P(x)  Q(x))  (y R(y))
– All variables are bound; thus it is a proposition
• (x P(x)  Q(y))  (y R(y))
– The y in Q(y) is not bound; this not a proposition

35
Negation
We can use negation with quantified expressions as
we used them with propositions
Lemma: Let P(x) be a predicate. Then the followings
hold:
(x P(x))  x P(x)
Ø (x P(x))  x P(x)
This is essentially the quantified version of De
Morgan’s Law (when the universe of discourse is
finite, this is exactly De Morgan’s Law)
Negating quantifications

• Consider the statement:


– All students in this class have red hair
• What is required to show the statement is false?
– There exists a student in this class that does NOT have red
hair
• To negate a universal quantification:
– You negate the propositional function
– AND you change to an existential quantification
– ¬x P(x) = x ¬P(x)

37
Negating quantifications 2

• Consider the statement:


– There is a student in this class with red hair
• What is required to show the statement is
false?
– All students in this class do not have red hair
• Thus, to negate an existential quantification:
– you negate the propositional function
– AND you change to a universal quantification
– ¬x P(x) = x ¬P(x)
38
Negation: Truth

Truth Values of Negated Quantifiers

Statement True when… False when...


x P(x)  There is an x for which
P(x) is false for every x P(x) is true
x P(x)
x P(x)  There is an x for which P(x) is true for every x
x P(x) P(x) is false
Precedence of quantifiers
 and  have higher precedence than all logical operators
from propositional calculus

x p ( x)  q ( x)  (x p ( x))  q ( x) rather tha n x ( p ( x)  q( x))

40
THANKS

You might also like