1 / 71

CSCI 4310

CSCI 4310. Lecture 7: Rule Systems. Book. Winston Chapter 7. Knowledge Representation. General problem-solving techniques are useful, but effectiveness often depends on extensive, domain-specific knowledge. Knowledge-based systems use a KNOWLEDGE BASE (KB) of facts about the world

mbriana
Télécharger la présentation

CSCI 4310

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. CSCI 4310 Lecture 7: Rule Systems

  2. Book • Winston Chapter 7

  3. Knowledge Representation • General problem-solving techniques are useful, but effectiveness often depends on extensive, domain-specific knowledge. • Knowledge-based systems use a KNOWLEDGE BASE (KB) of facts about the world • Knowledge usually comes from “experts” in the domain.

  4. Examples of knowledge • Diagnosing a programming bug • Ex: checking for base cases in recursive routines • Requires domain knowledge

  5. Using Knowledge Representations • Contents of KB is part of cognitive model Questions, requests Examples, Statements Answers, analyses Inference Mechanism(s) Learning Mechanism(s) Knowledge Base

  6. Knowledge Representation (KR) language • Expressiveness • can all the knowledge required for the problem be represented adequately? • Naturalness • Does the representation allow the knowledge to be input and manipulated in a natural fashion?

  7. Knowledge Representation (KR) language continued • Efficiency • Can the system access and process the domain knowledge efficiently? • Inference • Does the representation support the generation of inferences? (new knowledge)

  8. A knowledge-based (or expert) system is: An AI program Capable of representing and reasoning about some knowledge-rich domain With a view to solving problems and giving advice Definition

  9. KB system levels We can talk about knowledge-based systems at different levels: Knowledge Logical Implementation

  10. KB system levels continued • The knowledge level describes what is known independent of representation. • knowing in an abstract sense that robins are birds • The logical level describes the statement(s) in the Knowledge Representation model that represent a fact. • isa(robin,bird)

  11. KB system levels continued • The implementation level refers to the way in which the knowledge is encoded • isa(robin,bird) might be encoded as • List • Array • Database record • Something more abstract

  12. Getting started • What types of information need to be represented? • Which knowledge representation model should we use? • How should information be encoded in the knowledge representation model? • How will the information be accessed?

  13. Types of Knowledge • Declarative: facts about the world. • ex: Robins have wings • Procedural: Operations embodying knowledge • ex: an algorithm for addition • Analogy: Associating knowledge about different things. • ex: Robins can fly. Robins are like sparrows. So I suspect that sparrows can fly too.

  14. Types of Knowledge cont. • Generalization: Making generalizations from specific examples: • ex: Robins can fly, sparrows can fly, cardinals can fly…I suspect all birds can fly. • Meta-level Knowledge: Knowledge about what is known. • ex: I don’t know Jim Rogers, so I probably don’t know his phone number. • Rough definition of meta: one level higher

  15. Explicit vs. Implicit Knowledge • Explicit knowledge is information that is encoded directly in the representation. • ex: has_part(robin,wing) • Implicit knowledge is information that can be derived from the representation. • explicit: has-part(bird,wing) • explicit: is-a(robin,bird) • implicit: has-part(robin,wing)

  16. Explicit vs. Implicit Knowledge • Trade-off: Relying on implicit knowledge can reduce the size of the knowledge base, but it can increase the access time…. • Similar to using opening chess moves calculated offline. • Time vs. space once again

  17. Explicit vs. Implicit Knowledge • Trivial example previously is deceptive • This can be prohibitively expensive • Satisfiability (SAT) problem • The granddaddy NP-complete problem • Graph coloring can be encoded as SAT • Many planning and scheduling problems also

  18. Knowledge Representation Models • Propositional Logic • Predicate Calculus • Production Systems (rule-based systems) • Semantic networks • Frames • Bayesian Networks

  19. Example • http://www.aiinc.ca/demos/whale.html

  20. Components of a rule­based system • Working memory • Knowledge base of current assertions sometimes called context • Things that are believed to be true about the world. • This will change as rules are evaluated • Overlap with concepts from Automata Theory

  21. Components of a rule­based system cont. • Rule base: set of inference rules • Each rule (sometimes called a production) is a condition­action pair. • All predicates in the condition must be true for the rule to fire. • An action can add or delete facts from the working memory. • Rule interpreter • Determines which rules to apply and executes actions.

  22. Forward Reasoning Until no rule can fire or goal state is achieved: 1. Find all rules whose left sides match assertions in working memory. 2. Pick some to execute; modify working memory by applying right sides of rules. • There is no point executing multiple rules that take identical actions. • Rules may be implicitly ordered in terms of likelihood, importance, etc. • Choose the first or highest priority satisfied rule 3. Iterate

  23. Example • If A or B then C • If C or (D and E) then F • If C and F then G • If G or H then I Working Memory: A E Which rules will follow? Cycle 1: Cycle 2: Cycle 3: etc.

  24. Three Parts to the Forward­Chaining Rule Interpreter Match: identify which rules are applicable at any given point in the reasoning Conflict Resolution: select which (of possibly many rules) should be applied at any given point in the reasoning Execute: execute the right­hand side of the chosen rule

  25. Three Parts to the Forward­Chaining Rule Interpreter cont. Heart of Rule-Based Systems • The Knowledge Base • Matching algorithm • Conflict Resolution

  26. Matching for Forward­Chaining Simply search all rules incrementally Problems: • A large rule base would lead to a very slow search. • Satisfaction of the rule's preconditions may not be obvious. • Could view as a search through all possible variable bindings and use depth­first search, for example. It's not obvious what sort of heuristics would help.

  27. Forward Chaining Example unknown IF X & Y & Z THEN C

  28. Pros and Cons of Forward Reasoning • Forward reasoning has no goal in mind so it can generate a lot of irrelevant assertions in undirected fashion. • Think of all the info you discard when you add something to your working memory • I am driving… • On a road • Roads are made of asphalt • My tires are making contact with the road • None of this is relevant. • Humans detect relevancy to prune the search space • Some mental disorders cloud this ability

  29. Pros and Cons of Forward Reasoning • Forward­chaining systems often require user to encode heuristic knowledge to guide the search. • Rule base often consists of both domain knowledge and control knowledge.

  30. If (?x has hair) then (?x is mammal) If (?x has feathers) then (?x is bird) If (?x files) and (?x lays eggs) then (?x is bird) If (?x is mammal) and (?x eats meat) then (?x is carnivore) If (?x is mammal) and (?x eats grass) then (?x is herbivores) If (?x is mammal) and (?x has hooves) then (?x is herbivores) If (?x is carnivore) and (?x has tawny color) then (?x is tiger) If (?x is herbivores) and (?x has black/white color) then (?x is zebra) If (?x is bird) and (?x swims) then (?x is penguin) If (?x is bird) and (?x files) and (?x black/white color) then (?x is albatross) Rules

  31. Facts F1: (Subject has hair) F2: (Subject eats grass) F3: (Subject has black/white color) Stored in Working Memory

  32. Backward Reasoning • Start with an hypothesis and… • Some assertions in working memory • Work backward from the hypothesis • Tries to counter the undirected nature of forward-chaining

  33. Backward Reasoning Until the hypothesis has been satisfied, or until no more rules are applicable, do the following: 1. Find all rules whose right side matches the hypothesis.

  34. Backward Reasoning part 2 2. For each matching rule: • Try to support each of the rule's conditions by matching against assertions in working memory, or generating sub­hypotheses and backward chaining recursively. • If all the rule's conditions are satisfied, then success!

  35. Control: Backward Chaining • IF A THEN C • IF B THEN C • IF C THEN D • If we want to establish D as being true, then we should establish C as being true. • To do this we need to show that A is true or that B is true • Eventually we have to • ask the user of the system • go to a database • interrogate a sensor • ...

  36. Rules form a search tree • R1: IF A and B and C and D THEN E • R2: IF X and Y THEN A • R3: IF Z THEN B • R4: IF W THEN C • R5: IF F THEN D • R6: IF G THEN D • R7: IF H THEN G Prove E? Facts: X, Y, Z, W, H

  37. Rules drawn as a tree X R2 A Y Z R3 B E R1 W R4 C F R5 D H R7 R6 AND G

  38. Search aspects of backward chaining • What search strategy do we use • normally depth first • When two rules are available to prove a conclusion, which one do we use first? • if A then C • if B then C • When a premise consists of multiple components, what order do we work on them? • If A and B and C then D

  39. If (?x has hair) then (?x is mammal) If (?x feeds young milk) then (?x is mammal) If (?x has feathers) then (?x is bird) If (?x flies) and (?x lays eggs) then (?x is bird) If (?x is mammal) and (?x eats meat) then (?x is carnivore) If (?x is mammal) and (?x has pointed teeth) and (?x has claws) and (?x has eyes point forward) then (?x is carnivore) If (?x is mammal) and (?x eats grass) then (?x is herbivore) If (?x is mammal) and (?x has hooves) then (?x is herbivore) Knowledge about animals (1)

  40. If (?x is carnivore) and (?x has tawny color) and (?x has dark spots) then (?x is cheetah) If (?x is carnivore) and (?x has tawny color) and (?x has dark stripes) then (?x is tiger) If (?x is herbivore) and (?x has tawny color) and (?x has dark spots) and (?x has long neck) then (?x is giraffe) If (?x is herbivore) and (?x has black/white color) then (?x is zebra) If (?x is bird) and (?x has long neck) then (?x is ostrich) If (?x is bird) and (?x swims) and (?x is black/white color) then (?x is penguin) If (?x is bird) and (?x flies) and (?x is black/white color) then (?x is albatross) Knowledge about animals (2)

  41. Want to know what species george is Information available on request: (george has hair). (george lays unknown). (george, unknown). (george eats unknown). (george has pointed teeth). (george has claws). (george has eyes point forward). (george tawny color). (george has dark spots). (george neck short). What species is george?

  42. Matching for Backward Chaining With forward chaining we can generate all applicable rules and then select one using a well­defined conflict resolution strategy. Backward chaining is more complicated because...

  43. Matching for Backward Chaining • The hypothesis must be matched against WM assertions and rule consequents. • The hypothesis can contain variables. • More than one rule can provide a variable binding. • Backward chaining typically uses DFS with backtracking to select individual rules.

  44. Fan Out • A set of facts can lead to many conclusions • A higher degree of fan out argues for backward chaining

  45. Fan In • A higher degree of fan in argues for forward chaining

  46. Pros and Cons of Backward Reasoning • Backward­chaining is best when there is a distinct goal state that is likely to be obtainable. (If there are many acceptable goal states, then forward chaining might be fine.) • Backward reasoning can be efficient when the branching factor of the initial working memory is higher than the branching factor of the assertions that lead to the conclusion. • Backward reasoning only asks for information when it is relevant, which is extremely useful when knowledge is expensive to access.

  47. Rule-based Systems • Many problems are best characterized by a set of rules. If-then rules (implication) are the focus of problem-solving. • Problem-solving systems that use rule-based knowledge representation and rule-based reasoning are sometimes called production systems. • This is not how humans do it, though

  48. Rule-based Systems • Production systems may use a somewhat less formal representation scheme, use an incomplete inference procedure, and treat the consequents of rules as logical actions rather than logical conclusions. • Book refers to this as a reaction system • Need conflict-resolution procedure to decide which action to take

  49. In principle, anything that an expert can do, and can be persuaded to articulate. It is useful to distinguish between analytic tasks which involve analysing something which already exists, and synthetic tasks which involve creating something which doesn’t. What can an expert system do?

More Related