Backward chaining Assume the same representation of rules as in forward chaining, i.e. If is true, is true, … is true Then is true. Rule interpretation.

Slides:



Advertisements
Similar presentations
Some Prolog Prolog is a logic programming language
Advertisements

Inference Rules Universal Instantiation Existential Generalization
SLD-resolution Introduction Most general unifiers SLD-resolution
Introduction to Theorem Proving
Standard Logical Equivalences
1 Logic Logic in general is a subfield of philosophy and its development is credited to ancient Greeks. Symbolic or mathematical logic is used in AI. In.
Artificial Intelligence
Inference and Reasoning. Basic Idea Given a set of statements, does a new statement logically follow from this. For example If an animal has wings and.
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.
Methods of Proof Chapter 7, second half.. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound)
For Friday No reading Homework: –Chapter 9, exercise 4 (This is VERY short – do it while you’re running your tests) Make sure you keep variables and constants.
Logic Use mathematical deduction to derive new knowledge.
13 Automated Reasoning 13.0 Introduction to Weak Methods in Theorem Proving 13.1 The General Problem Solver and Difference Tables 13.2 Resolution.
Methods of Proof Chapter 7, Part II. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound) generation.
Logic.
Resolution in Propositional and First-Order Logic.
Inferences The Reasoning Power of Expert Systems.
Forward chaining: an overview We start with a set of data collected through observations, and check each rule to see if the data satisfy its premises.
Artificial Intelligence Chapter 14. Resolution in the Propositional Calculus Artificial Intelligence Chapter 14. Resolution in the Propositional Calculus.
1 Applied Computer Science II Resolution in FOL Luc De Raedt.
Formal Logic Proof Methods Direct Proof / Natural Deduction Conditional Proof (Implication Introduction) Reductio ad Absurdum Resolution Refutation.
Proof methods Proof methods divide into (roughly) two kinds: –Application of inference rules Legitimate (sound) generation of new sentences from old Proof.
Inference in FOL Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 9 Spring 2004.
1 Automated Reasoning Introduction to Weak Methods in Theorem Proving 13.1The General Problem Solver and Difference Tables 13.2Resolution Theorem.
Inference and Resolution for Problem Solving
Existential Graphs and Davis-Putnam April 3, 2002 Bram van Heuveln Department of Cognitive Science.
Methods of Proof Chapter 7, second half.
Knoweldge Representation & Reasoning
Chapter 3 Propositional Logic
Artificial Intelligence
Artificial Intelligence Chapter 14 Resolution in the Propositional Calculus Artificial Intelligence Chapter 14 Resolution in the Propositional Calculus.
CS1502 Formal Methods in Computer Science Lecture Notes 10 Resolution and Horn Sentences.
INFERENCE IN FIRST-ORDER LOGIC IES 503 ARTIFICIAL INTELLIGENCE İPEK SÜĞÜT.
Methods of Proof & Proof Strategies
Notes for Chapter 12 Logic Programming The AI War Basic Concepts of Logic Programming Prolog Review questions.
Inference is a process of building a proof of a sentence, or put it differently inference is an implementation of the entailment relation between sentences.
Proof Systems KB |- Q iff there is a sequence of wffs D1,..., Dn such that Dn is Q and for each Di in the sequence: a) either Di is in KB or b) Di can.
Inference in First-Order logic Department of Computer Science & Engineering Indian Institute of Technology Kharagpur.
CS 4100 Artificial Intelligence Prof. C. Hafner Class Notes Jan 19, 2012.
1 Sections 1.5 & 3.1 Methods of Proof / Proof Strategy.
Logical Inference 2 rule based reasoning
Pattern-directed inference systems
Advanced Topics in Propositional Logic Chapter 17 Language, Proof and Logic.
Logical Agents Logic Propositional Logic Summary
1 Knowledge Representation. 2 Definitions Knowledge Base Knowledge Base A set of representations of facts about the world. A set of representations of.
ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM] Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information.
Unification Algorithm Input: a finite set Σ of simple expressions Output: a mgu for Σ (if Σ is unifiable) 1. Set k = 0 and  0 = . 2. If Σ  k is a singleton,
CS Introduction to AI Tutorial 8 Resolution Tutorial 8 Resolution.
Logical Agents Chapter 7. Knowledge bases Knowledge base (KB): set of sentences in a formal language Inference: deriving new sentences from the KB. E.g.:
Automated Reasoning Early AI explored how to automated several reasoning tasks – these were solved by what we might call weak problem solving methods as.
Automated Reasoning Early AI explored how to automate several reasoning tasks – these were solved by what we might call weak problem solving methods as.
© Copyright 2008 STI INNSBRUCK Intelligent Systems Propositional Logic.
For Wednesday Finish reading chapter 10 – can skip chapter 8 No written homework.
Dr. Shazzad Hosain Department of EECS North South Universtiy Lecture 04 – Part B Propositional Logic.
Lecture 9a: Resolution Strategies Heshaam Faili University of Tehran Restriction strategies for resolution Horn clauses.
1 Propositional Logic Limits The expressive power of propositional logic is limited. The assumption is that everything can be expressed by simple facts.
Logical Agents Chapter 7. Outline Knowledge-based agents Propositional (Boolean) logic Equivalence, validity, satisfiability Inference rules and theorem.
Answer Extraction To use resolution to answer questions, for example a query of the form  X C(X), we must keep track of the substitutions made during.
Proof Methods for Propositional Logic CIS 391 – Intro to Artificial Intelligence.
Copyright 1999Paul F. Reynolds, Jr. Foundations of Logic Programming.
Logical Agents. Outline Knowledge-based agents Logic in general - models and entailment Propositional (Boolean) logic Equivalence, validity, satisfiability.
EA C461 Artificial Intelligence
Resolution in the Propositional Calculus
Logic Use mathematical deduction to derive new knowledge.
Biointelligence Lab School of Computer Sci. & Eng.
Artificial Intelligence: Agents and Propositional Logic.
CS 416 Artificial Intelligence
Biointelligence Lab School of Computer Sci. & Eng.
Methods of Proof Chapter 7, second half.
Inference in FOL All PL inference rules hold in FOL, as well as the following additional ones: Universal elimination rule: x, A ===> Subst({x / g}, A).
Presentation transcript:

Backward chaining Assume the same representation of rules as in forward chaining, i.e. If is true, is true, … is true Then is true. Rule interpretation starts with (i) an empty fact base, and (ii) a list of goals which the system tries to derive, and consists of the following steps: 1Form a stack initially composed of all “top-level” goals. 2Consider the first goal from the stack, and gather all of the rules capable of satisfying this goal. 3For each of these rules, examine the rule’s premises: If all premises are satisfied, execute the rule to infer its conclusion, and remove the satisfied goal from the stack.

Backward chaining (cont.)  If there is a premise which is not satisfied, look for rules by means of which this premise can be derived; if such rules exist, add the premise as a sub-goal on the top of the stack, and go to 2. If no rule exists to satisfy the unknown premise, place a query to the user and add the supplied value to the fact base. If the premise cannot be satisfied, consider the next rule which has the initial goal as its conclusion. 4If all rules that can satisfy the current goal have been attempted, and all failed, then the goal is unsatisfiable; remove the unsatisfiable goal from the stack and go to 2. If the stack is empty (i.e. all of the goals have been satisfied) stop.

The fruit identification example Assuming that we do not have any information about the object that we are trying to recognize, let the “top-level” goal be (fruit = (? X)). Step1 Initial fact base: ( ) Initial stack of goals: ((fruit = (? X))) Step 2 Rules capable of satisfying this goal are: 1, 1A, 6, 7, 8, 9, 10, 11, 12, 13, 13A, 13B. Step 3 Consider Rule 1. Its first premise is (shape = long). There is no data in the FB matching this premise and no rule has (shape = (? Y)) as its conclusion. Therefore, a query is placed to the user to acquire for the shape of the fruit under consideration. Assume that the user replies that the fruit is round, i.e. the current FB becomes Current fact base: ((shape = round)). Rule 1 fails, and Rule 6 is examined next. The first premise of Rule 6 results in a new goal which is added at the beginning of the current stack of goals. Current stack of goals: ((fruitclass = (? Y)) (fruit = (? X)))

