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

Unit2 Propositional Logic

Unit 2 covers propositional logic, including concepts such as truth values, logical equivalence, conditionals, and digital logic circuits. It introduces key elements like propositions, logical connectives, well-formed formulas, and the significance of tautologies and contradictions. The unit also explores the relationships between different logical statements and their implications through truth tables.

Uploaded by

sat.zhanibekuly
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Unit2 Propositional Logic

Unit 2 covers propositional logic, including concepts such as truth values, logical equivalence, conditionals, and digital logic circuits. It introduces key elements like propositions, logical connectives, well-formed formulas, and the significance of tautologies and contradictions. The unit also explores the relationships between different logical statements and their implications through truth tables.

Uploaded by

sat.zhanibekuly
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 57

Unit 2

Propositional Logic

Albert Sung

Propositional Logic 2-1


Outline of Unit 2
 2.1 True or False?
 2.2 Logical Equivalence
 2.3 Conditionals
 2.4 Digital Logic Circuits

Propositional Logic 2-2


Unit 2.1

True or False?

Propositional Logic 2-3


On an island, there are two types of inhabitants…

He always He always
tells the truth. lies.

knight knave

Propositional Logic 2-4


You met two islanders…

I’m a knave Are they knights


but he isn’t. or knaves?

1) Both are knights.


2) Both are knaves.
3) A is knight and B is knave.
4) A is knave and B is knight.
A B

Propositional Logic 2-5


Propositions
 A proposition is a  Are they propositions?
statement that is
either true or 1) “1 + 1 = 3.”
false, but not
both. 2) “What’s your name?”

3) “God exists.”
 Each proposition
has a truth value, 4) “Study logic more often, please.”
either T or F.

Propositional Logic 2-6


Logical Connectives
 Propositions can be combined to form
compound propositions by using logical
connectives.

 Three basic logical connectives are


 negation, NOT
 conjunction, AND
 disjunction, OR

Propositional Logic 2-7


Negation - NOT
 Given a proposition p, the compound
proposition ~p is called the negation of p.
 It is read as “not p” or “It is not the case that p”.
 Sometimes, it is written as ¬p.

 Truth table:

Propositional Logic 2-8


Conjunction - AND

 Given p and q, the compound proposition p ∧ q


is called the conjunction of p and q.
 It is read as “p and q”.
 Truth table:

It is true only when


both p and q are true.
22 = 4
rows

Propositional Logic 2-9


Disjunction - OR
 Given p and q, the compound proposition p ∨ q
is called the disjunction of p and q.
 It is read as “p or q”.
 Truth table:

It is false only when


both p and q are false.
Propositional Logic 2-10
Well-Formed Formulas
 A well-formed formula (or simply formula) is an
expression constructed according to the following rules:
1) Each propositional variable is a formula.
 e.g. p, q, and r
2) Formulas combined by logical connectives (with
parenthesis if involving two formulas) is a formula.
 e.g. ~p, (p ∨ q), (p ∧ q)
• Negation does not require parenthesis.
 Outer parenthesis can be omitted
• e.g., ((p ∨ q) ∧ (~q ∨ r)) can be written as (p ∨ q) ∧ (~q ∨ r).
 More logical connectives will be introduced later.

Propositional Logic 2-11


Classwork
 Are they (well-formed) formulas?

1) (p ∧ ~~q)

2) (p ∧ q ∨ r)

3) (p ∨ q) ∧ ~(p ∧ q)

Propositional Logic 2-12


Compound Truth Tables
 The compound truth table for (p ∨ q) ∧ ~(p ∧ q):

Intermediate result Final result

The formula means “(p or q) and not (both p and q).”


