0% found this document useful (0 votes)
2 views

3c - Introduction to Logic and Truth Tables

The document provides an overview of logical concepts, including logical connectives such as conjunction, disjunction, conditional, biconditional, and negation, along with their truth tables. It explains the construction of truth tables for compound statements and introduces key principles such as tautologies, contradictions, and logical equivalences. Additionally, it outlines the laws of logic, including commutative, associative, distributive, and De Morgan's laws.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

3c - Introduction to Logic and Truth Tables

The document provides an overview of logical concepts, including logical connectives such as conjunction, disjunction, conditional, biconditional, and negation, along with their truth tables. It explains the construction of truth tables for compound statements and introduces key principles such as tautologies, contradictions, and logical equivalences. Additionally, it outlines the laws of logic, including commutative, associative, distributive, and De Morgan's laws.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

CFI2107

INTRODUCTION
 Logic has been studied ever since Alan Turing (an English
logician who is considered the founder of Computer
Science) introduced methods to break German encryption
techniques during World War II.
 Mathematicians and logicians spend a lot of time talking
about proofs because they need not only convince
themselves, but others too.
 To do this, they make use of declarative statements.
 Declarative statements can be simple (atomic) or
compound (built up by connecting simple statements).
 The logical connectives are listed below with their symbols
and official names:
LOGICAL CONNECTIVES
 CONNECTIVE SYMBOL NAME
 and ∧ conjunction
 or ∨ disjunction
 if ..., then ... → conditional (also
referred to as
implication)
 if and only if ↔ biconditional
 it is not the case that ¬ negation
CONJUCTION
 If p and q represent statements, then p ∧ q represents
the statement “p and q”.
 This is called the conjunction of p and q.
 The conjunction is true only if both p and q are true,
otherwise it is false.
 Examples
 The earth is flat and lions eat meat. (The whole
statement is not true because the earth is not flat).
 While running == true and count < 6 (something you
should be familiar with from Python).
CONJUCTION
p q p∧ q
T T T
T F F
F T F
F F F
DISJUCTION
 If p and q represent statements, then p ∨ q represents the
statement “p or q”,
 This is called the disjunction of p and q (either ... or ..., or
both).
 The word “or” is used in two different ways in ordinary
English.
 It may have the exclusive sense “either ... or ... but not both”,
or
 the inclusive sense “either ... or ... or both”.
 The inclusive “or” is what “∨” refers to because the
disjunction can be combined with the conjunction and
negation to form the exclusive “or” sense as follows:
 (p ∧ ¬q) ∨ (¬ p ∧ q)
DISJUCTION
p q p∨q
T T T
T F T
F T T
F F F
DISJUCTION
 Most programming languages (including Python and
Delphi) use what is called the short-circuit testing
rule.
 Because if one of the testaments in a disjunction is
true, the whole statement becomes true, once the first
half proves to the true, the programming language
does not bother testing the second part.
 If the first part proves false, the second part is then
tested.
CONDITIONAL
 If p and q represent statements, then p → q
represents the statement “If p, then q”, and we may
describe p → q as a conditional statement with
hypothesis p and conclusion q.
 p is often referred to as the antecedent and q as the
consequent.
 It represents something of the nature of a promise,
for example, “if it rains today, then I will buy you an
umbrella”
 Therefore, the only time it is false is when the
antecedent proves to be true but the consequent
turns out to be false.
CONDITIONAL
p q p→q
T T T
T F F
F T T
F F T
BICONDITIONAL
 If p and q represent statements, then p ↔ q represents
the statement “p if and only if q”
 This can also be written as “p iff q”.
 This is referred to as the biconditional.
 The only time it is false is when p and q are
contradictory.
BICONDITIONAL
p q p↔q
T T T
T F F
F T F
F F T
NEGATION
 If p represents some statement, then ¬p represents the
statement “It is not the case that p”, or more briefly
“not p”.
 This is called the negation of a given statement.
 Negation is different from the other connectives
because it doesn't actually connect two statements.
 However, it is an important way to build compound
statements from simple statements.
NEGATION
p ¬p
T F
F T
BUILDING TRUTH TABLES
 In building truth tables, lower-case letters of the alphabet
such as p, q, and r are used to denote simple statements.
 The order in which a compound statement is built up from
simple statements will usually be indicated by brackets,
except that we reduce the number of brackets required by
applying them to the shortest compound statement in
order of priority.
 Brackets are omitted if they will enclose only a simple
