You are on page 1of 52

Chapter 2

Fundamentals of Logic
1. What is a valid argument or proof?
2. Study system of logic
3. In proving theorems or solving
problems, creativity and insight are
needed, which cannot be taught
Discrete Math by R.S. Chang, Dept. CSIE, NDHU

Chapter 2. Fundamentals of Logic


2.1 Basic connectives and truth tables
statements (propositions): declarative sentences that are
either true or false--but not both.
Eg. Margaret Mitchell wrote Gone with the Wind.
2+3=5.
not statements:
What a beautiful morning!
Get up and do your exercises.

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

Chapter 2. Fundamentals of Logic


2.1 Basic connectives and truth tables
primitive and compound statements
combined from primitive statements by logical connectives
or by negation ( p , p )
logical connectives:
(a) conjunction (AND): p q
(b) disjunction(inclusive OR): p q
(c) exclusive or: p q
(d) implication: p q
(if p then q)
(e) biconditional: p q (p if and only if q, or p iff q)
Discrete Math by R.S. Chang, Dept. CSIE, NDHU

Chapter 2. Fundamentals of Logic


2.1 Basic connectives and truth tables
"The number x is an integer." is not a statement because its
truth value cannot be determined until a numerical value
is assigned for x.
First order logic vs. predicate logic

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

Chapter 2. Fundamentals of Logic


2.1 Basic connectives and truth tables
Truth Tables
p

pq

pq

p q

0
0

0
1

0
0

0
1

0
1

1
1

1
0

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

pq

pq

Chapter 2. Fundamentals of Logic


2.1 Basic connectives and truth tables
Ex. 2.1

s: Phyllis goes out for a walk.


t: The moon is out.
u: It is snowing.
( t u ) s : If the moon is out and it is not snowing, then
Phyllis goes out for a walk.
If it is snowing and the moon is not out, then Phyllis
will not go out for a walk. ( u t ) s

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

Chapter 2. Fundamentals of Logic


2.1 Basic connectives and truth tables
Def. 2.1. A compound statement is called a tautology(T0) if it is
true for all truth value assignments for its component statements.
If a compound statement is false for all such assignments, then it is
called a contradiction(F0).
p ( p q ) : tautology
p ( p q ) : contradiction

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

Chapter 2. Fundamentals of Logic


2.1 Basic connectives and truth tables
an argument: ( p1 p 2 p n ) q
premises

conclusion

If any one of p1 , p 2 , , p n is false, then no matter what


truth value q has, the implication is true. Consequently,
if we start with the premises p1 , p 2 , , p n --each with
truth value 1--and find that under these circumstances
q also has value 1, then the implication is a tautology and
we have a valid argument.
Discrete Math by R.S. Chang, Dept. CSIE, NDHU

Chapter 2. Fundamentals of Logic


2.2 Logical Equivalence: The Laws of Logic
Ex. 2.7

p
0
0
1
1

q
0
1
0
1

p q

1
1
0
0

1
1
0
1

pq
1
1
0
1

Def 2.2 . logically equivalent

s1 s2
Discrete Math by R.S. Chang, Dept. CSIE, NDHU

Chapter 2. Fundamentals of Logic


2.2 Logical Equivalence: The Laws of Logic
logically equivalent ( p q ) p q
( p q) ( p q) (q p)
( p q ) ( p q ) ( q p )
( p q ) ( p q ) ( p q )
( p q ) ( p q )
We can eliminate the connectives
from compound statements.

and

(and,or,not) is a complete set.


Discrete Math by R.S. Chang, Dept. CSIE, NDHU

10

Chapter 2. Fundamentals of Logic


2.2 Logical Equivalence: The Laws of Logic
Ex 2.8. DeMorgan's Laws

( p q ) p q
( p q ) p q
p and q can be any compound statements.

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

11

Chapter 2. Fundamentals of Logic


2.2 Logical Equivalence: The Laws of Logic
(1) p p
Law of Double Negation

