Horn clauses and unification
This presentation is the property of its rightful owner.
Sponsored Links
1 / 13

Horn Clauses and Unification PowerPoint PPT Presentation


  • 76 Views
  • Uploaded on
  • Presentation posted in: General

Horn Clauses and Unification. Propositional Logic Clauses Resolution Predicate Logic Horn Clauses Unification Resolution of Horn Clauses. Propositional Logic. “If the butler had a motive and the butler was alone with the victim then the butler is guilty.” Define our atomic formulas:

Download Presentation

Horn Clauses and Unification

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Horn clauses and unification

Horn Clauses and Unification

Propositional Logic

Clauses

Resolution

Predicate Logic

Horn Clauses

Unification

Resolution of Horn Clauses

CSE 341 -- S. Tanimoto Horn Clauses and Unification


Propositional logic

Propositional Logic

“If the butler had a motive and the butler was alone with the victim then the butler is guilty.”

Define our atomic formulas:

P: The butler had a motive.

Q: The butler was alone.

R: The butler is guilty.

Express the compound formula:

(P & Q) -> R a typeable version of (P  Q)  R

CSE 341 -- S. Tanimoto Horn Clauses and Unification


Clause form

Clause Form

Any boolean formula can be put into conjunctive normal form (CNF). From there, it’s easy to get “clause form.” Automatic inference using resolution requires statements be in clause form.

If not Y then X and not Z.

Y or (X & not Z)

(Y or X & (Y or not Z)

(X V Y) & (Y V ~Z)

clauses: (X V Y), (Y V ~Z)

X, Y, and ~Z are called literals. (A literal is a variable or a negated variable.)

Each clause is a disjunction of literals.

A formula in CNF is a conjunction of clauses.

For our example with the butler, we get the following clause:

~ P V ~ Q V R

CSE 341 -- S. Tanimoto Horn Clauses and Unification


Resolution

Resolution

Resolution is a way to make a new clause from two existing clauses. If the two original clauses were true, then the new one is, too.

The two existing clauses must be compatible, in order to use resolution. There must exist some literal in one clause that occurs negated in the other clause.

Example: Clause 1: A V ~ B V C

Clause 2: B V D

These are compatible, because the literal ~B in Clause 1 occurs negated (as B) in Clause 2.

These two clauses have a unique resolvent, since there is only one complementary literal, B.

The resolvent is formed by disjoining (i.e., combining with "V" all the literals of clause 1 and clause 2 except the ones involving B.

This results in A V C V D.

CSE 341 -- S. Tanimoto Horn Clauses and Unification


Example of resolution

Example of Resolution

“If the butler had a motive and the butler was alone with the victim then the butler is guilty. If the butler needed money, then the butler had a motive. The butler needed money. The butler was alone with the victim.”

Prove that the butler was guilty.

Premises: c1: ~ P V ~ Q V R

c2: ~ S V P If the butler needed money, then the butler had a motive.

c3: S The butler needed money.

c4: Q The butler was alone with the victim.

Assume to the contrary that the butler was not guilty: c5: ~ R

Show a contradiction by resolving to obtain the null clause [].

c1 and c4 resolve to give c6: ~ P V R

c6 and c2 resolve to give c7: ~ S V R

c7 and c5 resolve to give c8: ~ S

c8 and c3 resolve to give c6: [] Q.E.D. (Quod Erat Demonstrandum)

CSE 341 -- S. Tanimoto Horn Clauses and Unification


Going from propositional logic to predicate logic

Going from Propositional Logic to Predicate Logic

Propositional logic is too limited in its expressive power to help us do real-world programming.

We need to extend it to a system that uses domain variables, functions, and constants.

We will still be able to use resolution to perform inference mechanically.

CSE 341 -- S. Tanimoto Horn Clauses and Unification


Predicate logic

Predicate Logic

“Every Macintosh computer uses electricity.”

(all x) (Macintosh(x) implies UsesElectricity(x))

variables: x, y, z, etc.

constants: a, b, c, etc.

function symbols: f, g, etc.

Predicate symbols: P, Q,

Macintosh, UsesElectricity

quantifiers: all, exists

Logical connectives: not, implies, and, or.

~, ->, &, V.

CSE 341 -- S. Tanimoto Horn Clauses and Unification


Clause form1

Clause Form

(all x) (Macintosh(x) -> UsesElectricity(x)

UsesElectricity(x) V Not Macintosh(x).

Clause form for predicate calculus expressions is similar to that for propositional calculus expressions.

To achieve clause form, several steps may be required.

a. Rewrite X -> Y expressions as ~ X V Y.

b. Reduce scopes of negation.

c. Using strict rules, eliminate quantifiers.

If the scope of a universal quantifier is the whole formula,

then drop the quantifier, the quantification will be implicit.

Using Skolem constants and or Skolem functions, remove

any existential quantifiers.

d. Convert to conjunctive normal form

CSE 341 -- S. Tanimoto Horn Clauses and Unification


Horn clauses

Horn Clauses

Horn clause: at most one unnegated literal

(X V Y) is not a Horn clause.

(Y V ~Z) is a Horn clause.

“If X is the mother of Y and Y is a parent of Z, then

X is a grandmother of Z.”

(m(X,Y) & p(Y, Z)) -> g(X,Z).

grandmother(X, Z) provided mother(X, Y) and parent (Y, Z)

g(X,Z) :- m(X,Y), p(Y,Z). ; Edinburgh Prolog syntax

grandmother(X, Z) :- % head

mother(X, Y), % subgoal 1

parent(Y, Z). % subgoal 2

CSE 341 -- S. Tanimoto Horn Clauses and Unification


How does matching work in prolog

How Does Matching Work in Prolog?

Literals are matched using a method called unification.

The scope of a variable in Prolog is a single clause.

Unification involves substituting “terms” for variables.

CSE 341 -- S. Tanimoto Horn Clauses and Unification


Unification of literals

Unification of Literals

A substitution is a set of term/variable pairs.

{ f(a)/x, b/y, z/w }

A unifier for a pair of literals is a substitution that when applied to both literals, makes them identical.

P(x, a), P(f(a), y) have the unifier

{ f(a)/x, a/y }

P(x), P(y) have the unifier { a/x, a/y },

but they also have the unifier { x/y }.

The latter is more general because after

unifying with { x/y} we get P(x) whereas with the other it is P(a), yet we can obtain the latter from the former with an additional substitution { a/x }.

CSE 341 -- S. Tanimoto Horn Clauses and Unification


Horn clause resolution

Horn-Clause Resolution

Example of resolution with the grandmother rules:

g(X, Z) :- m(X, Y), p(Y, Z).

m(X, Y) :- p(X, Y), f(X).

g(X, Z) :- p(X, Y), f(X), p(Y, Z).

more generally, from:

P :- Q1, Q2.

Q1 :- R1, R2.

we obtain the resolvent:

P :- R1, R2, Q2

CSE 341 -- S. Tanimoto Horn Clauses and Unification


A backtracking horn clause resolver

A Backtracking Horn-Clause Resolver

Maintain the rules in a database of rules.

Accept a query (goal) as a positive unit clause, e.g.,

P(a, b).

Put this goal on the subgoal list.

Repeatedly try to satisfy the next clause on the subgoal list as follows:

Find a rule in the database whose head unifies with the subgoal. Apply the same unifier to the literals in the body of that rule and replace the subgoal by these new literals.

If the subgoal list is empty, stop. The combined set of unifiers includes the solution.

CSE 341 -- S. Tanimoto Horn Clauses and Unification


  • Login