Download presentation

Presentation is loading. Please wait.

Published byRoland Cowdery Modified over 2 years ago

1
**Horn Form A sentence is in Horn form if and only if ….**

It is a conjunction of atomic sentences on the left side, and a single atom on the right side i.e. P Q R X A B P Q R X

2
Overview We plan to represent the world (or some subset thereof, ie our domain) in FOL, and to TELL this information into our Knowledge Base KB. We will represent our problem (ie the statement we want to prove) in FOL. We will sometimes call the statement to be proved a goal. So proving a statement is equivalent to seeing if the goal is in the KB, or if not in it, can be deduced (entailed) from it.

3
**The simplest example Suppose our KB consists of P Q R**

A simple goal is … Q. Literally we are asking is it the case that Q is true. In this case, the answer is yes!

4
**Another simple example**

Suppose our KB consists of P Q R Now suppose the goal is … P Q. We are literally asking is it the case that P is true and Q is true. In this case, the fact P Q is not in our KB. But we can infer it by using the And-Introduction rule.

5
**A more interesting example**

Suppose our KB consists of facts about containment General facts about containment x,y,z in(x,y) in(y,z) enclosedby(x,z) x,y in(x,y) enclosedby(x,y) Specific facts for our particular problem in(A,B) in(B,C) in(F,C) Note, “in” means directly inside with nothing in between, “encloses” means inside, possibly with other items in between. A F B A goal might be x enclosedby(B,x) (ie, is there any thing inside B?) or x,y,z enclosedby(x,y) enclosedby(y,z) C

6
**Models I A model is simply a “world” in which a sentence is true.**

Consider the sentence P Q , given that P Means “is tall”. Q Means “is rich”. We can now ask if the following interpretations of P Q are models… “Bill Gates” is not a model of P Q “Eamonn Keogh” is not a model of P Q “Michael Jordan” is a model of P Q

7
**Models II If we have the sentence P Q, and P Means “is astronaut”.**

Q Means “is female”. Which of the following interpretations of P Q are models? “Neil Armstrong”, “Eamonn Keogh”, “Sally Ride”, “Dolly Parton”, “Bill Clinton”, “Valentina Tereshkova”,

8
Models III Models are important because they allow a simple definition of entailment. A Knowledge Base KB entails a sentence if and only if, all models of KB are also models of . For example the KB P Q …can be said to entail the sentence P Q, since all models of P Q are also models of P Q.

9
**In propositional logic, proof is easy I**

Suppose we had P and P Q in our KB, and we have a goal of Q We can always build a truth table with an entry for each symbol and each item from our KB P Q P Goal: Q? P Q P Q FALSE TRUE We need to look at all rows where the statements in our KB are true…

10
**In propositional logic, proof is easy I**

Suppose we had P and P Q in our KB, and we have a goal of Q We can always build a truth table with an entry for each symbol and each item from our KB P Q P Q? P Q P Q FALSE TRUE We need to look at all rows where the statements in our KB are true. Since in every case where our KB statements are true, Q is also true, thus we have proved Q! (I.e our KB entails Q) All models of {P Q , P} are also models of Q.

11
In FOL, proof is harder Suppose we had P(A) and x P(x) Q(x) in our KB, and we have a goal of Q(A) We can build a truth table but we cannot fill it in. x P(x) Q(x) P(A) Q(A)? P(A) Q(A) x P(x) Q(x) FALSE ? TRUE I.e. the general sentence never follows from any of these instances. How are we to know if the KB entails the sentence Q(A)?

12
In the next few slides we will look at some tools that will allow us to prove facts in First Order Logic This tools are: Substitution Universal Elimination Existential Elimination Existential Introduction

13
**Substitution (Binding, Instantiation)**

Substitution is a variable (or set of variables) paired with a term. Example: SUBST{x/Harpo}is a substitution indicating that Harpo should be substituted for x. Brother(x,Groucho) becomes Brother(Harpo,Groucho) Example: SUBST{x/YoungestSonOF(Minnie)}is a substitution indicating that YoungestSonOF(Minnie)} should be substituted for x. Brother(x,Groucho) becomes Brother(YoungestSonOF(Minnie),Groucho)

14
**Universal Elimination (Universal Instantiation)**

