Prolog
Prolog
Γ├
• Goal: to prove a theorem
• Negated goal
Refutation Theorem-proving
• If the empty clause can be derived by applying a series of
resolution, the negated goal is unsatisfiable (contradictory).
• Proof by contradiction Γ
– The initial formula follows from Γ .
• If is a theorem (provable),
– We can prove or deduce it. Γ├
– There is a proof.
– There is a refutation proof.
– The null clause can be derived by resolution.
Gödel’s Incompleteness Theorem
• First-order Logic
x. P( x) y. Q ( y )
• Propositional Logic
– Coupled with a complete search algorithm, the
resolution yields sound and complete algorithm
for deciding the satisfiability.
Horn Clauses
• A clause with at most one positive literal.
P Q R P S T
P
Q
– In Prolog,
hungry.
sunny(rochester).
Horn Clause Logic
• A rule
– 1 positive literal, >= 1 negative literal.
P1 P2 Pn Q
( P1 P2 Pn ) Q
P1 P2 Pn Q
– In Prolog,
goal subgoal1, subgoal2, …, subgoaln
snowy :- rainy, cold.
Horn Clause Logic
• A negated goal
– 0 positive literal, >= 1 negative literal.
P1 P2 Pn
( P1 P2 Pn )
• X 1 X 2 X i l1 l2 l j
– The resolvent is again a horn clause.
Resolution against a Negated Goal
• Negated goal: P Y Y2 Y j
P X 1 X 2 X i P Y Y2 Y j
X 1 X 2 X i Y1 Y2 Y j
• X 1 X 2 X i Y1 Y2 Y j
– Horn clause
– Negated goal (if not null)
– P is removed.
Resolution against a Negated Goal
ψ : a negated goal
Γ : a set of facts and rules
P ψ
C Γ, P C
ψ' := resolve(ψ, C )
choose C Γ where P C ;
ψ' : resolve( ψ , C );
bc( ψ' , Γ )
If bc( ~φ, Γ ) suceeds,
} φ is a consequence of Γ.
Backward Chaining
• Complete for horn clauses
– If Γ├ , there is a backward-chaining proof of
from Γ .
Pure Prolog
• An implementation of the bc algorithm
– Clauses in Г are ordered by the programmer.
• fact1.
• fact2.
• rule1.
– Negative literals in each clause are ordered by the
programmer.
• goal :- subgoal1, subgoal2. (goal | ~subgoal1 | ~subgoal2)
– The “pick” operations picks the first literal in ψ.
• subgoal1, subgoal2
– Search is carried out in depth-first search order.
• subgoal1, subsubgoal1_1, subsubsubgoal1_1_1, …