Вы находитесь на странице: 1из 89

# Chapter 2: The Fundamentals of Logic

## Logic is commonly known as the science of

reasoning.
Logic as a working tool in proving theorems
or solving problems, creativity and insight
are needed, which cannot be taught.
Reason to study logic:
Hardware level the design of logic
circuits to implement instruction
Software level a knowledge of logic is
helpful in the design of programs.
1

## 2.1: Logical Form

2.2: Truth Tables
2.3: The Law of Logic
2.4: Valid and Invalid Arguments
2.5: Rule of Inference
2.6: Quantified Statements

## 2.1: Logical Form

Basic connectives:
Primitive statements(propositions): declarative
sentences that are either True or False; but not
both.
Eg: Susanna wrote Discrete Mathematics book.
Eg: 2 + 3 = 5
Not statements:
Eg: What a beautiful morning!
Eg: Get up and do your exercises.

## 2.1: Logical Form

use lowercase letters, such as p, q, r,. to
represent propositions.
Eg:
p : It is raining
The truth value of a proposition is true, denoted by
T or 1 whereas the truth value of a proposition is
false, denoted by F or 0.

Exercise:

## Proposition with truth value (F)

2+3=7
Not a proposition
X+1=5
Not a proposition
3+1
Not a proposition
Go away!
SSK3003 is course code for Discrete Structures
Proposition with truth value (T)

## I wear a red shirt Proposition with truth value (F)

2 + 2 = 4 Proposition with truth value (T)
5

## 2.1: Logical Form

Proposition represented by p, q, r. are
considered as primitive proposition no way to
break to anything simpler.
Two ways to obtain new proposition:1.Transform proposition p that is given to p,
which denotes its negation and is read NOT
p.
2.Combine two or more propositions into
compound proposition using logical
connectives.
6

## 2.1: Logical Form

Logical connectives:
Compound statements: combined primitive
statements by logical connectives or by
negation.
Logical connectives:
a) conjunction(AND): p q
b) Disjunction(inclusive OR): p q
c) Exclusive OR:
d) Implication: p q (if p then q)
e) Biconditional: p q (p if only if q , or p iff q)
7

## 2.1: Logical Form

conjunction(AND): p q

## Let p and q be propositions. The conjunction of p

and q is denoted by p ^ q, which is read p and q
True only both p and q are true and false otherwise.
Eg:
x : I am a man
y : I have five children

8

## 2.1: Logical Form

Disjunction(inclusive OR): p q
Disjunction of p and q, is denoted by p v q which
or is used in inclusive way The proposition is
false only when both p and q are false, otherwise it
is true.
Sometimes write and/or to point this out.
The exclusive or is denoted by p v q.
The compound proposition is true only p or q is
true but not both are true or false.
p : I am a girl
q : I am a boy
9

## 2.1: Logical Form

Implication: p q (if p then q)
We say p implies q
pq
Alternatively
If p, then q
p is sufficient for q
p is a sufficient condition for q
q is necessary for p
q is necessary condition for p
p only if q
10

## 2.1: Logical Form

Implication:(continue)
pq
The proposition p is called hypothesis of the
implication whereas q is called the conclusion.
This compound proposition does not need any
causal relationship between the primitive
proposition for the implication to be true.
Example:
y : I go to school everyday.
q : I score A
yq
If I go to school everyday then I score A
11

## 2.1: Logical Form

Biconditional: p q (p if only if q , or p iff q)

Is denoted by p q or p iff q
: which is read if and only if
p q (p q) ^ (q p)
Example:
y : I go to school everyday.
q : I score A
yq
I go to school everyday if and only if I score A
12

## 2.1: Logical Form

Eg 1: Negation
p: Combinatorics is a required course for sophomores.
p: Combinatorics is not a required course for sophomores.
Eg 2: conjunction(AND)
p: Combinatorics is a required course for sophomores.
q: Susanna wrote Discrete Mathematics book.
p q:Combinatorics is a required course for sophomores and
Susanna wrote Discrete Mathematics book.

13

## 2.1: Logical Form

