Download - Lec 6-7-8 DS
-
7/28/2019 Lec 6-7-8 DS
1/36
Discrete Structures, ,
Muhammad Sultan ZiaAssistant Professor
COMSATS, Institute of Information Technology, Sahiwal
-
7/28/2019 Lec 6-7-8 DS
2/36
Overview
COMSATS, Institute of Information Technology, Sahiwal
-
7/28/2019 Lec 6-7-8 DS
3/36
Predicate Logic
Propositional logic provides a useful setting in
which we can analyze many types of logicalargument
, ,propositional logic is inadequate. e.g.
All even numbers are integers. 8 is an even
number. Therefore 8 is an integer. It is not true that all prime numbers are odd.
Therefore there must be at least one prime number
that is not odd.COMSATS, Institute of Information Technology, Sahiwal
-
7/28/2019 Lec 6-7-8 DS
4/36
Predicate Logic
There are situations (as in previous examples)
where propositional logic is inadequate,
because it cannot deal with the logical
u u watomic propositions
In order to analyze such arguments, we need to
look at the logical structure within atomicpropositions.
Predicate logic allows us to do thisCOMSATS, Institute of Information Technology, Sahiwal
-
7/28/2019 Lec 6-7-8 DS
5/36
Predicate/Propositional Function
A predicate is a statement containing one or
more variables. If values are assigned to all the
variables in a predicate, the resulting statement
.Examples
x is a multiple of 5
P ( x ) = x < 5
COMSATS, Institute of Information Technology, Sahiwal
-
7/28/2019 Lec 6-7-8 DS
6/36
Predicate/Propositional Function
Functions with multiple variables:
P(x,y) = x + y == 0
P(1,2) is false, P(1,-1) is true
P(x,y,z) = x + y == z
P(3,4,5) is false, P(1,2,3) is true
P(x1,x
2,x
3 x
n) =
COMSATS, Institute of Information Technology, Sahiwal
-
7/28/2019 Lec 6-7-8 DS
7/36
Predicate/Propositional Function
Functions with multiple variables:
x is taller than y
a is greater than one of b, c
x is at least n inches taller than y
COMSATS, Institute of Information Technology, Sahiwal
-
7/28/2019 Lec 6-7-8 DS
8/36
Quantifiers
Why quantifiers?
Many things (in this course and beyond) are specifiedusing quantifiers
A quantifier is an operator that limits thevariables of a proposition
Two types:
Universal
Existential
COMSATS, Institute of Information Technology, Sahiwal
-
7/28/2019 Lec 6-7-8 DS
9/36
Universal Quantification
Represented by an upside-down A:
It means for all
Let P(x) = x+1 > x
We can state the following:
x P(x)
English translation: for all values of x, P(x) istrue
English translation: for all values of x, x+1>x istrue
COMSATS, Institute of Information Technology, Sahiwal
-
7/28/2019 Lec 6-7-8 DS
10/36
Universal Quantification
But is that always true?
x P(x) Let x = the character a
Is a+1 > a?
Let x = the province of Punjab Is Punjab+1 > Punjab?
You need to specify your universe! What values x can represent
Called the domain or universe of discourse by thetextbook
COMSATS, Institute of Information Technology, Sahiwal
-
7/28/2019 Lec 6-7-8 DS
11/36
Universal Quantification
Let the universe be the real numbers.
Let P(x) = x/2 < x Not true for the negative numbers!
, When the domain is all the real numbers
In order to prove that a universal quantification is true,it must be shown for ALL cases
In order to prove that a universal quantification is false,it must be shown to be false for only ONE case
COMSATS, Institute of Information Technology, Sahiwal
-
7/28/2019 Lec 6-7-8 DS
12/36
Universal Quantification
Given some propositional function P(x)
And values in the universe x1
.. xn
The universal quantification x P(x) implies:
P(x1) P(x
2) P(x
n)
COMSATS, Institute of Information Technology, Sahiwal
-
7/28/2019 Lec 6-7-8 DS
13/36
Existential Quantification
Represented by an backwards E:
It means there exists Let P(x) = x+1 > x
We can state the following: x P(x)
English translation: there exists (a value of) x
such that P(x) is true
English translation: for at least one value of x,x+1>x is true
COMSATS, Institute of Information Technology, Sahiwal
-
7/28/2019 Lec 6-7-8 DS
14/36
Existential Quantification
Note that you still have to specify your
universe
There is no numerical value x for which x+1
-
7/28/2019 Lec 6-7-8 DS
15/36
Existential Quantification
Let P(x) = x+1 > x
There is a numerical value for which x+1>x
In fact, its true for all of the values of x!
Thus, x P(x) is true
In order to show an existential quantification istrue, you only have to find ONE value
In order to show an existential quantification isfalse, you have to show its false for ALLvalues
COMSATS, Institute of Information Technology, Sahiwal
-
7/28/2019 Lec 6-7-8 DS
16/36
Existential Quantification
Given some propositional function P(x)
And values in the universe x1
.. xn
The existential quantification x P(x) implies:
P(x1) P(x
2) P(x
n)
COMSATS, Institute of Information Technology, Sahiwal
-
7/28/2019 Lec 6-7-8 DS
17/36
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 iseither true or false
There are two ways to make a propositionalfunction into a proposition:
Supply it with a value
For example, P(5) is false, P(0) is true
Provide a quantification
For example, x P(x) is false and x P(x) is true
Let the universe of discourse be the real numbersCOMSATS, Institute of Information Technology, Sahiwal
-
7/28/2019 Lec 6-7-8 DS
18/36
Binding Variables
Let P(x,y) be x > y
Consider: x P(x,y)
s s not a propos t on What is y?
If its 5, then x P(x,y) is false
If its x-1, then x P(x,y) is true
Note that y is not bound by a quantifierCOMSATS, Institute of Information Technology, Sahiwal
-
7/28/2019 Lec 6-7-8 DS
19/36
Example 1
Write the following propositions in symbols:
For every number x there is a number y such that y= x + 1.
There is a number such that for ever number x
y = x + 1.
Solution:
Let P(x,y) denote the predicate y = x + 1.
Note carefully the difference in meaning between the two propositionsCOMSATS, Institute of Information Technology, Sahiwal
-
7/28/2019 Lec 6-7-8 DS
20/36
Multivariate Quantification
When two or more variables are involved
each of which is bound by a quantifier, theorder of the binding is important and the
meaning often requires some thought.
COMSATS, Institute of Information Technology, Sahiwal
-
7/28/2019 Lec 6-7-8 DS
21/36
Quantifiers
When evaluating an expression such as
x y z P(x,y,z )
Translate the proposition in the same order to
ng s : There is anx such that for ally there is az
such thatP(x,y,z) holds.
COMSATS, Institute of Information Technology, Sahiwal
-
7/28/2019 Lec 6-7-8 DS
22/36
Parsing Example
P(x,y,z ) = y -x z
There is anx such that for ally there is az suchthaty -x z.
There is some number which when
subtracted from any number y results in anumber bigger than some numberz.
Q: If the universe of discourse forx, y, andz isthe non-negative integers {0,1,2,3,4,5,6,7,}whats the truth value ofxy z P(x,y,z )?
COMSATS, Institute of Information Technology, Sahiwal
-
7/28/2019 Lec 6-7-8 DS
23/36
Parsing ExampleA: True.
For any exists we need to find a positiveinstance.
Since x is the first variable in the expression and ,
all other y, z. Set x = 0 (want to ensure that y -xis not too small).
Now for each y we need to find a positive
instance z such that y - x z holds. Plugging in x= 0 we need to satisfy y z so we have manysolutions like z := y or z := 0 or some other validsolution.
COMSATS, Institute of Information Technology, Sahiwal
-
7/28/2019 Lec 6-7-8 DS
24/36
Parsing Example
Q: Isnt it simpler to satisfy
x y z (y -x z )
by setting x := y and z := 0 ?
A: No, this is illegal ! The existence of x comes
before we know about y. I.e., the scope of x is
higher than the scope of y so as far as y cantell, x is a constant and cannot affect x.
COMSATS, Institute of Information Technology, Sahiwal
-
7/28/2019 Lec 6-7-8 DS
25/36
Order Matters
Set the universe of discourse to be whole
numbers {0, 1, 2, 3, }. LetR (x,y ) = x
-
7/28/2019 Lec 6-7-8 DS
26/36
Order Matters But Not Always
Q: What if we have two quantifiers of the same
kind? Does order still matter?No! If we have two quantifiers of the same kind
order is irrelevant.
x y is the same as y x because these areboth interpreted as for every combination ofxandy
x y is the same as y x because these areboth interpreted as there is a pairx ,y
COMSATS, Institute of Information Technology, Sahiwal
-
7/28/2019 Lec 6-7-8 DS
27/36
Translating from EnglishIn the specification of a system for booking theatre seats,
B(p,s) denotes the predicate person p has booked seat s.
Write the following sentences in symbolic form:
a) Seat s has been booked.
b) Person p has booked a (that is, at least one) seat.
c) All the seats are booked.
d) No seat is booked by more than one person.
COMSATS, Institute of Information Technology, Sahiwal
-
7/28/2019 Lec 6-7-8 DS
28/36
Translating from English
What about if the universe of discourse is all
students (or all people?) Every student in this class has studied calculus.
x (S(x)C(x))
This is wrong! Why?
x (S(x)C(x))
COMSATS, Institute of Information Technology, Sahiwal
-
7/28/2019 Lec 6-7-8 DS
29/36
Translating from English
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
COMSATS, Institute of Information Technology, Sahiwal
-
7/28/2019 Lec 6-7-8 DS
30/36
Translating from English Consider: Some students have visited Mexico
Rephrasing: There exists a student who has visitedMexico
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! Why?
x (S(x) M(x))
COMSATS, Institute of Information Technology, Sahiwal
-
7/28/2019 Lec 6-7-8 DS
31/36
Translating from English
Consider: Every student in this class has
visited Canada or Mexico
x x x
When the universe of discourse is all students
x (S(x)(M(x)C(x)) When the universe of discourse is all people
COMSATS, Institute of Information Technology, Sahiwal
-
7/28/2019 Lec 6-7-8 DS
32/36
Negating Quantifications Consider the statement:
All students in this class have black hair What is required to show the statement is false?
have black hair
To negate a universal quantification:
You negate the propositional function AND you change to an existential quantification
x P(x) = x P(x)
COMSATS, Institute of Information Technology, Sahiwal
-
7/28/2019 Lec 6-7-8 DS
33/36
Negating Quantifications
Consider the statement:
There is a student in this class with red hair
What is required to show the statement is false?
Thus, to negate an existential quantification:
To negate the propositional function
AND you change to a universal quantification x P(x) = x P(x)
COMSATS, Institute of Information Technology, Sahiwal
-
7/28/2019 Lec 6-7-8 DS
34/36
Negation Example
Compute: x y x2 y
In English, we are trying to find the opposite ofeveryx admits ay greater or equal toxs square.The opposite is that somex does not admit ay
Algebraically, one just flips all quantifiers from to and vice versa, and negates the interior
propositional function. In our case we get:
xy (x2 y ) xy x2 >y
COMSATS, Institute of Information Technology, Sahiwal
-
7/28/2019 Lec 6-7-8 DS
35/36
Translating between English and quantifiers
The product of two negative integers is positive
xy ((x0 >0 x+ /2 > 0
The difference of two negative integers is not necessarilynegative
xy ((x
-
7/28/2019 Lec 6-7-8 DS
36/36
Translating between English and quantifiers
xy (x+y = y)
There exists an additive identity for all real numbers
xy (((x0) (y 0))
A non-ne ative number minus a ne ative number is reaterthan zero
xy (((x0) (y0)) (x-y > 0))
The difference between two non-positive numbers is notnecessarily non-positive (i.e. can be positive)
xy (((x0) (y0)) (xy 0))
The product of two non-zero numbers is non-zero if andonly if both factors are non-zero
COMSATS, Institute of Information Technology, Sahiwal