1 Inference in First Order Logic CS 171/271 (Chapter 9) Some text and images in these slides were...

20
1 Inference in First Order Logic CS 171/271 (Chapter 9) Some text and images in these slides were drawn from Russel & Norvig’s published material

Transcript of 1 Inference in First Order Logic CS 171/271 (Chapter 9) Some text and images in these slides were...

Page 1: 1 Inference in First Order Logic CS 171/271 (Chapter 9) Some text and images in these slides were drawn from Russel & Norvig’s published material.

1

Inference in First Order Logic

CS 171/271(Chapter 9)

Some text and images in these slides were drawn fromRussel & Norvig’s published material

Page 2: 1 Inference in First Order Logic CS 171/271 (Chapter 9) Some text and images in these slides were drawn from Russel & Norvig’s published material.

2

Inference Algorithms Reduction to Propositional

Inference Lifting and Unification Chaining Resolution

Page 3: 1 Inference in First Order Logic CS 171/271 (Chapter 9) Some text and images in these slides were drawn from Russel & Norvig’s published material.

3

Propositionalization Strategy: convert KB to

propositional logic and then use PL inference

Ground atomic sentences become propositional symbols

What about the quantifiers?

Page 4: 1 Inference in First Order Logic CS 171/271 (Chapter 9) Some text and images in these slides were drawn from Russel & Norvig’s published material.

4

Example KB in FOL:

x King(x) Greedy(x) Evil(x) King(John) Greedy(John) Brother(Richard,John)

The last 3 sentences can be symbols in PL

Apply Universal Instantiation to the first sentence

Page 5: 1 Inference in First Order Logic CS 171/271 (Chapter 9) Some text and images in these slides were drawn from Russel & Norvig’s published material.

5

Universal Instantiation UI says that from a universally quantified

sentence, we can infer any sentence obtained by substituting a ground term for the variable

Back to Example From: x King(x) Greedy(x) Evil(x) To:

King(John) Greedy(John) Evil(John) King(Richard) Greedy(Richard) Evil(Richard) …

Page 6: 1 Inference in First Order Logic CS 171/271 (Chapter 9) Some text and images in these slides were drawn from Russel & Norvig’s published material.

6

Issue with UI Ground terms: all symbols that refer to

objects as well as function applications (recall that function applications return objects)

For example, suppose Father is a function: Father(John) and Father(Richard) are also

objects/ground terms But so are Father(Father(John)) and

Father(Father(Father(John))) Infinitely many ground terms/instantiations

Page 7: 1 Inference in First Order Logic CS 171/271 (Chapter 9) Some text and images in these slides were drawn from Russel & Norvig’s published material.

7

Existential Instantiation Whenever there is a sentence, x P,

introduce a new object symbol called the skolem constant and then add the unquantified sentence P, substituting the variable with that constant

Example: From: x Crown(x) OnHead(x, John) To: Crown(Cnew) OnHead(Cnew, John)

Page 8: 1 Inference in First Order Logic CS 171/271 (Chapter 9) Some text and images in these slides were drawn from Russel & Norvig’s published material.

8

Substitution UI and EI apply substitutions A substitution is represented by a variable

v and a ground term g; {v/g} Can have sets of these pairs if there are more

variables involved Let be a sentence (possibly containing v) SUBST( {v/g}, ) stands for the

sentence that applies the substitution to

Page 9: 1 Inference in First Order Logic CS 171/271 (Chapter 9) Some text and images in these slides were drawn from Russel & Norvig’s published material.

9

UI and EI Defined UI:

v α ___ for any ground term g SUBST({v/g}, α)

EI: v α ___ for some constant symbol

k not SUBST({v/k}, α) yet in the knowledge base

Page 10: 1 Inference in First Order Logic CS 171/271 (Chapter 9) Some text and images in these slides were drawn from Russel & Norvig’s published material.

10