( 2 ) ( p q ) p q
( p q ) p q
( 3) p q q p
pq q p
( 4) p ( q r ) ( p q) r

Demorgan's Laws
Commutative Laws
Associative Laws

p ( q r ) ( p q) r
Discrete Math by R.S. Chang, Dept. CSIE, NDHU

12

Chapter 2. Fundamentals of Logic


2.2 Logical Equivalence: The Laws of Logic

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

Distributive Law

p ( q r ) ( p q) ( p r )
( 6) p p p , p p p
( 7 ) p F0 p , p T0 p

Idempotent Law
Identity Law

( 8) p p T0 , p p F0

Inverse Law

( 9 ) p T0 T0 , P F0 F0
Domination Law
(10) p ( p q ) p , p ( p q ) p Absorption Law
Discrete Math by R.S. Chang, Dept. CSIE, NDHU

13

Chapter 2. Fundamentals of Logic


2.2 Logical Equivalence: The Laws of Logic
All the laws, aside from the Law of Double Negation, all
fall naturally into pairs.
Def. 2.3 Let s be a statement. If s contains no logical connectives
other than and , then the dual of s, denoted sd, is the
statement obtained from s by replacing each occurrence of
and by and , respectively, and each occurrence of T0
and F0 by F0 and T0, respectively.
Eg. s: ( p q ) ( r T0 ), s d : ( p q ) ( r F0 )
The dual of p q is ( p q ) d p q
Discrete Math by R.S. Chang, Dept. CSIE, NDHU

14

Chapter 2. Fundamentals of Logic


2.2 Logical Equivalence: The Laws of Logic
Theorem 2.1 (The Principle of Duality) Let s and t be statements.
If s t , then s d t d .
First Substitution Rule (replace each p by another statement q)
Ex. 2.10 P: ( p q ) ( p q ) is a tautology. Replace
each occurrence of p by r s
P1: [( r s) q ] [ ( r s) q ] is also a tautology.

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

15

Chapter 2. Fundamentals of Logic


2.2 Logical Equivalence: The Laws of Logic
Second Substitution Rule
Ex. 2.11 P: ( p q ) r
Then, P P1
P1: ( p q ) r because ( p q ) ( p q )
Ex. 2.12 Negate and simplify the compound statement ( p q ) r
[( p q ) r ] [ ( p q ) r ]
[( p q ) r ] ( p q ) r
( p q ) r
Discrete Math by R.S. Chang, Dept. CSIE, NDHU

16

Chapter 2. Fundamentals of Logic


2.2 Logical Equivalence: The Laws of Logic
Ex. 2.13 What is the negation of "If Joan goes to Lake George,
then Mary will pay for Joan's shopping spree."?
Because ( p q ) ( p q ) p q
The negation is "Joan goes to Lake George, but (or and)
Mary does not pay for Joan's shopping spree."

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

17

Chapter 2. Fundamentals of Logic


2.2 Logical Equivalence: The Laws of Logic
Ex. 2.15

contrapositive of
p
0
0
1
1

q
0
1
0
1

pq

p q q p q p p q
1
1
0
1

1
1
0
1
converse

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

1
0
1
1

1
0
1
1
inverse
18

Chapter 2. Fundamentals of Logic


2.2 Logical Equivalence: The Laws of Logic
Compare the efficiency of two program segments.
z:=4;
.
for i:=1 to 10 do
.
Number
of
comparisons?
begin
.
20
vs.
10+3=13
x:=z-1;
if x>0 then
y:=z+3*i;
if y>0 then
if ((x>0) and (y>0)) then

writeln(The value of the sum x+y is, x+y)


end
( p q ) r logically equivalent p (q r )
Discrete Math by R.S. Chang, Dept. CSIE, NDHU

19

Chapter 2. Fundamentals of Logic


2.2 Logical Equivalence: The Laws of Logic
simplification of compound statement
Ex. 2.16
( p q ) (p q )
( p q ) (p q )

Demorgan's Law

( p q ) ( p q )

