Lec 5 Truth Tables
Lec 5 Truth Tables
Lec 5 Truth Tables
Set of Integers:
• • • • • •
3 -2 -1 0 1 2
• • • • • • •
-3 -2 -1 0 1 2 3
LOGIC:
Logic is the study of the principles and methods that distinguish between a
valid and an invalid argument.
SIMPLE STATEMENT:
A statement is a declarative sentence that is either true or false but not both.
A statement is also referred to as a proposition
EXAMPLES:
a. 2+2 = 4,
b. It is Sunday today
EXAMPLES:
Propositions Not Propositions
1) Grass is green. 1) Close the door.
2) 4 + 2 = 6 2) x is greater than 2.
3) 4 + 2 = 7 3) He is very rich
4) There are four fingers in a hand.
Rule:
If the sentence is preceded by other sentences that make the pronoun or variable reference
clear, then the sentence is a statement.
Example
Example:
x=1 Bill Gates is an American
x>2 He is very rich
“x > 2” is a statement with truth-value “He is very rich” is a statement with truth-
FALSE. value TRUE.
4
1-Logic
UNDERSTANDING STATEMENTS
1) x + 2 is positive. Not a statement
2) May I come in? Not a statement
3) Logic is interesting. A statement
4) It is hot today. A statement
5) -1 > 0 A statement
6) x + y = 12 Not a statement
COMPOUND STATEMENT:
Simple statements could be used to build a compound statement.
LOGICAL CONNECTIVES
EXAMPLES:
SYMBOLIC REPRESENTATION
Statements are symbolically represented by letters such as p, q, r,...
EXAMPLES:
Disjunction or ∨ Vel
5
1-Logic
EXAMPLES
EXAMPLE
Truth Table
A truth table specifies the truth value of a compound proposition for all
possible truth values of its constituent propositions.
6
1-Logic
NEGATION (~):
If p is a statement variable, then negation of p, “not p”, is denoted as “~p”
It has opposite truth value from p i.e., if p is true, then ~ p is false; if p is false, then ~ p is
true.
p ~p
T F
F T
CONJUNCTION (∧):
If p and q are statements, then the conjunction of p and q is “p and q”, denoted as
“p ∧ q”.
Remarks
o p ∧ q is true only when both p and q are true.
o If either p or q is false, or both are false, then p ∧ q is false.
p q p∧q
T T T
T F F
F T F
F F F
Remarks:
o p ∨ q is true when at least one of p or q is true.
o p ∨ q is false only when both p and q are false.
7
1-Logic
p q p∨q
T T T
T F T
F T T
F F F
Note it that in the table F is only in that row where both p and q have F and all other
values are T. Thus for finding out the truth values for the disjunction of two statements
we will only first search out where the both statements are false and write down the F in
the corresponding row in the column of p ∨ q and in all other rows we will write T in the
column of p ∨ q.
Remark:
Note that for Conjunction of two statements we find the T in both the
statements, But in disjunction we find F in both the statements. In other words, we will
fill T in the first row of conjunction and F in the last row of disjunction.
SUMMARY
1. What is a statement?
2. How a compound statement is formed.
3. Logical connectives (negation, conjunction, disjunction).
4. How to construct a truth table for a statement form.
8
2-Truth Tables
Truth Tables
1. ~p∧q
2. ~ p ∧ (q ∨ ~ r)
3. (p∨q) ∧ ~ (p∧q)
p q ~p ~p∧q
T T F F
T F F F
F T T T
F F T F
p q r ~r q∨~r ~p ~ p ∧ (q ∨ ~ r)
T T T F T F F
T T F T T F F
T F T F F F F
T F F T T F F
F T T F T T T
F T F T T T T
F F T F F T F
F F F T T T T
Truth table for (p∨q) ∧ ~ (p∧q)
The word OR is sometimes used in an exclusive sense (p or q but not both). As in the
below statement
While defining a disjunction the word OR is used in its inclusive sense. Therefore, the
symbol ∨ means the “inclusive OR”
EXCLUSIVE OR:
When OR is used in its exclusive sense, The statement “p or q” means “p or q but not
both” or “p or q and not p and q” which translates into symbols as (p ∨ q) ∧ ~ (p ∧ q)
It is abbreviated as p ⊕ q or p XOR q
T T F
T F T
F T T
F F F
T T T T F F
T F T F T T
F T T F T T
F F F F T F
10
2-Truth Tables
Note: Basically
p ⊕ q ≡ (p ∧ ∼ q) ∨ (~ p ∧ q)
≡ [p ∧ ~ q) ∨ ~ p] ∧ [(p ∧ ~ q) ∨ q]
≡ (p ∨ q) ∧ ∼ (p ∧ q)
≡ (p ∨ q) ∧ (∼ p ∨ ~ q)
LOGICAL EQUIVALENCE
If two logical expressions have the same logical values in the truth table, then we say that
the two logical expressions are logically equivalent. In the following example, ~ (~ p ) is
logically equivalent p. So it is written as ~(~p) ≡ p
p ~p ~(~p)
T F T
F T F
Example
Rewrite in a simpler form:
“It is not true that I am not happy.”
Solution:
Let p = “I am happy”
then ~ p = “I am not happy”
and ~ ( ~ p) = “It is not true that I am not happy”
Since ~ ( ~ p) ≡ p
Hence the given statement is equivalent to “I am happy”
Example
Show that ~ (p∧q) and ~ p ∧ ~ q are not logically equivalent
Solution:
p q ~p ~q p∧q ~(p∧q) ~p ∧ ~q
T T F F T F F
T F F T F T F
F T T F F T F
F F T T F T T
11
2-Truth Tables
DE MORGAN’S LAWS
Symbolically ~ (p ∧ q) ≡ ~ p ∨ ~ q
Symbolically ~ (p ∨ q) ≡ ~ p ∧ ~ q
Truth Table of ~ (p ∨ q) ≡ ~ p ∧ ~ q
p q ~p ~q p∨q ~(p ∨ q) ~p ∧ ~q
T T F F T F F
T F F T T F F
F T T F T F F
F F T T F T T
Solution:
a) The fan is not slow and it is not very hot.
b) Akram is not unfit or Saleem is not injured.
12
2-Truth Tables
EXERCISE:
1. Show that (p ∧ q) ∧ r ≡ p ∧ (q ∧ r)
2. Are the statements ( p ∧ q ) ∨ r and p ∧ ( q ∨ r ) logically equivalent?
TAUTOLOGY:
A tautology is a statement form that is always true regardless of the truth values of the
statement variables. A tautology is represented by the symbol “t”.
p ~p p∨~p
T F T
F T T
p∨~p≡t
CONTRADICTION:
A contradiction is a statement form that is always false regardless of the truth values of
the statement variables. A contradiction is represented by the symbol “c”.
EXAMPLE:
The statement form p ∧ ~ p is a contradiction.
p ~p p∧~p
T F F
F T F
Since in the last column in the truth table we have F in all the entries, so it is a
contradiction i.e. p ∧ ~ p ≡c
REMARKS:
– Most statements are neither tautologies nor contradictions.
– The negation of a tautology is a contradiction and vice versa.
– In common usage we sometimes say that two statement are contradictory.
By this we mean that their conjunction is a contradiction: they cannot both
be true.
13
2-Truth Tables
1. Show that p ∧ t ≡ p
p t p∧t
T T T
F T F
Since in the above table the entries in the first and last columns are identical so we have
the corresponding statement forms are Logically equivalent that is
p∧t≡p
Show that p ∧ c ≡ c
p c p∧c
T F F
F F F
EXERCISE:
Use truth table to show that ( p ∧ q ) ∨ (~ p ∨ ( p ∧ ~q )) is a tautology.
SOLUTION:
Since we have to show that the given statement form is Tautology, so the
column of the above proposition in the truth table will have all entries as T. As clear from
the table below
p q p∧q ~p ~q p∧~q ~ p∨ (p ∧ ~q) (p ∧ q) ∨
(~p ∨ (p ∧ ~q))
T T T F F F F T
T F F F T T T T
F T F T F F T T
F F F T T F T T
Hence ( p ∧ q ) ∨(~ p ∨( p ∧ ~ q )) ≡ t
EXERCISE:
Use truth table to show that (p ∧ ~q) ∧(~p∨q) is a contradiction.
14
2-Truth Tables
SOLUTION:
Since we have to show that the given statement form is Contradiction, so its
column in the truth table will have all entries as F. As clear from the table below.
p q ~q p∧~q ~p ~p∨q ( p ∧ ~ q ) ∧( ~ p ∨ q )
T T F F F T F
T F T T F F F
F T F F T T F
F F T F T T F
LAWS OF LOGIC
1) Commutative Laws
p∧q ≡q∧ p
p∨q ≡q∨ p
2) Associative Laws
(p∧q ) ∧r ≡ p∧(q ∧r)
(p∨q ) ∨r ≡ p∨(q ∨r)
3) Distributive Laws
p∧(q∨r) ≡(p∧q ) ∨( p∧r)
p∨(q ∧r) ≡(p∨q ) ∧( p∨r)
4) Identity Laws
p∧t ≡p
p∨c≡p
5) Negation Laws
p ∨ ∼p ≡ t
p ∧ ∼p ≡ c
7) Idempotent Laws
p∧p≡p
p∨p≡p
8) DeMorgan’s Laws
~ ( p ∧ q ) ≡ ~p ∨ ∼q
~ ( p ∨ q ) ≡ ~p ∧ ∼q
15
2-Truth Tables
16
FUNDAMENTALS OF MATHEMATICAL LOGIC
Review Problems
Problem 1.1
Indicate which of the following sentences are propositions.
a. 1,024 is the smallest four-digit number that is perfect square.
b. She is a mathematics major.
c. 128 = 26
d. x = 26 .
Problem 1.2
Consider the propositions:
p: Juan is a math major.
q: Juan is a computer science major.
Problem 1.3
In the following sentence is the word ”or” used in its inclusive or exclusive
sense? ”A team wins the playoffs if it wins two games in a row or a total of
three games.”
Problem 1.4
Write the truth table for the proposition: (p ∨ (∼ p ∨ q))∧ ∼ (q∧ ∼ r).
Problem 1.5
Let t be a tautology. Show that p ∨ t ≡ t.
Problem 1.6
Let c be a contradiction. Show that p ∨ c ≡ p.
Problem 1.7
Show that (r ∨ p) ∧ [(∼ r ∨ (p ∧ q)) ∧ (r ∨ q)] ≡ p ∧ q.
Problem 1.8
Use De Morgan’s laws to write the negation for the proposition:”This com-
puter program has a logical error in the first ten lines or it is being run with
an incomplete data set.”
1 PROPOSITIONS AND RELATED CONCEPTS
Problem 1.9
Use De Morgan’s laws to write the negation for the proposition:”The dollar
is at an all-time high and the stock market is at a record low.”
Problem 1.10
Assume x ∈ IR. Use De Morgan’s laws to write the negation for the proposition:0 ≥
x > −5.
Problem 1.11
Show that the proposition s = (p ∧ q) ∨ (∼ p ∨ (p∧ ∼ q)) is a tautology.
Problem 1.12
Show that the proposition s = (p∧ ∼ q) ∧ (∼ p ∨ q) is a contradiction.
Problem 1.13
a. Find simpler proposition forms that are logically equivalent to p ⊕ p and
p ⊕ (p ⊕ p).
b. Is (p ⊕ q) ⊕ r ≡ p ⊕ (q ⊕ r)? Justify your answer.
c. Is (p ⊕ q) ∧ r ≡ (p ∧ r) ⊕ (q ∧ r)? Justify your answer.
Problem 1.14
Show the following:
a. p ∧ t ≡ p, where t is a tautology.
b. p ∧ c ≡ c, where c is a contradiction.
c. ∼ t ≡ c and ∼ c ≡ t.
d. p ∨ p ≡ p and p ∧ p ≡ p.