Title: Production%20Systems
1Production 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.
2What 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
3When 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
4Forward and Backward chaining
Evidence
Hypothesis
Narrow and deep
Good applications for BC
Facts
Conclusions
Broad and shallow
Good applications for FC
5Incremental forward chaining
rule '9.3' american(X) and weapon(Y) and
sells(X,Y,Z) and hostile(Z) gt criminal(X).
rule '9.6' missile(X) and owns(nono,X) gt
sells(west,X,nono). rule '9.7' missile(X)
gt weapon(X). rule '9.8' enemy(X,america)
gt hostile(X). facts tgt owns(nono,m1).
9.4 tgt missile(m1).
9.5 tgt american(west). 9.9 tgt
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)
6Forward 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)
Derivations 9.6 gt sells(west,m1,nono)
9.7 gt weapon(m1) 9.8 gt
hostile(nono) 9.3 gt criminal(west)
Time 0 ms
facts owns(nono,m1) and 9.4
missile(m1) and 9.5 american(west)
and 9.9 enemy(nono,america). 9.10
7Production Systems
- Forward Chained
- All communictations via Working Memory (WM).
- Matching Find all the rules whose premise are
satisfied - Conflict Resolution If more than one rule
apply, select the one with the highest priority - Execution Execute(fire) the rule selected. The
execution will change the WM. - Then start again from top.
8Efficiency 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.
9Efficiency 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
10Efficiency 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.
11Efficiency 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) gt criminal(X)
- which avoids redundant inferences if west is
in the magic set. -
12Efficiency 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) gt
criminal(X) but hostile(Z) and sells(X,Y,Z)
and weapon(X) and american(X) gt criminal(X)
13Facts searching for rules
Rules searching for facts
FACTS
RULES
Facts searching for rules
RULES
FACTS
14The Rete() algorithm
Efficient algorithm to match facts against
(patterns) of rules to determine which rules have
all its conditions fullfilled
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.
() pronounced as treaty. Means net in Latin
15Production 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
16Production system PROXY
PROlog implementationof produXion sYstem
- All communictations via Working Memory (WM).
- Matching Find the first rule whose premise are
satisfied - Conflict Resolution The first has highest
priority - Execution Execute(fire) the rule selected. The
execution will - change the WM. Then start from top.
17Conflict Resolution Strategies
LEX strategy
Menu
- First found
- Least recently used
- Most recently used
- Antecedent ordered
- Consequent ordered
- Most complex first
- Simplest first
- Rule priority
- User defined
Refraction (dont fire twice in
sequence) Recency (the newest fact has
priority) Specificity (the rule that matches
most facts) Arbitrary choice
18The logic of ProxyImperative logic
Indicative Logic If Conditions then
Conclusions Productions If Conditions then
Actions Imperative Logic If Conditions then
cause Conclusions
19PROXY 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.
20Proxys Refraction Rule
Refraction (from refrain)
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 (lt 1000 rules).
21CLIPS
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) gt (assert (adult harry))
(retract (child harry)) (retract (age harry
17)) (assert (age harry 18)) (print t
harry is now an adult))
22OPS-5with 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 OnPhys-ObjectHolds (goal status active
type on ôbject-name lto1gt) (phys-object name
lto1gt at ltpgt) (monkey at ltpgt holds ltgt
nil) --gt (make goal status active type on
object-name nil))
23Pragma
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.
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.
24Pragma rule example
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 lt 0430,
Sixteen is Four 1200), queryitem(timenow(NO
W)), NOW gt Sixteen
queryitem(today(TODAY)), queryitem(todaysdate(
TODATE)), daysucc(TODAY,TOMORROW),
add_days(TODATE,1,TODATE1),
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').