Presentation is loading. Please wait.

Presentation is loading. Please wait.

Production Systems Productions systems are rule based forward chaining systems. They are based on forward chained reasoning, but are extended to be a kind.

Similar presentations


Presentation on theme: "Production Systems Productions systems are rule based forward chaining systems. They are based on forward chained reasoning, but are extended to be a kind."— Presentation transcript:

1 Production Systems Productions systems are rule based forward chaining systems. They are based on forward chained reasoning, but are extended to be a kind of programming language systems. Systems exist that can handle several thousand rules efficiently.

2 What is Production Systems  Algorithmic,procedural (C,FORTRAN)  Applicative,functional (LISP)  Logic programming (PROLOG)  Object oriented (Smalltalk,Java,Simula)  Hybrid systems (KEE,NEXPERT,ART) Forward chained Rule based Symbolic Rules comunicate only through Working Memory

3 When is Production Systems used When the knowledge is present on the form situation-action When the program control is very complex, i.e. no algorithm When the program is expected to be heavily extended and modified over a long period

4 Good applications for FC Good applications for BC Conclusions Hypothesis Evidence Facts Forward and Backward chaining Narrow and deep Broad and shallow

5 Incremental forward chaining % rule '9.3' american(X) and weapon(Y) and sells(X,Y,Z) and hostile(Z) => criminal(X). % rule '9.6' missile(X) and owns(nono,X) => sells(west,X,nono). % rule '9.7' missile(X) => weapon(X). % rule '9.8' enemy(X,america) => hostile(X). % facts t=> owns(nono,m1). % 9.4 t=> missile(m1). % 9.5 t=> american(west). % 9.9 t=> enemy(nono,america). % 9.10 Derivations: + owns(nono,m1) + missile(m1) + sells(west,m1,nono) + weapon(m1) + american(west) + enemy(nono,america) + hostile(nono) + criminal(west)

6 Forward chaining Proxy format rule '9.3' if american(X) and weapon(Y) and sells(X,Y,Z) and hostile(Z) then criminal(X). rule '9.6' if missile(X) and owns(nono,X) then sells(west,X,nono). rule '9.7' if missile(X) then weapon(X). rule '9.8' if enemy(X,america) then hostile(X) facts owns(nono,m1) and % 9.4 missile(m1) and % 9.5 american(west) and % 9.9 enemy(nono,america). % 9.10 Derivations *** 9.6 ==> sells(west,m1,nono) *** *** 9.7 ==> weapon(m1) *** *** 9.8 ==> hostile(nono) *** *** 9.3 ==> criminal(west) *** *** Time 0 ms

7 Production Systems Forward Chained All communictations via Working Memory (WM). 1.[Matching] Find all the rules whose premise are satisfied 2.[Conflict Resolution] If more than one rule apply, select the one with the highest priority 3.[Execution] Execute(fire) the rule selected. The execution will change the WM. 4.Then start again from top.

8 Efficiency considerations 1 Forward reasoning can be done in levels. Every new fact must be derived from at least 1 fact in the previous level. This is true because inference mechanism that does not require a new fact from level t-1 could have been done at in level t-1 already.

9 Efficiency considerations 2 With suitable indexing, it is easy to identify all the rules that can be triggered by a new fact. Typically, there are many more rules than facts in a production system rule base. Rules Facts

10 Efficiency considerations 3 Forward chaining gives a lot of irrelevant facts. One way to avoid this is to simulate backward chaining. This means that goals and subgoals are explicitly represented and used to control the reasoning. Another way is to restrict forward chaining to a subset of rules.

11 Efficiency considerations 4 (according to AIMA) A method is to rewrite the rule set using information about the goal so that only relevant variable bindings – those belonging to a magic set – are considered during forward inference. For instance, if the goal is criminal(west), the rule that concludes criminal(X) is prefixed with an extra conjunct magic(X) and american(X) and weapon(X) and sells(X,Y,Z) and hostile(Z) => criminal(X) which avoids redundant inferences if west is in the magic set.

12 Efficiency considerations 5 There may be 300 mill americans but only 5(?) hostile nations. It may be smart to reorder the condition sequence of the rules in increasing ”plurality”. not american(X) and weapon(X) and sells(X,Y,Z) and hostile(Z) => criminal(X) but hostile(Z) and sells(X,Y,Z) and weapon(X) and american(X) => criminal(X)