It is called Exclusive-OR (XOR), and denoted by p ⊕ q.
Propositional Logic 2-13
Knights and Knaves (Revisited)
I’m a knave  p = “A is a knight”
but he isn’t.  q = “B is a knight”
~𝑝𝑝 ∧ 𝑞𝑞 p q ~p ∧ q
T T F
In propositional logic,
“but” is the same as “and”. T F F
F T T
A B F F F
This must be the case.

 𝑝𝑝 and ~𝑝𝑝 ∧ 𝑞𝑞 must have identical truth values.


 If A is a knight (i.e. 𝑝𝑝 is true) , he tells the truth, so ~𝑝𝑝 ∧ 𝑞𝑞 is true.
 If A is a knave (i.e. 𝑝𝑝 is false), he lies, so ~𝑝𝑝 ∧ 𝑞𝑞 is false.

Propositional Logic 2-14


Class Exercise

Either I am a knave Are they knights


or B is a knight. or knaves?

Use truth table to


find your answer.

A B

Propositional Logic 2-15


Solution (template)
 Let p = “A is a knight”
 Let q = “B is a knight”
 Which formula should be considered?

p q

 Answer?
Propositional Logic 2-16
Unit 2.2

Logical Equivalence

Propositional Logic 2-17


Logical Equivalence
Two formulas X and Y  Example: p ∧ q ≡ q ∧ p
are called logically  It can be proved by a
equivalent (or simply truth table:
equivalent), denoted by

X ≡ Y,
if they have identical
truth values in all cases.

Propositional Logic 2-18


Classwork
 Is it true that ~(p ∧ q) ≡ ~p ∧ ~q?

𝑝𝑝 𝑞𝑞 ~𝑝𝑝 ~𝑞𝑞 𝑝𝑝∧𝑞𝑞 ~(𝑝𝑝∧𝑞𝑞) ~𝑝𝑝∧~𝑞𝑞

intermediate results final results

Propositional Logic 2-19


De Morgan’s Law
 The negation of a conjunction is
the disjunction of the negations:

 The negation of a disjunction is


Augustus De Morgan
the conjunction of the negations. (1806-1871), a British
mathematician and
logician.

Propositional Logic 2-20


Applying De Morgan’s Law
 Write the negations for
1. The bus was late or Tom’s watch was slow.

The bus was not late and Tom’s watch was not slow.

Alternative answer:
Neither was the bus late nor was Tom’s watch slow.

2. −1 < 𝑥𝑥 ≤ 4

𝑥𝑥 ≤ −1 or 𝑥𝑥 > 4.

Propositional Logic 2-21


Tautologies
 A statement that is always
true is called a tautology.

Example: p ∨ ~p
p ~p p ∨ ~p
T F T
F T T

Propositional Logic 2-22


Tautology – Stating the Obvious?!

阿媽係女人! The Pope is


A literal translation: Catholic!
“My mum is a woman!”

Remark: Tautologies reveal hidden truths. For example,


all theorems in mathematics are tautologies.
Propositional Logic 2-23
Contradictions
 A statement that is always
false is called a contradiction.

Example: p ∧ ~p
 This course is interesting, and
this course is not interesting.
 You can use truth table to
prove that it’s always false.

Propositional Logic 2-24


A fable from an ancient Chinese book
《韓非子 - Hanfeizi》

What if you used My spears are so sharp,


My shields are so firm,
your spears to pierce that there is nothing that
that there is nothing
your shields? they cannot pierce.
that can pierce them.

(3 min) https://www.youtube.com/watch?v=RCg3vMu9boQ
Propositional Logic 2-25
Equivalence involving t and c
 If t is a tautology and c is a contradiction, then
𝑝𝑝 ∧ 𝐭𝐭 ≡ 𝑝𝑝 and 𝑝𝑝 ∧ 𝐜𝐜 ≡ 𝐜𝐜.

Propositional Logic 2-26


Theorem 2.1 (Logical Equivalences)

Propositional Logic 2-27


Example: Applying Theorem 2.1
 Prove that

Commutative law is
often obvious and
may be skipped.

Remark: Truth table can also be used to prove


both equivalence and non-equivalence.
Propositional Logic 2-28
Class Exercise
 Prove that (𝑝𝑝 ∧ ~𝑞𝑞) ∨ 𝑝𝑝 ≡ 𝑝𝑝.