x SUBST({x/g, }) For any sentence , variable x, and term g. For example, from x loves(x, Beatles) We can use the substitution {x/Nick} to infer loves(Nick, Beatles) Or can use the substitution {x/MotherOf(Joe) } to infer loves(MotherOf(Joe) , Beatles) Terms (A term is an expression that refers to an object). Either A symbol A function application Symbols can be constants: John, Mary, 17, 56 or variables: F_name, L_name, X, Y Function applications are usually written as SomethingOf MotherOf(John) AgeOf(Mary) EyeColorOf(MotherOf(John))

15
**Existential Elimination (Existential Instantiation)**

For any sentence , variable x, and constant term k. Where k does not already exist in our KB x SUBST({x/k, }) For example from x President(x, USA) We can use substitution SUBST{x/someoldwhiteguy} to infer President(someoldwhiteguy, USA) Later on, if we happen to learn the president is Bush we can assign someoldwhiteguy = Bush Terms (A term is an expression that refers to an object). Either A symbol A function application Symbols can be constants: John, Mary, 17, 56 or variables: F_name, L_name, X, Y Function applications are usually written as SomethingOf MotherOf(John) AgeOf(Mary) EyeColorOf(MotherOf(John))

16
**Existential Introduction**

For any sentence , term g that occurs in and x that does not occur in . x SUBST({g/x, }) For example from President(Bush, USA) We can infer x President(x, USA)

17
**We can now take these new tools**

Universal Elimination Existential Elimination Existential Introduction Combined with some tools we have already defined To prove facts in First Order Logic

18
**A sample proof in FOL Bob is a buffalo Buffalo(Bob)**

Pat is a pig Pig(Pat) Buffaloes outrun pigs x,y Buffalo(x) Pig(y) Faster(x,y) Can Bob outrun Pat? Faster(Bob,Pat)?

19
**A sample proof in FOL Buffalo(Bob) Pig(Pat)**

x,y Buffalo(x) Pig(y) Faster(x,y) Buffalo(Bob) Pig(Pat) Can Bob outrun Pat? Faster(Bob,Pat)? 1. We can use And Introduction to add the following to our database… Buffalo(Bob) Pig(Pat)

20
**A sample proof in FOL Buffalo(Bob) Pig(Pat)**

x,y Buffalo(x) Pig(y) Faster(x,y) Buffalo(Bob) Pig(Pat) Buffalo(Bob) Pig(Pat) Faster(Bob, Pat) Can Bob outrun Pat? Faster(Bob,Pat)? 1. We can use And Introduction to add the following to our database… Buffalo(Bob) Pig(Pat) 2. We can do Universal Elimination to get… {x/Bob, y/Pat} Buffalo(Bob) Pig(Pat) Faster(Bob, Pat)

21
**A sample proof in FOL Buffalo(Bob) Pig(Pat)**

x,y Buffalo(x) Pig(y) Faster(x,y) Buffalo(Bob) Pig(Pat) Buffalo(Bob) Pig(Pat) Faster(Bob, Pat) Faster(Bob, Pat) Can Bob outrun Pat? Faster(Bob,Pat)? 1. We can use And Introduction to add the following to our database… Buffalo(Bob) Pig(Pat) 2. We can do Universal Elimination to get… {x/Bob, y/Pat} Buffalo(Bob) Pig(Pat) Faster(Bob, Pat) 3. We then use Modus Ponens to derive Faster(Bob, Pat)

22
**The need for a better proof mechanism**

The proof mechanism we have just seen can be imagined as search. The operators are inference rules (Existential Introduction, Universal Elimination, etc) The states are set of sentences (The KB itself) The goal test is to see if a state contains the query sentence. This idea works, but… It seriously slows down when the KB gets larger, because the number of possible substitutions grows exponentially. One possible solution is to reduce the number of operators… This leads us to Generalized Modus Ponens (GMP).

23
**SUBST({/q}) = SUBST({x/Bob, y/Pat, z/Steve })**

