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

PL Model Checking Efficient PL Model Checking

The document discusses model checking and inference in first-order logic. It covers topics such as Davis-Putnam algorithm for efficient propositional model checking, generalized modus ponens for inference rules in first-order logic, Horn clauses and how they relate to Prolog, and forward and backward chaining for reasoning strategies. An example of forward chaining is provided to demonstrate deriving the goal sentence "sneeze(mary)" from an initial knowledge base.

Uploaded by

andhika
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)
94 views17 pages

PL Model Checking Efficient PL Model Checking

The document discusses model checking and inference in first-order logic. It covers topics such as Davis-Putnam algorithm for efficient propositional model checking, generalized modus ponens for inference rules in first-order logic, Horn clauses and how they relate to Prolog, and forward and backward chaining for reasoning strategies. An example of forward chaining is provided to demonstrate deriving the goal sentence "sneeze(mary)" from an initial knowledge base.

Uploaded by

andhika
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

Overview

• Model checking for PL


• Inference in first-order logic
– Inference rules and generalized modes ponens
– Forward chaining
– Backward chaining
– Resolution
•  Clausal form
Chapter 9 •  Unification
•  Resolution as search
Some material adopted from notes by Andreas
Geyer-Schulz,, Chuck Dyer, and Mary Getoor

PL Model checking Efficient PL model checking


•  Davis-Putnam algorithm (DPLL) is a generate-and-test
• Given KB, does sentence S hold? model checking with:
–  Early termination: short-circuiting of disjunction and conjunction
• Basically generate and test: –  Pure symbol heuristic: Any symbol that only appears negated or
– Generate all the possible models unnegated must be FALSE/TRUE respectively
e.g., in [(A∨¬B), (¬B∨ ¬C), (C∨A)] A & B are pure, C is impure. Make pure symbol
literal true: if there’s a model for S, then making a pure symbol true is also a model
– Consider the models M in which KB is TRUE
–  Unit clause heuristic: Any symbol that appears in a clause by itself
– If ∀M S , then S is provably true can immediately be set to TRUE or FALSE

– If ∀M ¬S, then S is provably false •  WALKSAT: Local search for satisfiability: Pick a symbol
to flip (toggle TRUE/FALSE), either using min-conflicts or
– Otherwise (∃M1 S ∧ ∃M2 ¬S): S is satisfiable choosing randomly
but neither provably true or provably false •  …or you can use any local or global search algorithm!

1
Reminder: Inference rules for FOL
•  Inference rules for propositional logic apply to
FOL as well
Automating FOL
–  Modus Ponens, And-Introduction, And-Elimination, …
•  New (sound) inference rules for use with
inference
quantifiers:
– Universal elimination
– Existential introduction
with Generalized
– Existential elimination
– Generalized Modus Ponens (GMP)
Modus Ponens

Automated inference for FOL Generalized Modus Ponens


•  Automated inference using FOL is harder than PL •  Modus Ponens
–  Variables can potentially take on an infinite number of – P, P=>Q |= Q
possible values from their domains
•  Generalized Modus Ponens (GMP) extends this to
–  Hence there are potentially an infinite number of ways to
apply the Universal Elimination rule of inference
rules in FOL
•  Godel's Completeness Theorem says that FOL •  Combines And-Introduction, Universal-Elimina-
entailment is only semidecidable tion, and Modus Ponens, e.g.
–  If a sentence is true given a set of axioms, there is a – from P(c) and Q(c) and ∀x P(x)∧Q(x) → R(x)
procedure that will determine this derive R(c)
–  If the sentence is false, then there is no guarantee that a •  Need to deal with
procedure will ever determine this — i.e., it may never
halt – more than one condition on left side of rule
– variables

