Presentation is loading. Please wait.

Presentation is loading. Please wait.

Reasoning Forward and Backward Chaining Andrew Diniz da Costa

Similar presentations


Presentation on theme: "Reasoning Forward and Backward Chaining Andrew Diniz da Costa"— Presentation transcript:

1 Reasoning Forward and Backward Chaining Andrew Diniz da Costa andrew@les.inf.puc-rio.br

2 © LES/PUC-Rio Roadmap Overview about Reasoning Forward Chaining –Presentation –Examples Backward Chaining –Presentation –Examples JTP API Final Considerations

3 © LES/PUC-Rio Reasoning Reasoning is the mental (cognitive) process of looking for reasons to support beliefs, conclusions, actions or feelings. In philosophy, the study of reasoning typically focuses on what makes reasoning efficient or inefficient, appropriate or inappropriate, good or bad.

4 © LES/PUC-Rio Reasoning The main division between forms of reasoning that is made in philosophy is between deductive reasoning and inductive reasoning. Formal logic has been described as 'the science of deduction'. The study of inductive reasoning is generally carried out within the field known as informal logic or critical thinking.

5 © LES/PUC-Rio Deductive Reasoning Deductive arguments are intended to have reasoning that is valid. Reasoning in an argument is valid if the argument's conclusion must be true when the premises (the reasons given to support that conclusion) are true. Example Premise 1: All humans are mortal. Premise 2: Socrates is a human. Conclusion: Socrates is mortal.

6 © LES/PUC-Rio Deductive Reasoning Within the field of formal logic, a variety of different forms of deductive reasoning have been developed. Some logics –Modal logic –Propositional logic –Predicate logic

7 © LES/PUC-Rio Inductive Reasoning Inductive reasoning contrasts strongly with deductive reasoning. Even in the best, or strongest, cases of inductive reasoning, the truth of the premises does not guarantee the truth of the conclusion. The conclusion of an inductive argument follows with some degree of probability. Example –Premise: The sun has risen in the east every morning up until now. –Conclusion: The sun will also rise in the east tomorrow.

8 © LES/PUC-Rio Reasoning If-then rules have become the most popular form of declarative knowledge representation used in AI applications. Algorithms to process if-the rules –Forward Chaining –Backward Chaining Forward Chaining can be used to produce new facts Backward Chaining can deduce whether conclusions are true or not.

9 © LES/PUC-Rio Forward Chaining It is one of the two main methods of reasoning when using inference rules. Forward chaining starts with the available data until a goal to be reached. Use inference rules to extract more data until a goal to be reached.

10 © LES/PUC-Rio Forward Chaining An inference engine using forward chaining searches the inference rules until it finds one where the If clause is known to be true. When found it can conclude, or infer, the Then clause, resulting in the addition of new information to its dataset. Require three basic elements –A knowledge base of rules and facts; –A working memory for storing data during inferencing; –An inference engine.

11 © LES/PUC-Rio Forward Chaining – First Example The Vehicles Rule Base Cycle: IF num_wheels < 4 THEN vehicleType=cycle Automobile: IF num_wheels=4 AND motor=yes THEN vehicleType=automobile MiniVan: IF vehicleType=automobile AND size=medium AND num_doors=3 THEN vehicle=MiniVan...

12 © LES/PUC-Rio Forward Chaining – First Example Initial values in the working memory –num_wheels=4 –motor=yes –num_doors=3 –size=medium Cycle: IF num_wheels < 4 THEN vehicleType=cycle (Rule is false) Automobile: IF num_wheels=4 AND motor=yes THEN vehicleType=automobile

13 © LES/PUC-Rio Forward Chaining – First Example Values in the working memory –num_wheels=4 –motor=yes –num_doors=3 –size=medium –vehicleType=automobile MiniVan: IF vehicleType=automobile AND size=medium AND num_doors=3 THEN vehicle=MiniVan

14 © LES/PUC-Rio Forward Chaining – First Example Values in the working memory –num_wheels=4 –motor=yes –num_doors=3 –size=medium –vehicleType=automobile –vehicle=MiniVan

15 © LES/PUC-Rio Forward Chaining – Second Example Suppose that the goal is to conclude the color of my pet Fritz, given that he croaks and eats flies, and that the rule base contains the following two rules: –If Fritz croaks and eats flies - Then Fritz is a frog –If Fritz is a frog - Then Fritz is green croaks=true eats_flies=true croaks=true eats_flies=true Fritz=frog croaks=true eats_flies=true Fritz=frog green=true Working memory

