Вы находитесь на странице: 1из 16

Riga Technical University

Faculty of Computer Science and Information Technology


Department of Systems Theory and Design

FUNDAMENTALS OF ARTIFICIAL
INTELLIGENCE
Lecture 9

PRODUCTION SYSTEMS

Dr.habil.sc.ing., professor Janis Grundspenkis, Dr.sc.ing., lecturer Alla Anohina-Naumeca


Department of Systems Theory and Design
Faculty of Computer Science and Information Technology
Riga Technical University
E-mail: {janis.grundspenkis, alla.anohina-naumeca}@rtu.lv
Address: Meza street 1/4- {550, 545}, Riga, Latvia, LV-1048
Phone: (+371) 67089{581, 595}
Definition (1)

A production system is a system based on IF… THEN… rules and


consisting of 3 parts:

1. The set of production rules

2. Working memory

3. The recognize-act cycle

2/16
Definition (2)
A production or a rule is condition-action pair presented in the
following form:

IF condition THEN action

A production is a single chunk of problem-solving knowledge. The


condition part of the rule is a pattern that determines when the rule
may be applied to a problem. The action part defines the associated
problem-solving step.

The w orking m em ory contains a description of the current state of


the problem-solving.

The recognize-act cycle implements search allowing the production


system to move towards a goal within the set of rules.
3/16
Pattern-directed search (1)

Operation of the recognize-act cycle are based on the pattern-


directed search :
1. The working memory contains a pattern corresponding to the
current state in the problem-solving process

2. The pattern is matched against IF or THEN part of rules (it


depends on the direction of search)

3. If several rules match the pattern, the conflict set appears. The
production rules in the conflict set are said to be enabled .
Selection of one rule from the conflict set is called conflict
resolution .

4/16
Pattern-directed search (2)
Operation of the recognize-act cycle are based on the pattern-
directed search (continued):
4. One of the enabled rules is fired and it changes the content of
the working memory

5. The control cycle repeats with the modified working memory

6. The process terminates when no rules are matched by the


content of the working memory

Working memory Knowledge base


C-condition IF C1 THEN A1
IF C2 THEN A2
A-action …
[Pattern]
IF Cn THEN An

5/16
Control of search in production
systems
For real world problems a knowledge base typically includes a huge
number of IF...THEN... rules. In order to make search more effective,
developers of intelligent systems must use heuristic control of search.

There are 3 control strategies:

1. Control through choice of search strategy

2. Control through rule structure

3. Control through conflict resolution

6/16
Control through choice of search
strategy (1)
It is possible to choose a direction of search in production systems:
1. Data-driven search (forward chaining)

2. Goal-driven search (backward chaining)


Data-driven search:

1. Begins with a problem description (a pattern) added to the working


memory

2. The recognize-act cycle compares matching of the pattern with IF part


of rules in the knowledge base

3. Firing a rule, its THEN part is added to the working memory and the
process continues

4. Search stops when the goal is found 7/16


Control through choice of search
strategy (2)
Example: Data-driven search
Knowledge base:
A B
1. IF John is a student THEN John enjoys student’s life
B C
2. IF John enjoys student’s life THEN John meets friends AND
D
John participates in university’s events
C E
3. IF John meets friends THEN John needs money
E F
4. IF John needs money THEN John has a job
D
C
5. IF John meets friends AND John participates in university’s events
G
THEN John has little free time
G F H
6. IF John has little free time AND John has a job THEN John is not successful in studies AND
I
John does not receive scholarship
8/16
Control through choice of search
strategy (3)
Example: Data-driven search

Knowledge base:
1. IF A THEN B Start - A
2. IF B THEN C AND D Goal - I
3. IF C THEN E
4. IF E THEN F
5. IF C AND D THEN G
6. IF G AND F THEN H AND I

Iteration Working memory Conflict set Fired rule


0 A 1 1
1 A, B 1, 2 2
2 A, B, C, D 1, 2, 3, 5 5
3 A, B, C, D, G 1, 2, 3, 5 3
4 A, B, C, D, G, E 1, 2, 3, 5, 4 4
5 A, B, C, D, G, E, F 1, 2, 3, 5, 4, 6 6
6 A, B, C, D, G, E, F, H, I 1, 2, 3, 5, 4, 6 goal 9/16
Control through choice of search
strategy (4)

Goal-driven search:

1. A goal (a pattern) is added to the working memory

2. The recognize-act cycle compares matching of the pattern with


THEN part of rules in the knowledge base

3. Firing a rule, its IF part is added to the working memory and the
process continues

4. Search stops when facts on problem are found

10/16
Control through choice of search
strategy (5)
Example:
Goal-driven search

Knowledge base:
1. IF p AND q THEN goal
2. IF r AND s THEN p
3. IF w AND r THEN q
4. IF t AND u THEN q
5. IF v THEN s
6. IF start THEN v AND r AND q

Iteration Working memory Conflict set Fired rule


0 goal 1 1
1 goal, p, q 1, 2, 3, 4 2
2 goal, p, q, r, s 1, 2, 3, 4, 5 3
3 goal, p, q, r, s, w 1, 2, 3, 4, 5 4
4 goal, p, q, r, s, w, t, u 1, 2, 3, 4, 5 5
5 goal, p, q, r, s, w, t, u, v 1, 2, 3, 4, 5, 6 6
6 goal, p, q, r, s, w, t, u, v, start 1, 2, 3, 4, 5, 6 stop
11/16
Control through rule structure (1)

Human experts encode crucial heuristics within their rules of expertise.


The order of conditions encodes important procedural information for
solving the problem. It is important that this form be preserved in
building an intelligent system that solves problems like the expert.
When a mechanic says “if the engine won’t turn over and the lights
don’t come on then check the battery”, he/she is suggesting a specific
sequence of things to try. This from of the rules is critical in controlling
search, making the system behave logically.

12/16
Control through rule structure (2)

RULE STRUCTURE
+
RULE ORDER IN THE KNOWLEDGE BASE

Defines search order and its effectiveness

13/16
Control through rule structure (3)
RULE STRUCTURE

What is the content of IF part? Kas būs darbības daļā?

How several What will be the What will be the


conditions will order of order of actions if
be connected conditions if they they are several?
(AND, OR) ? are several?
… THEN a & b & c
IF a & b & c…
… THEN b & a & c
IF b & a & c…

14/16
Control through rule structure (4)

RULE ORDER

1. RULE A 1. RULE E

2. RULE B 2. RULE B

3. RULE C 3. RULE D

4. RULE D 4. RULE A

5. RULE E 5. RULE C

15/16
Control through conflict resolution
The simplest strategy is to choose the first rule that matches the content of the
working memory and do not use recently fired rules.
Common strategy:

1. Once a rule has fired, it may not fire again until the working memory
elements that match its conditions have been modified, this discourages
looping.
2. Rules whose conditions match with the patterns most recently added to
the working memory are more preferred. This focuses the search on a
single line of reasoning.
3. A more specific problem-solving rule is preferred to a general rule. A
rule is more specific than another if it has more conditions.

IF a THEN c
IF a AND b THEN c more specific rule
16/16