Propositional Logic 2-29


Unit 2.3

Conditionals

Propositional Logic 2-30


The Conditional “→”
 “If p then q,” or equivalently, “p implies q”, is
represented by “p → q”.
 p is called the antecedent.
 q is called the consequent.
 “p → q” is sometimes written as “p ⊃ q”.

 How should we define it? p q p→q


T T
Don’t read the next page at
this moment… T F
F T
F F

Propositional Logic 2-31


Truth Table for “→”

If p is true, then p → q
takes the truth value of q.
If p is false, then p → q is
regarded to be true. (why?)

Propositional Logic 2-32


Counter-Intuitive?
“If the sun is made of cheese,
then life exists on the moon.”

 For p → q to be true, there is not necessarily any


cause-and-effect relationship between p and q,
 It depends only on the truth values of p and q.
 p → q is called material implication.
 Its meaning is not exactly the same as “if … then…” in
daily life.

Propositional Logic 2-33


Promise: to keep or to break?
 p → q does conform to some of our ordinary
intuitions about implication.
 “If I am healthy, then I will come to class.”

I keep the promise.


I break the promise.

I do not violate the promise.

Propositional Logic 2-34


“→” defined by NOT and OR
 → can be defined by ~ and ∨.

𝑝𝑝 → 𝑞𝑞 ≡ ~𝑝𝑝 ∨ 𝑞𝑞

p q ~p ~p ∨ q p → q
T T F T T
T F F F F
F T T T T
F F T T T

Propositional Logic 2-35


Conditional Converse Inverse Contrapositive
𝑝𝑝 → 𝑞𝑞 𝑞𝑞 → 𝑝𝑝 ~𝑝𝑝 → ~𝑞𝑞 ~𝑞𝑞 → ~ 𝑝𝑝

a) Is it true that p → q ≡ q → p ?

converse

b) Is it true that p → q ≡ ~p → ~q ?

inverse

c) Is it true that p → q ≡ ~q → ~p ?

contrapositive
Propositional Logic 2-36
Converse: q → p

“If it is a dog, then


it has four legs.” ≡? “If it has four legs, then
it is a dog.”

Propositional Logic 2-37


Inverse: ~p → ~q

“If you eat its fruit,


you will die.” ≡? “If you do not eat its
fruit, you will not die.”

Propositional Logic 2-38


Contrapositive: ~q → ~p

“If it is raining, then


the grass is wet.” ≡? “If the grass is not wet,
then it is not raining”

Propositional Logic 2-39


Class Exercise
 Use a truth table to prove

p → q ≡ ∼q → ∼p

 Answer:

p q p→q ~p ~q ~q → ~p

Propositional Logic 2-40


Contrapositive, Converse & Inverse
 Consider p → q.
 We have seen that
the Law of
p → q ≡ ~q → ~p Contrapositive

 Is it true that p → q ≡ q → p ?

converse

 Is it true that p → q ≡ ~p → ~q ?

inverse
Propositional Logic 2-41
Only If
 “p only if q” means
 “If not q then not p”, or equivalently,
 “If p then q”.

 If it is raining, then the grass is wet.


 It is raining only if the grass is wet.

Propositional Logic 2-42


Necessary & Sufficient Conditions
 When p → q,
 p is called a sufficient condition for q.
 q is called a necessary condition for p.

 “If you are below the lion rock,


you are in Hong Kong.”
 Being below the Lion Rock is a
sufficient condition of being in Hong
Kong.

 Being in Hong Kong is a necessary


condition of being below the Lion
Rock.

A classic Cantopop (1979): https://www.youtube.com/watch?v=9Sx3kncm77w


Propositional Logic 2-43
The Biconditional “ ”
 Biconditional, or if and only if (iff):
p q ≡ (p → q) ∧ (q → p)

True only when


p and q have
identical truth
values.

p only if q p if q p iff q

Propositional Logic 2-44


Operator Precedence
 It is more convenient if some parenthesis
