Inference in Fol 2
Inference in Fol 2
Lecture 8
Inference in First Order Logic
8-12-2022
Outline
Definite clause and Horn clauses.
Generalized Modus Ponens.
Forward chaining.
Backward chaining.
Resolution in first order logic
Conversion to CNF
Skolemization
Definite clause and Horn clause
Definite clause: disjunction of literals with exactly
one positive literal
P ∨¬ Q (Q P)
𝑃1 𝑃2 … 𝑃𝑛 Q
Q
¬ Q
Example
The following are not Horn clauses:
P∨R (two positive literals)
C ⟹ (A ∨ B) (two positive literals)
𝛼 ⟹ 𝛽, 𝛼
𝛽
Example,
α Adam study hard
α⇒β if Adam study hard, Adam will pass
----------
β Adam will pass
Generalized Modus Ponens (GMP)
𝑃′1 , 𝑃′2 , … , 𝑃′ 𝑛 , 𝑃1 𝑃2 … 𝑃𝑛 ⇒ 𝑄
𝑄θ
θ is a substitution
where Pi'θ = Pi θ for all i : 1, …, n
𝑃 𝑥 , 𝑄 𝐴 , 𝑄 𝑦 𝑃 𝐵 ⇒ 𝑅(𝑥,𝑦)
Example 1:
𝑅(𝐵, 𝐴)
θ = { x / B, y/ A}
Generalized Modus Ponens (GMP)
𝑃′1 , 𝑃′2 , … , 𝑃′ 𝑛 , 𝑃1 𝑃2 … 𝑃𝑛 ⇒ 𝑄
𝑄θ where Pi'θ = Pi θ for all i : 1, …, n
Example 2:
𝑃1 𝑖𝑠 𝐾𝑖𝑛𝑔 𝑥 𝑃2 is Greedy(x)
𝑃′1 𝑃′2
𝑲𝒊𝒏𝒈 𝑱𝒐𝒉𝒏 , 𝑮𝒓𝒆𝒆𝒅𝒚 𝒚 , (𝑲𝒊𝒏𝒈 𝒙 ∧ 𝑮𝒓𝒆𝒆𝒅𝒚(𝒙) ⟹ 𝑬𝒗𝒊𝒍 (𝒙)
Q is Evil(x)
𝑬𝒗𝒊𝒍 𝑱𝒐𝒉𝒏
Qθ is Evil (John)
rule4
rule 3 rule 5
Forward chaining proof tree for
Example 1
American(x) Weapon(y) Sells(x, y, z) Hostile(z) Criminal(x) 1
rule 1
Properties of forward chaining
Sound and complete for first-order definite clauses
American(West) Fact 6
Backward chaining for Example 1
Missile(M1) Fact 2
Backward chaining for Example 1
Father(Murad, Basem)
Father(Basem, Adam)
Mother(Samia, Basem)
The following family rules can be used:
GrandParent(Murad, Adam)
Using rule 3 with substitution
{x2/Murad, y2/ Basem, z/Adam}
GrandParent(Murad, Adam)
Using rule 3 with substitution
{x2/Murad, y2/ Basem, z/Adam}
GrandParent(Murad, Adam)
And then use rule 3 to get 2 subgoals:
Parent(Murad, y2) Parent (y2, Adam)
Using rule 1:
Father(Murad, y2) Father(y2, Adam)
The 2 facts are true using the substitution {y2/Bassem}:
Father(Murad, Basem) Father(Basem, Adam)
Father(x, y) ⟹ Parent(x, y) rule 1
Parent(x2, y2) Parent (y2, z) ⟹ Grandparent(x2, z) rule 3
Example 2 (cont.)
In the backward chaining, we start with the goal:
Write the
substitution used GrandParent(Murad, Adam)
in each step
(l1 ··· li-1 li+1 ··· lk m1 ··· mj-1 mj+1 ··· mn)θ
where Unify(li, mj) = θ, i.e., θ li = θ mj
Example,
Rich(x) Unhappy(x)
Rich(Adam)
, θ = {x/Adem}
Unhappy(Adem)
Resolution in FOL (cont.)
Full first-order version:
l1 ··· lk, m1 ··· mn
(l1 ··· li-1 li+1 ··· lk m1 ··· mj-1 mj+1 ··· mn)θ
where Unify(li, mj) = θ.