You are on page 1of 77

BMATH2305 • DISCRETE STRUCTURE

Topic 3
Logic & Proof
Outline
• Introduction to Logic
• Truth Tables
• Implication
• Logical Implication and Equivalence
• Valid Argument
• Predicate Calculus

BMATH2305 Discrete Structure 2


Introduction to Logic

Statement and Truth Value


Compound Statement
Variables
Logical Connectives

BMATH2305 Discrete Structure 3


Statement and Truth Value
• A statement is a declarative sentence that is
either true or false.
• The truth value of a statement is either TRUE
or FALSE.
• Although statements are either true or false
(and never both), we may not have enough
information to know its truth value.

BMATH2305 Discrete Structure 4


Example Statement

 George Washington was the first president of the United


States.
 This is a true statement.
 The New York Knicks won the NBA basketball championship
in 1989.
 This is a false statement.

BMATH2305 Discrete Structure 5


Compound Statement
• A compound statement is formed by combining statements
using the words “and,” “or,” “not,” or “if, then.”
• A simple statement is a statement that is not a compound
statement.

BMATH2305 Discrete Structure 6


Variables

• To develop the rules of logic and logical


arguments, we need to deal with any logical
statement, rather than specific examples. We
use the variables a, b, c, and so on to
represent simple statements.

BMATH2305 Discrete Structure 7


Example Compound
Statement

The number 6 is even and the number 5 is odd.


This compound statement is of the form p and q where p =
“The number 6 is even” and q = “The number 5 is odd.”
Tom Jones does a term paper or takes the final exam.
This compound statement is of the form p or q where p = “Tom
Jones does a term paper” and
q = “Tom Jones takes the final exam.”

BMATH2305 Discrete Structure 8


Logical Connectives

• When writing compound statements in terms of its component parts, the


following logic symbols are used:

Word Symbol
and ^
or V

not ~
if, then 
BMATH2305 Discrete Structure 9
Example Compound Statement
with ^

Define p and q and determine the logical connective to rewrite


the following statement:
Fred and Cindy like each other.
Let p = “Fred likes Cindy.”
Let q = “Cindy likes Fred.”
The symbolic statement then becomes p ^ q.

BMATH2305 Discrete Structure 10


Example Compound Statement with
V

Define p and q and determine the logical connective


to rewrite the following statement:
The train stops in New York or Washington.
Let p = “The train stops in New York.”
Let q = “The train stops in Washington.”
The symbolic statement then becomes p V q.

BMATH2305 Discrete Structure 11


Example Compound Statement
with ~

Define p and q and determine the logical connective to rewrite


the following statement:
Fred likes Cindy but Cindy does not like Fred.
Let p = “Fred likes Cindy.”
Let q = “Cindy likes Fred.”
The symbolic statement then becomes p ^ ~q.

BMATH2305 Discrete Structure 12


Example Compound Statement with

Define p and q and determine the logical connective


to rewrite the following statement:
If the train stops in New York, it does not stop in
Washington.
Let p = “The train stops in New York.”
Let q = “The train stops in Washington.”
The symbolic statement then becomes p ~ q.

BMATH2305 Discrete Structure 13


Summary Section
 A logical statement (proposition) is a
declarative sentence that is either TRUE or FALSE.
 Logical statements frequently have
connectives such as and ^, or V, not ~, and
implies (if, then ) .

BMATH2305 Discrete Structure 14


Outline
• Introduction to Logic√
• Truth Tables
• Implication
• Logical Implication and Equivalence
• Valid Argument
• Predicate Calculus
• Logic Circuits

BMATH2305 Discrete Structure 15


Truth Tables
Statement Form
Propositional Calculus
Truth Table
Tautology and Contradiction
Exclusive Or
Tree
Logic and Computer Languages

BMATH2305 Discrete Structure 16


Statement Form

•A statement form is an expression formed from


simple statements and connectives according to
the following rules.
•A simple statement is a statement form.
•If p is a statement form, ~p is a statement form.
•If p and q are statement forms, then so are p ^
q, p V q, and p  q.

BMATH2305 Discrete Structure 17


Example Statement Form

• If p, q, and r are simple statements, then


a) ( p ^ ~ r )  r is a statement form.
b) ~ ( p  ( q v ~ r )) is a statement form.

