Docsity

More Inference, Plus Ontologies - Artificial Intelligence Programming | CS 662, Study notes of Computer Science

Partial preview of the text

Download More Inference, Plus Ontologies - Artificial Intelligence Programming | CS 662 and more Study notes Computer Science in PDF only on Docsity!

Artificial Intelligence

Programming

More Inference (plus ontologies)

Chris Brooks Department of Computer Science University of San Francisco

Previously on CS ...

We introduced propositional logic

Also three inference mechanisms: forward chaining,backward chaining, and resolution. But propositional logic has some seriousrepresentational problems.

So we introduced first-order logic.

Can say more complex things. Can we also perform inference?

Our goal: apply propositional inference mechanisms tofirst-order logic.

Department of Computer Science — University of San Francisco – p.1/

Inference in FOL

Can we do the same sorts of inference with First-orderlogic that we do with propositional logic? Yes, with some extra details. Need to keep track of variable bindings (substitution)

Department of Computer Science — University of San Francisco – p.3/

Inference in FOL

As with propositional logic, we’ll need to convert ourknowledge base into a canonical form. In the simplest approach, we can convert our FOLsentences to propositional sentences. We do this byremoving quantification.

we leave in predicates for readability, but remove allvariables.

Department of Computer Science — University of San Francisco – p.4/

Removing quantifiers

Existential Instantiation: we can give a name to theobject that satisfies a sentence.

xLivesIn

x, Springf ield

knows

x, Homer

We know this must hold for at least one object. Let’scall that object

K

LivesIn

K, Springf ield

knows

K, Homer

K

is called a

Skolem constant

K

must be unused - gives us a way of referring to an

existential object.

Once we’ve removed quantifiers, we can usepropositional inference rules.

Department of Computer Science — University of San Francisco – p.6/

Propositionalization

We can replace every existential sentence with aSkolemized version. For universally quantified sentences, substitute in

every

possible substitution. This will (in theory) allow us to use propositionalinference rules. Problem: very inefficient! This was the state of the art until about 1960. Unification of variables is much more efficient.

Department of Computer Science — University of San Francisco – p.7/

Generalized Modus Ponens

This reasoning is a generalized form of Modus Ponens. Basic idea: Let’s say we have:

An implication of the form

P

1

P

2

P

i

Q

Sentences

P

′ 1

, P

′ (^2)

, ..., P

′ (^) i

a set of substitutions such that P

1

P

′ 1

, P

2

P

′ 2

, ..., P

′ n

P

n

We can then apply the substitution and apply ModusPonens to conclude

Q

this technique of using substitutions to pair upsentences for inference is called

unification

Department of Computer Science — University of San Francisco – p.9/

Unification

Our inference process now becomes one of findingsubstitutions that will allow us to derive new sentences. The Unify algorithm: takes two sentences, returns a setof substitutions that unifies the sentences.

W orksAt ( x, P owerP lant ) , W orksAt ( Homer, P owerP lant ) produces { x/Homer } . W orksAt ( x, P owerP lant ) , W orksAt ( Homer, y ) produces { x/Homer, y/P owerP lant } W orksAt ( x, P owerP lant ) , W orksAt ( F atherOf ( Bart ) , y ) produces { x/F atherOf ( Bart ) , y/P owerP lant } W orksAt ( x, P owerP lant ) , W orksAt ( Homer, x ) fails - x can’t bind to both Homer and PowerPlant. Department of Computer Science — University of San Francisco – p.10/

Unification

What if there is more than one substitution that canmake two sentences look the same?

Sibling

Bart, x

, Sibling

y, z

can produce

Bart/y, x/z

or

x/Bart, y/Bart, z/Bart

the first unification is more general than the second - itmakes fewer commitments. We want to find the

most general unifier

when

performing inference.

(This is the heuristic in our search.)

Department of Computer Science — University of San Francisco – p.12/

Unification Algorithm

To unify two sentences, proceed recursively. If either sentence is a single variable, find a unificationthat binds the variable to a constant. Else, call unify in the first term, followed by the rest ofeach sentence.

Sibling

x, Bart

P laysSax

x

and

Sibling

Lisa, y

We can unify

Sibling

x, Bart

and

Sibling

Lisa, y

with

x/Lisa, y/Bart

The process of finding a complete set of substitutions isa search process.

State is the list of substitutions Successor function is the list of potential unificationsand new substitution lists.

Department of Computer Science — University of San Francisco – p.13/

Forward Chaining Algorithm

while (1) : for rule in rules : if (can_unify(rule, facts)) : fire_rule(rule)assert consequent facts if (no rules fired) : return Department of Computer Science — University of San Francisco – p.15/

Example

The law says that it is a crime for an American to sell weapons to hostile nations. The countryof Nono, an enemy of America, has some missiles. All of its missiles were sold to it byColonel West, who is an American.

Prove that West is a criminal.

It is a crime for an American to sell weapons to hostile nations. 1 .American ( x ) ∧ W eapon ( y ) ∧ Hostile ( z ) ∧ Sells ( x, y, z ) ⇒ Criminal ( x ) Nono has missiles. 2 .∃ xOwns ( N ono, x ) ∧ M issile ( x ) Use Existential Elimination to substitute M 1 for x 3 .Owns ( N ono, M 1 ) ,^ 4 .M issile ( M 1 ) Department of Computer Science — University of San Francisco – p.16/

Example

Algorithm: Repeatedly fire all rules whose antecedentsare satisfied. Rule 6 matches with Fact 4.

x/M 1

. Add

W eapon

M

1

Rule 5 matches with 3 and 4.

x/M 1

. Add

Sells

W est, M 1 , N ono

Rule 7 matches with 9.

x/N ono

. Add

Hostile

N ono

Iterate again. Now we can match rule 1 with

x/W est, y/M 1 , z/N ono

and conclude

Criminal

W est

Department of Computer Science — University of San Francisco – p.18/

Analyzing basic forward chaining

Forward chaining is sound, since it uses Modus Ponens. Forward chaining is complete for definite clauses. Works much like BFS This basic algorithm is not very efficient, though.

Finding all possible unifiers is expensive Every rule is rechecked on every iteration. Facts that do not lead to the goal are generated.

Department of Computer Science — University of San Francisco – p.19/