2
Generalized Modus Ponens Our rules are Horn clauses
•  General case: Given •  A Horn clause is a sentence of the form:
–  atomic sentences P1, P2, ..., PN P1(x) ∧ P2(x) ∧ ... ∧ Pn(x) → Q(x)
–  implication sentence (Q1 ∧ Q2 ∧ ... ∧ QN) → R where
•  Q1, ..., QN and R are atomic sentences
–  ≥ 0 Pis and 0 or 1 Q
–  substitution subst(θ, Pi) = subst(θ, Qi) for i=1,...,N
–  the Pis and Q are positive (i.e., non-negated) literals
–  Derive new sentence: subst(θ, R)
•  Substitutions •  Equivalently: P1(x) ∨ P2(x) … ∨ Pn(x) where the
–  subst(θ, α) denotes the result of applying a set of Pi are all atomic and at most one is positive
substitutions defined by θ to the sentence α •  Prolog is based on Horn clauses
–  A substitution list θ = {v1/t1, v2/t2, ..., vn/tn} means to
replace all occurrences of variable symbol vi by term ti •  Horn clauses represent a subset of the set of
–  Substitutions made in left-to-right order in the list sentences representable in FOL
–  subst({x/Cheese, y/Mickey}, eats(y,x)) =
eats(Mickey, Cheese)

Horn clauses II Horn clauses III


•  Special cases •  Where are the quantifiers?
–  Typical rule: P1 ∧ P2 ∧ … Pn → Q –  Variables appearing in conclusion are universally
–  Constraint: P1 ∧ P2 ∧ … Pn → false quantified
–  A fact: true → Q –  Variables appearing only in premises are existentially
quantified
•  These are not Horn clauses:
•  Example: grandparent relation
– p(a) ∨ q(a)
– parent(P1, X) ∧ parent(X, P2) → grandParent(P1, P2)
– (P ∧ Q) → (R ∨ S) – ∀ P1,P2 ∃ PX parent(P1,X) ∧ parent(X, P2) →
•  Note: can’t assert or conclude disjunctions, no grandParent(P1, P2)
negation – Prolog: grandParent(P1,P2) :- parent(P1,X), parent(X,P2)
•  No wonder reasoning over Horn clauses is easier

3
Forward & Backward Reasoning Forward chaining
•  We usually talk about two reasoning strategies:
Forward and backward ‘chaining’ •  Proofs start with the given axioms/premises in
•  Both are equally powerful KB, deriving new sentences using GMP until
the goal/query sentence is derived
•  You can also have a mixed strategy
•  This defines a forward-chaining inference
procedure because it moves “forward” from the
KB to the goal [eventually]
•  Inference using GMP is sound and complete
for KBs containing only Horn clauses

Forward chaining algorithm Forward chaining example


•  KB:
–  allergies(X) → sneeze(X)
–  cat(Y) ∧ allergicToCats(X) → allergies(X)
–  cat(felix)
–  allergicToCats(mary)
•  Goal:
–  sneeze(mary)

4
Backward chaining Backward chaining algorithm
•  Backward-chaining deduction using GMP is also
complete for KBs containing only Horn clauses
•  Proofs start with the goal query, find rules with that
conclusion, and then prove each of the antecedents
in the implication
•  Keep going until you reach premises
•  Avoid loops: check if new subgoal is already on
the goal stack
•  Avoid repeated work: check if new subgoal
–  Has already been proved true
–  Has already failed

Backward chaining example Forward vs. backward chaining

•  KB: • FC is data-driven


–  allergies(X) → sneeze(X) – Automatic, unconscious processing
– E.g., object recognition, routine decisions
–  cat(Y) ∧ allergicToCats(X) → allergies(X)
– May do lots of work that is irrelevant to the goal
–  cat(felix)
– Efficient when you want to compute all conclusions
–  allergicToCats(mary)
• BC is goal-driven, better for problem-solving
•  Goal: – Where are my keys? How do I get to my next
–  sneeze(mary) class?
– Complexity of BC can be much less than linear in
the size of the KB
– Efficient when you want one or a few decisions