BMATH2305 Discrete Structure 18


Tautology and Contradiction
•A statement form that has truth value TRUE
regardless of the truth values of the individual
statement variables it contains is called a
tautology.
•A statement form that has truth value FALSE
regardless of the truth values of the individual
statement variables it contains is called a
contradiction.

BMATH2305 Discrete Structure 19


Example Truth Table of Negation ( ~ )

p ~p
T F
F T
Note: T means TRUE and F means FALSE.
The statement form ~ p has the opposite truth
value as the statement form p.
BMATH2305 Discrete Structure 20
Example Truth Table of Conjunction
(^)

p q p^q
T T T
T F F
F T F
F F F
The statement form p ^ q is TRUE if and only if
both statement forms p and q are TRUE.
BMATH2305 Discrete Structure 21
Example Truth Table of Disjunction
(v)

p q p vq
T T T
T F T
F T T
F F F
The statement form p V q is FALSE if and only if
both statement forms p and q are FALSE.
BMATH2305 Discrete Structure 22
Truth Table for More Than One
Connective

•If a statement form contains more than one


connective, the truth table often includes the
truth values of the intermediate steps. See the
following example.

BMATH2305 Discrete Structure 23


Example More Than One Connective

Find the truth table for ( p v q ) ^ ~ ( p ^ q ).

p q ( p v q) ^ ~ (p^q)

T T T F F T
T F T T T F
F T T T T F
F F F F T F
1 2 3 6 5 4

BMATH2305 Discrete Structure 24


Exclusive Or
•The statement of the previous example
( p v q ) ^~ ( p ^ q )
•can be read as “p or q but not both p and q.” This is the exclusive or and is denoted by
the symbol v.

p q pvq
T T F
T F T
F T T
F F F
BMATH2305 Discrete Structure 25
Example More Than Two Variables

Construct the truth table for


( p V q ) ^ (( p V r ) ^ ~ q ).

BMATH2305 Discrete Structure 26


Example More Than Two Variables

p q r ( p v q ) ^ (( p v r ) ^ ~ q )
T T T F F T F F
T T F F F T F F
T F T T T T T T
T F F T T T T T
F T T T F T F F
F T F T F F F F
F F T F F T T T
F F F F F F F T
1 2 3 4 8 5 7 6
BMATH2305 Discrete Structure 27
Tree
•Another method of describing a For example:
statement form is by using a
tree. The statement form is (p^~q)r
written at the top of the tree.
The statement is then separated
along the branches into its
operands until only simple
( p ^ ~ q) r
statements are at the end of the
branches.

p ~q

BMATH2305 Discrete Structure


q 28
Example Tree
T
•Use a tree to find the
truth value of
•( p ^ ~ q ) v r T F
•if p is true and q and r
are both false.
T T
•The statement is TRUE.

F
BMATH2305 Discrete Structure 29
Logic and Computer Languages

•Many computer languages and graphing calculators use logical


connectives in programs that depend on logical decision making.
•For example in a TI-89

Calculator
Logic symbol
Function
AND ^
OR V
NOT ~
XOR v
BMATH2305 Discrete Structure 30
Example Excel
•Use an Excel spreadsheet to find the truth value
of
(p^~q)vr
if p is TRUE and q and r are both FALSE.

BMATH2305 Discrete Structure 31


Summary Section
 A statement without any connectives is called
a simple statement. A statement form is a simple
statement or simple statements with
connectives. The truth value of a statement
form depends only on the truth values of the
simple statements it contains.
 The exclusive or, denoted by p v q, is TRUE only
if one of p or q is TRUE but not both. Otherwise, it
is FALSE.
BMATH2305 Discrete Structure 32
Summary Section

 A truth table or tree can be used to determine the truth value


of a statement form.
 The truth table for the connectives ~, ^, V and V is

p q ~p p^q pVq pvq


T T F T T F
T F F F T T
F T T F T T
F F T F F F
BMATH2305 Discrete Structure 33
Summary Section
 A statement that always has a truth value TRUE
is called a tautology. A statement that always
has a truth value FALSE is called a contradiction.
 The logical connectives used in computer
languages and calculators AND, OR, NOT and XOR
correspond to the symbols ^, V, ~ and V,
respectively.

BMATH2305 Discrete Structure 34