16 © LES/PUC-Rio Forward Chaining Cycle 1 - Load the rule base into the inference engine and load any facts from the knowledge base into the working memory. 2 - Add any additional initial data into the working memory 3 - Match the rules against the data in the working memory which rules are triggered, meaning that all of their antecedent clauses are true. This set of triggered rules is called the conflict set. 4 – Use a procedure to select a single rule from the conflict set. 5 – Update the working memory. 6 – Repeat steps 3, 4 and 5 until the conflict set is empty.

17 © LES/PUC-Rio Backward Chaining A particular consequence or goal clause is evaluated first. Unlike forward chaining, which uses rules to produce new information, backward chaining uses rules to answer questions about whether a goal clause is true or not. It only processes rules that are relevant to the question.

18 © LES/PUC-Rio Backward Chaining - Example We go to work using a rule from our Vehicles rule base as an example. Cycle: IF num_wheels < 4 THEN vehicleType=cycle Automobile: IF num_wheels=4 AND motor=yes THEN vehicleType=automobile MiniVan: IF vehicleType=automobile AND size=medium AND num_doors=3 THEN vehicle=MiniVan...

19 © LES/PUC-Rio Backward Chaining - Example Suppose we want to find out whether the vehicle we have is a MiniVan. MiniVan: IF vehicleType=automobile AND size=medium AND num_doors=3 THEN vehicle=MiniVan We start with an empty working memory. To verify if vehicle=MiniVan in the work memory. If not, then all the antecedent clauses of the MiniVan=true: rule must be true.

20 © LES/PUC-Rio Backward Chaining - Example The first thing we do is test if vehicleType=automobile is true. The vehicleType variable has no value, so we look for a rule that has vehicleType=automobile in its consequence clause Automobile: IF num_wheels=4 AND motor=yes AND vehicleType=automobile We look num_wheels=4 in the work memory and if there is a rule related. There are none, so we ask the user.

21 © LES/PUC-Rio Backward Chaining - Example Working memory –num_wheels=4 –motor=yes –vehicleType=automobile Going back to our original rule MiniVan: IF vehicleType=automobile AND size=medium AND num_doors=3 THEN vehicle=MiniVan

22 © LES/PUC-Rio Backward Chaining - Example Working memory –num_wheels=4 –motor=yes –vehicleType=automobile –size=medium –num_doors=3 –vehicle=MiniVan

23 © LES/PUC-Rio Backward Chaining - Cycle 1 - Load the rule base into the inference engine and load any facts from the knowledge base into the working memory 2 - Add any additional initial data into the working memory 3 – Specify a goal variable for the inference engine to find 4 – Find the set rules that refer to the goal variable in a consequence clause. Put each rule on the goal stack 5 – Take the top rule off the goal stack 6 – Try to prove the rule is true by testing all antecedent clauses to see if they are true.

24 © LES/PUC-Rio JTP:An Object-Oriented Modular Reasoning System Knowledge Systems Laboratory of Computer Science Department in Stanford University JTP is based on a very simple and general reasoning architecture. Backward-chaining and forward chaining Reasoner is the principal functional component of the architecture. –process - This method attempts to find proof for the goal.

25 © LES/PUC-Rio Final Considerations Forward-chaining uses inference rules to extract more data. Backward chaining uses rules to answer questions about whether a goal clause is true or not. Very used in AI applications. APIs that use forward- and backward-chaining (ex: JTP).

26 © LES/PUC-Rio Bibliography Bigus, Joseph P.; Bigus, Jennifer, Constructing Intelligent Agents Using Java – Second Edition. Forward chaining - Wikipedia (2007), http://en.wikipedia.org/wiki/Forward_chaining, August. Forward chaining of Rules (2007), http://msdn2.microsoft.com/en-us/library/aa349441.aspx, August. Reasoning – Wikipedia (2007), http://en.wikipedia.org/wiki/Reasoning, August

27 © LES/PUC-Rio Bibliography Backward chaining – Wikipedia (2007) http://en.wikipedia.org/wiki/Backward_chaining, August. API JTP Web site (2007), http://www- ksl.stanford.edu/software/jtp/, August.

28 Questions?

29 The End.


Download ppt "Reasoning Forward and Backward Chaining Andrew Diniz da Costa"

Similar presentations


Ads by Google