01a Propositional Logic Handout
01a Propositional Logic Handout
Propositional Logic
WS 14/15
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 1/1
Propositional logic
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 2/1
Propositional logic - Outline
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 3/1
Propositional logic - Outline
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 4/1
Syntax of propositional logic
Abstract syntax of well-formed propositional formulae:
ϕ := a | (¬ϕ) | (ϕ ∧ ϕ)
Syntactic sugar:
⊥ := (a ∧ ¬a)
> := (a ∨ ¬a)
( ϕ1 ∨ ϕ2 ) := ¬((¬ϕ1 ) ∧ (¬ϕ2 ))
( ϕ1 → ϕ2 ) := ((¬ϕ1 ) ∨ ϕ2 )
( ϕ1 ↔ ϕ2
L ) := ((ϕ1 → ϕ2 ) ∧ (ϕ2 → ϕ1 ))
( ϕ1 ϕ2 ) := (ϕ1 ↔ (¬ϕ2 ))
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 5/1
Formulae
binds stronger
¬ ∧ ∨ → ↔
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 6/1
Propositional logic - Outline
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 7/1
Semantics: Assignments
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 8/1
Only the projected assignment matters...
Projection
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 9/1
Semantics I: Truth tables
Q: How many binary operators can we define that have different semantics?
A: 16
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 10 / 1
Semantics I: Example
Q: Does α satisfy ϕ?
A1: Compute with truth table:
a b c b → c a ∨ (b → c)
0 0 0 1 1
0 0 1 1 1
0 1 0 0 0
0 1 1 1 1
1 0 0 1 1
1 0 1 1 1
1 1 0 0 1
1 1 1 1 1
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 11 / 1
Semantics II: Satisfaction relation
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 12 / 1
Semantics II: Example
Q: Does α satisfy ϕ?
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 13 / 1
Semantics III: The algorithmic view
Eval (α, ϕ) {
i f ϕ ≡ a r e t u r n α(a) ;
i f ϕ ≡ (¬ϕ1 ) r e t u r n not Eval (α, ϕ1 ) ;
i f ϕ ≡ (ϕ1 op ϕ2 )
r e t u r n Eval (α, ϕ1 ) [[op]] Eval (α, ϕ2 ) ;
}
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 14 / 1
Semantics III: Example
Hence, α |= ϕ.
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 15 / 1
Satisfying assignments
Intuition: each formula specifies a set of assignments satisfying it.
Remember: V denotes the set of all assignments.
Function sat : PropFormulae → 2V
(a formula → set of its satisfying assignments)
Recursive definition:
sat(a) = {α | α(a) = 1}, a ∈ Prop
sat(¬ϕ1 ) = V \ sat(ϕ1 )
sat(ϕ1 ∧ ϕ2 ) = sat(ϕ1 ) ∩ sat(ϕ2 )
sat(ϕ1 ∨ ϕ2 ) = sat(ϕ1 ) ∪ sat(ϕ2 )
sat(ϕ1 → ϕ2 ) = (V \ sat(ϕ1 )) ∪ sat(ϕ2 )
α |= ϕ iff α ∈ sat(ϕ)
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 16 / 1
Satisfying assignments: Example
sat(a ∨ (b → c)) =
sat(a) ∪ sat(b → c) =
sat(a) ∪ ((V \ sat(b)) ∪ sat(c)) =
{α ∈ V | α(a) = 1}∪
{α ∈ V | α(b) = 0}∪
{α ∈ V | α(c) = 1} =
{α ∈ V | α(a) = 1 or α(b) = 0 or α(c) = 1}
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 17 / 1
Extensions of |=
We define |= ⊆ 2V × PropFormulae by
T |= ϕ iff T ⊆ sat(ϕ)
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 18 / 1
Short summary for propositional logic
Syntax of propositional formulae ϕ ∈ PropFormulae:
ϕ := prop | (¬ϕ) | (ϕ ∧ ϕ)
Semantics:
Assignments α ∈ V :
α : Prop → {0, 1}
α ∈ 2Prop
α ∈ {0, 1}Prop
Satisfaction relation:
|= ⊆ V × PropFormulae , (e.g., α |=ϕ )
|= ⊆ 2V × PropFormulae , (e.g., {α1 , . . . , αn }|=ϕ )
|= ⊆ PropFormulae × PropFormulae, (e.g., ϕ1 |=ϕ2 )
sat : PropFormulae → 2V , (e.g., sat(ϕ) )
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 19 / 1
Propositional logic - Outline
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 20 / 1
Semantic classification of formulae
satisfiable unsatisfiable
valid
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 21 / 1
Some notations
We can write:
|= ϕ when ϕ is valid
|= ¬ϕ when ϕ is unsatisfiable
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 22 / 1
Examples
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 23 / 1
Examples
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 24 / 1
The satisfiability problem for propositional logic
no
Satisfiability
Is ϕ satisfiable? checker
yes
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 26 / 1
Before we solve this problem...
Suppose we can solve the satisfiability problem... how can this help us?
There are numerous problems in the industry that are solved via the
satisfiability problem of propositional logic
Logistics
Planning
Electronic Design Automation industry
Cryptography
...
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 27 / 1
Example 1: Placement of wedding guests
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 28 / 1
Example 1 (continued)
Notation: Aunt = 1, Sister = 2, Father = 3
Left chair = 1, Middle chair = 2, Right chair = 3
Introduce a propositional variable for each pair (person, chair):
xp,c = “person p is sited in chair c” for 1 ≤ p, c ≤ 3
Constraints:
Aunt doesn’t want to sit near Father:
¬x1,1
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 29 / 1
Example 1 (continued)
Each person is placed:
(x1,1 ∨ x1,2 ∨ x1,3 ) ∧ (x2,1 ∨ x2,2 ∨ x2,3 ) ∧ (x3,1 ∨ x3,2 ∨ x3,3 )
3 _
^ 3
xp,c
p=1 c=1
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 30 / 1
Example 2: Assignment of frequencies
n radio stations
For each station assign one of k transmission frequencies, k < n.
E – set of pairs of stations, that are too close to have the same
frequency.
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 31 / 1
Example 2 (continued)
Notation:
xs,f = “station s is assigned frequency f ” for 1 ≤ s ≤ n, 1 ≤ f ≤ k
Constraints:
Every station is assigned at least one frequency:
n k
!
^ _
xs,f
s=1 f =1
Every station is assigned at most one frequency:
n k−1
^ ^ k
^
¬xs,f 1 ∨ ¬xs,f 2
s=1 f 1=1 f 2=f 1+1
n participants
n topics
Set of preferences E ⊆ {1, . . . , n} × {1, . . . , n}
(p, t) ∈ E means: participant p would take topic t
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 33 / 1
Example 3 (continued)
Notation: xp,t = “participant p is assigned topic t”
Constraints:
Each participant is assigned at least one topic:
n n
!
^ _
xp,t
p=1 t=1
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 34 / 1
Example 3 (continued)
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 35 / 1
Propositional logic - Outline
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 36 / 1
Definitions
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 37 / 1
Definitions
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 38 / 1
Negation Normal Form (NNF)
Examples:
ϕ1 = ¬(a ∨ ¬b) is not in NNF
ϕ2 = ¬a ∧ b is in NNF
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 39 / 1
Converting to NNF
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 40 / 1
Disjunctive Normal Form (DNF)
Example:
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 42 / 1
Satisfiability of DNF
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 43 / 1
Conjunctive Normal Form (CNF)
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 44 / 1
Converting to CNF
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 45 / 1
Converting to CNF: Tseitin’s encoding
b c
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 46 / 1
Converting to CNF: Tseitin’s encoding
Need to satisfy: → h1
(h1 ↔ (a → h2 ))∧
(h2 ↔ (b ∧ c))∧
a ∧ h2
(h1 )
b c
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 47 / 1
Converting to CNF: Tseitin’s encoding
Need to satisfy:
(h1 ↔ (a → h2 )) ∧ (h2 ↔ (b ∧ c)) ∧ (h1 )
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 48 / 1
Converting to CNF: Tseitin’s encoding
Let’s go back to
ϕn = (x1 ∧ y1 ) ∨ (x2 ∧ y2 ) ∨ · · · ∨ (xn ∧ yn )
Hence, we have
3n + 1 clauses, instead of 2n .
3n variables rather than 2n.
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 49 / 1
Propositional logic - Outline
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 50 / 1
Two classes of algorithms for validity
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 51 / 1
The satisfiability problem
Inference rules:
Antecedents
(rule name)
Consequents
a→b b→c
(Trans)
a→c
a→b a
(M.P.)
b
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 53 / 1
Axioms
(H1 )
a → (b → a)
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 54 / 1
Proofs
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 55 / 1
Example
Let H be the proof system comprised of the rules Trans and M.P. that
we saw earlier:
a→b b→c
(Trans)
a→c
a→b a
(M.P.)
b
a → b, b → c, c → d , d → e, a `H e
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 56 / 1
Deductive proof: Example
a → b, b → c, c → d , d → e, a `H e
1. a→b premise
2. b→c premise
3. a→c 1, 2, Trans
4. c →d premise
5. d →e premise
6. c →e 4, 5, Trans
7. a→e 3, 6, Trans
8. a premise
9. e 7, 8, M.P.
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 57 / 1
Proof graph
a→b b→c c →d d →e
trans trans
a→c c →e
trans
a→e a
M.P.
e
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 58 / 1
Soundness and completeness
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 59 / 1
Soundness and completeness
Soundness of H : if `H ϕ then |= ϕ
Completeness of H : if |= ϕ then `H ϕ
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 60 / 1
Example: Hilbert axiom system (H)
(H1)
a → (b → a)
(H2)
((a → (b → c)) → ((a → b) → (a → c)))
(H3)
(¬b → ¬a) → (a → b)
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 61 / 1
Soundness and completeness
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 62 / 1
The resolution inference system
Example:
(a ∨ b) (¬a ∨ c)
(b ∨ c)
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 63 / 1
Proof by resolution
(a1 ∨ a3 ) (¬a1 )
(a3 )
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 64 / 1
Resolution
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 65 / 1
Example
(¬a1 ) (a1 ∨ a3 )
a3 ¬a3
()
Satisfiability Checking — Prof. Dr. Erika Ábrahám (RWTH Aachen University) WS 14/15 66 / 1
Soundness and completeness of resolution
Soundness is straightforward. Just prove by truth table that
|= ((ϕ1 ∨ a) ∧ (ϕ2 ∨ ¬a)) → (ϕ1 ∨ ϕ2 ).