1 / 19

Rules: Knowledge Representation & Manipulation

Rules: Knowledge Representation & Manipulation. Artificial Intelligence CMSC 25000 January 8, 2002. Agenda. Knowledge Representation: Assertions & Rules Knowledge Manipulation: Forward & Backward Chaining Deduction & Reaction Systems Costs, Choices, and Mechanisms.

omirabal
Download Presentation

Rules: Knowledge Representation & Manipulation

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. Rules:Knowledge Representation &Manipulation Artificial Intelligence CMSC 25000 January 8, 2002

  2. Agenda • Knowledge Representation: • Assertions & Rules • Knowledge Manipulation: • Forward & Backward Chaining • Deduction & Reaction Systems • Costs, Choices, and Mechanisms

  3. Representing Knowledge • Assertion: • Statement that something is true • “Stretch is a giraffe”,”The sky is blue” • Collection of assertions: “Working Memory”

  4. Representing Knowledge: Rules • If - then rules If A1, A2 Antecedent Then B1, B2 Consequent

  5. Representing Knowledge: Rules • May include variables, e.g. • Variables: ?x,?y,?z • Same name => same value If (parent-of ?x ?y), (parent-of ?y ?z), then (grandparent-of ?x ?z)

  6. Knowledge Manipulation • Forward chaining: • Reason from “if” antecedents to “then” consequents • Backward chaining: • Confirm hypothesis matching “then” patterns by verifying “if” patterns

  7. Rule-based Systems • Separate knowledge from control • Contrast from typical programming: Integrated Add consequent Assertions Rules Rule Interpreter Select rule Match antecedent

  8. Forward Chaining • Identify triggered rules • Antecedents match assertions • Match variables -> rule instances • Select a triggered rule to fire • Conflict resolution strategy: first, random, LRU, combination • Fire a rule • Add consequents to list of assertions (deduction) • Perform action(s) in consequent (reaction)

  9. Forward Chaining Example R1: if (signs (nasal congestion)) (signs (viremia)) then (diagnosis influenza) R2: if (runny nose) then (signs (nasal congestion)) R3: if (body-aches) then (signs (achiness)) R4: if (temp >100) then (signs (fever)) R5: if (headache) then (signs (achiness)) R6: if (signs (fever)) (signs (achiness)) (cough) then (signs (viremia)) Assertions: F1: runny nose F2: temp = 101.5 F3: headache Execution: R2 Fires: Asserts (signs (nasal congestion)) R4 Fires: Asserts (signs (fever)) R5 Fires: Asserts (signs (achiness)) R6 Fires: Asserts (signs (viremia)) R1 Fires: Asserts (diagnosis influenza)

  10. Forward Chaining with variables IF (parent ?x ?y) (parent A B) (parent ?y ?z) (parent A C) THEN (grand-parent ?x ?z) (parent B D) (parent C E) (parent ?x ?y) (parent ?y ?z) (grand-parent ?x ?z) (x:A y:B) (y:A z:B) conflict in y (y:A z:C) conflict in y (y:B z:D) (x:A y:B z:D) (y:C z:E) conflict in y (x:A y:C) (y:A z:B) conflict in y (y:A z:C) conflict in y (y:B z:D) conflict in y (y:C z:E) (x:A y:C z:E) (x:B y:D) (y:A z:B)conflict in y (y:A z:C) conflict in y (y:B z:D) conflict in y (y:C z:E) conflict in y (x:C y:E) (y:A z:B) conflict in y (y:A z:C) conflict in y (y:B z:D) conflict in y (y:C z:E) conflict iny

  11. Forward Chaining: Analysis • Reason from antecedents to consequents • Trigger rules if all antecedents match assertions • Add assertions or do actions in consequents • May be computationally expensive • Many possible deductions to make • Brute force approach: k antecedents, N assertions • N^k!! • Rete method

  12. Backward Chaining • Test hypothesis • Reason from consequents to antecedents • Use assertions and rules • If no assertions or rules give evidence, ask questions

  13. Backchain(G) - Rule interpreter If G matched assertion in database, then return True Else If there are rules whose consequent matches G For each matching rule R For each antecedent C of R If Backchain(C) is true, proceed Else go to next rule. Return True /* when all antecedents are true */ Return False /* when no matching rule succeeds */ Else, ask user if G is true. If answer is “yes” return True, Else return False. From Lozano-Perez, April 00

  14. Backward Chaining Example R1: if (signs (nasal congestion)) (signs (viremia)) then (diagnosis influenza) R2: if (runny nose) then (signs (nasal congestion)) R3: if (body-aches) then (signs (achiness)) R4: if (temp >100) then (signs (fever)) R5: if (headache) then (signs (achiness)) R6: if (signs (fever)) (signs (achiness)) (cough) then (signs (viremia))

  15. Backward Chaining Example Hypothesis: (diagnosis influenza) Diagnosis Influenza AND (Signs (nasal congestion)) (Signs (viremia) AND (Runny nose) (Signs (fever)) (Signs (achiness)) (cough) Ask Ask OR Yes Yes (Temp > 100) Ask Yes (Body-ache) (Headache) Ask Ask No Yes

  16. Reaction Systems • Deduction systems • Produce new assertions • Keep firing all triggered rules • Order less important • Reaction systems • Produce arbitrary actions: assertions, printing, moving, bagging • Side effects -> Order important

  17. Reaction System: Example • For example, IF (at ?x ?y) (move ?x to ?z) ADD (at ?x ?z) DELETE (move ?x to ?z) (at ?x ?y) • Assume an initial database: • (at A room1) (move A room2) • Then the rule would add:(at A room2) • And, delete: • (at A room1) (move A room2)

  18. Conflict Resolution • When >1 rule is triggered, which fires?? • First: Rules are ordered. Fire first triggered. • Random: Randomly select a rule to fire • Most specific: Fire rule with most antecedents • Least recently fired: Avoids rule starvation. • Combination • Design rule set wrt conflict resolution strategy

  19. Conflict Resolution: Deduction • Generally, less important,but • Possible to create infinitely recursive rule • if ?x, (not (not ?x))…. • Need conflict resolution • Allow other rules to fire • E.g. stop rule

More Related