Generalized Modus Ponens Combines And-Introduction, Universal-Elimination, and Modus Ponens For atomic sentences p1’, p2’, and q, where there is a substitution such that SUBST({/ pi’ }) = SUBST({/ pi}) p1’, p2’,…pn’ (p1 p2… pn q ) SUBST({/q}) Example: p1’ = Faster(Bob,Pat) p2’ = Faster(Pat,Steve) p1 p2 q = Faster(x,y) Faster(y,z) Faster(x,z) SUBST({/q}) = SUBST({x/Bob, y/Pat, z/Steve }) Then using GMP we can conclude Faster(Bob,Steve) Note that GMP only works for a KB of definite clauses (Exactly one positive literal): either a single atom or (conjunction of atomic sentences) atomic sentence Sentences in this form are known as horn clauses. Note also that all sentences are assumed to be universally qualified

24
**SUBST({/q}) = SUBST({x/Bob, y/Pat, z/Steve })**

Generalized Modus Ponens Combines And-Introduction, Universal-Elimination, and Modus Ponens For atomic sentences p1’, p2’, and q, where there is a substitution such that SUBST({/ pi’ }) = SUBST({/ pi}) p1’, p2’ (p1 p2 q ) SUBST({/q}) Example: p1’ = Faster(Bob,Pat) p2’ = Faster(Pat,Steve) p1 p2 q = Faster(x,y) Faster(y,z) Faster(x,z) SUBST({/q}) = SUBST({x/Bob, y/Pat, z/Steve }) Then using GMP we can conclude Faster(Bob,Steve) Faster(Bob,Pat) Faster(Pat,Steve) Faster(Bob,Steve)

25
Forward Chaining Proofs start with the given axioms/premises in KB, deriving new sentences using GMP until the goal/query sentence is derived. This defines a forward chaining inference procedure because it moves "forward" from the KB to the goal. Example: KB = All cats like fish, cats eat everything they like, and Ziggy is a cat. In FOL, KB = x cat(x) likes(x, Fish) x y (cat(x) likes(x,y)) eats(x,y) cat(Ziggy) Goal query: Does Ziggy eat fish? Proof: Use GMP with (1) and (3) to derive: 4. likes(Ziggy, Fish) Use GMP with (3), (4) and (2) to derive eats(Ziggy, Fish) So, Yes, Ziggy eats fish.

26
**Backward Chaining x cat(x) likes(x, Fish)**

Backward-chaining deduction using GMP is complete for KBs containing only Horn clauses. Proofs start with the goal query, find implications that would allow you to prove it, and then prove each of the antecedents in the implication, continuing to work "backwards" until we get to the axioms, which we know are true. Example: Does Ziggy eat fish? To prove eats(Ziggy, Fish), first see if this is known from one of the axioms directly. Here it is not known, so see if there is a Horn clause that has the consequent (i.e., right-hand side) of the implication matching the goal. Here, Proof: Goal matches RHS of Horn clause (2), so try and prove new sub-goals cat(Ziggy) and likes(Ziggy, Fish) that correspond to the LHS of (2) cat(Ziggy) matches axiom (3), so we've "solved" that sub-goal likes(Ziggy, Fish) matches the RHS of (1), so try and prove cat(Ziggy) cat(Ziggy) matches (as it did earlier) axiom (3), so we've solved this sub-goal There are no unsolved sub-goals, so we're done. Yes, Ziggy eats fish. x cat(x) likes(x, Fish) x y (cat(x) likes(x,y)) eats(x,y) cat(Ziggy)

27
We have seen that we can use Generalized Modus Ponens (GMP) combined with search to see if a fact is entailed from a Knowledge Base. Unfortunately, there are some facts that we cannot prove using GMP Suppose we have in our KB GoToSchool(Joe) GoToSchool(Sue) GoToSchool(Joe) GoToSchool(Sue) And we want to know if GoToSchool(Sue) Although humans can look at such a KB and immediately see that GoToSchool(Sue) is true, GMP cannot entail that fact!! So GMP is not complete.

28
**Is there any complete inference procedure for FOL?**

Yes! It is called resolution refutation (or just resolution). It is complete. It is sound. It is optimally efficient. It works for KB in any format unlike GMP which only works for KBs in Horn clause format (although we generally have to reorganize the format).

29
**How resolution refutation works I**

Suppose our KB consists the following sentences P Q P R Q R And the goal is to prove R S We negate the goal, so R S becomes (R S) R S (by De Morgan’s law) R , S (And-Elimination) Now we add R , S to our knowledge base and look for a contradiction. P Q P R Q R R S

