You are on page 1of 34

Discrete Mathematics Structures

23 1391


:
14-16
16-18
:
http://blog.bamneshin.ir/
:
:
Mohammad.bamneshin@yahoo.com
:
BASU_DM_1391
2

23 1391

23 1391

23 1391

23 1391


) ( )(%30
)(%50
)(%20

23 1391

Expectations
 This is really a fun course!
 This class contains some of the most beautiful math
youll ever learn.
 Its even useful, beyond giving you techniques to use
solving the puzzles in Games Magazine.
Hints for success
 Read the textbook.
 Lectures really do help!
 Do the homework.

1391 23

Propositional Logic
is a declarative statement thats either TRUE or
A proposition
Whats
a proposition?
FALSE (but not both).

Propositions

Not Propositions

3 + 2 = 32

Bring me coffee!

DM is Bryans favorite class.

DM is her favorite class.

Every cow has 4 legs.

3+2

There is other life in the


universe.

Do you like Cake?

1391 23

Propositional Logic - negation


Suppose p is a proposition.
The negation of p is written p and has meaning:
It is not the case that p.
 Ex. DM is NOT Bryans favorite class.

Truth table for negation:

T
F

F
T

Notice that

p is a
proposition!

1391 23

Propositional Logic - conjunction


Conjunction corresponds to English and.
p q is true exactly when p and q are both true.
 Ex. Amy is curious AND clever.

Truth table for conjunction:

1391 23

pq

T
T
F
F

T
F
T
F

T
F
F
F

10

Propositional Logic - disjunction


Disjunction corresponds to English or.
p q is when p or q (or both) are true.
 Ex. Michael is brave OR nuts.

Truth table for disjunction:

1391 23

pq

T
T
F
F

T
F
T
F

T
T
T
F

11

Propositional Logic - implication


Implication: p q corresponds to English if p then q, or p
implies q.
 If it is raining then it is cloudy.
 If there are 200 people in the room, then I am the Easter
Bunny.
 If p then 2+2=4.

Truth table for implication:

1391 23

pq

T
T
F
F

T
F
T
F

T
F
T
T

12

Propositional Logic - logical equivalence


How many different logical connectives could we define?
16

How many different logical connectives do we need?


??

To answer, we need the notion of


logical equivalence.

p is logically equivalent to q if their truth tables are the same. We


write p q.
1391 23

13

Propositional Logic - logical equivalence


Challenge: Try to find a proposition that is equivalent to p q, but that
uses only the connectives , , and .

1391 23

pq

q p

T
T
F
F

T
F
T
F

T
F
T
T

T
T
F
F

T
F
T
F

F
F
T
T

T
F
T
T

14

Propositional Logic - proof of 1 famous


Distributivity:

p (q r) (p q) (p r)

I could say
prove a law of
distributivity.
(p q) (p r)

qr

p (q r)

pq

pr

F T
All truth
assignment
F T
s for p, q,
F F
and r.
F F

1391 23

15

Propositional Logic - special definitions


Contrapositives: p q and q p

One of these
things is not
like the others.

 Ex. If it is noon, then I am hungry.


If I am not hungry, then it is not noon.
Converses: p q and q p
 Ex. If it is noon, then I am hungry.
Hint: In one
instance, the pair
If I am hungry, then it is noon.
of propositions is
Inverses: p q and p q
equivalent.
 Ex. If it is noon, then I am hungry.
If it is not noon, then I am not hungry.

p q q p
1391 23

16

Propositional Logic - 2 more defn,


A tautology is a proposition thats always TRUE.
A contradiction is a proposition thats always FALSE.

p p p p p p

1391 23

17

Propositional Logic - say a bit,


This session were using propositional logic as a foundation for
formal proofs.
Propositional logic is also the key to writing good codeyou
cant do any kind of conditional (if) statement without
understanding the condition youre testing.
All the logical connectives weve discussed are also found in
hardware and are called gates.
Well talk about more applications.
1391 23

18

Propositional Logic - an infamous


(p q) q p q

if NOT (blue AND NOT red) OR red then

(p q) q

1391 23

(p q) q

DeMorgans

(p q) q

Double negation

p (q q)

Associativity

p q

Idempotent

19

Propositional Logic - one last proof


 Show that [p (p q)] q is a tautology.
 We use to show that [p (p q)] q T.
[p (p q)] q
[p (p q)] q

1391 23

substitution for

[(p p) (p q)] q

distributive

[ F (p q)] q
(p q) q
(p q) q
(p q) q
p (q q )
p T
T

uniqueness
identity
substitution for
DeMorgans
associative
excluded middle
domination

20

Predicate Logic - everybody loves somebody


Proposition, YES or NO?
YES
3+2=5
X+2=5
NO
X + 2 = 5 for any choice of X in {1, 2, 3}
X + 2 = 5 for some X in {1, 2, 3}

YES

YES

1391 23

21

Predicate Logic - everybody loves somebody

Alicia eats pizza at least once a week.


Garrett eats pizza at least once a week.
Allison eats pizza at least once a week.
Gregg eats pizza at least once a week.
Ryan eats pizza at least once a week.
Meera eats pizza at least once a week.
Ariel eats pizza at least once a week.

1391 23

22

Predicates

Define:

Alicia eats pizza at least once a week.

EP(x) = x eats pizza at least once a week.


Universe of Discourse - x is a student in DM
A predicate, or propositional function, is a
function that takes some variable(s) as
arguments and returns True or False.
Note that EP(x) is not a proposition, EP(Ariel) is.

1391 23

23

Predicates
Suppose Q(x,y) = x > y
Proposition, YES or NO?

Q(x,y)
Q(3,4)
Q(x,9)

NO
YES
NO

1391 23

Predicate, YES or NO?

Q(x,y)
Q(3,4)
Q(x,9)
-

YES
NO
YES
24

Predicates - the universal quantifier


Another way of changing a predicate into a proposition.
Suppose P(x) is a predicate on some universe of discourse.
Ex. B(x) = x is carrying a backpack, x is set of DM students.

The universal quantifier of P(x) is the proposition:


P(x) is true for all x in the universe of discourse.
We write it x P(x), and say for all x, P(x)
x P(x) is TRUE if P(x) is true for every single x.
x P(x) is FALSE if there is an x for which P(x) is false.
x B(x)?
1391 23

25

Predicates - the universal quantifier


B(x) = x is wearing sneakers.
L(x) = x is at least 21 years old.
Y(x)= x is less than 24 years old.

Universe of discourse
is people in this room.

Are either of these propositions true?


a)
b)

