Sei sulla pagina 1di 34

Strategies for Deduction

Part I: Rules and Tools

Overview of What We Are Trying to Do


We plan to represent the world in FOPC, putting these beliefs in a knowledge base. Well represent our problem itself as a FOPC sentence, i.e., a goal to be proved. If we can deduce the problem sentence from the knowledge base, then there is a solution.
Well also include the details of any particular problem we would like to solve.

The details of the deduction should provide the steps of a solution.

Example: A Blocks World Problem


Our KB contains
General facts about the blocks world: E.g., x,y,z(On(x,y) (On(x,z) y=z))
x,y(On(x,y) Clear(y))

Specific facts for a particular problem: A goal might be

other static facts about our world facts about moving

E.g., On(A,B), On(B,Table), On(C,Table), Clear(A), Clear(C)

The particular sequence of actions should be implicit in our proof.

On(A,B) On(B,C) (Or some suchwe havent yet specified the details of how we will express change and actions.)

Our Plan
Look at
deduction in FOPC. some efficiency considerations and trade-offs. the world, generally change and action in FOPC.

Look at how to represent

Try to apply deduction to produce a general problem solver.

Deduction From A Data Base Point of View


One attractive way to think about deduction is as follows:
We have a KB, and can ask if a given sentence is in it. We extend the notion of in the KB to be in or follows from the KB. If it is not literally in the KB, well try to deduce it.

Such a sentence is called a goal or a query. A retriever that works this way would be doing deductive information retrieval.

Again, the details of how the goal is true might also be useful.

Deduction
Ideally, wed like an inference procedure that would be
Sound Complete Fast

Unfortunately, there is no analogy to truth tables for general deduction for FOPC.

In Prop Calc, Theres ALWAYS a Truth Table


Suppose we believe P and PQ, and want to know if Q. Can always build a truth table with an entry for each symbol and each item in the DB:
P false false true true Q false true false true PQ true true false true

Now we pay attention to those we believe are true.

In Prop Calc, Theres ALWAYS a Truth Table


Suppose we believe P and PQ, and want to know if Q. Can always build a truth table with an entry for each symbol and each item in the DB:
P false false true true Q false true false true PQ true true false true

Now we pay attention to those we believe are true. And now, look at the combinations that are all true.

In Prop Calc, Theres ALWAYS a Truth Table


Suppose we believe P and PQ, and want to know if Q. Can always build a truth table with an entry for each symbol and each item in the DB:
P false false true true Q false true false true PQ true true false true

Now we pay attention to those we believe are true. And now, look at the combinations that are all true. Q is true in these cases, so we have proven it.

But In FOPC
Suppose x P(x)Q(x), P(A) and we want to know if Q(A). We can build a table, but we cant fill it in:
P(A) false false true true Q(A) false true false true x P(x) Q(x) ? ? false ?

I.e., the general sentence never follows from any these instances.

Rules of Inference
But, as in Proposition Logic, we can still have rules of inference consisting of If we have sentences that match the premises of the rule, we may infer sentences matching the conclusions. We would like our rules to be sound, i.e., if the premises are true, then the conclusions will in fact be true. Well have to specify procedures to use these, and ask if they are sound, complete, efficient.
Expect trade-offs. a set of sentences, called the premises a set of sentences, called the conclusions

Rules of Inference Carry Over from Prop. Calc.


Modus ponens:

Or introduction:

And elimination:

Resolution:

And introduction:

Plus our various logical equivalences.

(The Greek letters denote FOPC sentences.)

Need Some New Rules Involving Quantification


First, some simple rules:
The following equivalences involving negation and quantifiers hold: x x x x (We can establish these semantically.)

Before We See Some More Interesting Rules


Lets introduce a notation for substitution. A substitution is set of variables paired with terms.
Example: {x/Jan, y/Father(Pat)} is a substitution, specifying that Jan should be substituted for x, and Father(Pat) for y.

We write to mean the expression that results if we apply substitution to expression .

