0% found this document useful (0 votes)
6 views17 pages

Prolog

Uploaded by

shubhrajkumar707
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views17 pages

Prolog

Uploaded by

shubhrajkumar707
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Refutation Theorem-proving

Γ├ 
• Goal: to prove a theorem 

• From a set of axioms Γ

• 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

• Any horn clause belongs to one of four


categories:
– The null clause: an empty clause
– A fact: 1 pos lit, and 0 neg lit.
– A rule: 1 pos lit, and at least one neg lit.
– A negated goal: 0 pos lit, at least one neg lit.
Horn Clause Logic
• A fact or unit
– 1 positive literal, 0 negative literal.

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 )

– goal is what you want to prove.


P P1  P2  P3
– cf. P1  P2
Horn Clause Theories
• Propositional horn theories
– Can be decided in polynomial time.

• First-order horn theories


– Only semi-decidable
– In practice, resolution over horn theories runs
much more efficiently than resolution over
general first-order theories.
Resolution on Horn Clauses
• If restricted to horn clauses, some interesting
properties appear.
Resolution on Horn Clauses
P  X 1  X 2    X i P  l1  l2    l j
X 1  X 2    X i  l1  l2    l j

• l1, …, lj : at most one positive literal

• 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 )

ψ' (resolvent) is another negated goal with P removed.


Resolution in Prolog
• fact1: rainy.
• fact2: cold.
• rule1: snowy :- rainy, cold.
(rainy & cold) -> snowy
~(rainy & cold) | snowy
~rainy | ~cold | snowy
• goal: ?- snowy.

• resolve (~snowy, ~rainy | ~cold | snowy)


• resolve (~rainy | ~cold, rainy)
• resolve (~cold, cold)
Backward Chaining
// ψ : negated goal, Γ : a set of facts and rules
bc( ψ , Γ ) {
if ψ  null then succeed;
pick a literal P in ψ ; Order doesn’t matter.

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, …

You might also like