5
Mixed strategy Completeness of GMP
•  Many practical reasoning systems do both forward •  GMP (using forward or backward chaining) is
and backward chaining complete for KBs that contain only Horn clauses
•  The way you encode a rule determines how it is •  not complete for simple KBs with non-Horn clauses
used, as in •  The following entail that S(A) is true:
% this is a forward chaining rule 1. (∀x) P(x) → Q(x)
spouse(X,Y) => spouse(Y,X). 2. (∀x) ¬P(x) → R(x)
% this is a backward chaining rule 3. (∀x) Q(x) → S(x)
wife(X,Y) <= spouse(X,Y), female(X). 4. (∀x) R(x) → S(x)
•  Given a model of the rules you have and the kind •  If we want to conclude S(A), with GMP we cannot,
of reason you need to do, it’s possible to decide since the second one is not a Horn clause
which to encode as FC and which as BC rules. •  It is equivalent to P(x) ∨ R(x)

How about in Prolog?


•  Let’s try encoding this in Prolog
1. q(X) :- p(X). 1.  (∀x) P(x) → Q(x)
Automating
2.  (∀x) ¬P(x) → R(x)

FOL Inference
2. r(X) :- neg(p(X)).
3.  (∀x) Q(x) → S(x)
3. s(X) :- q(X).
4.  (∀x) R(x) → S(x)
4. s(X) :- r(X).
–  We should not use \+ or not (in SWI) for negation
since it means “negation as failure”
–  Prolog explores possible proofs independently
with Resolution
–  It can’t take a larger view and realize that one
branch must be true since p(x) ∨ ~p(x) is always true

6
Resolution
Resolution covers many cases
•  Resolution is a sound and complete inference
procedure for unrestricted FOL •  Modes Ponens
•  Reminder: Resolution rule for propositional logic: –  from P and P → Q derive Q
–  P1 ∨ P2 ∨ ... ∨ Pn –  from P and ¬ P ∨ Q derive Q
–  ¬P1 ∨ Q2 ∨ ... ∨ Qm •  Chaining
–  Resolvent: P2 ∨ ... ∨ Pn ∨ Q2 ∨ ... ∨ Qm –  from P → Q and Q → R derive P → R
•  We’ll need to extend this to handle –  from (¬ P ∨ Q) and (¬ Q ∨ R) derive ¬ P ∨ R
quantifiers and variables •  Contradiction detection
–  from P and ¬ P derive false
–  from P and ¬ P derive the empty clause (=false)

Resolution in first-order logic


A resolution proof tree
• Given sentences in conjunctive normal form:
–  P1 ∨ ... ∨ Pn and Q1 ∨ ... ∨ Qm
– Pi and Qi are literals, i.e., positive or negated predicate
symbol with its terms
• if Pj and ¬Qk unify with substitution list θ, then derive
the resolvent sentence:
subst(θ, P1∨…∨Pj-1∨Pj+1…Pn∨ Q1∨…Qk-1∨Qk+1∨…∨Qm)
• Example
– from clause P(x, f(a)) ∨ P(x, f(y)) ∨ Q(y)
– and clause ¬P(z, f(a)) ∨ ¬Q(z)
– derive resolvent P(z, f(y)) ∨ Q(y) ∨ ¬Q(z)
– Using θ = {x/z}

7
A resolution proof tree Resolution refutation
~P(w) v Q(w) ~Q(y) v S(y)
•  Given a consistent set of axioms KB and goal sentence Q,
show that KB |= Q
~True v P(x) v R(x) •  Proof by contradiction: Add ¬Q to KB and try to prove
P(x) v R(x) false, i.e.:
(KB |- Q) ↔ (KB ∧ ¬Q |- False)
•  Resolution is refutation complete: it can establish that a
~P(w) v S(w)
~R(w) v S(w)
given sentence Q is entailed by KB, but can’t (in general)
generate all logical consequences of a set of sentences
•  Also, it cannot be used to prove that Q is not entailed by KB
•  Resolution won’t always give an answer since entailment is
S(x) v R(x)
only semi-decidable
–  And you can’t just run two proofs in parallel, one trying to prove Q and
the other trying to prove ¬Q, since KB might not entail either one
S(A)