Law of Double Negation

p ( q q )

Distributive Law

p F0 p

Inverse Law and


Identity Law

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

20

Chapter 2. Fundamentals of Logic


2.3 Logical Implication: Rules of Inference
an argument: ( p1 p 2 p n ) q
premises

conclusion

is a valid argument
( p1 p 2 p n ) q

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

is a tautology

21

Chapter 2. Fundamentals of Logic


2.3 Logical Implication: Rules of Inference
Ex. 2.19 statements: p: Roger studies. q: Roger plays tennis.
r: Roger passes discrete mathematics.
premises: p1: If Roger studies, then he will pass discrete math.
p2: If Roger doesn't play tennis, then he'll study.
p3: Roger failed discrete mathematics.
Determine whether the argument ( p1 p 2 p 3 ) q is
valid.
p1: p r , p 2 : q p , p 3 : r
which is a tautology,
the original argument
( p1 p 2 p 3 ) q
is true

[( p r ) ( q p ) r ] q

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

22

Chapter 2. Fundamentals of Logic


2.3 Logical Implication: Rules of Inference
Ex. 2.20
p r s p r ( p r ) s r s [ p (( p r ) s)] ( r s)
0 0 0 0
1
1
1
a tautology
0 0 1 0
1
1
1
deduced or
0 1 0 0
1
0
1
inferred from
0 1 1 0
1
1
1
the two
1 0 0 0
1
1
1
premises
1 0 1 0
1
1
1
1 1 0 1
0
0
1
1 1 1 1
1
1
1
Discrete Math by R.S. Chang, Dept. CSIE, NDHU

23

Chapter 2. Fundamentals of Logic


2.3 Logical Implication: Rules of Inference
Def. 2.4. If p, q are any arbitrary statements such that p q
is a tautology, then we say that p logically implies q and we
write

p q to denote this situation.

p q means p q is a tautology.

p q means p q

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

is a tautology.

24

Chapter 2. Fundamentals of Logic


2.3 Logical Implication: Rules of Inference
rule of inference: use to validate or invalidate a logical
implication without resorting to truth table (which will be
prohibitively large if the number of variables are large)
Ex 2.22 Modus Ponens (the method of affirming)
or the Rule of Detachment

[ p ( p q )] q

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

p
pq
q

25

Chapter 2. Fundamentals of Logic


2.3 Logical Implication: Rules of Inference
Example 2.23 Law of the Syllogism

[( p q ) ( q r )] ( p r )
Ex 2.25

p
p q
q r
r

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

pq
qr
pr

26

Chapter 2. Fundamentals of Logic


2.3 Logical Implication: Rules of Inference
Ex. 2.25 Modus Tollens (method of denying)
[( p q ) q ] p
example:
pr
ps
pu
rs
s t
t s
s u
t u
tu
u
p
Discrete Math by R.S. Chang, Dept. CSIE, NDHU

pq
q
p

27

Chapter 2. Fundamentals of Logic


2.3 Logical Implication: Rules of Inference
Ex. 2.25 Modus Tollens (method of denying)
[( p q ) q ] p
example:
pr
ps
rs
p
t s
s
t u
t
u
another reasoning
p
Discrete Math by R.S. Chang, Dept. CSIE, NDHU

pq
q
p

28

Chapter 2. Fundamentals of Logic


2.3 Logical Implication: Rules of Inference
fallacy

pq
q
p

(1) If Margaret Thatcher is the president of the U.S., then she


is at least 35 years old.
(2) Margaret Thatcher is at least 35 years old.
(3) Therefore, Margaret Thatcher is the president of the US.

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

29

Chapter 2. Fundamentals of Logic


2.3 Logical Implication: Rules of Inference
fallacy

pq
p
q

(1) If 2+3=6, then 2+4=6.


(2) 2+3 6
(3) Therefore, 2+4 6

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

30

Chapter 2. Fundamentals of Logic


