Forward and Backward Chaining

Slides:



Advertisements
Similar presentations
Computer Science CPSC 322 Lecture 25 Top Down Proof Procedure (Ch 5.2.2)
Advertisements

Inference Rules Universal Instantiation Existential Generalization
CHAPTER 13 Inference Techniques. Reasoning in Artificial Intelligence n Knowledge must be processed (reasoned with) n Computer program accesses knowledge.
1 Rule Based Systems Introduction to Production System Architecture.
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.
Methods of Proof Chapter 7, second half.. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound)
Reasoning Forward and Backward Chaining Andrew Diniz da Costa
Methods of Proof Chapter 7, Part II. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound) generation.
Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Logic.
CS 484 – Artificial Intelligence1 Announcements Choose Research Topic by today Project 1 is due Thursday, October 11 Midterm is Thursday, October 18 Book.
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.
B. Ross Cosc 4f79 1 Forward chaining backward chaining systems: take high-level goal, and prove it by reducing it to a null goal - to reduce it to null,
Reasoning System.  Reasoning with rules  Forward chaining  Backward chaining  Rule examples  Fuzzy rule systems  Planning.
Intelligent systems Lecture 6 Rules, Semantic nets.
Knowledge Engineering.  Process of acquiring knowledge from experts and building knowledge base  Narrow perspective  Knowledge acquisition, representation,
Rule Based Systems Michael J. Watts
Artificial Intelligence Lecture No. 16
Chapter 12: Expert Systems Design Examples
Expert System Human expert level performance Limited application area Large component of task specific knowledge Knowledge based system Task specific knowledge.
Proof methods Proof methods divide into (roughly) two kinds: –Application of inference rules Legitimate (sound) generation of new sentences from old Proof.
Introduction to Expert Systems
1 5.0 Expert Systems Outline 5.1 Introduction 5.2 Rules for Knowledge Representation 5.3 Types of rules 5.4 Rule-based systems 5.5 Reasoning approaches.
Lecture 04 Rule Representation
Knowledge in intelligent systems So far, we’ve used relatively specialized, naïve agents. How can we build agents that incorporate knowledge and a memory?
1 Pertemuan 6 RULE-BASED SYSTEMS Matakuliah: H0383/Sistem Berbasis Pengetahuan Tahun: 2005 Versi: 1/0.
1 Chapter 9 Rules and Expert Systems. 2 Chapter 9 Contents (1) l Rules for Knowledge Representation l Rule Based Production Systems l Forward Chaining.
Rules and Expert Systems
Methods of Proof Chapter 7, second half.
Production Rules Rule-Based Systems. 2 Production Rules Specify what you should do or what you could conclude in different situations. Specify what you.
Knoweldge Representation & Reasoning
EXPERT SYSTEMS Part I.
Logical Agents Chapter 7 Feb 26, Knowledge and Reasoning Knowledge of action outcome enables problem solving –a reflex agent can only find way from.
Modelling planning problems using PDDL
CPSC 433 Artificial Intelligence CPSC 433 : Artificial Intelligence Tutorials T01 & T02 Andrew “M” Kuipers note: please include.
Prof. Bodik CS 164 Lecture 16, Fall Global Optimization Lecture 16.
INTELLIGENT SYSTEMS Rule based systems 1. Aims of session To understand  Basic principles  Forward chaining  Problems with rule-based systems  Backward.
Production Systems A production system is –a set of rules (if-then or condition-action statements) –working memory the current state of the problem solving,
IDDS: Rules-based Expert Systems
Knowledge based Humans use heuristics a great deal in their problem solving. Of course, if the heuristic does fail, it is necessary for the problem solver.
Chapter 9: Rules and Expert Systems Lora Streeter.
‘In which we introduce a logic that is sufficent for building knowledge- based agents!’
Logical Agents Logic Propositional Logic Summary
ARTIFICIAL INTELLIGENCE DR. ABRAHAM AI a field of computer science that is concerned with mechanizing things people do that require intelligent.
Rule Based Systems  If then  Rules to solve problems  What is forward chaining?  What is backward chaining?  Expert systems.
Expert System Note: Some slides and/or pictures are adapted from Lecture slides / Books of Dr Zafar Alvi. Text Book - Aritificial Intelligence Illuminated.
1 Defining a Problem as a State Space 1. Define a state space that contains all the possible configurations of the relevant objects. 2. Specify one (or.
COM362 Knowledge Engineering Inferencing 1 Inferencing: Forward and Backward Chaining John MacIntyre
Types of logic. Propositional logic: syntax Limitations of Propositional Logic 1. It is too weak, i.e., has very limited expressiveness: Each rule has.
1 Knowledge Based Systems (CM0377) Lecture 10 (Last modified 19th March 2001)
Inferencing in rule-based systems: forward and backward chaining.
Chapter 4: Inference Techniques
© Copyright 2008 STI INNSBRUCK Intelligent Systems Propositional Logic.
1 Propositional Logic Limits The expressive power of propositional logic is limited. The assumption is that everything can be expressed by simple facts.
Review: What is a logic? A formal language –Syntax – what expressions are legal –Semantics – what legal expressions mean –Proof system – a way of manipulating.
Proof Methods for Propositional Logic CIS 391 – Intro to Artificial Intelligence.
Artificial Intelligence: Applications
By Muhammad Safdar MCS [E-Section].  There are times in life when you are faced with challenging decisions to make. You have rules to follow and general.
11 Making Decisions in a Program Session 2.3. Session Overview  Introduce the idea of an algorithm  Show how a program can make logical decisions based.
Logical Agents. Outline Knowledge-based agents Logic in general - models and entailment Propositional (Boolean) logic Equivalence, validity, satisfiability.
EA C461 Artificial Intelligence
Advanced AI Session 2 Rule Based Expert System
Chapter 9. Rules and Expert Systems
EA C461 – Artificial Intelligence Logical Agent
Forward Chaining DFS can supply compatible bindings for forward chaining.
CPSC 433 : Artificial Intelligence Tutorials T01 & T02
Chapter 9. Rules and Expert Systems
Methods of Proof Chapter 7, second half.
Inference and Resolution for Problem Solving
Presentation transcript:

Forward and Backward Chaining

Rule-Based Systems Instead of representing knowledge in a relatively declarative, static way (as a bunch of things that are true), rule-based system represent knowledge in terms of a bunch of rules that tell you what you should do or what you could conclude in different situations. A rule-based system consists of a bunch of IF-THEN rules, a bunch of facts, and some interpreter controlling the application of the rules, given the facts.

Two broad kinds of rule system Forward chaining systems and Backward chaining systems. Forward chaining is a data driven method of deriving a particular goal from a given knowledge base and set of inference rules. Inference rules are applied by matching facts to the antecedents of consequence relations in the knowledge base

Cont’d… In a forward chaining system you start with the initial facts, and keep using the rules to draw new conclusions (or take certain actions) given those facts. Forward chaining systems are primarily data-driven Inference rules are successively applied to elements of the knowledge base until the goal is reached

Cont’d… A search control method is needed to select which element(s) of the knowledge base to apply the inference rule to at any point in the deduction. facts in the system are represented in a working memory which is continually updated.

Cont’d… Rules in the system represent possible actions to take when specified conditions hold on items in the working memory they are sometimes called condition-action rules The conditions are usually patterns that must match items in the working memory.

Forward Chaining Systems actions usually involve adding or deleting items from the working memory. interpreter controls the application of the rules, given the working memory, thus controlling the system's activity. It is based on a cycle of activity sometimes known as a recognize-act cycle The system first checks to find all the rules whose conditions hold selects one and performs the actions in the action part of the rule selection of a rule to fire is based on fixed strategies, known as conflict resolution strategies

Forward Chaining Systems The actions will result in a new working memory, and the cycle begins again. This cycle will be repeated until either no rules fire, or some specified goal state is satisfied. Rule-based systems vary greatly in their details and syntax, so the following examples are only illustrative

Forward Chaining Example Knowledge Base: If [X croaks and eats flies] Then [X is a frog] If [X chirps and sings] Then [X is a canary] If [X is a frog] Then [X is colored green] If [X is a canary] Then [X is colored yellow] [Fritz croaks and eats flies] Goal: [Fritz is colored Y]?

Forward Chaining Example Knowledge Base If [X croaks and eats flies] Then [X is a frog] If [X chirps and sings] Then [X is a canary] If [X is a frog] Then [X is colored green] If [X is a canary] Then [X is colored yellow] [Fritz croaks and eats flies] Goal [Fritz is colored Y]? CPSC 433 Artificial Intelligence

Forward Chaining Example Knowledge Base If [X croaks and eats flies] Then [X is a frog] If [X chirps and sings] Then [X is a canary] If [X is a frog] Then [X is colored green] If [X is a canary] Then [X is colored yellow] [Fritz croaks and eats flies] Goal [Fritz is colored Y]? CPSC 433 Artificial Intelligence

Forward Chaining Example Knowledge Base If [X croaks and eats flies] Then [X is a frog] If [X chirps and sings] Then [X is a canary] If [X is a frog] Then [X is colored green] If [X is a canary] Then [X is colored yellow] [Fritz croaks and eats flies] Goal [Fritz is colored Y]? [Fritz croaks and eats flies] If [X croaks and eats flies] Then [X is a frog] [Fritz is a frog] CPSC 433 Artificial Intelligence

Forward Chaining Example Knowledge Base If [X croaks and eats flies] Then [X is a frog] If [X chirps and sings] Then [X is a canary] If [X is a frog] Then [X is colored green] If [X is a canary] Then [X is colored yellow] [Fritz croaks and eats flies] [Fritz is a frog] Goal [Fritz is colored Y]? [Fritz croaks and eats flies] If [X croaks and eats flies] Then [X is a frog] [Fritz is a frog] CPSC 433 Artificial Intelligence

Forward Chaining Example Knowledge Base If [X croaks and eats flies] Then [X is a frog] If [X chirps and sings] Then [X is a canary] If [X is a frog] Then [X is colored green] If [X is a canary] Then [X is colored yellow] [Fritz croaks and eats flies] [Fritz is a frog] Goal [Fritz is colored Y]? [Fritz croaks and eats flies] If [X croaks and eats flies] Then [X is a frog] [Fritz is a frog] ? CPSC 433 Artificial Intelligence

Forward Chaining Example Knowledge Base If [X croaks and eats flies] Then [X is a frog] If [X chirps and sings] Then [X is a canary] If [X is a frog] Then [X is colored green] If [X is a canary] Then [X is colored yellow] [Fritz croaks and eats flies] [Fritz is a frog] Goal [Fritz is colored Y]? If [X croaks and eats flies] Then [X is a frog] [Fritz croaks and eats flies] [Fritz is a frog] CPSC 433 Artificial Intelligence

Forward Chaining Example Knowledge Base If [X croaks and eats flies] Then [X is a frog] If [X chirps and sings] Then [X is a canary] If [X is a frog] Then [X is colored green] If [X is a canary] Then [X is colored yellow] [Fritz croaks and eats flies] [Fritz is a frog] Goal [Fritz is colored Y]? If [X croaks and eats flies] Then [X is a frog] [Fritz croaks and eats flies] If [X is a frog] Then [X is colored green] [Fritz is a frog] [Fritz is colored green] CPSC 433 Artificial Intelligence

Forward Chaining Example Knowledge Base If [X croaks and eats flies] Then [X is a frog] If [X chirps and sings] Then [X is a canary] If [X is a frog] Then [X is colored green] If [X is a canary] Then [X is colored yellow] [Fritz croaks and eats flies] [Fritz is a frog] [Fritz is colored green] Goal [Fritz is colored Y]? If [X croaks and eats flies] Then [X is a frog] [Fritz croaks and eats flies] If [X is a frog] Then [X is colored green] [Fritz is a frog] [Fritz is colored green] CPSC 433 Artificial Intelligence

Forward Chaining Example If [X croaks and eats flies] Then [X is a frog] Knowledge Base If [X croaks and eats flies] Then [X is a frog] If [X chirps and sings] Then [X is a canary] If [X is a frog] Then [X is colored green] If [X is a canary] Then [X is colored yellow] [Fritz croaks and eats flies] [Fritz is a frog] [Fritz is colored green] Goal [Fritz is colored Y]? [Fritz croaks and eats flies] If [X is a frog] Then [X is colored green] [Fritz is a frog] [Fritz is colored green] ? CPSC 433 Artificial Intelligence

Forward Chaining Example If [X croaks and eats flies] Then [X is a frog] Knowledge Base If [X croaks and eats flies] Then [X is a frog] If [X chirps and sings] Then [X is a canary] If [X is a frog] Then [X is colored green] If [X is a canary] Then [X is colored yellow] [Fritz croaks and eats flies] [Fritz is a frog] [Fritz is colored green] Goal [Fritz is colored Y]? [Fritz croaks and eats flies] If [X is a frog] Then [X is colored green] [Fritz is a frog] [Fritz is colored green] CPSC 433 Artificial Intelligence

Forward Chaining Example If [X croaks and eats flies] Then [X is a frog] Knowledge Base If [X croaks and eats flies] Then [X is a frog] If [X chirps and sings] Then [X is a canary] If [X is a frog] Then [X is colored green] If [X is a canary] Then [X is colored yellow] [Fritz croaks and eats flies] [Fritz is a frog] [Fritz is colored green] Goal [Fritz is colored Y]? [Fritz croaks and eats flies] If [X is a frog] Then [X is colored green] [Fritz is a frog] [Fritz is colored green] [Fritz is colored Y] ? Y = green CPSC 433 Artificial Intelligence

Backward chaining Backward chaining is a goal driven method of deriving a particular goal from a given knowledge base and set of inference rules Inference rules are applied by matching the goal of the search to the consequents of the relations stored in the knowledge base

Cont’d... When such a relation is found, the antecedent of the relation is added to the list of goals (and not into the knowledge base, as is done in forward chaining) Search proceeds in this manner until a goal can be matched against a fact in the knowledge base

Cont’d… As with forward chaining, a search control method is needed to select which goals will be matched against which consequence relations from the knowledge base backward chaining systems are goal-driven

Backward Chaining Systems In a backward chaining system you start with some hypothesis (or goal) you are trying to prove, and keep looking for rules that would allow you to conclude that hypothesis, perhaps setting new sub goals to prove as you go

Cont’d So far we have looked at how rule-based systems can be used to draw new conclusions from existing data, adding these conclusions to a working memory This approach is most useful when you know all the initial facts, but don't have much idea what the conclusion might be If you DO know what the conclusion might be, or have some specific hypothesis to test, forward chaining systems may be inefficient

backward chaining system Note that a backward chaining system does NOT need to update a working memory Instead it needs to keep track of what goals it needs to prove its main hypothesis. Lets take an example ……………..

Forward chaining vs. backward chaining Data-driven, forward chaining Starts with the initial given data and search for the goal. At each iteration, new conclusion (RHS) becomes the pattern to look for next Working memory contains true sentences (RHS’s). Stop when the goal is reached. Goal-driven is the reverse. Starts with the goal and try to search for the initial given data. At each iteration, new premise (LHS) becomes the new sub goals, the pattern to look for next working memory contains sub goals (LHS’s) to be satisfied. Stop when all the premises (sub goals) of fired productions are reached. Sense of the arrow is in reality reversed. Both repeatedly pick the next rule to fire.

Cont’d….. condition  action premise  conclusion Forward chaining Backward chaining Starts with premise conclusion Search for Working memory true statements sub goals to be proved Stopping criteria goal is reached Initial data are reached Data-driven Goal-driven

Combining forward- and backward-chaining Begin with data and search forward until the number of states becomes unmanageably large. Switch to goal-directed search to use sub goals to guide state selection.

Strategies These strategies may help in getting reasonable behavior from a forward chaining system, but the most important thing is how we write the rules. They should be carefully constructed, with the preconditions specifying as precisely as possible when different rules should fire. Otherwise we will have little idea or control of what will happen

Conclusion Goal-driven, backward chaining Data-driven, forward chaining conditions first, then actions working memory contains true statements describing the current environment actions first, then conditions (sub goals) working memory contains sub goals to be shown as true

Forwards vs. Backwards Reasoning Whether you use forward or backwards reasoning to solve a problem depends on the properties of your rule set and initial facts. Sometimes, if you have some particular goal (to test some hypothesis), then backward chaining will be much more efficient, as you avoid drawing conclusions from irrelevant facts.

However, sometimes backward chaining can be very wasteful - there may be many possible ways of trying to prove something, and you may have to try almost all of them before you find one that works. Forward chaining may be better if you have lots of things you want to prove when you have a small set of initial facts; and when there tend to be lots of different rules which allow you to draw the same conclusion Backward chaining may be better if you are trying to prove a single fact, given a large set of initial facts, and where, if you used forward chaining, lots of rules would be eligible to fire in any cycle.