Resolution example Refutation resolution proof tree


•  KB:
¬allergies(w) v sneeze(w) ¬cat(y) v ¬allergicToCats(z) ∨ allergies(z)
–  allergies(X) → sneeze(X)
w/z
–  cat(Y) ∧ allergicToCats(X) → allergies(X)
¬cat(y) v sneeze(z) ∨ ¬allergicToCats(z) cat(felix)
–  cat(felix)
y/felix
–  allergicToCats(mary)
sneeze(z) v ¬allergicToCats(z) allergicToCats(mary)
•  Goal: z/mary
–  sneeze(mary) sneeze(mary) ¬sneeze(mary)

Notation
old/new false

negated query

8
questions to be answered
•  How to convert FOL sentences to conjunctive normal
form (a.k.a. CNF, clause form): normalization and
skolemization
Converting
•  How to unify two argument lists, i.e., how to find their
most general unifier (mgu) q: unification
•  How to determine which two clauses in KB should be
to CNF
resolved next (among all resolvable pairs of clauses) :
resolution (search) strategy

Converting sentences to clausal form


Converting sentences to CNF Skolem constants and functions
1. Eliminate all ↔ connectives
5. Eliminate existential quantification by introducing Skolem
(P ↔ Q) ⇒ ((P → Q) ^ (Q → P)) constants/functions
2. Eliminate all → connectives (∃x)P(x) ⇒ P(C)
(P → Q) ⇒ (¬P ∨ Q) C is a Skolem constant (a brand-new constant symbol that is not
used in any other sentence)
3. Reduce the scope of each negation symbol to a single predicate
(∀x)(∃y)P(x,y) ⇒ (∀x)P(x, f(x))
¬¬P ⇒ P since ∃ is within scope of a universally quantified variable, use a
¬(P ∨ Q) ⇒ ¬P ∧ ¬Q Skolem function f to construct a new value that depends on the
universally quantified variable
¬(P ∧ Q) ⇒ ¬P ∨ ¬Q
f must be a brand-new function name not occurring in any other
¬(∀x)P ⇒ (∃x)¬P sentence in the KB
¬(∃x)P ⇒ (∀x)¬P E.g., (∀x)(∃y)loves(x,y) ⇒ (∀x)loves(x,f(x))
4. Standardize variables: rename all variables so that each In this case, f(x) specifies the person that x loves
quantifier has its own unique variable name a better name might be oneWhoIsLovedBy(x)

9
Converting sentences to clausal form An example
(∀x)(P(x) → ((∀y)(P(y) → P(f(x,y))) ∧ ¬(∀y)(Q(x,y) → P(y))))
6. Remove universal quantifiers by (1) moving them all to the
2. Eliminate →
left end; (2) making the scope of each the entire sentence;
and (3) dropping the “prefix” part (∀x)(¬P(x) ∨ ((∀y)(¬P(y) ∨ P(f(x,y))) ∧ ¬(∀y)(¬Q(x,y) ∨ P(y))))
Ex: (∀x)P(x) ⇒ P(x) 3. Reduce scope of negation
(∀x)(¬P(x) ∨ ((∀y)(¬P(y) ∨ P(f(x,y))) ∧(∃y)(Q(x,y) ∧ ¬P(y))))
7. Put into conjunctive normal form (conjunction of
disjunctions) using distributive and associative laws 4. Standardize variables
(P ∧ Q) ∨ R ⇒ (P ∨ R) ∧ (Q ∨ R) (∀x)(¬P(x) ∨ ((∀y)(¬P(y) ∨ P(f(x,y))) ∧(∃z)(Q(x,z) ∧ ¬P(z))))
5. Eliminate existential quantification
(P ∨ Q) ∨ R ⇒ (P ∨ Q ∨ R)
(∀x)(¬P(x) ∨((∀y)(¬P(y) ∨ P(f(x,y))) ∧(Q(x,g(x)) ∧ ¬P(g(x)))))
8. Split conjuncts into separate clauses
6. Drop universal quantification symbols
9. Standardize variables so each clause contains only variable
names that do not occur in any other clause (¬P(x) ∨ ((¬P(y) ∨ P(f(x,y))) ∧(Q(x,g(x)) ∧ ¬P(g(x)))))