x (Y(x) B(x))
x (Y(x) L(x))

A: only a is true
B: only b is true
C: both are true
D: neither is true

1391 23

26

Predicates - the existential quantifier


Another way of changing a predicate into a proposition.
Suppose P(x) is a predicate on some universe of discourse.
Ex. C(x) = x has a candy bar, x is set of DM students.

The existential quantifier of P(x) is the proposition:


P(x) is true for some x in the universe of discourse.
We write it x P(x), and say for some x, P(x)
x P(x) is TRUE if there is an x for which P(x) is true.
x P(x) is FALSE if P(x) is false for every single x.

1391 23

x C(x)?

27

Predicates - the existential quantifier


B(x) = x is wearing sneakers.
L(x) = x is at least 21 years old.
Y(x)= x is less than 24 years old.

Universe of discourse
is people in this room.

Are either of these propositions true?


a)
b)

x B(x)
x (Y(x) L(x))

A: only a is true
B: only b is true
C: both are true
D: neither is true

1391 23

28

Predicates - more examples


L(x) = x is a lion.
Universe of discourse
is all creatures.
F(x) = x is fierce.
C(x) = x drinks coffee.
All lions are fierce.

x (L(x) F(x))

Some lions dont drink coffee.

x (L(x) C(x))

Some fierce creatures dont drink coffee.

x (F(x) C(x))
1391 23

29

Predicates - more examples


B(x) = x is a hummingbird.
L(x) = x is a large bird.
H(x) = x lives on honey.
R(x) = x is richly colored.

Universe of discourse
is all creatures.

x (B(x) R(x))

All hummingbirds are richly colored.


No large birds live on honey.

x (L(x) H(x))

Birds that do not live on honey are dully colored.


x (H(x) R(x))
1391 23

30

Predicates - quantifier negation


Not all large birds live on honey.

x (L(x) H(x))

x P(x) means P(x) is true for every x.


What about x P(x) ?
Not [P(x) is true for every x.]
There is an x for which P(x) is not true.

x P(x)
So, x P(x) is the same as x P(x).
x (L(x) H(x))
1391 23

31

Predicates - quantifier negation


No large birds live on honey.

x (L(x) H(x))

x P(x) means P(x) is true for some x.


What about x P(x) ?
Not [P(x) is true for some x.]
P(x) is not true for all x.

x P(x)
So, x P(x) is the same as x P(x).
x (L(x) H(x))
1391 23

32

Predicates - quantifier negation

So, x P(x) is the same as x P(x).


So, x P(x) is the same as x P(x).
General rule: to negate a quantifier, move
negation to the right, changing quantifiers as
you go.

1391 23

33

Predicates - quantifier negation


No large birds live on honey.
x (L(x) H(x)) x (L(x) H(x))

Negation
rule

x (L(x) H(x))

DeMorgans

x (L(x) H(x))

Subst for

Whats wrong with this


proof?

1391 23

34

You might also like