2.3 Logical Implication: Rules of Inference
Ex 2.26 Rule of Conjunction
p
q
pq
Ex. 2.27 Rule of Disjunctive Syllogism
pq
p
q
Discrete Math by R.S. Chang, Dept. CSIE, NDHU

31

Chapter 2. Fundamentals of Logic


2.3 Logical Implication: Rules of Inference
Ex. 2.28 Rule of Contradiction

p F0
p

Proof by Contradiction
To prove

( p1 p 2 p n ) q

we prove (( p1 p2 pn ) q ) F0
( p1 p2 pn q ) F0

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

( p q)
(p q )
p q

32

Chapter 2. Fundamentals of Logic


2.3 Logical Implication: Rules of Inference
Ex. 2.29
pr
p q
qs
r s

r p

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

r q
r s

33

Chapter 2. Fundamentals of Logic


2.3 Logical Implication: Rules of Inference
Ex. 2.30
pq
q ( r s)
r ( t u )
pt
u

r, s
t u

p, t

No systematic way to prove except by truth table (2n).

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

34

Chapter 2. Fundamentals of Logic


2.3 Logical Implication: Rules of Inference
Ex 2.32 Proof by Contradiction
p q
p q
qr
qr
r
r
p
p

q
r
F0

F0

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

35

Chapter 2. Fundamentals of Logic


2.3 Logical Implication: Rules of Inference
p1

p1

p2

p2

pn

pn

q r

q
r

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

reasoning
p (q r )
p (q r )
p ( q r )
( p q ) r
( p q ) r
( p q) r
36

Chapter 2. Fundamentals of Logic


2.3 Logical Implication: Rules of Inference
Ex 2.33
ur
(r s) ( p t )
q ( u s)
t
q p

ur
(r s) ( p t )
q ( u s)
t
q
p

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

us

pt

u, s
p

37

Chapter 2. Fundamentals of Logic


2.3 Logical Implication: Rules of Inference
How to prove that an argument is invalid?
Just find a counterexample (of assignments) for it !

Ex 2.34 Show the following to be invalid.


p
p=1
pq
q=0
1
q (r s)
( r s) 0
r=1
tr
s t
0
s=0,t=1
Discrete Math by R.S. Chang, Dept. CSIE, NDHU

38

Chapter 2. Fundamentals of Logic


2.4 The Use of Quantifiers
Def. 2.5 A declarative sentence is an open statement if
(1) it contains one or more variables, and
(2) it is not a statement, but
(3) it becomes a statement when the variables in it are replaced
by certain allowable choices.
universe
examples: The number x+2 is an even integer.
x=y, x>y, x<y, ...
Discrete Math by R.S. Chang, Dept. CSIE, NDHU

39

Chapter 2. Fundamentals of Logic


2.4 The Use of Quantifiers
notations:

p(x): The number x+2 is an even integer.

q(x,y): The numbers y+2, x-y, and x+2y are even integers.
p(5): FALSE, p( 7 ) : TRUE, q(4,2): TRUE
p(6): TRUE, p( 8) : FALSE, q(3,4): FALSE
Therefore,
For some x, p(x) is true.
For some x,y, q(x,y) is true.
Discrete Math by R.S. Chang, Dept. CSIE, NDHU

For some x, p ( x) is true.


For some x,y, q ( x, y) is true.
40

Chapter 2. Fundamentals of Logic


2.4 The Use of Quantifiers
existential quantifier: For some x:
universal quantifier: For all x: x
x in p(x): free variable
x in x, p ( x): bound variable

x, p ( x) is either

true or false.

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

41

Chapter 2. Fundamentals of Logic


2.4 The Use of Quantifiers
Ex 2.36
universe: real numbers
p ( x): x 0

x[ p ( x) r ( x)]: TRUE
x[ p ( x) q ( x)]: TRUE

q ( x): x 2 0

x[ p ( x) q ( x)]: TRUE

r ( x): x 2 3x 4 0

x[ q ( x) s( x)]: FALSE

s( x): x 2 3 0

x=4