Example
7. Convert to conjunction of disjunctions
(¬P(x) ∨ ¬P(y) ∨ P(f(x,y))) ∧ (¬P(x) ∨ Q(x,g(x))) ∧

Unification
(¬P(x) ∨ ¬P(g(x)))
8. Create separate clauses
¬P(x) ∨ ¬P(y) ∨ P(f(x,y))
¬P(x) ∨ Q(x,g(x))
¬P(x) ∨ ¬P(g(x))
9. Standardize variables
¬P(x) ∨ ¬P(y) ∨ P(f(x,y))
¬P(z) ∨ Q(z,g(z))
¬P(w) ∨ ¬P(g(w))

10
Unification Unification algorithm
•  Unification is a “pattern-matching” procedure procedure unify(p, q, θ)
– Takes two atomic sentences, called literals, as input Scan p and q left-to-right and find the first corresponding
terms where p and q “disagree” (i.e., p and q not equal)
– Returns “Failure” if they do not match and a
If there is no disagreement, return θ (success!)
substitution list, θ, if they do
Let r and s be the terms in p and q, respectively,
•  That is, unify(p,q) = θ means subst(θ, p) = subst(θ, q) for where disagreement first occurs
two atomic sentences, p and q If variable(r) then {
•  θ is called the most general unifier (mgu) Let θ = union(θ, {r/s})
•  All variables in the given two literals are implicitly Return unify(subst(θ, p), subst(θ, q), θ)
} else if variable(s) then {
universally quantified
Let θ = union(θ, {s/r})
•  To make literals match, replace (universally quantified) Return unify(subst(θ, p), subst(θ, q), θ)
variables by terms } else return “Failure”
end

Unification: Remarks Unification examples


•  Unify is a linear-time algorithm that returns the •  Example:
most general unifier (mgu), i.e., the shortest-length –  parents(x, father(x), mother(Bill))
–  parents(Bill, father(Bill), y)
substitution list that makes the two literals match
–  {x/Bill,y/mother(Bill)} yields parents(Bill,father(Bill), mother(Bill))
•  In general, there isn’t a unique minimum-length •  Example:
substitution list, but unify returns one of minimum –  parents(x, father(x), mother(Bill))
length –  parents(Bill, father(y), z)
–  {x/Bill,y/Bill,z/mother(Bill)} yields parents(Bill,father(Bill), mother(Bill))
•  Common constraint: A variable can never be
replaced by a term containing that variable •  Example:
–  parents(x, father(x), mother(Jane))
Example: x/f(x) is illegal.
–  parents(Bill, father(y), mother(y))
–  This “occurs check” should be done in the above pseudo- –  Failure
code before making the recursive calls

11
Practice example
Did Curiosity kill the cat

Resolution
•  Jack owns a dog
•  Every dog owner is an animal lover
•  No animal lover kills an animal
•  Either Jack or Curiosity killed the cat, who is named Tuna.

example
•  Did Curiosity kill the cat?

