Lec 6-7-8 DS

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 36

Discrete Structures

Lecture # 6,7,8

Muhammad Sultan Zia Assistant Professor COMSATS, Institute of Information Technology, Sahiwal

Overview

COMSATS, Institute of Information Technology, Sahiwal

Predicate Logic
Propositional logic provides a useful setting in which we can analyze many types of logical argument There are situations, however, where 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

Predicate Logic
There are situations (as in previous examples) where propositional logic is inadequate, because it cannot deal with the logical structure that is sometimes present within atomic propositions In order to analyze such arguments, we need to look at the logical structure within atomic propositions. Predicate logic allows us to do this
COMSATS, Institute of Information Technology, Sahiwal

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 is a proposition. Examples x is a multiple of 5 P(x) = x < 5

COMSATS, Institute of Information Technology, Sahiwal

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,x2,x3 xn) =
COMSATS, Institute of Information Technology, Sahiwal

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

Quantifiers
Why quantifiers?
Many things (in this course and beyond) are specified using quantifiers

A quantifier is an operator that limits the variables of a proposition Two types:


Universal Existential

COMSATS, Institute of Information Technology, Sahiwal

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) is true English translation: for all values of x, x+1>x is true
COMSATS, Institute of Information Technology, Sahiwal

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 the textbook
COMSATS, Institute of Information Technology, Sahiwal

Universal Quantification
Let the universe be the real numbers. Let P(x) = x/2 < x
Not true for the negative numbers! Thus, x P(x) is false
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

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(x2) P(xn)
COMSATS, Institute of Information Technology, Sahiwal

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

Existential Quantification
Note that you still have to specify your universe Let P(x) = x+1 < x
There is no numerical value x for which x+1<x Thus, x P(x) is false

COMSATS, Institute of Information Technology, Sahiwal

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 is true, you only have to find ONE value In order to show an existential quantification is false, you have to show its false for ALL values
COMSATS, Institute of Information Technology, Sahiwal

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(x2) P(xn)
COMSATS, Institute of Information Technology, Sahiwal

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 quantification
For example, x P(x) is false and x P(x) is true
Let the universe of discourse be the real numbers
COMSATS, Institute of Information Technology, Sahiwal

Binding Variables
Let P(x,y) be x > y Consider: x P(x,y)
This is not a proposition! 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 quantifier


COMSATS, Institute of Information Technology, Sahiwal

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 y such that, for every 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 propositions


COMSATS, Institute of Information Technology, Sahiwal

Multivariate Quantification

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.

COMSATS, Institute of Information Technology, Sahiwal

Quantifiers
When evaluating an expression such as x y z P (x,y,z ) Translate the proposition in the same order to English: There is an x such that for all y there is a z such that P (x,y,z) holds.

COMSATS, Institute of Information Technology, Sahiwal

Parsing Example
P (x,y,z ) = y - x z There is an x such that for all y there is a z such that y - x z. There is some number x which when subtracted from any number y results in a number bigger than some number z. Q: If the universe of discourse for x, y, and z is the non-negative integers {0,1,2,3,4,5,6,7,} whats the truth value of xy z P (x,y,z )?
COMSATS, Institute of Information Technology, Sahiwal

Parsing Example
A: True. For any exists we need to find a positive instance. Since x is the first variable in the expression and is existential, we need a number that works for all other y, z. Set x = 0 (want to ensure that y -x is 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 many solutions like z := y or z := 0 or some other valid solution.
COMSATS, Institute of Information Technology, Sahiwal

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 can tell, x is a constant and cannot affect x.
COMSATS, Institute of Information Technology, Sahiwal

Order Matters
Set the universe of discourse to be whole numbers {0, 1, 2, 3, }. Let R (x,y ) = x < y. Q1: What does x y R (x,y ) mean?
All numbers x admit a bigger number y

True

Q2: What does y x R (x,y ) mean?


Some number y is bigger than all x

False

Q3: Whats the truth value of each expression?


COMSATS, Institute of Information Technology, Sahiwal

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 are both interpreted as for every combination of x and y x y is the same as y x because these are both interpreted as there is a pair x , y
COMSATS, Institute of Information Technology, Sahiwal

Translating from English


In 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

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

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

Translating from English


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! Why?

x (S(x) M(x))
COMSATS, Institute of Information Technology, Sahiwal

Translating from English


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
COMSATS, Institute of Information Technology, Sahiwal

Negating Quantifications
Consider the statement:
All students in this class have black hair

What is required to show the statement is false?


There exists a student in this class that does NOT 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

Negating Quantifications
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:


To negate the propositional function AND you change to a universal quantification x P(x) = x P(x)
COMSATS, Institute of Information Technology, Sahiwal

Negation Example
Compute: x y x2 y
In English, we are trying to find the opposite of every x admits a y greater or equal to xs square. The opposite is that some x does not admit a y greater or equal to xs square Algebraically, one just flips all quantifiers from to and vice versa, and negates the interior propositional function. In our case we get:

x y ( x 2 y ) x y x 2 > y
COMSATS, Institute of Information Technology, Sahiwal

Translating between English and quantifiers


The product of two negative integers is positive xy ((x<0) (y<0) (xy > 0)) Why conditional instead of and? The average of two positive integers is positive xy ((x>0) (y>0) ((x+y)/2 > 0)) The difference of two negative integers is not necessarily negative xy ((x<0) (y<0) (|x-y|0)) Why and instead of conditional? The absolute value of the sum of two integers does not exceed the sum of the absolute values of these integers xy (|x+y| |x| + |y|)
COMSATS, Institute of Information Technology, Sahiwal

Translating between English and quantifiers xy (x+y = y)


There exists an additive identity for all real numbers

xy (((x0) (y<0)) (x-y > 0))


A non-negative number minus a negative number is greater than zero

xy (((x0) (y0)) (x-y > 0))


The difference between two non-positive numbers is not necessarily non-positive (i.e. can be positive)

xy (((x0) (y0)) (xy 0))


The product of two non-zero numbers is non-zero if and only if both factors are non-zero
COMSATS, Institute of Information Technology, Sahiwal

You might also like