1 / 62

Reasoning and search

Reasoning and search. An overview. Representation and reasoning system Rule-based reasoning Forward reasoning Backward reasoning Conflict resolution Advantages and disadvantages Solving problem by search – search strategies hill-climbing search backtracking search

thane
Download Presentation

Reasoning and search

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Reasoning and search

  2. An overview • Representation and reasoning system • Rule-based reasoning • Forward reasoning • Backward reasoning • Conflict resolution • Advantages and disadvantages • Solving problem by search – search strategies • hill-climbing search • backtracking search • graph search strategies Reasoning and search

  3. Representation and reasoning system (RRS) Reasoning and search

  4. Introduction to RRS • question: how can computer solve • difficult, non-trivial, complex, unusually large problems • in a non-trivial human-like (intelligent) way • application examples: • toy problems (15-puzzle, n-queens, chess playing) • route-finding (automatic travel advisory system) • diagnostic problems (medical diagnosis) • natural language translation systems • expert systems • RRSs • tools for the automation of problem solving tasks • problem  representation  computation Reasoning and search

  5. Main components of RRS • An RRS consists of: • language to communicate with the computer: formal language • a way to assign meaning to the symbol: semantics • a procedure to compute answer or solve problem: reasoning • An implementation of RRS consists of: • language parser: maps sentences of the language into data structures • reasoning procedure: implementation of reasoning + search strategy Note: the semantics aren’t reflected in the implementation! Reasoning and search

  6. Using an RRS (example) • begin with a task domain that you want to characterize • distinguish those things you want to talk about in domain (ontology) • coffee-machine, valves, heater, valve_in is open, flow water through valve, heating the water • choose symbols in the computer to represent objects and relations in the domain • v1, v2, k, valve(V, open), flow(V), heating(W) • tell the system knowledge about the domain • switch(on), valve(v1,open), switch(on)  heating(water) • ask the system questions • ?valve(v1,X), ?heating(Y) Reasoning and search

  7. Questions and answers in RRS • determining what follows from the formal description • whether the question is implied by the defined clauses (logical consequence of the knowledge base – set of clauses claimed to be true) • construction of logical consequence/proof procedure  reasoning theory – a possible nondeterministic specification of how an answer can be derived from the knowledge base • nondeterministic specification: • have to make decision before knowing enough to make the right choice • make a choice and keep track of the alternatives (in case of fail) • can think as a search through the space of possible choices • an implementation of a reasoning theory together with a search strategy  reasoning procedure Reasoning and search

  8. Simplifying assumptions of RRS • the knowledge can be usefully described in terms of individuals and relations among individuals • the knowledge base contains only definite and positive clauses • definit clause: atom (fact) or of the form „b1  …  bm a” (rule) • environment is static (ignore change) • finite number of individuals of interest in the domain, each individual can be given a unique name DATALOG (special case of rule sets) Reasoning and search

  9. Rule-based reasoning Reasoning and search

  10. Knowledge-base The knowledge base (KB) of rule-based system consists of: • facts (predicates) • declarative knowledge about the given problem • statements with true or false values • values can change in time and during reasoning • rules (conditional statements) • represent heuristics or „rules of thumb” • modelling human’s thinking • describing experts’ knowledge (heuristics) • specify actions taking in a given situation • generally valid part of the practical knowledge • rules are operated by the inference engine • meta-rules (rules about how to use rules) Reasoning and search

  11. Rules and facts Rules: IF <condition> THEN <conclusion> THEN <conclusion> IF <condition> condition/premise conclusion/consequence/antecedent/action • condition, conclusion: • statements • and/or connections of statements • procedural elements (executable actions) ex. IF level is above max_level THEN close valve_in Facts:statements without conditions ex. valve_in is closed valve_out connected_to the output_port of water-heater Reasoning and search

  12. Reasoning 1 inference engine uses rules, derives new knowledge the reasoning algorithm: • pattern matching • finding applicable rules • fireable rules  conflict set • conflict resolution • selecting the most appropriate rule from conflict set • conflict resolution strategies • firing • executing the selected rule  new knowledge • watching termination conditions • restart of the cycle Reasoning and search

  13. Reasoning 2 • new facts can be deduced during reasoning • aim: • proving a goal statement • achieving a goal state • task: • finding a solution (reasoning path, chain of rules) between the initial and the goal states • reasoning tool: • applying rules/ matching • modus ponens (MP) A A  B B premise conclusion Reasoning and search

  14. Reasoning 3 • modus ponens can be used in two ways  two different forms of reasoning: • data-driven (forward) reasoning • aim: reach or construct a goal state starting from the initial state • new conclusions are generated by MP • until termination conditions satisfied or no more applicable rules (no more conclusion) • goal-driven (backward) reasoning • aim: prove a goal statement using initially valid facts • new subgoals are generated by MP • until all subgoals proved or no more applicable rules (no more provable subgoals) Reasoning and search

  15. Forward reasoning 1 • application of modus ponens: A, A  B  B • new fact into KB (conclusions of data) • the reasoning algorithm: • selecting the applicable rules: pattern matching • a rule is applicable when its condition part is true • matching: conditional part of rules/ facts • selecting the most appropriate rule: conflict resolution • conflict resolution strategies • executing the selected rule: firing • conclusion part of rule is executed (set to true) • watching termination conditions (a goal state is reached) • restart of the cycle Reasoning and search

  16. Reasoning and search

  17. Forward reasoning 3 the inference chain produced by the example Reasoning and search

  18. Forward reasoning 4 • the problems of forward reasoning: • forward reasoning with defined goal • given: the initial state of fact-base, the rule-base, the goal state(s) of fact-base • question: is goal state a consequence of initial state? can goal state be derived from initial state by the rules? decision problem: the whole search tree must be traversed in the worst case NP-complete (the size of the tree increases the number of computational steps exponentially) • forward reasoning (without defined goal) • given: the initial state of fact-base, the rule-base • compute: all the possible consequences of initial state search problem: the whole search tree must be traversed NP-complete (follows from the problem specification) Reasoning and search

  19. Backward reasoning 1 • application of modus ponens: prove B with A  B, need A • new subgoals (conditions of rule) • the reasoning algorithm: • selecting the applicable rules: pattern matching • a rule is applicable when its conclusion part matches (sub)goal • matching: facts orconclusion part of rules/ (sub)goals • selecting the most appropriate rule: conflict resolution • conflict resolution strategy usually the first applicable rule • executing the selected rule: firing • condition part of rule is executed (set to new subgoal) • watching termination conditions (all subgoals proved) • restart of the cycle Reasoning and search

  20. Backward reasoning 2 • backtracking: trying next alternative • cancel the last part of the path • go back to the previous state with more applicable rules • continue with another rule (next alternative) • backtrack is needed when: • there is no applicable rule for the actual state (came to dead-end) • not worth examining the actual state (on the basis on heuristics) • all of the rules applicable to the actual state is examined (mouth of dead-end) • reach a state is kept on the actual path (loop) • the state is too far from the initial state (depth limit) Reasoning and search

  21. Reasoning and search

  22. Backward reasoning 4 the inference chain produced by the example Reasoning and search

  23. Backward reasoning 5 • the problems of backward reasoning: • backward reasoning with defined state • given: the goal state of fact-base, the rule-base, one or more given states („s”) of fact-base • question: can „s” be a reason of the goal state? (can goal state be derived from „s” by the rules?) decision problem: the whole search tree must be traversed in the worst case NP-complete (the size of the tree increases the number of computational steps exponentially) • backward reasoning (without defined state) • given: the goal state of fact-base, the rule-base • compute: all the possible reasons of the goal state search problem: the whole search tree must be traversed NP-complete (follows from the problem specification) Reasoning and search

  24. Selection of reasoningtechnique Forward or backward technique can be applied? • the determinant elements are: • the number of possible initial and final states prediction in a real-time expert system, diagnosis in diagnostic system • which direction has greater branching factor proving a theorem in mathematics • explanation is needed or not medical diagnostic system • time-honoured observation: • in case of giving answer to a question: backward reasoning • in case of reaching new facts or states: forward reasoning Reasoning and search

  25. Bidirectional reasoning • problems where neither forward nor backward chaining is efficient, but they operate efficiently at an early stage • combination of backward and forward techniques  bidirectional reasoning • the goal state can be reached from two directions at same time • terminates when the reasoning bridge is built up Reasoning and search

  26. Conflict resolution 1 • problems: • no exact solution strategy optimal to every possible reasoning task • test every possible way of solution  combinatorial explosion • but: • no need to produce all possible solutions for most of the real practical problems  aim: „good enough” solution in a „short enough” time • conflict resolution: • choosing a rule to apply next from the applicable ones (conflict set) • almost always contains heuristic knowledge (extra knowledge about the structure of the rule-base) Reasoning and search

  27. Conflict resolution 2 • heuristic knowledge • no exact definition for heuristics • properties of a heuristic procedures: • „good enough” solution is found in most cases • optimal solution or any solution is not guaranteed • considerably improve the efficiency of problem solving (reduce the number of attempts to reach the solution) • properties of a good heuristics: • it is used and computed efficiently • it is a good estimate Reasoning and search

  28. Conflict resolution 3 • conflict resolution strategies: • using first applicable rule • rules are placed in order of importance • refractoriness • control reusing of rules (to release cycles in executing) • ex. an instance of a rule can only fire once or cannot executed in the following step • recency • attach time-stamps to facts • prefer rule instances referring to facts with fresh time-stamps • specificity • prefer rules with more conditions (specific rules, describe exceptions) • assigning priority Reasoning and search

  29. Advantages and disadvantages • advantages of rule-based systems • modularity • universal representation • naturalness • easy to complete with uncertainty handling methods • disadvantages of rule-based systems • endless chaining/loop • new rule or modification of rule  may be contradictory • rules and meta-rules are in the same syntax (not differ from each other), the two types of information are mixed • language of rules is not standardized  difficult to transfer it to another system Reasoning and search

  30. Solving problems by search Reasoning and search

  31. Reasoning and search 1 • reasoning problems are solved by search in the state space (r1): p1=t  p2=t (r2): p2=t  p3=t (r3): p3=u  p1=u initial state: {p1=t, p2=f, p3=u}, (a0) states: {p1=u, p2=f, p3=u}, (a1) {p1=t, p2=t, p3=u}, (a2) {p1=t, p2=t, p3=t}, (a3) {p1=u, p2=t, p3=u}, (a4) Reasoning and search

  32. Reasoning and search 2 • the state space of reasoning problem can be represented by a reasoning graph • reasoning problems are solved by search on the reasoning graph • search: general problem solving method or mechanism • search is needed: • difficult (non-trivial, complex, large or complicated) problem • an algorithm for problem solving is not given • non-trivial, human-like problem solving • efficiency of a search strategy can be measured by • whether (optimal) solution is founded • the cost of the solution • the cost of search (time and memory) Reasoning and search

  33. Search 1 • basic elements of problem definition (states and actions) • initial state(s) • set of possible actions (operators) • state space (set off all states reachable from the initial state by any set of actions – implicit) • goal test (or explicit set of possible goals) • cost of the actions • aim: to find a path from an initial state to a goal state (satisfies the goal test) • search space • generated on the fly • represented by directed acyclic graph (searching tree) Reasoning and search

  34. Search 2 • some notions: • node/arc • root • parent/children • branching factor • level • leaf • goal node • path • cost Reasoning and search

  35. Search strategies 1 • conflicts: search strategies needed for decision making • search strategies can be grouped according to modification • irrevocable strategies/non-modifiable strategies • no opportunity to withdraw the application of an action • no opportunity to try another applicable action • supposing that all of the chosen action have been selected properly • tentative strategies/modifiable strategies • able to recognize the erroneous or improper application of an action • algorithm can go back to an earlier state to try a new direction when • reaches a stage which does not lead to a goal state • it does not seem promising to resume the search in that direction Reasoning and search

  36. Search strategies 2 • search strategies can be grouped according to used knowledge • random search • goal achievement is not insured in finite time • blind search/uninformed search • all of the paths are traversed in a systematic way • no information about „goodness” of the path or node • algorithm distinguishes a goal state from a nongoal state • heuristic search/informed search • specific knowledge about the given problem (heuristic) • estimate the distance from a node to a solution Reasoning and search

  37. Search strategies 3 • irrevocable strategies/non-modifiable strategies • no possibility for withdraw/modification of a selected action • no possibility going back on the path from start node (to goal node) • algorithm stores information only the actual node on the path (without any earlier branch) • the applicable actions = the actions applicable on the actual node  selection (with local knowledge, the most promising child) • finding a(n optimal) solution is not guaranteed Reasoning and search

  38. Hill-climbing search 1 • the most known non-modifiable search strategy • choosing the next node  heuristic function (minimal in the initial node, maximal in the goal node) • special maximum search: • selects the child of the current node with the highest heuristic value • stops when no child with a higher value than the current node • known as gradient method beyond AI • applicable as minimum search, too Reasoning and search

  39. Hill-climbing search 2 Reasoning and search

  40. Hill-climbing search 3 • difficulties during hill-climbing search • foothills: local maximum/ global maximum • plateaus: the evaluation function around the current node is essentially flat • ridges: the values of the children nodes are lower, but node with higher value can be reached by the combination of steps • advantage of hill-climbing search: • small memory requirement • getting rid of difficulties • starting from some position (random restart hill-climbing) • selecting the child node at random (simulated annealing) Reasoning and search

  41. Backtracking strategy 1 • one of the most significant modifiable search strategies in AI • algorithm stores information about one – the actual path (nodes with other possible branches) • the applicable actions = the actions applicable on the last node of the path  selection (first alternative) • in case of dead-end (the path cannot be pursued)  backtrack • cancel the last part of the path • go back to the previous node with branching • continue with another direction (next alternative) • pursue until a goal node is reached or all paths are examined Reasoning and search

  42. Backtracking strategy 2 Reasoning and search

  43. Backtracking strategy 3 • advantages of backtracking strategy: • simple, easily implemented • small memory requirement • is great of importance in AI systems: • strategy of inference engines in rule-based expert systems • Prolog systems • disadvantages of backtracking strategy: • (optimal) solution is not guaranteed (endless depth or cycle) • wrong direction is detected only in the dead-end • a part of the path to the same dead-end can be examined several times (it has not memory) Reasoning and search

  44. Graph search strategies 1 • the other of the most significant modifiable search strategies in AI • algorithm stores information about all of the examined path (in some depth) from the initial node • move along the path which promises to the best from the aspects of reaching a goal node • all the successors of the node in the end of the selected path are produced  expanding the node • a subgraph is constructed • nodes in the end all of the examined path  frontier/open nodes (nodes that are waiting to be expanded) • does not forget the examined part of the searching graph Reasoning and search

  45. Graph search strategies 2 • the main steps of the general algorithm: • Add the initial node to L. (L: list of open nodes) • If L is empty, return failure; otherwise choose a node n from L. • If n is a goal node, stop and return the path from the initial node to n; otherwise, remove n from L, expand n, add the successors of n to L, return to step 2. • different graph search strategies according to: • how to select a node from open list • how to add a node to the open list Reasoning and search

  46. Graph search strategies 3 • some important graph search strategies: • uninformed strategies: • depth-first search • breadth-first search • uniform-cost search/lowest-cost-first search • informed strategies: • best-first search • A* search Reasoning and search

  47. Depth-first search 1 • uninformed graph search strategy • modification of the general algorithm: • n is the first node from L in step 2. • the successors of n is added to the front of L in step 3. • the open list is used as a stack • one of the nodes at the deepest level is expanded • only in case of dead-end (a nongoal node with no expansion) goes back and expands nodes at shallower levels Reasoning and search

  48. Depth-first search 2 Reasoning and search

  49. Depth-first search 3 • advantages of the method: • easy implementation • modest memory requirement (b*d, b: branching factor, d: depth) • disadvantages of the method: • can get stuck going down the wrong path (very deep or infinite search tree)  incomplete • can find solution that is more expensive than the optimal ones  not optimal Reasoning and search

  50. Breadth-first search 1 • uninformed graph search strategy • modification of the general algorithm: • n is the first node from L in step 2. • the successors of n is added to the end of L in step 3. • the open list is used as a queue • one of the nodes at the shallowest level is expanded • all the nodes at depth d in the search tree are expanded before the nodes at depth d+1 • considers all the path of length 1 first, then all those of length 2, and so on Reasoning and search

More Related