Eg 3: Disjunction(inclusive OR)
p: Combinatorics is a required course for sophomores.
q: Susanna wrote Discrete Mathematics book.
p q: Combinatorics is a required course for sophomores or
Susanna wrote Discrete Mathematics book.

Eg 4:Implication(if p then q)
p: Combinatorics is a required course for sophomores.
q: Susanna wrote Discrete Mathematics book.
p q: If Combinatorics is a required course for sophomores
then Susanna wrote Discrete Mathematics book.
Note: p is the hypothesis of the implication.
Note: q is the conclusion.
14

## 2.1: Logical Form

Eg 3: Biconditional (p if only if q , or p iff q)
p:Combinatorics is a required course for sophomores.
q: Susanna wrote Discrete Mathematics book.

## p q: Combinatorics is a required course for

sophomores if and only if Susanna wrote
Discrete Mathematics book.

15

## 2.1: Logical Form

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.

16

## 2.1: Logical Form

Ex 1:
s: David goes out for a walk.
t: The moon is out.
u: It is snowing.

(t u) s :

17

## 2.1: Logical Form

Ex 2:
s: David goes out for a walk.
t: The moon is out.
u: It is snowing.

(u t) s :

18

## 2.1: Logical Form

Ex 3:
s: David goes out for a walk.
t: The moon is out.
u: It is snowing.

t ( u s) :

19

## 2.1: Logical Form

Ex 4:
s: David goes out for a walk.
t: The moon is out.
u: It is snowing.

(s (u t)) :

20

## 2.1: Logical Form

Translating English Sentences to logical
expression:
Why?
Reasons:
a. English (and every other human language) is often
ambiguous. Translating removes the ambiguity.
b. Easy to analyze logical expressions to determine their truth
values, easy to manipulate.

21

## 2.1: Logical Form

Ex 5: Translating from English to logical
expression
Write each of the following sentences symbolically:
a. It is not hot but it is sunny.
b. It is neither hot nor sunny.
Let h: It is hot.
s: It is sunny.
a. h s
b. h s
22

## 2.1: Logical Form

Ex 6: Searching on the Internet
Internet search engines allow you to use some form of
and , or , not to refine the search process.
If you want to find web pages about careers in mathematics or
computer science but not finance or marketing, how you
Ans: Careers AND (mathematics OR computer science)
AND NOT (finance OR marketing)

23

## 2.1: Logical Form

Ex 7: And, or and Inequalities
Suppose x is a particular real number. Let p, q and r
symbolize as 0 < x , x < 3 and x = 3
respectively.
Write the following inequalities symbolically:
a. x < 3
b. 0 < x < 3
c. 0 < x < 3

Ans:
a.

qr

b. p q

c. p (q r)
24

## 2.1: Logical Form

Ex 8: Translate English sentence into a logical
expression
You can access the Internet from campus only if you are a
computer science major or you are not a freshman.
Ans:
Let a: You can access the Internet from campus.
c: You are a computer science major.
f: You are a freshman
a (c f)

25

## 2.1: Logical Form

Ex 9: Translate English sentence into a logical
expression
You cannot ride the roller coaster if you are under 4 feet tall
unless you are older than 16 years old.
Ans:
Let r: You cannot ride the roller coaster.
s: You are under 4 feet tall.
q: You are older than 16 years old.
(r s) q

26

## 2.1: Logical Form

Converse, contrapositive and inverse:
pq
The converse of p q is
The contrapositive of

qp

p q is q p

The inverse of p q is

pq

27

## 2.1: Logical Form

Eg: Converse, contrapositive and inverse:
What are the contrapositive, the converse and the inverse of
the implication
The home team wins whenever it is raining. ?
Contrapositive:
If the home team does not win, then it is not raining.
Converse:
If the home team wins, then it is raining.
Inverse:
If it is not raining, then the home team does not win.

28

## 2.1: Logical Form

Precedence of Logical operator:
Operator

Precedence

2
3
4
5

29

A truth

## table displays the relationship between the

truth values of propositions
p q p q p q pq pq

1
30

## 2.2: Truth Tables

Eg:Construct a truth table for the following compound proposition,
where p, q, r are denote primitive propositions: p ^ q q v r
p

p^q

q v r