13 Facts searching for rules FACTSRULES FACTS Facts searching for rules Rules searching for facts

14 The Rete(*) algorithm This algortithm preprocesses the set of rules in the knowledge base to construct a set of dataflow network in which each rule is a literal from the rule premise. Variable bindings flow through the network and are filtered out when they fail to match a literal. … At any given point, the state of a rete network captures all the partial matches of the rules, avoiding a great deal of recomputation. Efficient algorithm to match facts against (patterns) of rules to determine which rules have all its conditions fullfilled (*) pronounced as ”treaty”. Means ”net” in Latin

15 Production systems and applications System Application R1 XCON (configuration of VAX computers) OPS-5 Several applicatons CLIPS Severl applications, used by NASA ACT Cognitive architecture SOAR Cognitive architecture with learning PRAGMA BusTUC ( natural language interpretation) PROXY Education

16 Production system PROXY PRO log implementationof produ X ion s Y stem All communictations via Working Memory (WM). 1.[Matching] Find the first rule whose premise are satisfied 2.[Conflict Resolution] The first has highest priority 3.[Execution] Execute(fire) the rule selected. The execution will change the WM. Then start from top.

17 Conflict Resolution Strategies First found Least recently used Most recently used Antecedent ordered Consequent ordered Most complex first Simplest first Rule priority User defined Refraction (don’t fire twice in sequence) Recency (the newest fact has priority) Specificity (the rule that matches most facts) Arbitrary choice Menu ”LEX” strategy

18 The logic of Proxy ”Imperative logic” Indicative Logic If Conditions then Conclusions Productions If Conditions then Actions Imperative Logic If Conditions then cause Conclusions

19 PROXY implementation outline proxy:- repeat, not epoch. epoch :- ( if P then Q ), P, not Q, assert Q. % repeat until % epoch fails % find a rule % check that P is true % and not Q is true % put Q into KB Alternative for negative conclusions epoch :- ( if P then not Q ), P, Q, retract Q.

20 Proxy’s Refraction Rule Proxy requires that all the conditions and not all the conclusions are true when a rule fires. Then all the conclusions will be made true by the imperative logic, so the same rule will not fire the next time. The method is not particularly efficient, but suffices for small to medium rule bases (< 1000 rules). Refraction (from refrain)

21 CLIPS C Language Implementation of production Systems Example of rule format (defrule become-adult (child harry) (birthday harry August-15) (age harry 17) (date today August-15) => (assert (adult harry)) (retract (child harry)) (retract (age harry 17)) (assert (age harry 18)) (print t “harry is now an adult”))

22 OPS-5 with example of rules for goal based reasoning English version IF there is a goal for monkey to be on some physical object and the object is at a particular location and the monkey is at some location holding something THEN establish a goal for the monkey to hold nothing. (p On::Phys-Object:Holds (goal ^status active ^type on ôbject-name ) (phys-object ^name ^at ) (monkey ^at ^holds <> nil) --> (make goal ^status active ^type on ^object-name nil))

23 Pragma Example of Pragma rule (to be shown), Purpose: If time requested is before 430 (today) (" half past four" ) and time now is after requested time + 1200 then change time requested to 1200 + time requested and change day to tomorrow. Pragma is a production system for translating the natural language queries (in the form of an intermediate meaning representation language TQL) to a database query. At present, there are 1329 rules. In average, 10 rules are fired. The time used is negligable.

24 Pragma rule example then Sixteen isa clock, not Four isa clock, srel/Prep/time/Sixteen/D, not srel/Prep/time/Four/D, queryitem(atday(TOMORROW)), queryitem(atdate(TODATE1)), message( ‘I assume you mean routes for tomorrow'). rule defaulttomorrowafternoon if srel/Rel/time/Four/_, not _ isa midnight, not _ isa morning, not _ isa prenoon, not _ isa afternoon, not _ isa evening, not _ isa night, not _ isa date, not _ isa weekday, {Four < 0430, Sixteen is Four + 1200)}, queryitem(timenow(NOW)), {NOW > Sixteen} queryitem(today(TODAY)), queryitem(todaysdate(TODATE)), { daysucc(TODAY,TOMORROW)}, { add_days(TODATE,1,TODATE1)},


Download ppt "Production Systems Productions systems are rule based forward chaining systems. They are based on forward chained reasoning, but are extended to be a kind."

Similar presentations


Ads by Google