The fruit identification example (cont.) There are three rules capable of satisfying the newly stated goal, namely 2, 2A, and 3.The first premise of Rule 2, (shape = round), matches a datum in the FB. The second premise leads to a new query regarding the diameter of the fruit. Assume that the answer is (diameter = 1 inch). Current fact base: ((shape = round)(diameter = 1 inch)). Rules 2 and 2A fail, and Rule 3 is examined next. It succeeds, thus a new conclusion, (fruitclass = tree) is added to the FB and the first goal is removed from the current stack of goals. Current fact base: ((shape = round)(diameter = 1 inch)(fruitclass = tree)). Now Rules 6, 7 and 8 fail, and Rule 9 is examined next. Its first premise succeeds, but its second premise places a new query regarding the color of the fruit. Assume that the user enters (color = red), which fails Rules 9 and 10. The first two premises of Rule 11 are satisfied, the third premise places a query regarding the seedclass. Rules 4 and 5 have conclusions (seedclass = (? Z)), which becomes a new subgoal. Rule 4 only premise (seedcouunt = 1) cannot be dirived by any rule --> place a query to the user about the seedcount and assume that the answer is (seedcouunt = 1). Rule 4 succeeds and (seedclass = stonefruit), is added to the FB resulting in all premisses of Rule 11 to hold and its conclusion (fruit = cherry) is added to the FB. Note that this proves our top-level goal. Current fact base: ((shape = round)(diameter = 1 inch)(fruitclass = tree)(color = red)(seedcount = 1)(seedclass = stonefruit)(fruit = cherry)). Current stack of goals: () Step 4 Stop, no more goals remain to be proved.

Mixed modes of chaining Consider the following set of rules: Rule 1: F & H => K Rule 2: E & A => K Backward chaining rules Rule 3: E & B => H Rule 4: A & G => B Rule 5: B & D => H Rule 6: G & D => E Forward chaining rules Rule 7: A & B => D Rule 8: A & C => G Assume that A and C are the only known facts, and we want to infer K (the only top-level goal). Because the set of rules is divided into two subsets, backward and forward chaining rules, the are two ways in which these rules can be applied: 1Forward chaining rules have a higher priority, thus they are the first ones to be tried. 2Backward chaining rules have a higher priority.

Priority to forward chaining rules (example cont.) Assuming that the forward chaining rules have a higher priority, the inference process is carried out as follows, given FB: (A, C) and goal K. Step 1: Attempt to fire only forward chaining rules for as long as possible. Rule 8 fires thus the current FB becomes (A, C, G) Rule 4 fires thus the current FB becomes (A, C, G, B) Rule 7 fires thus the current FB becomes (A, C, G, B, D) Rule 5 fires thus the current FB becomes (A, C, G, B, D, H) Rule 6 fires thus the current FB becomes (A, C, G, B, D, H, E) Step 2: If no more forward chaining rules can fire, and the goal has not been derived, proceed with the backward chaining rules. Rule 1 is attempted, but fails. Rule 2 succeeds, thus K is proven.

Priority to backward chaining rules (example cont.) Assuming that the backward chaining rules have a higher priority, the inference process is carried out as follows: Step 1: Search for a backward chaining rule which has K as its conclusion. Rule 1 is such a rule, which will fire only if F and H are satisfied. Therefore, F and H become new goals. Step 1A: Search for a backward chaining rule whose conclusion is F. There is no such a rule, therefore this goal fail. Step 1B: Search for a backward chaining rule whose conclusion is H. Rule 3 is such a rule, and it in turn creates two new goals, E and B. However, there are no backward chaining rules whose conclusions are F, E or B, which is why the forward chaining rules must be activated next.

Priority to backward chaining rules (example cont.) Step 2: Given the fact base (A, C), forward chaining rules will fire in the following order: Rule 8 fires thus the current FB becomes (A, C, G). Rule 4 fires thus the current FB becomes (A, C, G, B). The derivation of B satisfies one of the goals on the stack of goals. The remaining goals are F and E. Rule 7 fires thus the current FB becomes (A, C, G, B, D). Rule 5 fires, thus the current FB becomes (A, C, G, B, D, H). Rule 6 fires, thus the current FB becomes (A, C, G, B, D, H, E). The derivation of E satisfies one of the current goals, which leaves F as the only goal that remains to be proved. However, no more forward chaining rules can fire meaning that F cannot be proved by either forward chaining or backward chaining rules. Step 3: Because our top-level goal was to prove K, we look for another backward chaining rule, which has K as its conclusion. Rule 2 is such a rule, and it can fire because both of its premises are satisfied at this point, thus proving our original goal K.