can be omitted.
 To avoid ambiguity, the operators have
different priorities:
from high to low: , ~, ∧, ∨, →, .
Sometimes (and in this course),
∧ and ∨ are regarded as having
the same precedence level.
 Example:
𝑝𝑝 ∨ ~𝑞𝑞 → ~𝑝𝑝 ∧ 𝑟𝑟 means (𝑝𝑝 ∨ ~𝑞𝑞) → (~𝑝𝑝 ∧ 𝑟𝑟).
Propositional Logic 2-45
Class Exercise
 Alice in Wonderland is written by Lewis Carroll,
a logician. It’s a tale that plays with logic.
March Hare
Hatter
Dormouse

Propositional Logic 2-46


An excerpt from Chapter 7, “A Mad
Tea-party,” from Alice in Wonderland
“Then you should say what you mean,” the March Hare
went on.
“I do,” Alice hastily replied; “at least—at least I mean what I
say—that’s the same thing, you know.”
“Not the same thing a bit!” said the Hatter. “Why, you might
just as well say that ‘I see what I eat’ is the same thing as ‘I
eat what I see’!”
“You might just as well say,” added the March Hare, “that ‘I
like what I get’ is the same thing as ‘I get what I like’!”
“You might just as well say,” added the Dormouse, which
seemed to be talking in his sleep, “that ‘I breathe when I
sleep’ is the same thing as ‘I sleep when I breathe’!”
https://www.youtube.com/watch?v=DGEUIOFIclU
(begins from the 2nd min.) Propositional Logic 2-47
Class Exercise
a) Rewrite “I say what I mean” in if-then form.
b) Rewrite “I mean what I say” in if-then form.
c) Are they logically equivalent? Explain the
logical relation between them.

Propositional Logic 2-48


Unit 2.4

Digital Logic Circuits

Propositional Logic 2-49


Logic Gates
 Computers are based on binary digits, or bits,
(i.e., either 0 or 1).
 They are built up from logic gates, which have
inputs and outputs either 0 or 1.
 1 represents True while 0 represents False.

Built up from transistors but often ignored


from a higher-level thinking.

Propositional Logic 2-50


Basic Logic
Gates

Propositional Logic 2-51


Combinatorial Circuit
 Logic gates can be combined to form
combinatorial circuits.

Propositional Logic 2-52


Boolean expression for a Circuit
 Can you see that the output of the circuit can be
expressed as 𝑃𝑃 ∨ 𝑄𝑄 ∧ ~ 𝑃𝑃 ∧ 𝑄𝑄 ?

 Conversely, if the expression 𝑃𝑃 ∨ 𝑄𝑄 ∧ ~ 𝑃𝑃 ∧ 𝑄𝑄 is


given, it is also easy to construct the above circuit.

Propositional Logic 2-53


NAND Gates and NOR Gates
 We often want to minimize the number of logic gates
used to construct a circuit.
 It is more convenient to have more types of logic
gates.
 NAND means NOT-AND, denoted by | (called Sheffer
stroke):
𝑃𝑃 | 𝑄𝑄 ≡ ~ 𝑃𝑃 ∧ 𝑄𝑄

 NOR means NOT-OR, denoted by ↓ (called Peirce


arrow):
𝑃𝑃 ↓ 𝑄𝑄 ≡ ~ 𝑃𝑃 ∨ 𝑄𝑄

Propositional Logic 2-54


Two More
Logic
Gates

Propositional Logic 2-55


Last Question (just for fun)

Is he a knight or
I’m a knave. a knave?

Propositional Logic 2-56


Recommended Readings
 Sections 2.1-2.2, 2.4, Susanna S. Epp,
Discrete Mathematics with
Applications, 4th ed., Brooks Cole,
2010.

 Raymond Smullyan, What Is the


Name of This Book?: The Riddle of
Dracula and Other Logical Puzzles,
Dover, 2011.
 Many logical puzzles.
 Just for fun; not required in this course.

Propositional Logic 2-57

You might also like