x=1
x[ r ( x) s( x)]: FALSE
x=5,6,...
x[ r ( x) p ( x)]: FALSE x=-1

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

42

Chapter 2. Fundamentals of Logic


2.4 The Use of Quantifiers
Ex 2.37 implicit quantification
sin 2 x cos 2 x 1 is

x(sin 2 x cos 2 x 1)

"The integer 41 is equal to the sum of two perfect squares."


is mn[ 41 m 2 n 2 ]

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

43

Chapter 2. Fundamentals of Logic


2.4 The Use of Quantifiers
Def. 2.6 logically equivalent for open statement p(x) and q(x)
x[ p ( x) q ( x)] , i.e., p ( x) q ( x) for any x

p(x) logically implies q(x)


x[ p ( x) q ( x)]

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

44

Chapter 2. Fundamentals of Logic


2.4 The Use of Quantifiers
Ex. 2.42 Universe: all integers
r ( x):2 x 1 5
then x[ r ( x) s( x)] is false
s( x): x 2 9

but xr ( x) xs( x) is true


Therefore, x[ r ( x) s( x)] xr ( x) xs( x)
but x[ p ( x) q ( x)] [xp ( x) xq ( x)]
for any p(x), q(x) and universe

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

45

Chapter 2. Fundamentals of Logic


2.4 The Use of Quantifiers
For a prescribed universe and any open statements p(x), q(x):
x[ p ( x) q ( x)] [xp ( x) xq ( x)]
x[ p ( x) q ( x)] [xp ( x) xq ( x)]
x[ p ( x) q ( x)] [xp ( x) xq ( x)]
[xp ( x) xq ( x)] x[ p ( x) q ( x)]

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

Note this!

46

Chapter 2. Fundamentals of Logic


2.4 The Use of Quantifiers
How do we negate quantified statements that involve a single
variable?

[xp ( x)] xp ( x)
[xp ( x)] xp ( x)
[xp ( x)] xp ( x)
[xp ( x)] xp ( x)

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

47

Chapter 2. Fundamentals of Logic


2.4 The Use of Quantifiers
Ex. 2.44
Negate

p(x): x is odd.
q(x): x2-1 is even.

x[ p ( x) q ( x)]

(If x is odd, then x2-1 is even.)

[x( p ( x) q ( x)] x[ ( p ( x) q ( x))]


x[ ( p ( x) q ( x))] x[ p ( x) q ( x)]
There exists an integer x such that x is odd and x2-1 is odd.
(a false statement, the original is true)
Discrete Math by R.S. Chang, Dept. CSIE, NDHU

48

Chapter 2. Fundamentals of Logic


2.4 The Use of Quantifiers
multiple variables

xyp ( x, y) yxp ( x, y)
xyp ( x, y) yxp ( x, y)

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

49

Chapter 2. Fundamentals of Logic


2.4 The Use of Quantifiers
BUT
Ex. 2.48 p(x,y): x+y=17.

xyp ( x, y) : For every integer x, there exists an integer y such


that x+y=17. (TRUE)

yxp ( x, y) : There exists an integer y so that for all integer x,


x+y=17. (FALSE)
Therefore, xyp( x, y ) yxp( x, y )
Discrete Math by R.S. Chang, Dept. CSIE, NDHU

50

Chapter 2. Fundamentals of Logic


2.4 The Use of Quantifiers
Ex 2.49

[xy[( p ( x, y) q ( x, y)) r ( x, y)]]

x[ y[( p ( x, y) q ( x, y)) r ( x, y)]]


xy[( p ( x, y) q ( x, y)) r ( x, y)]
xy[ [ p ( x, y) q ( x, y)] r ( x, y)]
xy[( p ( x, y) q ( x, y)) r ( x, y)]

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

51

Chapter 2. Fundamentals of Logic

Exercises. Exercise 2.2: 20


Exercise 2.3: 10
Exercise 2.4: 18, 26

Discrete Math by R.S. Chang, Dept. CSIE, NDHU

52

You might also like