p ^ q q v r

0
0
0
0
1
1
1
1

0
0
1
1
0
0
1
1

0
1
0
1
0
1
0
1

1
1
0
0
1
1
0
0

0
0
0
0
0
0
1
1

1
1
0
1
1
1
0
1

1
1
1
1
1
1
0
1

31

## 2.2: Truth Tables

Def: 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

32

## 2.2: Truth Tables

Eg: A Tautology and a contradiction

p p

p p

33

## A compound statement is called a tautology

if it is true for all truth value assignments
for its component statements.
p

pvq

p (p v q)

p ^ q

p ^ ( p ^ q)

34

## 2.2: Truth Tables

Logical Equivalence:
Def: Two statements forms are called logically equivalent if,
and only if, they have identical truth values for each
possible substitution of statements for their statement
variables.
P logically equivalent to Q is denoted by P = Q .

35

## 2.2: Truth Tables

Logical Equivalence:
Eg 1: Show that the propositions p q and p q are
logically equivalent.
p

pq

pq

T
T
F
F

T
F
T
F

F
F
T
T

T
F
T
T

T
F
T
T

36

## 2.2: Truth Tables

Logical Equivalence:
Eg 2: Show that the propositions p(qr) and (pq)(pr) are
logically equivalent.
p

0
0

0
0

0
1

qr

p(qr) pq pr

(pq)(pr)

37

Exercise
1. Verify that [p (q r)] [(p q) (p r)] is a
tautology.
2. Show that (p (p q)) and p q are logically
equivalent.
3. Show that (p q) (p q) is a tautology.

38

## 2.3: Law of Logic

Logical Equivalence:
Two propositions p1 and p2 are said to be logically
equivalent and we write p1 p2 when the
proposition p1 is true if and only if the p2 is true.

39

## 2.3: Law of Logic

Def: Logically equivalent

p
0
0
1
1

q
0
1
0
1

p
1
1
0
0

p q
1
1
0
1

pq
1
1
0
1

s1 s2
40

## 2.3: Law of Logic

De Morgan's Laws:

( p q ) p q
( p q ) p q
Note: p and q can be any compound statements.
Augustus De Morgan
1806-1871

41

## 2.3: Law of Logic

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

Demorgan's Laws

Commutative Laws
Associative Laws

42

## 2.3: Law 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
( 8) p p T0 , p p F0
( 9 ) p T0 T0 , P F0 F0

Idempotent Law
Identity Law
Inverse Law
Domination Law

43

## 2.3: Law of Logic

Exercise:
Negate and simplify the compound statement ( p q) r

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

44

## 2.3: Law of Logic

contrapositive of
p
0
0
1
1

pq

q p q q p q p p q
0
1
1
1
1
1
1
1
0
0
0
0
0
1
1
1
1
1
1
1
converse
inverse
45

## 2.3: Law of Logic