Completeness of the chaining algorithms Consider the following set of sentences:  x hungry(x) => likes(x, apple)  x ¬hungry(x) => likes(x, grapes)  x likes(x,apple) => likes(x, fruits)  x likes(x,grapes) => likes(x, fruits) Assume that we want to prove likes(Bob, fruits). Obviously, this is true if likes(Bob, apple) v likes(Bob, grapes) is true, which is always true, because the first disjunct depends on hungry(Bob) and the second disjunct depends on ¬hungry(Bob). None of the chaining algorithms, however, will allow us to infer likes(Bob, fruits). The reason is that  x ¬hungry(x) => likes(x, grapes) is not a Horn formula. Chaining algorithms, which use the generalized MP as the only inference rule, are incomplete for non-Horn KBs.

Why do we need a stronger inference rule? Consider the following example: Bob wants to take CS 501 next semester. This class will meet either MW 6: :00, or TR 6: :00. Bob has to be at his soccer sessions MTF 5: :30. Can he take CS 501? Initial KB: MW(CS501, ) v TR(CS501, ) MW(CS501, ) & Busy(Bob, M, ) => nogood-class(Bob) TR(CS501, ) & Busy(Bob, T, ) => nogood-class(Bob) Busy(Bob, M, ) Busy(Bob, T, ) Possible inferences: MW(CS501, ) => nogood-class(Bob) …. (A) TR(CS501, ) => nogood-class(Bob) ….. (B)

The resolution rule can help We can draw more inferences if we look at MW(CS501, ) v TR(CS501, ) as describing two different cases: Case 1: MW(CS501, ) is true, in which case nogood-class(Bob) is true by means of (A). Case 2: TR(CS501, ) is true, in which case nogood-class(Bob) is true by means of (B). The answer to the initial query is derived no matter which is the right case. This type of reasoning is called case analysis, and it can be carried out by means of the resolution rule as follows: ¬MW(CS501, ) v nogood-class(Bob) MW(CS501, ) v TR(CS501, ) nogood-class(Bob) v TR(CS501, ) ¬TR(CS501, ) v nogood-class(Bob) nogood-class(Bob) v nogood-class(Bob)  nogood-class(Bob)

The resolution rule revisited Recall the resolution rule for propositional logic: (A v B, ¬B v C  A v C)  (¬A => B, B => C  ¬A => C) There are two different ways to interpret this rule: 1As describing 2 cases, namely B is true, ¬B is false, in which case C is true. ¬B is true, B is false, in which case A is true. In both cases, A v C is true. 2Because the implication operation is transitive, the resolution rule let us link the premise of one implication with the conclusion of the second implication, ignoring intermediate sentence B, i.e. let us derive a new implication. None of these can be done with MP, because MP derives only atomic conclusions.

Consider the following propositional version of generalized MP: A1 & A2 & … & Am => B D1 & D2 & … & Dn => C From these two formulas, we can infer the following one making use of the monotonicity of the PL: A1 & A2 & … & Am & D1 & D2 & … & Dn => B Assume now that B = B1 v B2 v … v Bk, and C = Ai A1 & A2 & … & Am => B1 v B2 v … v Bk D1 & D2 & … & Dn => C A1 & A2 & …& A(i-1) & D1 & D2 & … & Dn & A(i+1) & … & Am => B1 v B2 v … v Bk Consider the following cases: 1If A’s hold, then at least one B holds. 2If m = 0, then our formula degenerates to a form B1 v B2 v … v Bk 3If k = 1, then our formula has the form A1 & A2 & … & Am => B1

4If k = 0, then A1 & A2 & … & Am => False, which is equivalent to ¬(A1&A2&…&Am), which is in turn equivalent to ¬A1 v … v ¬Am. Note that at the same time m = 1, then we can represent negated formulas such as ¬student(Bob), or in its equivalent form, student(Bob) => False. If m = 0, then we have True => False, which represents a contradiction. That is, formulas of the form A1 & A2 & … & Am => B1 v … v Bk are general enough to represent any logical formula. If a KB is comprised of only formulas of this type, we say that it is in a normal form. We need a generalized version of the resolution rule to work with such KBs.

The generalized resolution rule: definition Generalized resolution is the following rule of inference: A1 & A2 & … & Am => B1 v B2 v … v Bk D1 & D2 & … & Dn => C1 v C2 v … v Cx A1 & … & Ai & … & Am & D1 & … & Dn => B1 v … v Bk v C1 v… v Cj v… v Cx Here Ai = Cj, which is why we can ignore them from the l.h.s. and r.h.s. of the implication, respectively. Here is the alternative version of generalized resolution: A1 v A2 v … v Ai v … v Ap C1 v C2 v … v Cj v … v Ck A1 v A2 v … v Ai v… v Ap v C1 v… v Cj v… v Cx Here Ai = ¬Cj, which is why we can ignore them both.

