Lecture 02
Lecture 02
1
Topics
Propositional logic
A brief review of Lecture 01.
Classifying compound propositions
Converse, contrapositive, and inverse of implication.
Tautology, contradiction, contingency.
Logical equivalence
Equivalence, laws of logic, and properties of logical connectives.
Digital circuits
Gates, combinational circuits, and circuit equivalence.
2
Propositional logic
A brief review of Lecture 01.
3
Syntax and semantics of propositional logic
Syntax
Atomic propositions are “words” in propositional logic.
Propositional variables represent atomic propositions.
Compound propositions are “sentences” made with logical connectives:
¬, ∧, ∨, ⊕, →, ↔.
Semantics
A variable is either true (𝖳) or false (𝖥 ).
Truth tables show the meaning of compound propositions.
4
Connectives and truth tables
p q p→q p q p↔q
𝖥 𝖥 𝖳 𝖥 𝖥 𝖳
𝖥 𝖳 𝖳 𝖥 𝖳 𝖥
𝖳 𝖥 𝖥 𝖳 𝖥 𝖥
𝖳 𝖳 𝖳 𝖳 𝖳 𝖳
5
Implication can be tricky but truth tables don’t lie
p q p→q p implies q
whenever p is true q must be true
𝖥 𝖥 𝖳 if p then q
𝖥 𝖳 𝖳 q if p
𝖳 𝖥 𝖥 p is sufficient for q
𝖳 𝖳 𝖳
p only if q
q is necessary for p
In an implication p → q:
p is called the premise or antecedent.
q is called the conclusion or consequence.
6
Translating English sentences to logic
↓ Step 1: abstract
((q ∧ r ) → p) ∧ (q ∨ (¬ r ))
7
Understanding sentences with truth tables
p q r ¬r (q ∨ (¬r)) (q ∧ r) ((q ∧ r) → p) ((q ∧ r) → p) ∧ (q ∨ (¬r))
𝖥 𝖥 𝖥 𝖳 𝖳 𝖥 𝖳 𝖳
𝖥 𝖥 𝖳 𝖥 𝖥 𝖥 𝖳 𝖥
𝖥 𝖳 𝖥 𝖳 𝖳 𝖥 𝖳 𝖳
𝖥 𝖳 𝖳 𝖥 𝖳 𝖳 𝖥 𝖥
𝖳 𝖥 𝖥 𝖳 𝖳 𝖥 𝖳 𝖳
𝖳 𝖥 𝖳 𝖥 𝖥 𝖥 𝖳 𝖥
𝖳 𝖳 𝖥 𝖳 𝖳 𝖥 𝖳 𝖳
𝖳 𝖳 𝖳 𝖥 𝖳 𝖳 𝖳 𝖳
9
Implication and friends
Implication How do these relate to each other?
p→q
Converse p q p → q q → p ¬p ¬q ¬q → ¬p ¬p → ¬q
q→p 𝖥 𝖥 𝖳 𝖳
𝖥 𝖳 𝖳 𝖥
Contrapositive
¬q → ¬p 𝖳 𝖥 𝖥 𝖳
𝖳 𝖳 𝖥 𝖥
Inverse
¬p → ¬q
10
Implication and friends
Implication How do these relate to each other?
p→q
Converse p q p → q q → p ¬p ¬q ¬q → ¬p ¬p → ¬q
q→p 𝖥 𝖥 𝖳 𝖳 𝖳 𝖳
𝖥 𝖳 𝖳 𝖥 𝖳 𝖥
Contrapositive
¬q → ¬p 𝖳 𝖥 𝖥 𝖳 𝖥 𝖳
𝖳 𝖳 𝖳 𝖳 𝖥 𝖥
Inverse
¬p → ¬q
10
Implication and friends
Implication How do these relate to each other?
p→q
Converse p q p → q q → p ¬p ¬q ¬q → ¬p ¬p → ¬q
q→p 𝖥 𝖥 𝖳 𝖳 𝖳 𝖳 𝖳
𝖥 𝖳 𝖳 𝖥 𝖳 𝖥 𝖳
Contrapositive
¬q → ¬p 𝖳 𝖥 𝖥 𝖳 𝖥 𝖳 𝖥
𝖳 𝖳 𝖳 𝖳 𝖥 𝖥 𝖳
Inverse
¬p → ¬q
10
Implication and friends
Implication How do these relate to each other?
p→q
Converse p q p → q q → p ¬p ¬q ¬q → ¬p ¬p → ¬q
q→p 𝖥 𝖥 𝖳 𝖳 𝖳 𝖳 𝖳 𝖳
𝖥 𝖳 𝖳 𝖥 𝖳 𝖥 𝖳 𝖥
Contrapositive
¬q → ¬p 𝖳 𝖥 𝖥 𝖳 𝖥 𝖳 𝖥 𝖳
𝖳 𝖳 𝖳 𝖳 𝖥 𝖥 𝖳 𝖳
Inverse
¬p → ¬q
10
Implication and friends
Implication How do these relate to each other?
p→q
Converse p q p → q q → p ¬p ¬q ¬q → ¬p ¬p → ¬q
q→p 𝖥 𝖥 𝖳 𝖳 𝖳 𝖳 𝖳 𝖳
𝖥 𝖳 𝖳 𝖥 𝖳 𝖥 𝖳 𝖥
Contrapositive
¬q → ¬p 𝖳 𝖥 𝖥 𝖳 𝖥 𝖳 𝖥 𝖳
𝖳 𝖳 𝖳 𝖳 𝖥 𝖥 𝖳 𝖳
Inverse
¬p → ¬q
10
Tautology, contradiction, and contingency
A compound proposition is a
Tautology if it is always true;
Contradiction if it is always false;
Contingency if it can be either true or false.
(p → q) ∧ p
p ∨ ¬p
p⊕p
11
Tautology, contradiction, and contingency
A compound proposition is a
Tautology if it is always true;
Contradiction if it is always false;
Contingency if it can be either true or false.
(p → q) ∧ p
This is a contingency. It’s true when p = q = 𝖳 and false when p = 𝖳, q = 𝖥.
p ∨ ¬p
p⊕p
11
Tautology, contradiction, and contingency
A compound proposition is a
Tautology if it is always true;
Contradiction if it is always false;
Contingency if it can be either true or false.
(p → q) ∧ p
This is a contingency. It’s true when p = q = 𝖳 and false when p = 𝖳, q = 𝖥.
p ∨ ¬p
This is a tautology. It’s true no matter what truth value p takes on.
p⊕p
11
Tautology, contradiction, and contingency
A compound proposition is a
Tautology if it is always true;
Contradiction if it is always false;
Contingency if it can be either true or false.
(p → q) ∧ p
This is a contingency. It’s true when p = q = 𝖳 and false when p = 𝖳, q = 𝖥.
p ∨ ¬p
This is a tautology. It’s true no matter what truth value p takes on.
p⊕p
This is a contradiction. It’s false no matter what truth value p takes on.
11
Logical equivalence
Equivalence, laws of logic, and properties of logical connectives.
12
Equivalence of compound propositions
p∧q≡p∧q
p∧q≡q∧p
p∧q≢q∨p
13
Equivalence of compound propositions
p∧q≡p∧q
Two formulas that are syntactically identical are also equivalent.
p∧q≡q∧p
p∧q≢q∨p
13
Equivalence of compound propositions
p∧q≡p∧q
Two formulas that are syntactically identical are also equivalent.
p∧q≡q∧p
These two formulas are syntactically different but have the same truth table!
p∧q≢q∨p
13
Equivalence of compound propositions
p∧q≡p∧q
Two formulas that are syntactically identical are also equivalent.
p∧q≡q∧p
These two formulas are syntactically different but have the same truth table!
p∧q≢q∨p
When p = 𝖳 and q = 𝖥, p ∧ q is false but p ∨ q is true!
13
A ≡ B versus A ↔ B
A ≡ B is an assertion that A and B have the same truth tables.
This is not a compound proposition (sentence) in propositional logic!
It is also sometimes called a semantic judgement.
A ↔ B is a proposition that may be true or false depending on the
truth values of the variables that occur in A and B.
14
A ≡ B versus A ↔ B
A ≡ B is an assertion that A and B have the same truth tables.
This is not a compound proposition (sentence) in propositional logic!
It is also sometimes called a semantic judgement.
A ↔ B is a proposition that may be true or false depending on the
truth values of the variables that occur in A and B.
A ≡ B and (A ↔ B) ≡ 𝖳 have the same meaning.
A and B are equivalent when A ↔ B is a tautology.
14
Important equivalences: DeMorgan’s laws
¬(p ∧ q) ≡ ¬p ∨ ¬q
¬(p ∨ q) ≡ ¬p ∧ ¬q
15
Important equivalences: DeMorgan’s laws
¬(p ∧ q) ≡ ¬p ∨ ¬q
¬(p ∨ q) ≡ ¬p ∧ ¬q
15
Important equivalences: DeMorgan’s laws
¬(p ∧ q) ≡ ¬p ∨ ¬q
¬(p ∨ q) ≡ ¬p ∧ ¬q
15
Important equivalences: DeMorgan’s laws
¬(p ∧ q) ≡ ¬p ∨ ¬q
¬(p ∨ q) ≡ ¬p ∧ ¬q
15
Important equivalences: law of implication
p → q ≡ ¬p ∨ q
p q p → q ¬p ¬p ∨ q (p → q) ↔ (¬p ∨ q)
𝖥 𝖥 𝖳 𝖳 𝖳 𝖳
𝖥 𝖳 𝖳 𝖳 𝖳 𝖳
𝖳 𝖥 𝖥 𝖥 𝖥 𝖳
𝖳 𝖳 𝖳 𝖥 𝖳 𝖳
16
Important equivalences: law of implication
p → q ≡ ¬p ∨ q
p q p → q ¬p ¬p ∨ q (p → q) ↔ (¬p ∨ q)
𝖥 𝖥 𝖳 𝖳 𝖳 𝖳
𝖥 𝖳 𝖳 𝖳 𝖳 𝖳
𝖳 𝖥 𝖥 𝖥 𝖥 𝖳
𝖳 𝖳 𝖳 𝖥 𝖳 𝖳
16
Important equivalences: properties of connectives
Identity Commutativity Absorption
p∧𝖳≡p p∧q≡q∧p p ∧ (p ∨ q) ≡ p
p∨𝖥≡p p∨q≡q∨p p ∨ (p ∧ q) ≡ p
Domination Associativity Negation
p∧𝖥≡𝖥 (p ∧ q) ∧ r ≡ p ∧ (q ∧ r) p ∧ ¬p ≡ 𝖥
p∨𝖳≡𝖳 (p ∨ q) ∨ r ≡ p ∨ (q ∨ r) p ∨ ¬p ≡ 𝖳
Idempotence Distributivity Double negation
p∧p≡p p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r) p ≡ ¬¬p
p∨p≡p p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
17
Digital circuits
Gates, combinational circuits, and circuit equivalence.
18
Computing with logic
Digital circuits implement propositional logic:
𝖳 corresponds to 1 or high voltage.
𝖥 corresponds to 0 or low voltage.
Digital gates are functions that
take values 0/1 as inputs and produce 0/1 as output;
correspond to logical connectives (many of them).
19
AND gate
p q p∧q p q
p
q
AND out
𝖥 𝖥 𝖥 0 0 0
𝖥 𝖳 𝖥 0 1 0
𝖳 𝖥 𝖥 1 0 0
𝖳 𝖳 𝖳 1 1 1
p
AND out
q
20
OR gate
OR connective OR gate
p q p∨q p q
p
q OR out
𝖥 𝖥 𝖥 0 0 0
𝖥 𝖳 𝖳 0 1 1
𝖳 𝖥 𝖳 1 0 1
𝖳 𝖳 𝖳 1 1 1
p
OR out
q
21
NOT gate
p ¬p p p NOT out
𝖥 𝖳 0 1
𝖳 𝖥 1 0
p NOT out
22
Blobs are OK!
You may write gates using blobs instead of shapes.
p
AND out
q
p
OR out
q
p NOT out
23
Combinational logic circuits: wiring up gates
p NOT
AND out
q NOT
AND
r
s OR
24
Combinational logic circuits: wiring up gates
p NOT
AND out
q NOT
AND
r
s OR
24
Combinational logic circuits: wiring up gates
p
AND
q NOT OR out
AND
r
25
Combinational logic circuits: wiring up gates
p
AND
q NOT OR out
AND
r
25
Checking (circuit) equivalence
Describe an algorithm for checking if two logical expressions (or circuits)
are equivalent.
Why do we care?
26
Checking (circuit) equivalence
Describe an algorithm for checking if two logical expressions (or circuits)
are equivalent.
Compute the entire truth table for both of them!
What is the run time of the algorithm?
Why do we care?
26
Checking (circuit) equivalence
Describe an algorithm for checking if two logical expressions (or circuits)
are equivalent.
Compute the entire truth table for both of them!
What is the run time of the algorithm?
There are 2n entries in the column for n variables.
Why do we care?
26
Checking (circuit) equivalence
Describe an algorithm for checking if two logical expressions (or circuits)
are equivalent.
Compute the entire truth table for both of them!
What is the run time of the algorithm?
There are 2n entries in the column for n variables.
Why do we care?
Program and hardware verification reduces to logical equivalence
checking!
26
Summary
Propositions can be tautologies, contradictions, or contingencies.
Tautologies are always true.
Contradictions are never true.
Contingencies are sometimes true.
Propositions are equivalent when they have the same truth values.
Use truth tables or laws of logic to establish equivalence.
Digital circuits implement propositional logic!
𝖥 /𝖳 correspond to 0/1 (low/high voltage), respectively.
Gates implement logical connectives.
Combinational circuits implement compound propositions.
27