CM3112 Artificial Intelligence
Propositional logic Inference
Steven Schockaert
SchockaertS1@cardiff.ac.uk
School of Computer Science & Informatics Cardiff University
Entailment
A formula β is entailed by a formula α if every model of α is also a model of β
We write this as α ⊧ β
If β is entailed by α we also say that β is a logical consequence of α
It can be shown that β is entailed by α iff α➝β is a tautology iff α∧¬β is unsatisfiable
If both α ⊧ β and β ⊧ α we say that α and β are equivalent. We write this as α≣β
Entailment: example α = a∨b
β = (a∨c)∧(b∨¬c)
Does it hold that α ⊧ β?
a
b
cα
a∨c
b∨¬c
β
false false false false true true true true
false false true true false false true true
false true false true false true false true
Enumerate all interpretations
Entailment: example
α = a∨b
β = (a∨c)∧(b∨¬c)
Does it hold that α ⊧ β?
a
b
cα
a∨c
b∨¬c
β
false false false false true true true true
false false true true false false true true
false true false true false true false true
false false true true true true true true
false true false true true true true true
true false true true true false true true
false false false true true false true true
Check which interpretations are models of α and of β
KB = {breeze(1, 2) pit(1, 1) ⇥ pit(1, 3) ⇥ pit(2, 2) pit(2, 1) breeze(1, 1),
Knowledgbereebzea(s1e, 2s), ¬breeze(1, 1)} = ¬pit(2, 1)
A knowledge base typically consists of a set of formulas, which is 1 ⇥…⇥ n ⇥x
interpreted as a conjunction of formulas
⇥ ⇥…⇥⇥ ⇥¬x 1m
In practice, available knowledge usually consists of a combination of
‣ Generic knowledge: general beliefs about the world the agent lives in
‣ Factual knowledge: corresponding to observations made by the agent 1 ⇥…⇥ n ⇥⇥1 ⇥…⇥⇥m
generic knowledge: if there is a breeze in a grid cell, there is a pit in one of its adjacent cells
KB = {breeze(1, 2) pit(1, 1) ⇥ pit(1, 3) ⇥ pit(2, 2), …, breeze(1, 2), ¬breeze(1, 1)}
2 = ¬pit(2, 2)
Factual knowledge: where have we encountered a breeze?
⇥1 ⇥…⇥⇥m ⇥¬x
1 ⇥…⇥ n ⇥⇥1 ⇥…⇥⇥m Knowledge bases
KB = {breeze(1, 2) pit(1, 1) ⇥ pit(1, 3) ⇥ pit(2, 2), …, breeze(1, 2), ¬breeze(1, 1)}
1 = ¬pit(2, 1)
Is it safe to go to cell (2,1)?
➡ Check whether KB ⊧ α1
2
1
2
1
1
(a)
KB
2
1
123
α1
2
PIT
123
123
2
1
2
1
1
123
PIT
PIT
123
PIT
PIT
2
1
2
1
PIT
123
PIT
PIT
PIT
PIT
PIT
123
123
PIT
r
r
rr
r
r
r
r
e
e
e
e
e
e
e
e
B
B
B
BB
B
B
B
e
ee
e
e
e
e
e
z
z
z
z
z
z
z
z
e
e
e
e
e
e
e
e
⇥1 ⇥…⇥⇥m ⇥¬x
1 ⇥…⇥ n ⇥⇥1 ⇥…⇥⇥m Knowledge bases
KB = {breeze(1, 2) pit(1, 1) ⇥ pit(1, 3) ⇥ pit(2, 2), …, breeze(1, 2), ¬breeze(1, 1)}
2 = ¬pit(2, 2)
Is it safe to go to cell (2,2)?
1
➡2 Check whether KB ⊧ α2
2 PIT
KB
2 PIT
2
1
PIT
123
2
1 PIT
1 2 3 α1
2
1
2
1
α
123
2
1
123
KB
2
1
123
2
1
2
1
123
2 PIT
123 1 123
2
1
PIT
PIT
123
123
2 PIT
1
PIT
1PIT 1
123 123
(a) 1 (b)
2
PIT
PIT
PIT
PIT
PIT
PIT
PIT
1 PIT 2PITPIT
123 123
PIT
1 2
123 123
PIT
PIT
PIT
r
r
rr
r
r
r
r
r
r
r
r
r
r
r
r
e
e
e
e
e
e
e
e
e
e
e
e
e
e
e
e
B
B
B
BB
B
B
B
B
B
B
BB
B
B
B
e
ee
e
e
e
eee
e
e
e
e
e
e
e
z
z
z
z
z
z
z
z
z
z
z
z
z
z
z
z
e
e
e
e
e
ee
e
e
e
e
e
e
e
e
e
Conjunctive normal form
A literal is an atom or the negation of an atom (e.g. a,¬a, …)
A clause is a disjunction of literals (e.g. a∨¬b∨c)
A formula is in conjunctive normal form (CNF) if it is a
conjunction of clauses, e.g.:
(a_¬b_c)^x^(¬a_y) Every formula is equivalent to a formula in CNF
¬¬ ⌘
¬(↵_ ) ⌘ (¬↵^¬ ) Step 1: rewrite implications
Implication law:
¬(↵^ ) ⌘ (¬↵_¬ ) (a_¬b_c)^x^(¬a_y)
↵_( 1 ^…^ n) ⌘ (↵_ 1)^…^(↵_ n) ↵! ⌘ ¬↵_
↵! ⌘ ¬↵_ ¬(a ! (b ! c)) _ d
¬(a ! (b ! c)) _ d
⌘ ¬(¬a _ (b ! c)) _ d
⌘ ¬(¬a _ (b ! c)) _ d ⌘ ¬(¬a _ ¬b _ c) _ d
⌘ ¬(¬a _ ¬b _ c) _ d ⌘ (¬¬a ^ ¬¬b ^ ¬c) _ d
( a ^ b ^ ⌘ ¬ ( c a ) ^ _ b ^d ¬ c ) _ d
⌘ (a _ d) ^ (b _ d) ^ (¬c _ d) (a_d)^(b_d)^(¬c_d)
¬¬ ⌘
⌘¬¬_¬__
¬(↵_ ) ⌘ (¬↵^¬ ) Step 2: bring negations inside
¬(↵^ ) ⌘ (¬↵_¬ ) (a_¬b_c)^x^(¬a_y)
Laws of De Morgan
↵_( 1 ^…^ n) ⌘ (↵_ 1)^…^(↵_ n) ¬(↵_ ) ⌘ (¬↵^¬ )
↵! ⌘ ¬↵_ ¬(↵^ ) ⌘ (¬↵_¬ )
¬(a ! (b ! c)) _ d
↵! ⌘ ¬↵_
⌘ ¬(¬a _ (b ! c)) _ d
⌘ ¬(¬a _ ¬b _ c) _ d
⌘ (¬¬a ^ ¬¬b ^ ¬c) _ d ¬(a ! (b ! c)) _ d
⌘ (a ^ b ^ ¬c) _ d
⌘ ¬(¬a _ (b ! c)) _ d
⌘ (a _ d) ^ (b _ d) ^ (¬c _ d) ( a b c) d
¬¬ ⌘
¬(↵_ ) ⌘ (¬↵^¬ ) Step 3: remove double negations
¬(↵^ ) ⌘ (¬↵_¬ ) (a_¬b_c)^x^(¬a_y)
Double negation
↵_( 1 ^…^ n) ⌘ (↵_ 1)^…^(↵_ n) ¬¬↵ ⌘ ↵
↵! ⌘ ¬↵_ ¬(a ! (b ! c)) _ d
¬(↵_ ) ⌘ (¬↵^¬ ) ⌘ ¬(¬a _ (b ! c)) _ d
¬(↵^ ) ⌘ (¬↵_¬ ) ⌘ ¬(¬a _ ¬b _ c) _ d
⌘ (¬¬a ^ ¬¬b ^ ¬c) _ d ⌘ (a ^ b ^ ¬c) _ d
↵_( 1 ^…^ n) ⌘ (↵_ 1)^…^(↵_ n) ⌘ (a _ d) ^ (b _ d) ^ (¬c _ d)
¬¬ ⌘ _¬_^^¬_
(a_d)^(b_d)^(¬c_d)
¬(↵_ ) ⌘ (¬↵^¬ ) Step 4: distributivity
¬(↵_ ) ⌘ (¬↵^¬ ) ¬(↵^ ) ⌘ (¬↵_¬ )
¬(↵^ ) ⌘ (¬↵_¬ )
↵_( 1 ^…^ n) ⌘ (↵_ 1)^…^(↵_ n)
↵_( 1 ^…^ n) ⌘ (↵_ 1)^…^(↵_ n) ↵! ⌘ ¬↵_
↵! ⌘ ¬↵_ ¬(a ! (b ! c)) _ d
Distributivity
⌘ ¬(¬a _ (b ! c)) _ d ¬(a ! (b ! c)) _ d
⌘ ¬(¬a _ ¬b _ c) _ d
⌘ ¬(¬a _ (b ! c)) _ d
⌘ (¬¬a ^ ¬¬b ^ ¬c) _ d ⌘ ¬(¬a _ ¬b _ c) _ d
⌘ (a ^ b ^ ¬c) _ d
( a ^⌘ b ( a ^ _ ¬ d c ) ) ^ _ ( b d _ d ) ^ ( ¬ c _ d )