Outline
• Introduction to Logic √
• Truth Tables √
• Implication
• Logical Implication and Equivalence
• Valid Argument
• Predicate Calculus
• Logic Circuits

BMATH2305 Discrete Structure 35


Implication
Conditional Connective
English Equivalents
Converse
Biconditional Connective
Order of Precedence
Implication and Computer Languages

BMATH2305 Discrete Structure 36


Conditional Connective

•The logic symbol  is called p q p q


the conditional connective.
•The statement p  q is T T T
FALSE only if the hypothesis
p is TRUE and the conclusion T F F
q is FALSE. F T T
•Otherwise, it is TRUE.
F F T

BMATH2305 Discrete Structure 37


English Equivalents

• There are several ways to read p  q in English.


1. p implies q.
2. If p, then q.
3. p only if q.
4. q, if p.
5. p is sufficient for q.
6. q is a necessary condition for p.

BMATH2305 Discrete Structure 38


Example English Equivalences

• Determine the hypothesis and the conclusion


for each of the following.
a) Bill goes to the party only if Greta goes to the
party.
b) Sue goes to the party if Craig goes to the party.
c) For 6 to be even, it is sufficient that its square,
36, be even.

BMATH2305 Discrete Structure 39


Example English Equivalences (a)

a) Bill goes to the party only if Greta goes to the


party.
b) The statement is of the form p only if q.
c) The hypothesis p is “Bill goes to the party.”
d) The conclusion q is “Greta goes to the party.”

BMATH2305 Discrete Structure 40


Example English Equivalences (b)

b) Sue goes to the party if Craig goes to the


party.
• The statement is of the form q, if p.
• The hypothesis p is “Craig goes to the party.”
• The conclusion q is “Sue goes to the party.”

BMATH2305 Discrete Structure 41


Example English Equivalences (c)

c) For 6 to be even, it is sufficient that its


square, 36, be even.
• The statement is of the form p is sufficient for
q.
• The hypothesis p is “The square of the integer
6 is even.”
• The conclusion q is “The integer 6 is even.”

BMATH2305 Discrete Structure 42


Converse

•The implication q  p is the converse of the


statement p  q.
•For example, the converse of the statement
•“If x = -6, then x2 = 36”
•is
•“If x2 = 36, then x = -6.”

BMATH2305 Discrete Structure 43


Example Converse

•Construct the truth table for ( p  q ) ^ ( q  p ).

p q (pq) ^ (qp)
T T T T T
T F F F T
F T T F F
F F T T T
1 2 3 5 4

BMATH2305 Discrete Structure 44


Biconditional
•The statement form ( p  q ) ^ ( q  p ) is referred
to as the biconditional, which we write as p  q.
It is read as “p, if and only if q.”
•The biconditional is TRUE only if both statements
p and q have the same truth value. Otherwise
the statement is FALSE.

BMATH2305 Discrete Structure 45


Order of Precedence

•Whenever two or more connectives are listed


in a statement form with no parentheses to
indicate the order of the connectives, the
following order of precedence is to be used.
~, ^, V, , .

BMATH2305 Discrete Structure 46


Example Order of Precedence

•Insert parentheses in the statement


•p ^ q v r  ~ s ^ r
•to show the proper order for the application of
the connectives.
~
^ p ^ q v r~ s ^ r
v

BMATH2305 Discrete Structure 47


Implication and Computer
Languages

•The logical connective  is used in writing


computer programs. One example is the
•“IF … THEN … ELSE”
•statement. The computer checks to see if the
statement following IF is TRUE. If it is, then the
statement following THEN is executed. If it is not
TRUE, then the statement following ELSE is
executed.
BMATH2305 Discrete Structure 48
Example IF … THEN … ELSE

•For the given input values of A and B, use the program to


determine the value of C.
• IF (A*B + 6 > 10)
• THEN LET C = A*B
• ELSE LET C = 10
•a) A = -2, B = -7 b) A = -2, B = 3

•Note: * denotes multiplication.

BMATH2305 Discrete Structure 49


Example IF … THEN … ELSE (a)

•a) A = -2, B = -7:


•IF (A*B + 6 > 10):
•A*B + 6 > 10 is (-2)(-7) + 6 > 10.
•The above statement is TRUE.
•THEN LET C = A*B:
•C = A*B becomes C = 14.
•The computer sets C to 14.

