Math2305.Lecture 2 TAMUT
-
Upload
chubbaymoo -
Category
Documents
-
view
214 -
download
0
Transcript of Math2305.Lecture 2 TAMUT
-
8/13/2019 Math2305.Lecture 2 TAMUT
1/32
PREDICATES AND QUANTIFIERS
MATH-2305 Discrete Mathematics
1
-
8/13/2019 Math2305.Lecture 2 TAMUT
2/32
Truth Verification of those Statements
that are not Propositions
There are no rules in propositional logic thatallow to conduct the truth value of thefollowing statements:
There is at least one student in thisclassroom who took three Calculus classes
x+7=10
Each computer in this classroom is connectedto the network
y is a student
2
-
8/13/2019 Math2305.Lecture 2 TAMUT
3/32
Predicates
Statements like
x+7=10
y is a student
x 3have two parts.
The first part, a variable, is the subject of thestatement
The second part is the predicate. It refers to aproperty that the subject of the statement mayhave
3
-
8/13/2019 Math2305.Lecture 2 TAMUT
4/32
4
Predicates
Predicateis a dual-purpose term On the one hand, a predicateis a property or
description of subjects. The following predicatesare all shown in red and bold:
James is tall. The bridge is long.
19 is a prime number.
On the other hand, a predicate is also used as a
synonym of a propositional function, where thedescription is related not to a certain subject, butto a variable.
-
8/13/2019 Math2305.Lecture 2 TAMUT
5/32
Predicates and
Propositional Functions If a statement depends on a variable, this
statement is called a propositional function (oftena propositional function itself is called a
predicate) We can denote such a statement by .
Once a value has been assigned to the variable x,the statement becomes a proposition,
which has a truth value.
is also referred to as 1-place predicateorsimply a predicate
5
P x
P x
P x
-
8/13/2019 Math2305.Lecture 2 TAMUT
6/32
6
Multivariable Propositional Functions
Multivariable propositional functionsdepend on
more than one variable. For example,
xis taller than y
ais greater than one ofb, c x is at leastninches taller than y
x+y=z
x andy are students
-
8/13/2019 Math2305.Lecture 2 TAMUT
7/32
n-ary Predicates
A multivariable propositional function depends
on more than one variable. For example, the
propositional function x+y=zdepends on 3
variables.
Once some values have been assigned to the
variable x, y, z, the statement x+y=z
becomes a proposition, which has a truth value. A statement of the form is called a
n-place predicateor n-ary predicate.
7
1 2, ,..., nP x x x
-
8/13/2019 Math2305.Lecture 2 TAMUT
8/32
Propositional Functions and
Programming
Propositional functions are widely used incomputer programming and algorithm design forbranching programs and algorithms
If then
else
If (((x>0) and (xz))then
else
8
-
8/13/2019 Math2305.Lecture 2 TAMUT
9/32
Precondition and Postcondition
Preconditionis a statement that describes a valid
input of some algorithm or program segment
Postconditionis a statement that the output of
some algorithm or program segment should
satisfy when the algorithm (the program
segment) has run
Preconditions and Postconditions are widely usedto verify the correctness of algorithms and
programs
9
-
8/13/2019 Math2305.Lecture 2 TAMUT
10/32
Precondition and Postcondition
Example. Let we need to swap the values of
two variables x and y.
Algorithm: temp := x ; x := y; y := temp
Precondition: (x=a) & (y=b)
Postcondition: (x=b) & (y=a)
:= means set tox := y means set x equal to y
10
-
8/13/2019 Math2305.Lecture 2 TAMUT
11/32
11
Semantics
If logical propositions are to have meaning, they needto describe something. Up to now, propositions suchas Johnny is tall, Debbie is 5 years old, andx2=-1had no intrinsic meaning. Either they are true
or false, but no more. In order to make such propositions and propositional
functions meaningful, we need to have a domain(or universe) of discourse, (or simply domain(or universe)) i.e. a collection of subjectsabout which
the propositions relate.
Question: What are the domains for the threepropositions above?
-
8/13/2019 Math2305.Lecture 2 TAMUT
12/32
12
Semantics
Question: What are the domains for the followingpropositions and propositional functions?
Johnny is tall, Debbie is 5 years old
Possible answers: {Johnny, Debbie}; {People in theworld}; {People leaving in Texarkana}, etc.
x2=-1
Possible answers: Cthe set of complex numbers;Rthe set of real numbers, Zthe set of integernumbers
Depending on the particular domain, a propositionmay be true or false
-
8/13/2019 Math2305.Lecture 2 TAMUT
13/32
Semantics
Semantics is very important in computerprogramming
Each data structure and even each single variable
that are used in a computer program always havetheir domain of discourse (type).
For example, a variable xcan be declared as realor integer or byte or char.
Depending on this declaration, such expressionsas x=3.5, x=5, x=Class, x=-1 can be meaningfuland acceptable or not.
13
-
8/13/2019 Math2305.Lecture 2 TAMUT
14/32
Quantifiers
There are statements, which assert that someproperty is true for all values of a variable in aparticular domain (Each student in thisclassroom takes the Discrete Math course in Fall
semester 2012). There are also statements, which assert that
there is an element in a particular domain with acertain property (There is at least one person in
this classroom who is not a student). Such statements can be formulated using
quantifiers
14
-
8/13/2019 Math2305.Lecture 2 TAMUT
15/32
15
Quantifiers
There are two quantifiers
Universal Quantifier
reads for all or Each or Every Existential Quantifier
reads there exists or there is at leastone
A quantifier is placed in front of apropositional function and bindsit to obtain aproposition with semantic value.
-
8/13/2019 Math2305.Lecture 2 TAMUT
16/32
Quantifiers
A statement (propositional function) P(x) is quantifiedif there is a quantifier in a front of it, which is appliedto it:
x P(x) is TRUEif P(x) is true for every single x.
x P(x) is FALSEif there is an x for which P(x) is false.
x P(x) is TRUEif there is an x for which P(x) is true.
x P(x) is FALSEif P(x) is false for every single x.
16
x P X x P X
-
8/13/2019 Math2305.Lecture 2 TAMUT
17/32
Quantifiers
The truth table for quantifiers
17
The Truth Table for Quantifiers
Statement When True? When False?
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 true
P(x) is false
for every x x P X
x P X
-
8/13/2019 Math2305.Lecture 2 TAMUT
18/32
18
The Universal Quantifier
x P (x)is true when everyinstance ofxmakesP (x) true when plugged in
Like conjunctioning over entire domain of P (x)
x P (x) P (x1) P (x2) P (x3)
Example: Each non-negative real number has a
square root
-
8/13/2019 Math2305.Lecture 2 TAMUT
19/32
19
Existential Quantifier
x P (x)is true when an instance can be found
which when plugged in forxmakes P (x) true
Like disjunctioning over entire domain of P (x)
x P (x) P (x1) P (x2) P (x3)
Example: There exist a complex number whose
square is a negative real number (i2=-1, iis an imaginary unity)
-
8/13/2019 Math2305.Lecture 2 TAMUT
20/32
20
Multivariate Quantification
Quantification involving only one variable is
fairly straightforward. Just a bunch of ORs or
a bunch of ANDs.
When two or more variables are involved each
of which is bound by a quantifier, the order of
the binding is important and the meaning
often requires some thought.
-
8/13/2019 Math2305.Lecture 2 TAMUT
21/32
23
Parsing Example
Question: If the domain forx, y, and z is the natural
numbers {0,1,2,3,4,5,6,7,} whats the truth
value of xy z P (x,y,z ); P (x,y,z ) = y - x z ?
Answer: True. For any existswe need to find a positive
instance. Sincex is the first variable in the expression and
is existential, we need a number that works forall other y, z. Setx= 0 (want to ensure that y -xis not too small).
Now for each y we need to find a positiveinstance z such thaty-x z holds. Plugging in
x= 0 we need to satisfy y z so set z = y.
-
8/13/2019 Math2305.Lecture 2 TAMUT
22/32
24
Parsing Example
Question: If the domain forx, y, and z is the natural
numbers {0,1,2,3,4,5,6,7,} , did we have to set z
= y to ensure that xy z P (x,y,z );
P (x,y,z ) = y - x z is true?
Answer: No. Could also have used the constant
z= 0. There are other valid solutions.
-
8/13/2019 Math2305.Lecture 2 TAMUT
23/32
25
Parsing Example
Question: Isnt it simpler to satisfy x y z (y-x z )
by settingx = y and z= 0 ?
Answer: No, this is illegal ! The existence ofx comes
before we know about y. I.e., the scopeofx is
higherthan the scopeof y . So we have to find first
suchx
that does not depend ony. Thus, it is illegal
to choosexdepending on y.
-
8/13/2019 Math2305.Lecture 2 TAMUT
24/32
26
Order matters
Set the domain of discourse to be all realnumbers .
Let P (x,y ) = x < y.
Question: What does x y P (x,y )mean? Answer: x y P (x,y ):
All numbersx admit a larger number y
Question: Whats the truth value of thisexpression?
Answer: True. For any real number there is alarger real number
-
8/13/2019 Math2305.Lecture 2 TAMUT
25/32
27
Order matters
P (x,y ) = x < y
Question: What does y x P (x,y ) mean?
Answer: y x P (x,y ):
Some number y is larger than allx
Question: Whats the truth value of this
expression?
Answer: False. There is no the largest real
number. Additionally the number cannot belarger than itself.
-
8/13/2019 Math2305.Lecture 2 TAMUT
26/32
28
Order mattersbut not always
If we have two quantifiers of the same kind,order does not matter.
x y is the same as y x because these
are both interpreted as for everycombination ofx and y
x y is the same as y x because these are
both interpreted asthere is a pairx , y
-
8/13/2019 Math2305.Lecture 2 TAMUT
27/32
Predicates - the meaning of multiple quantifiers
xy P(x,y)
xy P(x,y)
xy P(x,y)
xy P(x,y)
P(x,y) true for all (x, y) pairs.
For every value of x we can find a (possibly different)y so that P(x,y) is true.
P(x,y) true for at least one (x, y) pair.
There is at least one x for which P(x,y)
is always true.
Quantification order is not
commutative in
general !
Suppose P(x,y) = xsfavorite class is y.
-
8/13/2019 Math2305.Lecture 2 TAMUT
28/32
Negation of Logical Expressions
with Quantifiers
What about and
Since the quantifiers are the same as taking a bunch of
ANDs () or ORs () we obtain applying De Morganslaws:
30
x P x ?x P x
1 2
1 2
...
.. ;
.
n
n
P x P x P x
P
x P x
x P xx P x P x
1 2
1 2
...
...
n
n
P x P x P x
P x P x
x P x
x P xP x
-
8/13/2019 Math2305.Lecture 2 TAMUT
29/32
-
8/13/2019 Math2305.Lecture 2 TAMUT
30/32
Negation of Logical Expressions
with Quantifiers
General rule: to negate a logical expression
containing quantifier (quantifiers), move
negation to the expression under quantifier
(quantifiers) and flip all quantifiers from toand vice versa.
32
-
8/13/2019 Math2305.Lecture 2 TAMUT
31/32
33
Negation Example
Compute:
In English, we are trying to find the opposite ofeveryx admits a y greater or equal toxsquared.The opposite is that somex does not admit ygreater or equal toxsquared
Algebraically, one just flips all quantifiers fromto and vice versa, and negates the interiorpropositional function. In our case we get:
2x y x y
2 22x y x yx y yx x y xy
-
8/13/2019 Math2305.Lecture 2 TAMUT
32/32
Logical Equivalences
Involving Predicates and Quantifiers
Statements involving predicates and
quantifiers are logically equivalent if and only
if they have the same truth value no matter
which predicates are substituted into thesestatements and which domain is used for the
variables in these propositional functions.
34