∃x Dog(x) ∧ Owns(Jack,x)
∀x (∃y) Dog(y) ∧ Owns(x, y) →
Practice example AnimalLover(x)
∀x AnimalLover(x) → (∀y Animal(y) →
Did Curiosity kill the cat • Convert to clause form ¬Kills(x,y))
Kills(Jack,Tuna) ∨ Kills(Curiosity,Tuna)
Cat(Tuna)
•  Jack owns a dog. Every dog owner is an animal lover. No A1. (Dog(D)) ∀x Cat(x) → Animal(x)
animal lover kills an animal. Either Jack or Curiosity killed Kills(Curiosity, Tuna)
the cat, who is named Tuna. Did Curiosity kill the cat? A2. (Owns(Jack,D))
•  These can be represented as follows: B. (¬Dog(y), ¬Owns(x, y), AnimalLover(x))
A. (∃x) Dog(x) ∧ Owns(Jack,x) C. (¬AnimalLover(a), ¬Animal(b), ¬Kills(a,b))
B. (∀x) ((∃y) Dog(y) ∧ Owns(x, y)) → AnimalLover(x) D. (Kills(Jack,Tuna), Kills(Curiosity,Tuna))
C. (∀x) AnimalLover(x) → ((∀y) Animal(y) → ¬Kills(x,y))
E. Cat(Tuna)
D. Kills(Jack,Tuna) ∨ Kills(Curiosity,Tuna)
E. Cat(Tuna) F. (¬Cat(z), Animal(z))
F. (∀x) Cat(x) → Animal(x) GOAL • Add the negation of query:
G. Kills(Curiosity, Tuna) ¬G: ¬Kills(Curiosity, Tuna)

12
The proof tree
The resolution refutation proof
¬G D
R1: ¬G, D, {} (Kills(Jack, Tuna)) {}

R2: R1, C, {a/Jack, b/Tuna} (~AnimalLover(Jack), R1: K(J,T) C


{a/J,b/T}
~Animal(Tuna))
R2: ¬AL(J) ∨ ¬A(T) B
R3: R2, B, {x/Jack} (~Dog(y), ~Owns(Jack, y),
{x/J}
~Animal(Tuna))
R3: ¬D(y) ∨ ¬O(J,y) ∨ ¬A(T) A1
R4: R3, A1, {y/D} (~Owns(Jack, D),
{y/D}
~Animal(Tuna))
R4: ¬O(J,D), ¬A(T) A2
R5: R4, A2, {} (~Animal(Tuna))
{}
R6: R5, F, {z/Tuna} (~Cat(Tuna)) R5: ¬A(T) F
R7: R6, E, {} FALSE
{z/T}
R6: ¬C(T) E
{}
R7: FALSE

Resolution Resolution TP as search


•  Resolution can be thought of as the bottom-up
construction of a search tree, where the leaves are the

search
clauses produced by KB and the negation of the goal
•  When a pair of clauses generates a new resolvent
clause, add a new node to the tree with arcs directed
from the resolvent to the two parent clauses

strategies
•  Resolution succeeds when a node containing the False
clause is produced, becoming the root node of the tree
•  A strategy is complete if its use guarantees that the
empty clause (i.e., false) can be derived whenever it is
entailed

13
Strategies Example
•  There are a number of general (domain-independent) 1.  Battery-OK ∧ Bulbs-OK → Headlights-Work
strategies that are useful in controlling a resolution 2.  Battery-OK ∧ Starter-OK → Empty-Gas-Tank ∨ Engine-Starts
theorem prover
3.  Engine-Starts → Flat-Tire ∨ Car-OK
•  We’ll briefly look at the following:
4.  Headlights-Work
– Breadth-first
5.  Battery-OK
– Length heuristics
6.  Starter-OK
– Set of support
7.  ¬Empty-Gas-Tank
– Input resolution
8.  ¬Car-OK
– Subsumption
9.  Goal: Flat-Tire ?
– Ordered resolution

Example Breadth-first search


•  Level 0 clauses are the original axioms and the negation of
1.  ¬Battery-OK ∨ ¬Bulbs-OK ∨ Headlights-Work the goal
2.  ¬Battery-OK ∨ ¬Starter-OK ∨ Empty-Gas-Tank ∨ Engine-Starts •  Level k clauses are the resolvents computed from two
3.  ¬Engine-Starts ∨ Flat-Tire ∨ Car-OK clauses, one of which must be from level k-1 and the other
from any earlier level
4.  Headlights-Work
•  Compute all possible level 1 clauses, then all possible level
5.  Battery-OK 2 clauses, etc.
6.  Starter-OK •  Complete, but very inefficient
7.  ¬Empty-Gas-Tank
8.  ¬Car-OK
9.  ¬Flat-Tire negated goal

