Upload
others
View
6
Download
0
Embed Size (px)
Citation preview
CSE 311 Lecture 03:Equivalence and ProofsEmina Torlak and Kevin Zatloukal
1
TopicsEquivalence and circuits
A brief review of .Checking equivalence
Applications and a basic brute-force algorithm.Logical proofs
A method for establishing equivalence that extends to richer logics.
Lecture 02
2
Equivalence and circuitsA brief review of .Lecture 02
3
Logical equivalence is an assertion that two propositions and have the same
truth values in all possible cases.
and have the same meaning.
A ≡ B A B
A ≡ B (A ↔ B) ≡ # $%&$'(')*
p ∧ q ≡ q ∧ pp q p ∧ q q ∧ p p ∧ q ↔ q ∧ p, , , , #, # , , ## , , , ## # # # #
p ∧ q ≢ q ∨ p
When and , is false but is true!
p = # q = , p ∧ qp ∨ q
4
Important equivalencesDeMorgan’s laws
Law of implication
Contrapositive
Biconditional
Double negation
Identity
Domination
Idempotence
Commutativity
Associativity
Distributivity
Absorption
Negation
¬(p ∧ q) ≡ ¬p ∨ ¬q¬(p ∨ q) ≡ ¬p ∧ ¬q
p → q ≡ ¬p ∨ q
p → q ≡ ¬q → ¬p
p ↔ q ≡ (p → q) ∧ (q → p)
p 𠪪p
p ∧ # ≡ pp ∨ , ≡ p
p ∧ , ≡ ,p ∨ # ≡ #
p ∧ p ≡ pp ∨ p ≡ p
p ∧ q ≡ q ∧ pp ∨ q ≡ q ∨ p
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
p ∧ (p ∨ q) ≡ pp ∨ (p ∧ q) ≡ p
p ∧ ¬p ≡ ,p ∨ ¬p ≡ #
We will always give you this list!
5
Digital circuitsDigital 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).
#,
6
AND, OR, and NOT gates
ANDpq out 0 0 0
0 1 0
1 0 0
1 1 1
ORpq out 0 0 0
0 1 1
1 0 1
1 1 1
NOTp out 0 1
1 0
p q '&$ p q p ∧ q, , ,, # ,# , ,# # #
p q '&$ p q p ∨ q, , ,, # ## , ## # #
p '&$ p ¬p, ## ,
7
Combinational logic circuits: wiring up gates
NOTq
ORrs
AND
AND outNOTp
Values get sent along wires connecting gates.
¬p ∧ (¬q ∧ (r ∨ s))
8
Combinational logic circuits: wiring up gates
ANDp
ANDr
NOTq OR out
Wires can send one value to multiple gates.
(p ∧ ¬q) ∨ (¬q ∧ r)
9
Other useful gates
NAND gate
0 0 1
0 1 1
1 0 1
1 1 0
NOR gate
0 0 1
0 1 0
1 0 0
1 1 0
XOR gate
0 0 0
0 1 1
1 0 1
1 1 0
XNOR gate
0 0 1
0 1 0
1 0 0
1 1 1
¬(p ∧ q)
p q '&$
¬(p ∨ q)
p q '&$
p ⊕ q
p q '&$
p ↔ q
p q '&$
10
Checking equivalenceApplications and a basic brute-force algorithm.
11
Why do we care about checking equivalence?
Many practical problems are solved by logical equivalence checking!Hardware verification, program verification, query optimization andcaching, compiler optimization, …
12
Why do we care about checking equivalence?
Many practical problems are solved by logical equivalence checking!Hardware verification, program verification, query optimization andcaching, compiler optimization, …
Example: verifying compiler optimizationsGiven a sequence of instructions and an optimized sequence , we canconstruct logical formulas and that encode their meaning. To verifythat behaves exactly like , we check that .
S Ps p
P S p ↔ s ≡ #
12
Why do we care about checking equivalence?
Many practical problems are solved by logical equivalence checking!Hardware verification, program verification, query optimization andcaching, compiler optimization, …
Example: verifying compiler optimizationsGiven a sequence of instructions and an optimized sequence , we canconstruct logical formulas and that encode their meaning. To verifythat behaves exactly like , we check that .
Demo: verifying compiler with Is correct?
S Ps p
P S p ↔ s ≡ #peephole optimizations Alive
this optimization
; Original program (S)%a = xor %y, %x ; a = y ^ x%b = and %y, %x ; b = x & x%c = ashr %b, 1 ; c = b >> 1%d = add %c, %a ; d = c + a =>; Optimized program (P)%d = add %x, %y ; d = x + y
12
Why do we care about checking equivalence?
Many practical problems are solved by logical equivalence checking!Hardware verification, program verification, query optimization andcaching, compiler optimization, …
Example: verifying compiler optimizationsGiven a sequence of instructions and an optimized sequence , we canconstruct logical formulas and that encode their meaning. To verifythat behaves exactly like , we check that .
Demo: verifying compiler with Is correct?
S Ps p
P S p ↔ s ≡ #peephole optimizations Alive
this optimization
; Original program (S)%a = xor %y, %x ; a = y ^ x%b = and %y, %x ; b = x & x%c = ashr %b, 1 ; c = b >> 1%d = add %c, %a ; d = c + a =>; Optimized program (P)%d = add %x, %y ; d = x + y
No! The right shi! (ashr)should be replaced with a le!shi! (shl).
12
Checking logical (and circuit) equivalence
Can we write an algorithm to decide if two propositions are equivalent?
What is the run time of the algorithm?
In theory, the news are bad …
But in practice, the news are pretty good …
13
Checking logical (and circuit) equivalence
Can we write an algorithm to decide if two propositions are equivalent?Yes! Generate the truth tables for both propositions and check if they arethe same for every entry.
What is the run time of the algorithm?
In theory, the news are bad …
But in practice, the news are pretty good …
13
Checking logical (and circuit) equivalence
Can we write an algorithm to decide if two propositions are equivalent?Yes! Generate the truth tables for both propositions and check if they arethe same for every entry.
What is the run time of the algorithm?Every propositional variable has two possibilities ( , ). If there are variables, there are rows in the truth table. So the running time isexponential in the number of variables.
In theory, the news are bad …
But in practice, the news are pretty good …
# , n2n
13
Checking logical (and circuit) equivalence
Can we write an algorithm to decide if two propositions are equivalent?Yes! Generate the truth tables for both propositions and check if they arethe same for every entry.
What is the run time of the algorithm?Every propositional variable has two possibilities ( , ). If there are variables, there are rows in the truth table. So the running time isexponential in the number of variables.
In theory, the news are bad …We know of no algorithm that performs better in general. If you foundone, or proved that it doesn’t exist, you’d solve incomputer science and .
But in practice, the news are pretty good …
# , n2n
a famous open problemwin $1 million
13
Checking logical (and circuit) equivalence
Can we write an algorithm to decide if two propositions are equivalent?Yes! Generate the truth tables for both propositions and check if they arethe same for every entry.
What is the run time of the algorithm?Every propositional variable has two possibilities ( , ). If there are variables, there are rows in the truth table. So the running time isexponential in the number of variables.
In theory, the news are bad …We know of no algorithm that performs better in general. If you foundone, or proved that it doesn’t exist, you’d solve incomputer science and .
But in practice, the news are pretty good …Provers like can solve equivalence checking problems with millions ofvariables and formulas. And that’s enough for many real applications!
# , n2n
a famous open problemwin $1 million
Z3
13
Logical proofsA method for establishing equivalence that extends to richer logics.
14
Proof: use known equivalences to derive new ones
To show that is equivalent to Apply a series of logical equivalences tosubexpressions to convert to .
A B
A B
To show that is a tautologyApply a series of logical equivalences tosubexpressions to convert to .
A
A #
15
Example: show that is equivalent to Let be , and let be .
DeMorgan’s laws
Law of implication
Contrapositive
Biconditional
Double negation
Identity
Domination
Idempotence
Commutativity
Associativity
Distributivity
Absorption
Negation
A BA p ∨ (p ∧ p) B p
p ∨ (p ∧ p) ≡≡ p
¬(p ∧ q) ≡ ¬p ∨ ¬q¬(p ∨ q) ≡ ¬p ∧ ¬q
p → q ≡ ¬p ∨ q
p → q ≡ ¬q → ¬p
p ↔ q ≡ (p → q) ∧ (q → p)
p 𠪪p
p ∧ # ≡ pp ∨ , ≡ p
p ∧ , ≡ ,p ∨ # ≡ #
p ∧ p ≡ pp ∨ p ≡ p
p ∧ q ≡ q ∧ pp ∨ q ≡ q ∨ p
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
p ∧ (p ∨ q) ≡ pp ∨ (p ∧ q) ≡ p
p ∧ ¬p ≡ ,p ∨ ¬p ≡ #
16
Example: show that is equivalent to Let be , and let be .
Idempotence
DeMorgan’s laws
Law of implication
Contrapositive
Biconditional
Double negation
Identity
Domination
Idempotence
Commutativity
Associativity
Distributivity
Absorption
Negation
A BA p ∨ (p ∧ p) B p
p ∨ (p ∧ p) ≡ p ∨ p≡ p
¬(p ∧ q) ≡ ¬p ∨ ¬q¬(p ∨ q) ≡ ¬p ∧ ¬q
p → q ≡ ¬p ∨ q
p → q ≡ ¬q → ¬p
p ↔ q ≡ (p → q) ∧ (q → p)
p 𠪪p
p ∧ # ≡ pp ∨ , ≡ p
p ∧ , ≡ ,p ∨ # ≡ #
p ∧ p ≡ pp ∨ p ≡ p
p ∧ q ≡ q ∧ pp ∨ q ≡ q ∨ p
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
p ∧ (p ∨ q) ≡ pp ∨ (p ∧ q) ≡ p
p ∧ ¬p ≡ ,p ∨ ¬p ≡ #
16
Example: show that is equivalent to Let be , and let be .
IdempotenceIdempotence
DeMorgan’s laws
Law of implication
Contrapositive
Biconditional
Double negation
Identity
Domination
Idempotence
Commutativity
Associativity
Distributivity
Absorption
Negation
A BA p ∨ (p ∧ p) B p
p ∨ (p ∧ p) ≡ p ∨ p≡ p
¬(p ∧ q) ≡ ¬p ∨ ¬q¬(p ∨ q) ≡ ¬p ∧ ¬q
p → q ≡ ¬p ∨ q
p → q ≡ ¬q → ¬p
p ↔ q ≡ (p → q) ∧ (q → p)
p 𠪪p
p ∧ # ≡ pp ∨ , ≡ p
p ∧ , ≡ ,p ∨ # ≡ #
p ∧ p ≡ pp ∨ p ≡ p
p ∧ q ≡ q ∧ pp ∨ q ≡ q ∨ p
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
p ∧ (p ∨ q) ≡ pp ∨ (p ∧ q) ≡ p
p ∧ ¬p ≡ ,p ∨ ¬p ≡ #
16
Example: show that is a tautologyLet be .
DeMorgan’s laws
Law of implication
Contrapositive
Biconditional
Double negation
Identity
Domination
Idempotence
Commutativity
Associativity
Distributivity
Absorption
Negation
AA ¬p ∨ (p ∨ p)
¬p ∨ (p ∨ p) ≡≡≡ #
¬(p ∧ q) ≡ ¬p ∨ ¬q¬(p ∨ q) ≡ ¬p ∧ ¬q
p → q ≡ ¬p ∨ q
p → q ≡ ¬q → ¬p
p ↔ q ≡ (p → q) ∧ (q → p)
p 𠪪p
p ∧ # ≡ pp ∨ , ≡ p
p ∧ , ≡ ,p ∨ # ≡ #
p ∧ p ≡ pp ∨ p ≡ p
p ∧ q ≡ q ∧ pp ∨ q ≡ q ∨ p
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
p ∧ (p ∨ q) ≡ pp ∨ (p ∧ q) ≡ p
p ∧ ¬p ≡ ,p ∨ ¬p ≡ #
17
Example: show that is a tautologyLet be .
Idempotence
DeMorgan’s laws
Law of implication
Contrapositive
Biconditional
Double negation
Identity
Domination
Idempotence
Commutativity
Associativity
Distributivity
Absorption
Negation
AA ¬p ∨ (p ∨ p)
¬p ∨ (p ∨ p) ≡ ¬p ∨ p≡≡ #
¬(p ∧ q) ≡ ¬p ∨ ¬q¬(p ∨ q) ≡ ¬p ∧ ¬q
p → q ≡ ¬p ∨ q
p → q ≡ ¬q → ¬p
p ↔ q ≡ (p → q) ∧ (q → p)
p 𠪪p
p ∧ # ≡ pp ∨ , ≡ p
p ∧ , ≡ ,p ∨ # ≡ #
p ∧ p ≡ pp ∨ p ≡ p
p ∧ q ≡ q ∧ pp ∨ q ≡ q ∨ p
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
p ∧ (p ∨ q) ≡ pp ∨ (p ∧ q) ≡ p
p ∧ ¬p ≡ ,p ∨ ¬p ≡ #
17
Example: show that is a tautologyLet be .
IdempotenceCommutativity
DeMorgan’s laws
Law of implication
Contrapositive
Biconditional
Double negation
Identity
Domination
Idempotence
Commutativity
Associativity
Distributivity
Absorption
Negation
AA ¬p ∨ (p ∨ p)
¬p ∨ (p ∨ p) ≡ ¬p ∨ p≡ p ∨ ¬p≡ #
¬(p ∧ q) ≡ ¬p ∨ ¬q¬(p ∨ q) ≡ ¬p ∧ ¬q
p → q ≡ ¬p ∨ q
p → q ≡ ¬q → ¬p
p ↔ q ≡ (p → q) ∧ (q → p)
p 𠪪p
p ∧ # ≡ pp ∨ , ≡ p
p ∧ , ≡ ,p ∨ # ≡ #
p ∧ p ≡ pp ∨ p ≡ p
p ∧ q ≡ q ∧ pp ∨ q ≡ q ∨ p
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
p ∧ (p ∨ q) ≡ pp ∨ (p ∧ q) ≡ p
p ∧ ¬p ≡ ,p ∨ ¬p ≡ #
17
Example: show that is a tautologyLet be .
IdempotenceCommutativityNegation
DeMorgan’s laws
Law of implication
Contrapositive
Biconditional
Double negation
Identity
Domination
Idempotence
Commutativity
Associativity
Distributivity
Absorption
Negation
AA ¬p ∨ (p ∨ p)
¬p ∨ (p ∨ p) ≡ ¬p ∨ p≡ p ∨ ¬p≡ #
¬(p ∧ q) ≡ ¬p ∨ ¬q¬(p ∨ q) ≡ ¬p ∧ ¬q
p → q ≡ ¬p ∨ q
p → q ≡ ¬q → ¬p
p ↔ q ≡ (p → q) ∧ (q → p)
p 𠪪p
p ∧ # ≡ pp ∨ , ≡ p
p ∧ , ≡ ,p ∨ # ≡ #
p ∧ p ≡ pp ∨ p ≡ p
p ∧ q ≡ q ∧ pp ∨ q ≡ q ∨ p
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
p ∧ (p ∨ q) ≡ pp ∨ (p ∧ q) ≡ p
p ∧ ¬p ≡ ,p ∨ ¬p ≡ #
17
Example: show equivalence with a truth table and proof
A truth table for .
p ∧ (p → q) ≡ p ∧ q
p ∧ (p → q) ↔ p ∧ q ≡ #p q p → q p ∧ (p → q) p ∧ q p ∧ (p → q) ↔ p ∧ q, , # , , #, # # , , ## , , , , ## # # # # #
18
Example: show equivalence with a truth table and proof
DeMorgan’s laws
Law of implication
Contrapositive
Biconditional
Double negation
Identity
Domination
Idempotence
Commutativity
Associativity
Distributivity
Absorption
Negation
p ∧ (p → q) ≡ p ∧ qp ∧ (p → q) ≡
≡≡≡≡ p ∧ q
¬(p ∧ q) ≡ ¬p ∨ ¬q¬(p ∨ q) ≡ ¬p ∧ ¬q
p → q ≡ ¬p ∨ q
p → q ≡ ¬q → ¬p
p ↔ q ≡ (p → q) ∧ (q → p)
p 𠪪p
p ∧ # ≡ pp ∨ , ≡ p
p ∧ , ≡ ,p ∨ # ≡ #
p ∧ p ≡ pp ∨ p ≡ p
p ∧ q ≡ q ∧ pp ∨ q ≡ q ∨ p
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
p ∧ (p ∨ q) ≡ pp ∨ (p ∧ q) ≡ p
p ∧ ¬p ≡ ,p ∨ ¬p ≡ #
19
Example: show equivalence with a truth table and proof
Law of implication
DeMorgan’s laws
Law of implication
Contrapositive
Biconditional
Double negation
Identity
Domination
Idempotence
Commutativity
Associativity
Distributivity
Absorption
Negation
p ∧ (p → q) ≡ p ∧ qp ∧ (p → q) ≡ p ∧ (¬p ∨ q)
≡≡≡≡ p ∧ q
¬(p ∧ q) ≡ ¬p ∨ ¬q¬(p ∨ q) ≡ ¬p ∧ ¬q
p → q ≡ ¬p ∨ q
p → q ≡ ¬q → ¬p
p ↔ q ≡ (p → q) ∧ (q → p)
p 𠪪p
p ∧ # ≡ pp ∨ , ≡ p
p ∧ , ≡ ,p ∨ # ≡ #
p ∧ p ≡ pp ∨ p ≡ p
p ∧ q ≡ q ∧ pp ∨ q ≡ q ∨ p
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
p ∧ (p ∨ q) ≡ pp ∨ (p ∧ q) ≡ p
p ∧ ¬p ≡ ,p ∨ ¬p ≡ #
19
Example: show equivalence with a truth table and proof
Law of implicationDistributivity
DeMorgan’s laws
Law of implication
Contrapositive
Biconditional
Double negation
Identity
Domination
Idempotence
Commutativity
Associativity
Distributivity
Absorption
Negation
p ∧ (p → q) ≡ p ∧ qp ∧ (p → q) ≡ p ∧ (¬p ∨ q)
≡ (p ∧ ¬p) ∨ (p ∧ q)≡≡≡ p ∧ q
¬(p ∧ q) ≡ ¬p ∨ ¬q¬(p ∨ q) ≡ ¬p ∧ ¬q
p → q ≡ ¬p ∨ q
p → q ≡ ¬q → ¬p
p ↔ q ≡ (p → q) ∧ (q → p)
p 𠪪p
p ∧ # ≡ pp ∨ , ≡ p
p ∧ , ≡ ,p ∨ # ≡ #
p ∧ p ≡ pp ∨ p ≡ p
p ∧ q ≡ q ∧ pp ∨ q ≡ q ∨ p
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
p ∧ (p ∨ q) ≡ pp ∨ (p ∧ q) ≡ p
p ∧ ¬p ≡ ,p ∨ ¬p ≡ #
19
Example: show equivalence with a truth table and proof
Law of implicationDistributivityNegation
DeMorgan’s laws
Law of implication
Contrapositive
Biconditional
Double negation
Identity
Domination
Idempotence
Commutativity
Associativity
Distributivity
Absorption
Negation
p ∧ (p → q) ≡ p ∧ qp ∧ (p → q) ≡ p ∧ (¬p ∨ q)
≡ (p ∧ ¬p) ∨ (p ∧ q)≡ , ∨ (p ∧ q)≡≡ p ∧ q
¬(p ∧ q) ≡ ¬p ∨ ¬q¬(p ∨ q) ≡ ¬p ∧ ¬q
p → q ≡ ¬p ∨ q
p → q ≡ ¬q → ¬p
p ↔ q ≡ (p → q) ∧ (q → p)
p 𠪪p
p ∧ # ≡ pp ∨ , ≡ p
p ∧ , ≡ ,p ∨ # ≡ #
p ∧ p ≡ pp ∨ p ≡ p
p ∧ q ≡ q ∧ pp ∨ q ≡ q ∨ p
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
p ∧ (p ∨ q) ≡ pp ∨ (p ∧ q) ≡ p
p ∧ ¬p ≡ ,p ∨ ¬p ≡ #
19
Example: show equivalence with a truth table and proof
Law of implicationDistributivityNegationCommutativity
DeMorgan’s laws
Law of implication
Contrapositive
Biconditional
Double negation
Identity
Domination
Idempotence
Commutativity
Associativity
Distributivity
Absorption
Negation
p ∧ (p → q) ≡ p ∧ qp ∧ (p → q) ≡ p ∧ (¬p ∨ q)
≡ (p ∧ ¬p) ∨ (p ∧ q)≡ , ∨ (p ∧ q)≡ (p ∧ q) ∨ ,≡ p ∧ q
¬(p ∧ q) ≡ ¬p ∨ ¬q¬(p ∨ q) ≡ ¬p ∧ ¬q
p → q ≡ ¬p ∨ q
p → q ≡ ¬q → ¬p
p ↔ q ≡ (p → q) ∧ (q → p)
p 𠪪p
p ∧ # ≡ pp ∨ , ≡ p
p ∧ , ≡ ,p ∨ # ≡ #
p ∧ p ≡ pp ∨ p ≡ p
p ∧ q ≡ q ∧ pp ∨ q ≡ q ∨ p
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
p ∧ (p ∨ q) ≡ pp ∨ (p ∧ q) ≡ p
p ∧ ¬p ≡ ,p ∨ ¬p ≡ #
19
Example: show equivalence with a truth table and proof
Law of implicationDistributivityNegationCommutativityIdentity
DeMorgan’s laws
Law of implication
Contrapositive
Biconditional
Double negation
Identity
Domination
Idempotence
Commutativity
Associativity
Distributivity
Absorption
Negation
p ∧ (p → q) ≡ p ∧ qp ∧ (p → q) ≡ p ∧ (¬p ∨ q)
≡ (p ∧ ¬p) ∨ (p ∧ q)≡ , ∨ (p ∧ q)≡ (p ∧ q) ∨ ,≡ p ∧ q
¬(p ∧ q) ≡ ¬p ∨ ¬q¬(p ∨ q) ≡ ¬p ∧ ¬q
p → q ≡ ¬p ∨ q
p → q ≡ ¬q → ¬p
p ↔ q ≡ (p → q) ∧ (q → p)
p 𠪪p
p ∧ # ≡ pp ∨ , ≡ p
p ∧ , ≡ ,p ∨ # ≡ #
p ∧ p ≡ pp ∨ p ≡ p
p ∧ q ≡ q ∧ pp ∨ q ≡ q ∨ p
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
p ∧ (p ∨ q) ≡ pp ∨ (p ∧ q) ≡ p
p ∧ ¬p ≡ ,p ∨ ¬p ≡ #
19
Example: show tautology with a truth table and proof
A truth table for .
(p ∧ q) → (q ∨ p)
(p ∧ q) → (q ∨ p) ≡ #p q p ∧ q q ∨ p (p ∧ q) → (q ∨ p), , , , #, # , # ## , , # ## # # # #
20
Example: show tautology with a truth table and proof
DeMorgan’s laws
Law of implication
Contrapositive
Biconditional
Double negation
Identity
Domination
Idempotence
Commutativity
Associativity
Distributivity
Absorption
Negation
(p ∧ q) → (q ∨ p)(p ∧ q) → (q ∨ p) ≡
≡≡≡≡≡≡≡≡ #
¬(p ∧ q) ≡ ¬p ∨ ¬q¬(p ∨ q) ≡ ¬p ∧ ¬q
p → q ≡ ¬p ∨ q
p → q ≡ ¬q → ¬p
p ↔ q ≡ (p → q) ∧ (q → p)
p 𠪪p
p ∧ # ≡ pp ∨ , ≡ p
p ∧ , ≡ ,p ∨ # ≡ #
p ∧ p ≡ pp ∨ p ≡ p
p ∧ q ≡ q ∧ pp ∨ q ≡ q ∨ p
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
p ∧ (p ∨ q) ≡ pp ∨ (p ∧ q) ≡ p
p ∧ ¬p ≡ ,p ∨ ¬p ≡ #
21
Example: show tautology with a truth table and proof
Law of implication
DeMorgan’s laws
Law of implication
Contrapositive
Biconditional
Double negation
Identity
Domination
Idempotence
Commutativity
Associativity
Distributivity
Absorption
Negation
(p ∧ q) → (q ∨ p)(p ∧ q) → (q ∨ p) ≡ ¬(p ∧ q) ∨ (q ∨ p)
≡≡≡≡≡≡≡≡ #
¬(p ∧ q) ≡ ¬p ∨ ¬q¬(p ∨ q) ≡ ¬p ∧ ¬q
p → q ≡ ¬p ∨ q
p → q ≡ ¬q → ¬p
p ↔ q ≡ (p → q) ∧ (q → p)
p 𠪪p
p ∧ # ≡ pp ∨ , ≡ p
p ∧ , ≡ ,p ∨ # ≡ #
p ∧ p ≡ pp ∨ p ≡ p
p ∧ q ≡ q ∧ pp ∨ q ≡ q ∨ p
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
p ∧ (p ∨ q) ≡ pp ∨ (p ∧ q) ≡ p
p ∧ ¬p ≡ ,p ∨ ¬p ≡ #
21
Example: show tautology with a truth table and proof
Law of implicationDeMorgan
DeMorgan’s laws
Law of implication
Contrapositive
Biconditional
Double negation
Identity
Domination
Idempotence
Commutativity
Associativity
Distributivity
Absorption
Negation
(p ∧ q) → (q ∨ p)(p ∧ q) → (q ∨ p) ≡ ¬(p ∧ q) ∨ (q ∨ p)
≡ (¬p ∨ ¬q) ∨ (q ∨ p)≡≡≡≡≡≡≡ #
¬(p ∧ q) ≡ ¬p ∨ ¬q¬(p ∨ q) ≡ ¬p ∧ ¬q
p → q ≡ ¬p ∨ q
p → q ≡ ¬q → ¬p
p ↔ q ≡ (p → q) ∧ (q → p)
p 𠪪p
p ∧ # ≡ pp ∨ , ≡ p
p ∧ , ≡ ,p ∨ # ≡ #
p ∧ p ≡ pp ∨ p ≡ p
p ∧ q ≡ q ∧ pp ∨ q ≡ q ∨ p
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
p ∧ (p ∨ q) ≡ pp ∨ (p ∧ q) ≡ p
p ∧ ¬p ≡ ,p ∨ ¬p ≡ #
21
Example: show tautology with a truth table and proof
Law of implicationDeMorganAssociativity
DeMorgan’s laws
Law of implication
Contrapositive
Biconditional
Double negation
Identity
Domination
Idempotence
Commutativity
Associativity
Distributivity
Absorption
Negation
(p ∧ q) → (q ∨ p)(p ∧ q) → (q ∨ p) ≡ ¬(p ∧ q) ∨ (q ∨ p)
≡ (¬p ∨ ¬q) ∨ (q ∨ p)≡ ¬p ∨ (¬q ∨ (q ∨ p))≡≡≡≡≡≡ #
¬(p ∧ q) ≡ ¬p ∨ ¬q¬(p ∨ q) ≡ ¬p ∧ ¬q
p → q ≡ ¬p ∨ q
p → q ≡ ¬q → ¬p
p ↔ q ≡ (p → q) ∧ (q → p)
p 𠪪p
p ∧ # ≡ pp ∨ , ≡ p
p ∧ , ≡ ,p ∨ # ≡ #
p ∧ p ≡ pp ∨ p ≡ p
p ∧ q ≡ q ∧ pp ∨ q ≡ q ∨ p
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
p ∧ (p ∨ q) ≡ pp ∨ (p ∧ q) ≡ p
p ∧ ¬p ≡ ,p ∨ ¬p ≡ #
21
Example: show tautology with a truth table and proof
Law of implicationDeMorganAssociativityAssociativity
DeMorgan’s laws
Law of implication
Contrapositive
Biconditional
Double negation
Identity
Domination
Idempotence
Commutativity
Associativity
Distributivity
Absorption
Negation
(p ∧ q) → (q ∨ p)(p ∧ q) → (q ∨ p) ≡ ¬(p ∧ q) ∨ (q ∨ p)
≡ (¬p ∨ ¬q) ∨ (q ∨ p)≡ ¬p ∨ (¬q ∨ (q ∨ p))≡ ¬p ∨ ((¬q ∨ q) ∨ p)≡≡≡≡≡ #
¬(p ∧ q) ≡ ¬p ∨ ¬q¬(p ∨ q) ≡ ¬p ∧ ¬q
p → q ≡ ¬p ∨ q
p → q ≡ ¬q → ¬p
p ↔ q ≡ (p → q) ∧ (q → p)
p 𠪪p
p ∧ # ≡ pp ∨ , ≡ p
p ∧ , ≡ ,p ∨ # ≡ #
p ∧ p ≡ pp ∨ p ≡ p
p ∧ q ≡ q ∧ pp ∨ q ≡ q ∨ p
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
p ∧ (p ∨ q) ≡ pp ∨ (p ∧ q) ≡ p
p ∧ ¬p ≡ ,p ∨ ¬p ≡ #
21
Example: show tautology with a truth table and proof
Law of implicationDeMorganAssociativityAssociativityCommutativity
DeMorgan’s laws
Law of implication
Contrapositive
Biconditional
Double negation
Identity
Domination
Idempotence
Commutativity
Associativity
Distributivity
Absorption
Negation
(p ∧ q) → (q ∨ p)(p ∧ q) → (q ∨ p) ≡ ¬(p ∧ q) ∨ (q ∨ p)
≡ (¬p ∨ ¬q) ∨ (q ∨ p)≡ ¬p ∨ (¬q ∨ (q ∨ p))≡ ¬p ∨ ((¬q ∨ q) ∨ p)≡ ¬p ∨ (p ∨ (¬q ∨ q))≡≡≡≡ #
¬(p ∧ q) ≡ ¬p ∨ ¬q¬(p ∨ q) ≡ ¬p ∧ ¬q
p → q ≡ ¬p ∨ q
p → q ≡ ¬q → ¬p
p ↔ q ≡ (p → q) ∧ (q → p)
p 𠪪p
p ∧ # ≡ pp ∨ , ≡ p
p ∧ , ≡ ,p ∨ # ≡ #
p ∧ p ≡ pp ∨ p ≡ p
p ∧ q ≡ q ∧ pp ∨ q ≡ q ∨ p
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
p ∧ (p ∨ q) ≡ pp ∨ (p ∧ q) ≡ p
p ∧ ¬p ≡ ,p ∨ ¬p ≡ #
21
Example: show tautology with a truth table and proof
Law of implicationDeMorganAssociativityAssociativityCommutativityAssociativity
DeMorgan’s laws
Law of implication
Contrapositive
Biconditional
Double negation
Identity
Domination
Idempotence
Commutativity
Associativity
Distributivity
Absorption
Negation
(p ∧ q) → (q ∨ p)(p ∧ q) → (q ∨ p) ≡ ¬(p ∧ q) ∨ (q ∨ p)
≡ (¬p ∨ ¬q) ∨ (q ∨ p)≡ ¬p ∨ (¬q ∨ (q ∨ p))≡ ¬p ∨ ((¬q ∨ q) ∨ p)≡ ¬p ∨ (p ∨ (¬q ∨ q))≡ (¬p ∨ p) ∨ (¬q ∨ q)≡≡≡ #
¬(p ∧ q) ≡ ¬p ∨ ¬q¬(p ∨ q) ≡ ¬p ∧ ¬q
p → q ≡ ¬p ∨ q
p → q ≡ ¬q → ¬p
p ↔ q ≡ (p → q) ∧ (q → p)
p 𠪪p
p ∧ # ≡ pp ∨ , ≡ p
p ∧ , ≡ ,p ∨ # ≡ #
p ∧ p ≡ pp ∨ p ≡ p
p ∧ q ≡ q ∧ pp ∨ q ≡ q ∨ p
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
p ∧ (p ∨ q) ≡ pp ∨ (p ∧ q) ≡ p
p ∧ ¬p ≡ ,p ∨ ¬p ≡ #
21
Example: show tautology with a truth table and proof
Law of implicationDeMorganAssociativityAssociativityCommutativityAssociativityCommutativity (twice)
DeMorgan’s laws
Law of implication
Contrapositive
Biconditional
Double negation
Identity
Domination
Idempotence
Commutativity
Associativity
Distributivity
Absorption
Negation
(p ∧ q) → (q ∨ p)(p ∧ q) → (q ∨ p) ≡ ¬(p ∧ q) ∨ (q ∨ p)
≡ (¬p ∨ ¬q) ∨ (q ∨ p)≡ ¬p ∨ (¬q ∨ (q ∨ p))≡ ¬p ∨ ((¬q ∨ q) ∨ p)≡ ¬p ∨ (p ∨ (¬q ∨ q))≡ (¬p ∨ p) ∨ (¬q ∨ q)≡ (p ∨ ¬p) ∨ (q ∨ ¬q)≡≡ #
¬(p ∧ q) ≡ ¬p ∨ ¬q¬(p ∨ q) ≡ ¬p ∧ ¬q
p → q ≡ ¬p ∨ q
p → q ≡ ¬q → ¬p
p ↔ q ≡ (p → q) ∧ (q → p)
p 𠪪p
p ∧ # ≡ pp ∨ , ≡ p
p ∧ , ≡ ,p ∨ # ≡ #
p ∧ p ≡ pp ∨ p ≡ p
p ∧ q ≡ q ∧ pp ∨ q ≡ q ∨ p
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
p ∧ (p ∨ q) ≡ pp ∨ (p ∧ q) ≡ p
p ∧ ¬p ≡ ,p ∨ ¬p ≡ #
21
Example: show tautology with a truth table and proof
Law of implicationDeMorganAssociativityAssociativityCommutativityAssociativityCommutativity (twice)Negation (twice)
DeMorgan’s laws
Law of implication
Contrapositive
Biconditional
Double negation
Identity
Domination
Idempotence
Commutativity
Associativity
Distributivity
Absorption
Negation
(p ∧ q) → (q ∨ p)(p ∧ q) → (q ∨ p) ≡ ¬(p ∧ q) ∨ (q ∨ p)
≡ (¬p ∨ ¬q) ∨ (q ∨ p)≡ ¬p ∨ (¬q ∨ (q ∨ p))≡ ¬p ∨ ((¬q ∨ q) ∨ p)≡ ¬p ∨ (p ∨ (¬q ∨ q))≡ (¬p ∨ p) ∨ (¬q ∨ q)≡ (p ∨ ¬p) ∨ (q ∨ ¬q)≡ # ∨ #≡ #
¬(p ∧ q) ≡ ¬p ∨ ¬q¬(p ∨ q) ≡ ¬p ∧ ¬q
p → q ≡ ¬p ∨ q
p → q ≡ ¬q → ¬p
p ↔ q ≡ (p → q) ∧ (q → p)
p 𠪪p
p ∧ # ≡ pp ∨ , ≡ p
p ∧ , ≡ ,p ∨ # ≡ #
p ∧ p ≡ pp ∨ p ≡ p
p ∧ q ≡ q ∧ pp ∨ q ≡ q ∨ p
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
p ∧ (p ∨ q) ≡ pp ∨ (p ∧ q) ≡ p
p ∧ ¬p ≡ ,p ∨ ¬p ≡ #
21
Example: show tautology with a truth table and proof
Law of implicationDeMorganAssociativityAssociativityCommutativityAssociativityCommutativity (twice)Negation (twice)Idempotence
DeMorgan’s laws
Law of implication
Contrapositive
Biconditional
Double negation
Identity
Domination
Idempotence
Commutativity
Associativity
Distributivity
Absorption
Negation
(p ∧ q) → (q ∨ p)(p ∧ q) → (q ∨ p) ≡ ¬(p ∧ q) ∨ (q ∨ p)
≡ (¬p ∨ ¬q) ∨ (q ∨ p)≡ ¬p ∨ (¬q ∨ (q ∨ p))≡ ¬p ∨ ((¬q ∨ q) ∨ p)≡ ¬p ∨ (p ∨ (¬q ∨ q))≡ (¬p ∨ p) ∨ (¬q ∨ q)≡ (p ∨ ¬p) ∨ (q ∨ ¬q)≡ # ∨ #≡ #
¬(p ∧ q) ≡ ¬p ∨ ¬q¬(p ∨ q) ≡ ¬p ∧ ¬q
p → q ≡ ¬p ∨ q
p → q ≡ ¬q → ¬p
p ↔ q ≡ (p → q) ∧ (q → p)
p 𠪪p
p ∧ # ≡ pp ∨ , ≡ p
p ∧ , ≡ ,p ∨ # ≡ #
p ∧ p ≡ pp ∨ p ≡ p
p ∧ q ≡ q ∧ pp ∨ q ≡ q ∨ p
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
p ∧ (p ∨ q) ≡ pp ∨ (p ∧ q) ≡ p
p ∧ ¬p ≡ ,p ∨ ¬p ≡ #
21
Truth tables versus proofsProofs are not smaller than truth tables where there are a fewpropositional variables.
But proofs are usually much smaller when there are many variables.
We can extend the proof method to reason about richer logics for whichtruth tables don’t apply.
Theorem provers use a combination of search (truth tables) anddeduction (proofs) to automate equivalence checking.
22
SummaryChecking equivalence has many real-world applications.
Verification, optimization, and more!There are two ways to check equivalence of propositional formulas.
Brute-force: compare their truth tables.Proof-based: apply equivalences to transform one into the other.
23