30
**How resolution refutation works II**

P Q P R Q R R S P Q Q P P R Q R Q R R R R R Contradiction! That's all there is to resolution for propositional logic, for first order logic we just have to put the KB in the right format, otherwise it works the same.

31
**Conjunctive Normal Form: The KB is a conjunction of disjunctions**

In order for resolution to work for FOL, the KB must be in Conjunctive Normal Form (CNF) Conjunctive Normal Form: The KB is a conjunction of disjunctions P(w) Q(w) P(x) R(x) Q(y) S(y) R(z) S(z) P(w) Q(w) Q(y) S(y) SUBST{y/w} P(w) S(w) S(w) P(w) The Goal is S(A), so negate it and add it to the KB P(x) R(x) SUBST{w/x} P(w) Q(w) P(x) R(x) Q(y) S(y) R(z) S(z) S(A) S(x) R(x) R(z) S(z) SUBST{x/A, z/A} S(A) S(A) Now lets look for a contradiction… We will address the problem of translating an arbitrary KB into CNF in the next few slides. S(A) S(A) Contradiction!

32
**We have seen that we can do resolution when the KB is in CNF.**

But most KB are not is that format. Theorem: We can convert any KB to CNF Eliminate Implications Move inwards Standardize Variables Move Quantifiers left Skolemize {Eliminate Existential Quantifiers, Drop Universal Quantifiers } Distribute over Flatten nested conjunctions and disjunctions. Note that we must do the steps in order! Gloss over!

33
**Gloss over! Eliminate Implications So A B becomes A B**

Change all implication sentences to disjunctions So A B becomes A B C D becomes C D etc Gloss over!

34
**Gloss over! Move inwards So (A B) becomes A B**

Negation is only allow on atom, not whole sentences. So (A B) becomes A B (A B) becomes A B x P becomes x P x P becomes x P P becomes P Gloss over!

35
**Gloss over! Standardize Variables So ( x P(x) ) ( x Q(x) ) becomes**

Make sure that you are not using the same variable name twice in a single sentence (unless you really meant to). So ( x P(x) ) ( x Q(x) ) becomes ( x P(x) ) ( z Q(z) ) Gloss over!

36
**Gloss over! Move Quantifiers left So x P(x) y Q(y) becomes**

Move all quantifiers left, but keep them in order! So x P(x) y Q(y) becomes x y P(x) Q(y) Gloss over!

37
**Skolemize {Eliminate Existential Quantifiers, Drop Universal Quantifiers }**

Existential quantifiers can be eliminated by the introduction of a new constant that does not appear elsewhere in the database. x P(x) Q(x) becomes P(A) Q(A) SUBST{x/A} One possible complication occurs if we also have Universal quantifiers… Consider x person(x) y heart(y) has(x,y) Becomes by SUBST{y/H} x person(x) heart(H) has(x,H) !!! Instead we have to create a new (Skolem) function to map from a person to their heart F(x) x person(x) heart(F(x)) has(x,F(x)) Gloss over! Drop Universal Quantifiers

38
**Just like distribution in arithmetic**

Distribute over (A B) C becomes (A C) (A B) Just like distribution in arithmetic (5 + 4) * becomes (5 * 6 ) + (4 * 6 ) Gloss over!

39
**Gloss over! Flatten nested conjunctions and disjunctions.**

(A B) C becomes (A B C) (A B) C becomes (A B C) Gloss over!

40
Done!! Eliminate Implications Move inwards Standardize Variables Move Quantifiers left Skolemize {Eliminate Existential Quantifiers, Drop Universal Quantifiers } Distribute over Flatten nested conjunctions and disjunctions. Once we have done all the above steps, our KB is in CNF. We can now do resolution refutation. There is still an element of search, we have to decide which pairs of sentences to resolve, and which substitutions we should use. The goal is simply to find a contradiction. There are many heuristics for the search (Our textbook lists Unit preference, Set of support, Input resolution )

41
Bad News Even with all the heuristics resolution is exponential in general. Resolution is complete, but only semidecidable. If our KB implies A (or it implies A), resolution will find the proof in finite time. But if the KB does not implies A (or A), resolution will simply run forever.

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google