statement e.g. in p ∧ (¬ q), write it as p ∧ ¬ q.
 However, in the case of p ∧ ¬ (q ∨ r) we may not drop the
brackets, since ¬ applies to q ∨ r, not just q.
BUILDING TRUTH TABLES
p q p→q
T T T
T F F
F T T
F F T
BUILDING TRUTH TABLES
 If p and q represent statements, then p → q represents
the statement “If p, then q”,
 We may describe p → q as a conditional statement
with hypothesis p and conclusion q.
 p is often referred to as the antecedent and q as the
consequent.
 Construct a truth table for the following statement:
 [¬ p → (q ∧ r)] ∨ r
BUILDING TRUTH TABLES
p q r ¬ p (q ∧ r) [¬ p → (q ∧ r)] [¬ p → (q ∧ r)] ∨ r

T T T F T T T
T T F F F T T
T F T F F T T
T F F F F T T
F T T T T T T
F T F T F F F
F F T T F F T
F F F T F F F
BUILDING TRUTH TABLES
 First of all, all the possible combinations of p, q and r
are plotted. Then (q ∧ r) and ¬ p are constructed,
before combining them.
 Finally the whole statement is then compiled.
 Suppose we want to construct a truth table for a
compound statement built up from n simple
declarative statements. There will be 2n rows in such a
table.
 In the above activity, n = 3, thus we have 23 = 8 rows.
RELATIONSHIPS BETWEEN
STATEMENTS
 Some compound statements are always true.
 Such a statement is called a tautology.
 Take p ∨ ¬ p as an example.
THE TAUTOLOGY
 When a compound statement is always true, then it
is a tautology.
 Example
 Whether you like it or not, I am going.

p ¬p p∨¬p
T F T
F T T
THE CONTRADICTION
 Some compound statements are always false.
 Such a statement is called a contradiction.
 For example p ∧ ¬ p.

p ¬p p∧¬p
T F F
F T F
THE CONTRADICTION

p ¬p p∧¬p
T F F
F T F
LOGICAL EQUIVALENTS
 The two statements a and b are logically equivalent,
denoted by a ≡ b, if and only if the statement a ↔ b is a
tautology.
 For example the truth table for (p → q) ↔ (¬ q → ¬ p):
LOGICAL EQUIVALENTS
p q ¬q ¬p p→q ¬q→¬p (p → q) ↔
(¬ q → ¬ p)

T T F F T T T
T F T F F F T
F T F T T T T
F F T T T T T
LOGICAL EQUIVALENTS
 Because there are only T’s in the final column, it
follows that (p → q) ↔ (¬ q → ¬ p) is a tautology.
 Only once we are satisfied that it is a tautology do we
replace ↔ with ≡ to make it (p → q) ≡ (¬ q → ¬ p),
thus declaring it logically equivalent.
THE LAWS OF LOGIC
a) p ∨ q ≡ q ∨ p
p∧q≡q∧p (commutative laws)
b) p ∨ (q ∨ r) ≡ (p ∨ q)∨ r
p ∧ (q ∧ r) ≡ (p ∧ q) ∧ r (associative laws)
c) p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)
p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r) (distributive laws)
d) p∨p≡p
p∧p≡p (idempotent laws)
e) ¬ (¬ p ) ≡ p (law of double negation)
THE LAWS OF LOGIC
f) ¬ (p ∨ q) ≡ ¬ p ∧ ¬ q
¬ (p ∧ q) ≡ ¬ p ∨ ¬ q (De Morgan’s laws)
g) p ∨ ¬ p ≡ T0, where T0 is a tautology
p ∧ ¬ p ≡ F0, where F0 is a contradiction (negation)
h) ¬ F0 ≡ T0
¬ T0 ≡ F0 (negations of T0 and F0)
i) p ∨ F0 ≡ p
p ∧ T0 ≡ p (identity)
j) p ∨ T0 ≡ T0
p ∧ F0 ≡ F0 (universal bound)
 We often refer to these as identities.
THE LAWS OF LOGIC
 (Truth tables can be used to show that:
 p ↔ q is logically equivalent to (p → q) ∧ (q → p),
which means we can always work with → and ∧ rather
than use ↔;
 p → q is logically equivalent to ¬ p ∨ q, which means
we can write conditional statements without actually
using →.

You might also like