14
Length heuristics
1.  ¬Battery-OK ∨ ¬Bulbs-OK ∨ Headlights-Work
2.  ¬Battery-OK ∨ ¬Starter-OK ∨ Empty-Gas-Tank ∨ Engine-Starts
•  Shortest-clause heuristic:
3.  ¬Engine-Starts ∨ Flat-Tire ∨ Car-OK Generate a clause with the fewest literals first
4.  Headlights-Work
5.  Battery-OK
•  Unit resolution:
6.  Starter-OK Prefer resolution steps in which at least one parent
7.  ¬Empty-Gas-Tank clause is a “unit clause,” i.e., a clause containing a
8.  ¬Car-OK single literal
9.  ¬Flat-Tire
1,4 10.  ¬Battery-OK ∨ ¬Bulbs-OK – Not complete in general, but complete for Horn
1,5 11.  ¬Bulbs-OK ∨ Headlights-Work clause KBs
2,3 12.  ¬Battery-OK ∨ ¬Starter-OK ∨ Empty-Gas-Tank ∨ Flat-Tire ∨ Car-OK
2,5 13.  ¬Starter-OK ∨ Empty-Gas-Tank ∨ Engine-Starts
2,6 14.  ¬Battery-OK ∨ Empty-Gas-Tank ∨ Engine-Starts
2,7 15.  ¬Battery-OK ¬ Starter-OK ∨ Engine-Starts
16.  … [and we’re still only at Level 1!]

Set of support
1.  ¬Battery-OK ∨ ¬Bulbs-OK ∨ Headlights-Work
2.  ¬Battery-OK ∨ ¬Starter-OK ∨ Empty-Gas-Tank ∨ Engine-Starts
•  At least one parent clause must be the negation of
3.  ¬Engine-Starts ∨ Flat-Tire ∨ Car-OK the goal or a “descendant” of such a goal clause
4.  Headlights-Work (i.e., derived from a goal clause)
5.  Battery-OK
6.  Starter-OK •  When there’s a choice, take the most recent
7.  ¬Empty-Gas-Tank descendant
8.  ¬Car-OK
9.  ¬Flat-Tire •  Complete, assuming all possible set-of-support
1,5 10.  ¬Bulbs-OK ∨ Headlights-Work clauses are derived
2,5 11.  ¬Starter-OK ∨ Empty-Gas-Tank ∨ Engine-Starts
12.  ¬Battery-OK ∨ Empty-Gas-Tank ∨ Engine-Starts
•  Gives a goal-directed character to the search (e.g.,
2,6
2,7 13.  ¬Battery-OK ¬ Starter-OK ∨ Engine-Starts like backward chaining)
3,8 14.  ¬Engine-Starts ∨ Flat-Tire
3,9 15.  ¬Engine-Starts ¬ Car-OK
16.  … [this doesn’t seem to be headed anywhere either!]