BMATH2305 Discrete Structure 50


Example IF … THEN … ELSE (b)

•b) A = -2, B = 3:
•IF (A*B + 6 > 10):
•A*B + 6 > 10 is (-2)(3) + 6 > 10.
•The above statement is FALSE.
•ELSE LET C = 10:
•The computer sets C to 10.

BMATH2305 Discrete Structure 51


Summary Section
 The truth table for the conditional connective  and the
biconditional connective  is

p q pq pq
T T T T
T F F F
F T F T
F F T T

BMATH2305 Discrete Structure 52


Summary Section
 The order of precedence of logical connectives is
~, ^, V,  ,  .
If parentheses are present in the statement, then they
take precedence over the above order.
 The converse of p  q is q  p. If an implication is TRUE,
its converse is not necessarily TRUE.

BMATH2305 Discrete Structure 53


Summary Section
 The statement p  q is the implication “if p, then q (or
p implies q).” It is FALSE only when p is TRUE and q is FALSE.
The two-way implication p  q is TRUE whenever p and q
have the same truth value and FALSE otherwise.
 The logical connective used in computer languages
IF…THEN corresponds to the logical symbol .

BMATH2305 Discrete Structure 54


Outline
• Introduction to Logic √
• Truth Tables √
• Implication √
• Logical Implication and Equivalence
• Valid Argument
• Predicate Calculus
• Logic Circuits

BMATH2305 Discrete Structure 55


Logical Implication and Equivalence
Logically Equivalent
Statements as Variables
De Morgan’s Laws
Other Equivalences
Substitution Principles
Logical Implications

BMATH2305 Discrete Structure 56


Logically Equivalent
Two statement forms that have the same truth tables are called
logically equivalent.
A statement that has the truth value TRUE regardless of the truth
value of its component statements is called a tautology and we
denote it with the letter t.
A statement that has the truth value FALSE regardless of the
truth value of its component statements is called a contradiction
and we denote it by the letter c.

BMATH2305 Discrete Structure 57


Example Logically Equivalent

•Verify that ~(p V q)  (~p ^ ~q).


p q ~( p V q )  ( ~p ^ ~q )

T T F T T F F F
T F F T T F F T
F T F T T T F F
F F T F T T T T
1 2 4 3 8 5 7 6

BMATH2305 Discrete Structure 58


Statements as Variables

For convenience, we denote compound statement


forms by capital letters.
P is logically equivalent to Q if and only if
P  Q is a tautology.
In this case, we write P  Q.

BMATH2305 Discrete Structure 59


De Morgan’s Laws

The following two statements are called De


Morgan’s laws.
~ (p V q)  (~ p ^ ~ q)
~ (p ^ q)  (~ p V ~ q)

BMATH2305 Discrete Structure 60


Example De Morgan’s Laws

Negate the statement “The earth’s orbit is round


and a year has 365 days.”
If p is “The earth’s orbit is round” and q is “A
year has 365 days,” then the original statement is
p ^ q. We want ~ (p ^ q)  (~ p V ~ q).
The negation is “The earth’s orbit is not round or
a year does not have 365 days.”

BMATH2305 Discrete Structure 61


Other Equivalences (1)
Double negation:
~ ~p  p
Commutative laws:
(p V q)  (q V p)
(p ^ q)  (q ^ p)
(p  q)  (q  p)
Associative laws:
(( p V q ) V r ))  ( p V ( q V r ))
(( p ^ q ) ^ r ))  ( p ^ ( q ^ r ))
BMATH2305 Discrete Structure 62
Other Equivalences (2)

Distributive laws:
( p v ( q ^ r ))  (( p v q ) ^ ( p v r ))
( p ^ ( q v r ))  (( p ^ q ) v ( p ^ r ))
Idempotent laws:
( p v p)  p
( p ^ p)  p
Identity laws:
(pvc)p
(pvt)t
BMATH2305 Discrete Structure 63
Other Equivalences (3)

(p^c)c
(p^t)p
( p v ~p)  t
( p ^ ~p)  c
Contrapositive:
( p  q) ( ~q  ~p )
Implication:
( p  q)  ( ~p v q )
( p  q)  ~ ( p ^ ~ q )
BMATH2305 Discrete Structure 64
Other Equivalences (4)