Back to Propositionalization Given a KB in FOL, convert KB to PL by

1. applying UI and EI to quantified sentences2. converting atomic sentences to symbols

If there are no functions (Datalog KB), UI application does not result in infinitely many sentences

Regular PL Inference can now be carried out without problems

What if there are functions?

Page 11: 1 Inference in First Order Logic CS 171/271 (Chapter 9) Some text and images in these slides were drawn from Russel & Norvig’s published material.

11

Dealing with Infinitely Many Ground Terms Can set a depth-limit for ground terms

Depth specifies levels of function nesting allowed

Carry out reduction and inference process for depth 1, then 2, then 3, …

Stop when entailment can be concluded This works if there is such a proof, but goes

into an endless loop if there is not The strategy is complete The entailment problem in this sense is

semidecidable

Page 12: 1 Inference in First Order Logic CS 171/271 (Chapter 9) Some text and images in these slides were drawn from Russel & Norvig’s published material.

12

Inefficiencies in Propositionalization An inordinate number of irrelevant

sentences may be generated, resulting from UI

This motivates generating only those sentences that are important in entailment

Page 13: 1 Inference in First Order Logic CS 171/271 (Chapter 9) Some text and images in these slides were drawn from Russel & Norvig’s published material.

13

Example Suppose KB contains:

x King(x) Greedy(x) Evil(x) y Greedy(y) King(John)

Suppose we want to conclude Evil(John) Because of the existence of objects

other than John (such as Richard) and the existence of functions, UI will generate many sentences

Page 14: 1 Inference in First Order Logic CS 171/271 (Chapter 9) Some text and images in these slides were drawn from Russel & Norvig’s published material.

14

Example, continued It is sufficient to generate:

King(John) Greedy(John) Evil(John) Greedy(John)

Which is just: SUBST( {x/John}, King(x) Greedy(x) Evil(x) ) SUBST( {y/John}, Greedy(y) )

Applying the substitution matches the Premises: King(x) Greedy(x) With other sentences in the KB:

Greedy(y), King(John)

Page 15: 1 Inference in First Order Logic CS 171/271 (Chapter 9) Some text and images in these slides were drawn from Russel & Norvig’s published material.

15

Lifted Modus Ponens Lifting: Raising propositional inference

rules to first order logic Example: Generalized Modus Ponens

If there is a substitution θ, such thatSUBST(θ, pi) = SUBST(θ, pi’) for all i, then

p1', p2', … , pn’, ( p1 p2 … pn q)_______________________________________________________________________________

SUBST(θ,q) In our example, = {x/John, y/John}

Page 16: 1 Inference in First Order Logic CS 171/271 (Chapter 9) Some text and images in these slides were drawn from Russel & Norvig’s published material.

16

Unification Process that makes logical

expressions identical Goal: match the premises of

implications so that conclusions can be derived

UNIFY algorithm takes two sentences and returns a unifier (substitution) if it exists

Page 17: 1 Inference in First Order Logic CS 171/271 (Chapter 9) Some text and images in these slides were drawn from Russel & Norvig’s published material.

17

Unification Algorithm

Page 18: 1 Inference in First Order Logic CS 171/271 (Chapter 9) Some text and images in these slides were drawn from Russel & Norvig’s published material.

18

Unification Algorithm

Page 19: 1 Inference in First Order Logic CS 171/271 (Chapter 9) Some text and images in these slides were drawn from Russel & Norvig’s published material.

19

About UNIFY UNIFY returns a Most General

Unifier (MGU) There are efficiency issues with

OCCUR-CHECK function May need to standardize apart:

rename variables to avoid name clashes

Unification is a key component of all first-order algorithms

Page 20: 1 Inference in First Order Logic CS 171/271 (Chapter 9) Some text and images in these slides were drawn from Russel & Norvig’s published material.

20

What’s Next? Forward and backward chaining

algorithms for FOL that use unification

Resolution-based theorem proving systems