15
1.  ¬Battery-OK ∨ ¬Bulbs-OK ∨ Headlights-Work 1.  ¬Battery-OK ∨ ¬Bulbs-OK ∨ Headlights-Work
2.  ¬Battery-OK ∨ ¬Starter-OK ∨ Empty-Gas-Tank ∨ Engine-Starts 2.  ¬Battery-OK ∨ ¬Starter-OK ∨ Empty-Gas-Tank ∨ Engine-Starts
3.  ¬Engine-Starts ∨ Flat-Tire ∨ Car-OK 3.  ¬Engine-Starts ∨ Flat-Tire ∨ Car-OK
4.  Headlights-Work 4.  Headlights-Work
5.  Battery-OK 5.  Battery-OK
6.  Starter-OK 6.  Starter-OK
7.  ¬Empty-Gas-Tank 7.  ¬Empty-Gas-Tank
8.  ¬Car-OK 8.  ¬Car-OK
9.  ¬Flat-Tire 9.  ¬Flat-Tire
9,3 10.  ¬Engine-Starts ∨ Car-OK 9,3 10.  ¬Engine-Starts ∨ Car-OK
10,2 11.  ¬Battery-OK ∨ ¬Starter-OK ∨ Empty-Gas-Tank ∨ Car-OK 10,8 11.  ¬Engine-Starts
10,8 12.  ¬Engine-Starts 11,2 12.  ¬Battery-OK ∨ ¬Starter-OK ∨ Empty-Gas-Tank
11,5 13.  ¬Starter-OK ∨ Empty-Gas-Tank ∨ Car-OK 12,5 13.  ¬Starter-OK ∨ Empty-Gas-Tank
11,6 14.  ¬Battery-OK ∨ Empty-Gas-Tank ∨ Car-OK 13,6 14.  Empty-Gas-Tank
11,7 15.  ¬Battery-OK ∨ ¬Starter-OK ∨ Car-OK 14,7 15.  FALSE
16.  … [a bit more focused, but we still seem to be wandering] [Hooray! Now that’s more like it!]

Simplification heuristics
•  Subsumption:
1.  ¬Battery-OK ∨ ¬Bulbs-OK ∨ Headlights-Work
Eliminate sentences that are subsumed by (more 2.  ¬Battery-OK ∨ ¬Starter-OK ∨ Empty-Gas-Tank ∨ Engine-Starts
specific than) an existing sentence to keep KB small 3.  ¬Engine-Starts ∨ Flat-Tire ∨ Car-OK
4.  Headlights-Work
–  If P(x) is already in the KB, adding P(A) makes no sense – 5.  Battery-OK
P(x) is a superset of P(A) 6.  Starter-OK
–  Likewise adding P(A) ∨ Q(B) would add nothing to the KB 7.  ¬Empty-Gas-Tank
8.  ¬Car-OK
•  Tautology: 9.  ¬Flat-Tire

Remove any clause containing two complementary


literals (tautology)
•  Pure symbol:
If a symbol always appears with the same “sign,”
remove all the clauses that contain it

16
Input resolution Ordered resolution
•  Search for resolvable sentences in order (left to
•  At least one parent must be one of the input right)
sentences (i.e., either a sentence in the original KB
•  This is how Prolog operates
or the negation of the goal)
•  Resolve the first element in the sentence first
•  Not complete in general, but complete for Horn
clause KBs •  This forces the user to define what is important in
generating the “code”
•  Linear resolution
–  Extension of input resolution
•  The way the sentences are written controls the
–  One of the parent sentences must be an input sentence or
resolution
an ancestor of the other sentence
–  Complete

Prolog: logic programming language


based on Horn clauses Summary
•  Resolution refutation •  Logical agents apply inference to a KB to derive
•  Control strategy: goal-directed and depth-first new information and make decisions
– always start from the goal clause •  Basic concepts of logic:
– always use new resolvent as one of parent clauses for resolution
–  Syntax: formal structure of sentences
–  Semantics: truth of sentences wrt models
– backtracking when the current thread fails
–  Entailment: necessary truth of one sentence given
– complete for Horn clause KB another
•  Supports answer extraction (can request single or all answers) –  Inference: deriving sentences from other sentences
•  Orders clauses & literals within a clause to resolve non- –  Soundness: derivations produce only entailed sentences
determinism –  Completeness: derivations can produce all entailed
sentences
– Q(a) may match both Q(x) <= P(x) and Q(y) <= R(y)
– A (sub)goal clause may contain >1 literals, i.e., <= P1(a), P2(a)
•  FC and BC are linear time, complete for Horn
clauses
•  Use “closed world” assumption (negation as failure)
•  Resolution is a sound and complete inference
– If it fails to derive P(a), then assume ~P(a) method for propositional and first-order logic

17

You might also like