Ex: simplification of compound statement
( 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
46

## 2.3: Law of Logic

Ex: Show that (p ( p q)) = ( p q) are logically
equivalent.

47

## 2.3: Law of Logic

Ex: Show that ( p q) ( p q) is a tautology.

48

## 2.3: Law of Logic

Ex: 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 below is valid

( p1 p 2 p 3 ) q

p1: p r , p 2 : q p , p 3 : r
( p1 p 2 p 3 ) q
[( p r ) ( q p ) r ] q

which is a tautology,
the original argument
is true
49

## 2.3: Law of Logic

Def. : If p, q are any arbitrary statements such that
is a tautology, then we say that p logically implies q and we
write

pq

## to denote this situation.

p q means p q is a tautology.

p q means p q is a tautology.

50

## 2.4: Valid & Invalid Arguments

An argument a sequence of statements and are called premises.
Testing an argument for validity:
1.

## Identify the premises and conclusion of the argument form.

2.

Construct a truth table showing the truth values of all the premises
and the conclusion.

3.

## Identify the critical rows:

If all the premises are true and the conclusion is false. Therefore,
the argument is invalid.
If all the premises are true and the conclusion is true. Therefore,
the argument is valid.
51

## 2.4: Valid & Invalid Arguments

An Invalid Argument Form:

pqr
qpr
pr

52

## 2.4: Valid & Invalid Arguments

From the table, we conclude that this argument form
(p q r) ( q p r) ( p r) is invalid.
p

qr

pr

pq

qpr

pr

T
F
T
T
F
F
T
T

T
F
T
F
T
T
T
T

r
T
T
T
T
F
F
F
F

T
T
F
F
T
T
F
F

T
F
T
F
T
F
T
F

F
T
F
T
F
T
F
T

T
T
F
T
T
T
F
T

T
F
T
F
F
F
F
F

T
T
F
T
T
T
T
T

premises

conclusion

53

## Alternatively, from the table below, we conclude that this

(p q r) ( q p r) ( p r) is NOT a tautology and
therefore the argument form is invalid

p
qr

q (p q
p r) ( q
r

T
T
T
T
F
F
F
F

T
T
F
F
T
T
F
F

T
F
T
F
T
F
T
F

T
T
F
T
T
T
T
T

T
F
T
T
F
F
T
T

( p r)

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

T
F
T
F
T
T
T
T

T
T
T
F
T
T
T
T

p r)

T
F
F
T
F
F
T
T

54

## 2.4: Valid & Invalid Arguments

From the table, we conclude that this argument form
(p q r) ( r) ( p q) is valid.
p

T
T
T
T
F
F
F
F

T
T
F
F
T
T
F
F

T
F
T
F
T
F
T
F

qr pqr
T
T
T
F
T
T
T
F

T
T
T
T
T
T
T
F

premises

pq

F
T
F
T
F
T
F
T

T
T
T
T
T
T
F
F

conclusion

55

## Alternatively, from the table below, we conclude that this

(p q r) ( r) ( p q) is a tautology and therefore
the argument form is valid
p

r pq
r

T
T
T
T
F
F
F
F

T
T
F
F
T
T
F
F

T
F
T
F
T
F
T
F

T
T
T
T
T
T
T
F

pq

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

F
T
F
T
F
T
F
T

T
T
T
T
T
T
F
F

T
T
T
T
T
T
T
T

56

## 2.5: Rule 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).
- a form of argument that is valid.
- Modus Ponens & modus Tollens are both rule of inference.
Modus Ponens :
Syllogism An argument form consisting of two premises and a conclusion.
The first and second premises are called the major and minor premises,
respectively.
Modus Ponens The most famous form of syllogism in logic.
-(the method of affirming) or the Rule of Detachment

[ p ( p q )] q

p
pq
q
57

Modus Ponens:
p

pq

T
T
F
F

T
F
T
F

T
F
T
T

T
T
F
F

T
F
T
F

premises

[ p ( p q )] q

p
pq
q

conclusion

58

Eg: Modus Ponens

[ p ( p q )] q

p
pq
q

## If the sum of the digits of 371,487 is divisible by 3, then

371,487 is divisible by 3.
The sum of the digits of 371,487 is divisible by 3.
371,487 is divisible by 3.

59

## 2.5: Rule of Inference

Modus Tollens - (method of denying) the conclusion
is a denial.

[( p q ) q ] p

pq
q
p

60

## 2.5: Rule of Inference

Eg: Modus Tollens
[( p q ) q ] p

pq
q
p

## Zeus is not mortal.

Zeus is not human.

61

## 2.5: Rule of Inference

Eg: Modus Ponens
a. Lydia wins a ten million dollar lottery.

quit her job.

## b. If Ali vacations in Paris, then she will have to win a

scholarship.
Ali vacations in Paris.

62

## 2.5: Rule of Inference

Eg: Modus Tollens
a. Lydia wins a ten million dollar lottery.

quit her job.

## b. If Ali vacations in Paris, then he will have to win a

scholarship.
Ali vacations in Paris.

63

## 2.5: Rule of Inference

Recognizing Modus Ponens and Modus Tollens:
Use Modus Ponens or modus Tollens to fill in the blanks:-

## a. If there are more pigeons than there are pigeonholes, then

two pigeons roost in the same hole.
There are more pigeons than there are pigeonholes.

64

## 2.5: Rule of Inference

Law of the Syllogism:

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

pq
qr
pr

Eg:

## 1) If the integer 35244 is divisible by 396, then the integer

35244 is divisible by 66.
2) If the integer 35244 is divisible by 66, then the integer
35244 is divisible by 3.
3) Therefore, if the integer 35244 is divisible by 396, then the
integer 35244 is divisible by 3.
65

