Lecture 4
Lecture 4
TOPICS
• Propositional Logic
• Logical Operations
• Equivalences
Logic?
What is logic?
Truth-preserving:
System: a set of
If the initial
mechanistic
statements are
transformations, based
true, the inferred
on syntax alone
statements will
be true Inference: the process of
deriving (inferring) new
statements from old
statements
Propositional Logic
A proposition is a statement that is either true or
false
Examples:
e.g. A B : “A or B”
A: It is snowing.
A: It is not snowing
A A
0 1
1 0
Logical and (conjunction)
Conjunction of A and B is A B
A: CS160 teaches logic.
B: CS160 teaches Java.
A B: CS160 teaches logic and Java.
A B AB
0 0 0
0 1 0
1 0 0
1 1 1
Logical or (disjunction)
Disjunction of A and B is A B
A: Today is Friday.
B: It is snowing.
A B: Today is Friday or it is snowing.
A B AB
0 0 0
0 1 1
1 0 1
1 1 1
Exclusive Or
The “or” connective is inclusive: it is true
if either or both arguments are true
There is also an exclusive or (either or):
A B AB
0 0 0
0 1 1
1 0 1
1 1 0
Confusion over
Inclusive OR and Exclusive OR
A B AB A B AB
0 0 1 0 0 1
0 1 1 0 1 0
1 0 0 1 0 0
1 1 1 1 1 1
Conditional implication
A: A programming homework is due.
B: It is Tuesday.
A B:
If a programming homework is due, then it
must be Tuesday.
Is this the same?
If it is Tuesday, then a programming
homework is due.
Bi-‐conditional
A B
A A AA AA
0 1 1 0
1 0 1 0
Result is always
false, no matter
what A is
Result is always
true, no matter
what A is Therefore, it is a Therefore, it is a
tautology contradiction
Logical Equivalence
Two compound propositions, p and q, are
logically equivalent if p q is a tautology.
Notation: p q
De Morgan’s Laws:
• (p q) p q
• (p q) p q
p q p q (p q) (p q) p q
0 0 1 1 0 1 1
0 1 1 0 0 1 1
1 0 0 1 0 1 1
1 1 0 0 1 0 0
=
Show (p q) p q
p q p q (p q) (p q) p q
0 0 1 1 0 1 1
0 1 1 0 1 0 0
1 0 0 1 1 0 0
1 1 0 0 1 0 0
=
Other Equivalences
Show p q p q
p q p p q p q
0 0 1 1 1
0 1 1 1 1
1 0 0 0 0
1 1 0 1 1
=
Show p (q r) (p q) (p r)
p q r q r p q p r p (q r) (p q) (p r)
0 0 0 0 0 0 0 0
0 0 1 0 0 1 0 0
0 1 0 0 1 0 0 0
0 1 1 1 1 1 1 1
1 0 0 0 1 1 1 1
1 0 1 0 1 1 1 1
1 1 0 0 1 1 1 1
1 1 1 1 1 1 1 1
=
More Equivalences
Equivalence Name
pTp Identity
pFp
pqq p Commutative
pqq p
p (p q) p Absorption
p (p q) p
p q q p p q p q
(p q) p q (p q) p q
p q q p q (p q) p q
0 0 1 1 0 0
0 1 0 0 1 1
1 0 1 0 1 1
1 1 0 1 0 0
=
Contrapositive
so now we have:
p q p q q p