Example: Loves(x,y){x/Jan, y/Father(Pat)} denotes the sentence Loves(Jan, Father(Pat))

Substitutions (cont)
Note that
this isnt part of FOPC per se; its just a convenient notation. it only makes sense to substitute for unbound variables but it is okay to substitute one variable for another. E.g., {x/y, w/z} is a perfectly fine, if not obviously useful, substitution.

Substitutions are sometimes also called bindings or binding lists.

Some More Rules Involving Quantification


Universal Instantiation: where G is any ground term, i.e., a term not containing variables. Example: From x y Hates(x,y)
UI allows concluding y Hates(x,y){x/Jan} which is y Hates(Jan,y) UI allows concluding y Hates(x,y){x/Father-of(Jan)} which is y Hates(Father-of(Jan),y) x {x/G}

Rules Involving Quantification (cont)


Existential Instantiation (version one):
x {x/N} where N is a symbol not mentioned in any other sentence.

Example: From
can conclude

x President(x,US) President(Somejoe,US)

as long as we havent used Somejoe before.

If we later learn president is Bush, add


Somejoe=Bush

Note: This Isnt Really a Rule of Inference Per se


Logicians dont usually talk about Existential Elimination as a rule of inference per se. I.e., it is not quite right to say that if we believe x President(x,US), we can prove President(Somejoe,US). Rather, a set of sentences with x President(x,US) among them is satisfiable if and only if the same sentences with President(Somejoe,US) instead is satisfiable. Or, everything that follows from a set of sentences containing x President(x,US) also follows from the same set with President(Somejoe,US) instead (except, of course, for President(Somejoe,US) ). So, we are justified in adding such sentences to our beliefs.

Existential Instantiation (cont)


In c x (Country(c) Leader(x,c)) cant replace x with a constant. But it would make sense to replace x with a function that maps countries to their leaders. E.g., if Head-of is function so that Head-of(US) denotes Bush Head-of(Russia) denotes Putin, etc. Then we could say c (Country(c) Leader(Head-of(c),c)) But we might not know what to call this function. So lets just make up a new function name!

Existential Instantiation (cont)


Or, generally:
y x y {x/F(y)}

as long as F is a new function (and contains no variables other than y). In the most general case: where F is a new function of all the universal variables. These are sometimes called Skolem functions.
y1,...,yn x y1,...,yn {x,F(y1,...yn)}

Existential Introduction
The dual of (the simple form of) Existential Instantiation is: x {G/x} E.g., given President(Bush,US) rule lets us conclude x President(x,US) A more general rule would undo the general case of Existential Instantiation.

where G is a ground term that occurs in , and x doesnt occur in .

So Existential Instantiation produces a sentence that is equivalent to its premise.

Inference Procedures
Now, we can take these rules, and use them somehow to make inferences from a KB in hopes of proving a goal. Remember, ideally, we would like an inference procedure in which
Everything that we deduce is logically implied. (soundness) Everything that is logically implied is derivable. (completeness) Inferences can be made efficiently.

Inference Procedures for FOPC (cont)


Are the inference rules we have seen so far are sound? Are they complete?
Yes. (We offered justifications from prop. calc. and semantics of FOPC.)

Is an effective (i.e., complete, sound) procedure in fact possible?


Yes! This is what Gdels Completeness theorem tells us. A very minor extension of our language, enough to allow arithmetic, loses this completeness property.
Thats Gdels Incompleteness Theorem.

Not obvious that our rules thus far will guarantee us a proof for everything logically implied!

Whats a complete procedure?


Gdel didnt say. We will, though.

Inference Procedures (cont)


How efficient are these procedures?
Injudicious use of even simple rules can lead to ridiculously inefficient algorithms.
E.g., Universal Instantiation lets us substitute a constant for a universally quantified variable; doing this randomly is valid, but not very wise.

Effective schemes, it turns out, are inefficient in principle. In general, we have trade-offs:

Sound, complete, inefficient schemes Sound, incomplete, more efficient schemes Unsound, incomplete, efficient schemes?

First, Some Tools for Inference


Motivation: E.g., suppose
Consider building a deductive retriever that responds to a query (or, goal) by trying to prove it from sentences in a KB. x Loves(x,x), Loves(Pat,Jan)

are in the DB, and our query is


Loves(Jan,Jan) We would like our deductive retriever to respond yes, because it can prove the goal from first formula (by Universal Instantiation).

But just getting back a yes or no answer may not be good enough. E.g., suppose the query is
z Loves(z,Jan)

If we just return yes, well be disappointed. Instead, we would like to know all the ways it might be true.

Matching Formulae
Intuitively, many inference procedures have a step in which two FOPC sentences match each other, i.e., are the same assuming some flexible method of variable matching. E.g.:
Loves(z,Jan) matches Loves(x,x) and Loves(Pat,Jan) Loves(Jan,Jan) matches Loves(x,x)

Unification
of matching. Two sentences unify with one another if there is a substitution of variables which, when applied to both sentences, denotes the same sentence. E.g., consider Loves(x,x) and Loves(z,Jan):
Loves(x,x)/{x/Jan,z/Jan} denotes Loves(Jan,Jan) Loves(z,Jan)/{x/Jan,z/Jan} denotes Loves(Jan,Jan) so Loves(x,x) and Loves(z,Jan) unify, with the unifier {x/Jan,z/Jan}.

Unification is a formalization of this notion

Unification (cont)
Many pairs of sentences can have more than one unifier. E.g.: can be unified by
{x/Pat,z/Pat} {x/Lynn,z/Lynn} {x/Pat,z/Pat,w/George} {x/z} Loves(x,Jan) Loves(z,Jan)

However, {x/z} seems most satisfying.

Most General Unifier (MGU)


A most general unifier (MGU) is a unifier which, after it is applied, produces an expression for which there is always another substitution that will produce the expression that any other unifier applied to an original expression will give us. E.g.,
Loves(x,Jan){x/Pat,z/Pat} produces Loves(Pat,Jan) Loves(x,Jan){x/z} produces Loves(z,Jan)

A most general unifier makes the least commitment possible. When we unify two expressions, we want to compute a MGU.

Examples
Formula 1
Loves(x,Jan) Loves(x,Jan) Loves(x,Jan) Loves(Jan,Pat) Loves(x,Father(x)) Loves(x,Father(x)) Loves(x,Father(x))

Formula 2
Loves(Lynn,y) Loves(x,Pat) Loves(Pat,x) Loves(Jan,Pat) Loves(Lynn,y) Loves(y,y)

MGU
{x/Lynn,y/Jan} Tilt! Tilt! {} {x/Lynn,y/Father(Lynn)} Tilt!

Loves(x,Father(Pat)) {x/Pat}

An Application of Unification
Unifiers are a nice way to express the idea of how something can be true. E.g., given the query z Loves(z,Jan) and the DB x Loves(x,x), Loves(Pat,Jan) the unifiers {z/Jan} {z/Pat} each reflect a different way the query might be supported by the knowledge base. So, in general, deductive retrievers to return lists, or streams, of unifiers, each presenting a different way the query might be true.

Practical Considerations for Unification


There may be more than one MGU, but they all produce the same sentence after substitution, except for variable naming. Unification is sensitive to variable names.
We need to take care, when we use unification in deduction, to be sure that the variables in different sentences arent accidentally the same. Two sentences unify, but with the empty unifier Two sentences cant be unified.

Take care to distinguish the following cases:

This will succeed, but produce { } (which a program is likely to represent by the empty list). The unification fails (which a program is likely to represent as nil).

Summary
There are inference rules for FOPC:
The inference rules and equivalences of propositional calculus carry over. There are some additional rules for quantified sentences.

We promised
complete, sound, but costly

Potrebbero piacerti anche