## 2.5: Rule of Inference

Law of the Syllogism:
Eg:
1) Rita is baking a cake.

## 2) If Rita is baking a cake, then she is not practicing her

flute.
3) If Rita is not practicing her flute, then her father will
4) Therefore Ritas father will not buy her a car.

p
p q
q r
r

66

## 2.5: Rule of Inference

Law of the Syllogism: How to establish the validity of the
argument?

p
p q
q r
r
Steps:

Reasons

1) p q

Premise

2) q r

Premise

3) p r

4) p

Premise

5) r

argument?

p
p q
q r
r
Steps:

Reasons

1) p

Premise

2) p q

Premise

3) q

4) q r

Premise

5) r

## 2.5: Rule of Inference

Eg: Modus Tollens

pr
rs
t s
t u

ps
s t
tu

pu

s u
p

u
p
69

## 2.5: Rule of Inference

Eg: Modus Tollens(Another reasoning)

pr
rs
t s
t u
u
p

ps
p

s
t

70

## 2.5: Rule of Inference

Ex : Rule of Conjunction
p
q
pq
Ex : Rule of Disjunctive Syllogism
pq
p
q
71

## 2.5: Rule of Inference

Exercise: Establish the validity of the given argument
pq

q (r s)
r ( t u)
pt
u

72

Steps

Reason

1) p q

Premise

2) q (r s)

Premise

3) p (r s)

4) p t

Premise

5) p

6) r s

7) r

## Step 6 and the Rule of Conjunctive Simplification

8) r ( t u) Premise
9) ( r t) u Step 8, the associative Law of , De Morgans Law

10) t

11) r t

12) u

## Steps 9 and 11, the Law of Double Negation,

and the Rule of Disjunctive Syllogism

73

## 2.5: Rule of Inference

Exercise: Establish the validity of the given argument:
If the band could not play rock music or the refreshments were
not delivered on time, then the New Years party would have
been canceled and Alicia would have been angry. If the party

( p q) (r s)
rt
t
u
74

Steps

Reason

1) r t

Premise

2) t

Premise

3) r

4) r s

Amplification

5) (r s)

6) ( p q) (r s)

Premise

7) ( p q)

8) p q

Double Negation

9) p

Simplification
75

## 2.6: Quantified Statements

The Use of Quantifiers
Def. : 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, ...
76

2.5:
2.6:Quantified
QuantifiedStatements
Statements
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, p( x) is true.
For some x,y, q(x,y) is true.
For some x,y, q( x, y) is true.
77

## 2.6: Quantified Statements

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.

78

## 2.6: Quantified Statements

The Use of Quantifiers
Ex :
universe: real numbers
p ( x): x 0
q ( x): x 2 0
r ( x): x 2 3x 4 0
s( x): x 2 3 0

## x[ p ( x) r ( x)]: TRUE x=4

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

## 2.6: Quantified Statements

The Use of Quantifiers
Ex : 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 ]

80

## 2.6: Quantified Statements

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

x[ p( x) q( x)]

81

## 2.6: Quantified Statements

The Use of Quantifiers
Ex.: Universe: all integers
r ( x):2 x 1 5

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)]

82

## 2.6: Quantified Statements

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)]

Note this!

83

## 2.6: Quantified Statements

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)

84

## 2.6: Quantified Statements

The Use of Quantifiers
Ex.

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

Negate

x[ p( x) q( x)]

## [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)
85

## 2.6: Quantified Statements

The Use of Quantifiers
multiple variables

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

86

## 2.6: Quantified Statements

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 )
87

## 2.6: Quantified Statements

The Use of Quantifiers
Ex

## [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)]

88

## End of Part 1 of Chapter 1

Next Predicate Calculus n Logic Circuits

89

## Нижнее меню

### Получите наши бесплатные приложения

Авторское право © 2021 Scribd Inc.