Equivalence:
( p  q )  (( p  q ) ^ ( q  p ))
Reductio ad absurdum:
( p  q )  (( p ^ ~ q )  c )

BMATH2305 Discrete Structure 65


Example Contrapositive
A recent Associated Press article quoted a
prominent official as having said, “If Mr. Jones
is innocent of a crime, then he is not a suspect.”
State the contrapositive.
The contrapositive is “If Mr. Jones is a suspect,
then he is guilty of a crime.”

BMATH2305 Discrete Structure 66


Substitution Principles

Suppose that the compound statement P is a tautology.


If p is a primitive statement that appears in P and we
replace each occurrence of p by the same statement q,
then the resulting compound statement Q is also a
tautology.
Let P be a compound statement where p is an arbitrary
statements that appears in P and let q be a statement
such that q  p. Suppose that in P we replace one or
more occurrences of p by q. Then this replacement
yield the compound statement Q and Q  P.
BMATH2305 Discrete Structure 67
Example Substitution Principles

Rewrite the statement form


(p q) ^ (q v r)
Using only the connectives ~ and v.

BMATH2305 Discrete Structure 68


Example Substitution Principles

(p  q) ^ (q v r)
 (~ p v q) ^ (q v r) Implication
 (q v ~p) ^ (q v r) Commutative law
 q v ( ~p ^ r) Distributive law
 q v ( ~p ^ ~ ~ r) Double negative
 q v ~ ( p v ~ r) De Morgan’s law.

BMATH2305 Discrete Structure 69


Logical Implications

Given statement forms P and Q, we say that P logically


implies Q whenever P  Q is a tautology. We write this
as P  Q.
Some logical implications are
Addition:
p  ( p v q)
Simplification:
( p ^ q)  p

BMATH2305 Discrete Structure 70


Logical Implications (2)

Modus ponens:
( p ^ (p  q))  q
Modus tollens:
(( p  q) ^ ~ q)  ~ p
Disjunctive syllogism:
(( p v q) ^ ~q )  p
Hypothetical syllogism:
(( p  q) ^ ( q  r)) ( p  r)

BMATH2305 Discrete Structure 71


Logical Implications (3)

Constructive dilemmas:
(( p  q) ^ ( r  s))  (( p v r)  ( q v s))
(( p  q) ^ ( r  s))  (( p ^ r)  ( q ^ s))

BMATH2305 Discrete Structure 72


Example Logical Implications

•Verify ( p ^ (p  q))  q.
p q ( p ^ (p  q))  q
T T T T T
T F F F T
F T F T T
F F F T T
1 2 4 3 5

BMATH2305 Discrete Structure 73


Summary Section

 We say two statements p and q are logically


equivalent and write p  q if they have the same truth
table, that is, p  q is a tautology.
 We say that p logically implies q and write
p  q if p  q is a tautology.
 The contrapositive of p  q is ~ q  ~ p. The two
statements are logically equivalent. That is,
( p  q ) ( ~ q  ~ p ) is a tautology.

BMATH2305 Discrete Structure 74


Summary Section

The first substitution principle states that if p  q and p is


substituted for q in a tautology compound statement P, then the
resulting compound statement Q is also a tautology.
 The second substitution principle states that if P and Q both
contain the primitive statement p and P  Q, then if R is
substituted for p everywhere it appears in P and Q to yield P ’ and
Q ’, respectively, then P’  Q ’.

BMATH2305 Discrete Structure 75


Summary Section

 There are many logical equivalences. Among these are the commutative,
associative, distributive, and De Morgan’s laws:
Commutative: ( p v q)  (q v p); ( p ^ q )  ( q ^ p )
Associative: ( p v q ) v r )  p v ( q v r );
(p^q)^r) p^(q^r)
Distributive: p v ( q ^ r )  ( p v q ) ^ ( p v r );
p^(qvr)(p^q)v(p^r)
De Morgan’s: ~ (p v q)  ~ p ^ ~ q) ;
~ (p ^ q)  ~ p v ~ q.
BMATH2305 Discrete Structure 76
Outline
• Introduction to Logic √
• Truth Tables √
• Implication √
• Logical Implication and Equivalence √
• Valid Argument
• Predicate Calculus
• Logic Circuits

BMATH2305 Discrete Structure 77

You might also like