Proving formulas by the resolution rule If we have a FOL KB, then Ai and Cj (in the first case, or ¬Cj in the second case), will be the same if there is a substitution  such that subst( , Ai) = subst( , Cj) (or subst( , Ai) = subst( , ¬Cj), respectively). Assuming that all formulas in the KB are in a normal form, we can apply the resolution rule in forward or backward chaining algorithms. Example: Consider the following KB ¬P(w) v Q(w), P(x) v R(x), ¬Q(y) v S(y), ¬R(z) v S(z). Using forward chaining, the following conclusions can be derived: ¬P(w) v Q(w) ¬Q(y) v S(y) {y / w} These are ¬P(w) v S(w) P(x) v R(x) called {w / x} resolvents. S(x) v R(x) ¬R(z) v S(z). {x /A, z /A} S(A) v S(A)  S(A)

Completeness of the chaining process with the resolution rule Chaining with the resolution rule is still an incomplete inference procedure. To see why, consider an empty KB from which you want to derive P v ¬P. Note that this is a valid formula, therefore it follows from any KB including the empty KB. However, using only the resolution rule, we cannot prove it. Assume that we add ¬(P v ¬P)  (¬P & P)  (¬P, P). Adding a negation of a valid formula to the exiting KB introduces a contradiction in that KB. If we can prove that KB & ¬A => False, where KB |= A, then we prove that KB |-- A. In the example above { P, ¬P} => Nil, which proves P v ¬P.

The refutation method The inference procedure that proves a formula by showing that its negation, if added to the KB, leads to a contradiction is called refutation. The following procedure implements the refutation method: 1Negate the theorem to be proved, and add the result to the set of axioms. 2Put a list of axioms into a normal form 3Until there is no resolvable pair of clauses do: aFind resolvable clauses, and resolve them. bAdd the result of the resolution to the list of clauses. cIf Nil is produced, stop (the theorem has been proved by refutation). 4Stop (the theorem is false). The refutation method is a complete inference procedure.

Example Consider the following set of axioms: ¬hungry(w) v likes(w, apple) hungry(x) v likes(x, grapes) ¬likes(y,apple) v likes(y, fruits) ¬likes(z,grapes) v likes(z, fruits) Assume that we want to prove likes(Bob, fruits). Therefore, we must add ¬likes(Bob, fruits) to the set of axioms. ¬hungry(w) v likes(w, apple) ¬likes(y,apple) v likes(y, fruits) {y / w} ¬hungry(w) v likes(w, fruits) hungry(x) v likes(x, grapes) {w / x} likes(x, fruits) v likes(x, grapes) ¬likes(z,grapes) v likes(z, fruits) {z / x} likes(x, fruits) ¬likes(Bob, fruits) {x / Bob} Nil

Problems with the resolution rule The resolution proof is exponential, which is why we must use some strategies to direct it. The following two ideas can help here: 1Every resolution involves the negated theorem or a derived clause which has used the negated theorem directly or indirectly. 2Always remember what your goal is, so that given what you currently have, you can find the difference, and using your intuition try to reduce this difference to get closer to the goal. This ideas can be implemented as resolution strategies working at a meta- logical level. Among the most popular strategies are the following: 1Unit preference. Always prefer a single literal when doing resolution. This strategy was found efficient only for relatively small problems. 2Set of support. The current resolution involves the negated theorem or the new clauses directly or indirectly involving it. The set of such clauses plus the theorem are called the support set. Initially, the support set involves only the negated theorem.

Resolution strategies (cont.) 3The breadth-first strategy. First resolve all possible pairs of initial clauses, then resolve all possible pairs of the resulting set together with the initial set, and so on. 4Input resolution. Every resolution uses one of the initial clauses or the negated theorem. If we allow resolutions to use also clauses where one clause is an ancestor or another clause, we have the strategy called linear resolution. 5Subsumption. Eliminate all sentences subsumed by other sentences. For example, if P(x)  KB, then P(A) will not be added if inferred, because it is subsumed by P(x). Note that in order to apply the refutation method, we must first convert the initial set of sentences into a normal form.