ECE473 Lecture 15: Propositional Logic
Jeffrey Mark Siskind
School of Electrical and Computer Engineering
Spring 2017
Siskind (Purdue ECE)
ECE473 Lecture 15: Propositional Logic
Spring 2017
1 / 23
What is a Logic?
A logic defines a:
syntax A set of well formed formulas
I a ‘language’ in a formal sense
I can be specified by a grammar
semantics A ‘meaning’ for each well formed formula
I typically meanings are Boolean truth values
Siskind (Purdue ECE)
ECE473 Lecture 15: Propositional Logic
Spring 2017
2 / 23
Syntax of Propositional Logic
atomic formulas p, q, p1 , p(a), . . .
I given a finite or infinite set of atomic formulas
I p(a) and p(b) are distinct and unrelated
compound formulas ¬Φ, Φ ∧ Ψ, Φ ∨ Ψ, Φ → Ψ, Φ ↔ Ψ
I Φ → Ψ sometimes written as Φ ⊃ Ψ
I Φ ↔ Ψ sometimes written as Φ ≡ Ψ
Siskind (Purdue ECE)
ECE473 Lecture 15: Propositional Logic
Spring 2017
3 / 23
Syntax of Propositional Logic as a Nondeterministic
Scheme Program
(define (an-atomic-formula p) (a-member-of p))
(define (a-compound-formula p)
(either ‘(not ,(a-formula p))
‘(and ,(a-formula p) ,(a-formula p))
‘(or ,(a-formula p) ,(a-formula p))
‘(implies ,(a-formula p) ,(a-formula p))
‘(iff ,(a-formula p) ,(a-formula p))))
(define (a-formula p)
(either (an-atomic-formula p)
(a-compound-formula p)))
Siskind (Purdue ECE)
ECE473 Lecture 15: Propositional Logic
Spring 2017
4 / 23
Semantics of Propositional Logic
An interpretation I is a total map from atomic formulas to truth values.
The meaning or value of Φ under I is given by a valuation function V(Φ, I):
I
V(Φ, I) is I(Φ) when Φ is an atomic formula.
I
V(¬Φ, I) is true if and only if V(Φ, I) is false.
I
V(Φ ∧ Ψ, I) is true if and only if both V(Φ, I) and V(Ψ, I) are true.
I
V(Φ ∨ Ψ, I) is true if and only if either V(Φ, I) or V(Ψ, I) is true.
I
V(Φ → Ψ, I) is true if and only if V(Φ, I) is false or V(Ψ, I) is true.
I
V(Φ ↔ Ψ, I) is true if and only if V(Φ, I) and V(Ψ, I) have the same truth value.
Siskind (Purdue ECE)
ECE473 Lecture 15: Propositional Logic
Spring 2017
5 / 23
Semantics of Propositional Logic as a Nondeterministic
Scheme Program
(define (v phi i)
(if (list? phi)
(case (first phi)
((not) (eq? (v (second phi) i) #f))
((and) (and (eq? (v (second phi) i) #t)
(eq? (v (third phi) i) #t)))
((or) (or (eq? (v (second phi) i) #t)
(eq? (v (third phi) i) #t)))
((implies) (or (eq? (v (second phi) i) #f)
(eq? (v (third phi) i) #t)))
((iff) (eq? (v (second phi) i) (v (third phi) i))))
(if (member phi i) #t #f)))
Siskind (Purdue ECE)
ECE473 Lecture 15: Propositional Logic
Spring 2017
6 / 23
Some Definitions—I
I
I is a model of Σ iff for all Φ ∈ Σ V(Φ, I) is true.
I
Σ is valid (universally valid) iff every I is a model of Σ.
I
Σ is satisfiable (consistent) iff some I is a model of Σ.
I
Σ is unsatisfiable (inconsistent) iff no I is a model of Σ.
I
M(Σ) denotes the set of all models of Σ.
I
Treat Φ as {Φ}.
Siskind (Purdue ECE)
ECE473 Lecture 15: Propositional Logic
Spring 2017
7 / 23
Some Definitions—II
I
A valid formula is called a tautology.
I
An inconsistent formula is called an inconsistency.
I
Σ |= Φ iff M(Σ) ⊆ M(Φ).
Φ and Ψ are equivalent iff M(Φ) = M(Ψ).
I
I
I
Φ → Ψ is equivalent to ¬Φ ∨ Ψ.
Φ1 ∧ · · · ∧ Φn → Ψ is equivalent to ¬Φ1 ∨ · · · ∨ ¬Φn ∨ Ψ.
Siskind (Purdue ECE)
ECE473 Lecture 15: Propositional Logic
Spring 2017
8 / 23
Conjunctive Normal Form (CNF)
literal: An atomic formula or a negated atomic formula
clause: A disjunction of literals
CNF formula: A conjunction of clauses
I
CNF formulas can be represented as sets of sets of literals.
I
Empty clause denotes inconsistency.
I
Empty CNF formula denotes a tautology.
Siskind (Purdue ECE)
ECE473 Lecture 15: Propositional Logic
Spring 2017
9 / 23
Conversion to CNF
1
2
Construct a truth table for Φ.
Take every row for which Φ evaluates to false and construct a clause as follows:
1
2
If the row maps the atomic formula Ψ to true then include ¬Ψ in the clause.
If the row maps the atomic formula Ψ to false then include Ψ in the clause.
Disadvantage: can require an exponential number of clauses.
Siskind (Purdue ECE)
ECE473 Lecture 15: Propositional Logic
Spring 2017
10 / 23
Better Conversion to CNF—I
(Ω ∨ Θ)∧
C ONVERT CNF(Ω, ¬Φ) = (¬Θ ∨ ¬Ω)∧
C ONVERT CNF(Θ, Φ)
(¬Ω ∨ Θ)∧
(¬Ω ∨ Υ)∧
4
(¬Θ
∨
¬Υ
∨
Ω)∧
C ONVERT CNF(Ω, Φ ∧ Ψ) =
C ONVERT CNF(Θ, Φ)∧
C ONVERT CNF(Υ, Ψ)
(Ω ∨ ¬Θ)∧
(Ω ∨ ¬Υ)∧
4
(Θ
∨
Υ
∨
¬Ω)∧
C ONVERT CNF(Ω, Φ ∨ Ψ) =
C ONVERT CNF(Θ, Φ)∧
C ONVERT CNF(Υ, Ψ)
4
Siskind (Purdue ECE)
ECE473 Lecture 15: Propositional Logic
Spring 2017
11 / 23
Better Conversion to CNF—II
4
C ONVERT CNF(Ω, Φ → Ψ) =
4
C ONVERT CNF(Ω, Φ ↔ Ψ) =
Siskind (Purdue ECE)
(Ω ∨ Θ)∧
(Ω ∨ ¬Υ)∧
(¬Θ ∨ Υ ∨ ¬Ω)∧
C ONVERT CNF(Θ, Φ)∧
C ONVERT CNF(Υ, Ψ)
(¬Ω ∨ ¬Θ ∨ Υ)∧
(¬Ω ∨ ¬Υ ∨ Θ)∧
(Ω ∨ ¬Θ ∨ ¬Υ)∧
(Ω ∨ Θ ∨ Υ)∧
C ONVERT CNF(Θ, Φ)∧
C ONVERT CNF(Υ, Ψ)
ECE473 Lecture 15: Propositional Logic
Spring 2017
12 / 23
Better Conversion to CNF—III
4
C ONVERT CNF(¬Φ) =
¬Θ∧
C ONVERT CNF(Θ, Φ)
Θ∧
4 Υ∧
C ONVERT CNF(Φ ∧ Ψ) =
C ONVERT CNF(Θ, Φ)∧
C ONVERT CNF(Υ, Ψ)
(Θ ∨ Υ)∧
4
C ONVERT CNF(Φ ∨ Ψ) = C ONVERT CNF(Θ, Φ)∧
C ONVERT CNF(Υ, Ψ)
Siskind (Purdue ECE)
ECE473 Lecture 15: Propositional Logic
Spring 2017
13 / 23
Better Conversion to CNF—IV
(¬Θ ∨ Υ)∧
C ONVERT CNF(Φ → Ψ) = C ONVERT CNF(Θ, Φ)∧
C ONVERT CNF(Υ, Ψ)
(¬Θ ∨ Υ)∧
(¬Υ ∨ Θ)∧
4
C ONVERT CNF(Φ ↔ Ψ) =
C ONVERT CNF(Θ, Φ)∧
C ONVERT CNF(Υ, Ψ)
4
Siskind (Purdue ECE)
ECE473 Lecture 15: Propositional Logic
Spring 2017
14 / 23
Conversion to CNF as Scheme code
(define (negate literal)
(list (not (first literal)) (second literal)))
(define (clauses p atomic-formulas)
(all-values
(let ((clause (map (lambda (atomic-formula)
(list (a-boolean) atomic-formula))
atomic-formulas)))
(when (apply p (map first clause)) (fail))
(map negate clause))))
Siskind (Purdue ECE)
ECE473 Lecture 15: Propositional Logic
Spring 2017
15 / 23
Disjunctive Normal Form (DNF)
literal: An atomic formula or a negated atomic formula
minterm: A conjunction of literals
DNF formula: A disjunction of minterms
I
DNF formulas can be represented as sets of sets of literals.
I
Empty minterm denotes tautology.
I
Empty DNF formula denotes an inconsistency.
I
Can convert any formula to DNF by analog of the first technique.
I
No analog of the second technique exists.
Siskind (Purdue ECE)
ECE473 Lecture 15: Propositional Logic
Spring 2017
16 / 23
Subsumption and Covering
I
Φ subsumes Ψ (or Ψ covers Φ) if M(Φ) ⊆ M(Ψ).
I
If Φ and Ψ are clauses represented as sets of literals then Φ subsumes Ψ iff Φ ⊆ Ψ.
I
If Φ and Ψ are minterms represented as sets of literals then Φ covers Ψ iff Φ ⊆ Ψ.
I
If a CNF formula contains two clauses Φ and Ψ such that Φ subsumes Ψ then can remove Ψ.
I
If a DNF formula contains two minterms Φ and Ψ such that Φ covers Ψ then can remove Ψ.
I
Can remove tautological clauses that contain Φ and ¬Φ.
I
Can remove inconsistent minterms that contain Φ and ¬Φ.
Siskind (Purdue ECE)
ECE473 Lecture 15: Propositional Logic
Spring 2017
17 / 23
(Prime) Implicates and Implicants
I
If Φ is a clause and Σ |= Φ then Φ is an implicate of Σ.
I
If Φ is an implicate of Σ and no other implicate of Σ subsumes Φ, then Φ is a prime implicate of
Σ.
I
If Φ is a minterm and Σ |= Φ, then Φ is an implicant of Σ.
I
If Φ is an implicant of Σ and no other implicant of Σ covers Φ, then Φ is a prime implicant of Σ.
I
Given a method for computing the set of all implicates or implicants, one can compute the set of
all prime implicates or prime implicants, respectively, simply by removing subsumed clauses or
covered minterms.
I
Furthermore, if one has the set of all implicates or implicants then one can compute the other set
by ‘multiplying out,’ i.e. distributing ∧ over ∨ or vice versa.
Siskind (Purdue ECE)
ECE473 Lecture 15: Propositional Logic
Spring 2017
18 / 23
Motivation for Resolution—I
Σ |= Φ
Σ |= Φ → Ψ
Σ |= Ψ
Σ |= Φ → Ψ
Σ |= Ψ → Υ
Σ |= Φ → Υ
Siskind (Purdue ECE)
ECE473 Lecture 15: Propositional Logic
Spring 2017
19 / 23
Motivation for Resolution—II
Σ |= Φ1 ∧ · · · ∧ Φn → Ψ
Σ |= Ψ ∧ Θ1 ∧ · · · ∧ Θm → Υ
Σ |= Φ1 ∧ · · · ∧ Φn ∧ Θ1 ∧ · · · ∧ Θm → Υ
Σ |= ¬Φ1 ∨ · · · ∨ ¬Φn ∨ Ψ
Σ |= ¬Ψ ∨ ¬Θ1 ∨ · · · ∨ ¬Θm ∨ Υ
Σ |= ¬Φ1 ∨ · · · ∨ ¬Φn ∨ ¬Θ1 ∨ · · · ∨ ¬Θm ∨ Υ
Siskind (Purdue ECE)
ECE473 Lecture 15: Propositional Logic
Spring 2017
20 / 23
Resolution (Robinson 1965)
Σ |= Φ1 ∨ · · · ∨ Φn ∨ Ψ
Σ |= ¬Ψ ∨ Θ1 ∨ · · · ∨ Θm
Σ |= Φ1 ∨ · · · ∨ Φn ∨ Θ1 ∨ · · · ∨ Θm
Siskind (Purdue ECE)
ECE473 Lecture 15: Propositional Logic
Spring 2017
21 / 23
Finding All Prime Implicates
1
Let C be the initial set of clauses.
2
Loop over all c1 ∈ C.
3
Loop over all c2 ∈ C.
4
Loop over all literals l ∈ c1 .
5
If c2 does not contain ¬l, continue with the next literal in step 4.
6
Let c = (c1 \ l) ∪ (c2 \ ¬l).
7
If c contains some literal l0 and its complement, continue with the next literal in step 4.
8
If C already contains some clause that subsumes c, continue with the next literal in step 4.
9
Remove from C any clause subsumed by c.
10
Add c into C.
11
Continue with the next literal in step 4.
12
When finished with the nested loops in steps 2, 3, and 4, if any clause c was added to C by step 10 then repeat step 2. Do this until
you finish a complete pass through steps 2, 3, and 4 without adding any new clauses to C.
Siskind (Purdue ECE)
ECE473 Lecture 15: Propositional Logic
Spring 2017
22 / 23
Conversion to Prime Implicates as Scheme code
(define (clauses p atomic-formulas)
(prime-implicates
(all-values
(let ((clause (map (lambda (atomic-formula)
(list (a-boolean) atomic-formula))
atomic-formulas)))
(when (apply p (map first clause)) (fail))
(map negate clause)))))
Siskind (Purdue ECE)
ECE473 Lecture 15: Propositional Logic
Spring 2017
23 / 23
© Copyright 2026 Paperzz