KEMBAR78
Rule based system | PPTX
RULE-BASED
SYSTEM
Dr. C.V. Suresh Babu
(CentreforKnowledgeTransfer)
institute
(CentreforKnowledgeTransfer)
institute
Objective
■ As you look to automate parts of your business, you’ve no doubt come across the
term ‘rule-based system’. (Alongside other, flashier terms like AI, RPA and software
“robots”.) But what is a rule-based system, exactly?
■ Rule-based logic is at the heart of most automated software processes.
Unfortunately, there are a lot of easy-to-make misconceptions of what a rule-based
system is and does.
■ So, to help clarify any confusion, here’s a closer look at rule-based systems and
how they work.
(CentreforKnowledgeTransfer)
institute
What is a rule-based system?
■ A rule-based system or production systems is a computer system that applies
human-made rules to store, sort and manipulate data to provide recommendations
or diagnoses, or to determine a course of action in a particular situation or to solve
a particular problem. In doing so, it mimics human intelligence.
(CentreforKnowledgeTransfer)
institute
Components of RBS
A rule-based system consists of a number of components:
1. Database of rules (also called a knowledge base)
– It consists of a set of rules that represent the knowledge that the system has.
2. Database of facts
– It represents inputs to the system that are used to derive conclusions, or to cause
actions.
3. Interpreter, or inference engine
– It is the part of the system that controls the process of deriving conclusions. It uses
the rules and facts, and combines them together to draw conclusions.
(CentreforKnowledgeTransfer)
institute
So, what is a rule-based system?
It’s a logical program that uses pre-defined
rules to make deductions and choices to
perform automated actions.
(CentreforKnowledgeTransfer)
institute
How rule-based system works?
■ To work, rule-based systems require a set of facts or source of data, and a set of
rules for manipulating that data. These rules are sometimes referred to as ‘If
statements’ as they tend to follow the line of ‘IF X happens THEN do Y’.
■ It automates processes by breaking them down into steps.
– First comes the data or new business event
– Then comes the analysis: the part where the system conditionally processes
the data against its rules
– Then comes any subsequent automated follow-up actions
(CentreforKnowledgeTransfer)
institute
Example
■ Rule-based systems, unsurprisingly, work based on rules. These rules outline triggers
and the actions that should follow (or are triggered). For example, a trigger might be an
email containing the word “invoice”. An action might then be to forward the email to
the finance team.
■ These rules most often take the form of if statements. ‘IF’ outlines the trigger, ‘THEN’
specifies the action to complete. So, if you want to create a rule-based system capable
of handling 100 different actions, you’d have to write 100 different rules. If you want to
then update the system and add actions, then you would need to write new rules.
■ In short, you use rules to tell a machine what to do, and the machine will do exactly as
you tell it. From there, rule-based systems will execute the actions until you tell it to
stop.
■ But remember: if you tell it to do something incorrectly, it will do it incorrectly.
(CentreforKnowledgeTransfer)
institute
What is a rule-based system not?
■ Due to early use in the fields, rule-based systems are commonly confused with
artificial intelligence and machine learning. However, they are not AI, and they are
not machine learning.
■ It’s easy to confuse the two as they can look very similar. Both involve machines
completing tasks, seemingly on their own. The difference is that AI can determine
the action to take itself; it can learn and adapt. Meanwhile, rule-based systems do
exactly as instructed by a human.
■ In other words, unlike artificial intelligence and machine learning, the actions
carried out by rule-based systems (the rules that they follow) are determined by a
human.
■ The system doesn’t work it out for itself, or intelligently make decisions.
(CentreforKnowledgeTransfer)
institute
A rule-based system won’t
change or update on its own,
and it won’t ‘learn’ from
mistakes.
(CentreforKnowledgeTransfer)
institute
Summary
■ What is a rule-based system? It’s not AI, and it’s not machine learning. (Thought it
might be used within them, to power certain aspects.)
■ Rather, rule-based systems simply follow rules laid out by humans. But in doing so,
they are incredibly useful.
https://www.youtube.com/watch?v=bes9e96stk8
(CentreforKnowledgeTransfer)
institute
Types of RBS
Using deduction to reach a conclusion from a
set of antecedents is called forward chaining.
An alternative method, backward chaining,
starts from a conclusion and tries to show it by
following a logical path backward from the
conclusion to a set of antecedents that are in
the database of facts.
(CentreforKnowledgeTransfer)
institute
Forward Chaining
■ Forward chaining employs the system starts from a set of facts, and a set of rules,
and tries to find a way of using those rules and facts to deduce a conclusion or
come up with a suitable course of action.
■ This is known as data-driven reasoning because the reasoning starts from a set
of data and ends up at the goal, which is the conclusion.
■ When applying forward chaining, the first step is to take the facts in the fact
database and see if any combination of these matches all the antecedents of one
of the rules in the rule database.
■ When all the antecedents of a rule are matched by facts in the database, then this
rule is triggered.
■ Usually, when a rule is triggered, it is then fired, which means its conclusion is
added to the facts database.
■ If the conclusion of the rule that has fired is an action or a recommendation, then
the system may cause that action to take place or the recommendation to be
made.
(CentreforKnowledgeTransfer)
institute
For example, consider the following set of
rules that is used to control an elevator in a
three-story building:
Rule 1
IF on first floor and button is pressed on first floor
THEN open door
Rule 2
IF on first floor
AND button is pressed on second floor
THEN go to second floor
Rule 3
IF on first floor
AND button is pressed on third floor
THEN go to third floor
Rule 4
IF on second floor
AND button is pressed on first floor
AND already going to third floor
THEN remember to go to first floor later
This represents just a subset of the rules that would be needed,
but we can use it to illustrate how forward chaining works.
Let us imagine that we start with the following facts in our
database:
Fact 1: At first floor
Fact 2: Button pressed on third floor
Fact 3: Today is Tuesday
• Now the system examines the rules and finds that Facts 1
and 2 match the antecedents of Rule 3.
• Hence, Rule 3 fires, and its conclusion “Go to third floor”
is added to the database of facts.
• Presumably, this results in the elevator heading toward
the third floor.
• Note that Fact 3 was ignored altogether because it did not
match the antecedents of any of the rules.
(CentreforKnowledgeTransfer)
institute
Now let us imagine that the elevator is on its way to the third floor and has
reached the second floor, when the button is pressed on the first floor. The
fact Button pressed on first floor
Is now added to the database, which results in Rule 4 firing.
Now let us imagine that later in the day the facts database contains the following
information:
Fact 1: At first floor
Fact 2 : Button pressed on second floor
Fact 3: Button pressed on third floor
In this case, two rules are triggered—Rules 2 and 3. In such cases where there is
more than one possible conclusion, conflict resolution needs to be applied to
decide which rule to fire.
(CentreforKnowledgeTransfer)
institute
Conflict Resolution
In a situation where more than one conclusion can be deduced from a set of
facts, there are a number of possible ways to decide which rule to fire.
For example, consider the following set of rules:
IF it is cold
THEN wear a coat
IF it is cold
THEN stay at home
IF it is cold
THEN turn on the heat
If there is a single fact in the fact database, which is “it is
cold,” then clearly there are three conclusions that can be
derived. In some cases, it might be fine to follow all three
conclusions, but in many cases the conclusions are
incompatible.
(CentreforKnowledgeTransfer)
institute
In one conflict resolution method, rules are given priority levels, and when a
conflict occurs, the rule that has the highest priority is fired, as in the following
example:
IF patient has pain
THEN prescribe painkillers priority 10
IF patient has chest pain
THEN treat for heart disease priority 100
• Here, it is clear that treating possible heart problems is more important than
just curing the pain.
• An alternative method is the longest-matching strategy.
• This method involves firing the conclusion that was derived from the longest
rule.
(CentreforKnowledgeTransfer)
institute
IF patient has pain
THEN prescribe painkiller
IF patient has chest pain
AND patient is over 60
AND patient has history of heart conditions
THEN take to emergency room
• Here, if all the antecedents of the second rule match,
then this rule’s conclusion should be fired rather than
the conclusion of the first rule because it is a more
specific match.
• A further method for conflict resolution is to fire the rule
that has matched the facts most recently added to the
database.
For example:
In each case, it may be that the system fires one rule and then stops, but in many cases, the system simply
needs to choose a suitable ordering for the rules because each rule that matches the facts needs to be fired at
some point.
(CentreforKnowledgeTransfer)
institute
Meta Rules
In designing an expert system, it is necessary to select the conflict resolution method that
will be used, and quite possibly it will be necessary to use different methods to resolve
different types of conflicts.
For example, in some situations it may make most sense to use the method that involves firing the most
recently added rules.
This method makes most sense in situations in which the timeliness of data is important. It might be, for
example, that as research in a particular field of medicine develops, and new rules are added to the system
that contradicts some of the older rules.
It might make most sense for the system to assume that these newer rules are more accurate than the older
rules.
It might also be the case, however, that the new rules have been added by an expert whose opinion is less
trusted than that of the expert who added the earlier rules.
In this case, it clearly makes more sense to allow the earlier rules priority.
This kind of knowledge is called meta knowledge—knowledge about knowledge. The rules that define how
conflict resolution will be used, and how other aspects of the system itself will run, are called meta rules.
(CentreforKnowledgeTransfer)
institute
Knowledge engineer
■ The knowledge engineer who builds the expert system is responsible for
building appropriate meta knowledge into the system (such as “expert A
is to be trusted more than expert B” or “any rule that involves drug X is
not to be trusted as much as rules that do not involve X”).
■ Meta rules are treated by the expert system as if they were ordinary
rules but are given greater priority than the normal rules that make up
the expert system.
■ In this way, the meta rules are able to override the normal rules, if
necessary, and are certainly able to control the conflict resolution
process
(CentreforKnowledgeTransfer)
institute
Backward Chaining
■ Forward chaining applies a set of rules and facts to deduce whatever
conclusions can be derived, which is useful when a set of facts are present,
but you do not know what conclusions you are trying to prove.
■ Forward chaining can be inefficient because it may end up proving a number of conclusions
that are not currently interesting.
■ In such cases, where a single specific conclusion is to be proved, backward chaining is
more appropriate.
■ In backward chaining, we start from a conclusion, which is the hypothesis we wish to prove,
and we aim to show how that conclusion can be reached from the rules and facts in the
database.
■ The conclusion we are aiming to prove is called a goal, and so reasoning in this way is
known as goal-driven reasoning.
■ Backward chaining is often used in formulating plans.
■ A plan is a sequence of actions that a program decides to take to solve a particular problem.
■ Backward chaining can make the process of formulating a plan more efficient than forward
chaining.
(CentreforKnowledgeTransfer)
institute
■ Backward chaining in this way starts with the goal state, which is the
set of conditions the agent wishes to achieve in carrying out its plan.
It now examines this state and sees what actions could lead to it.
For example,
■ if the goal state involves a block being on a table, then one possible action would be to
place that block on the table.
■ This action might not be possible from the start state, and so further actions need to be
added before this action in order to reach it from the start state.
■ In this way, a plan can be formulated starting from the goal and working back toward the
start state.
■ The benefit in this method is particularly clear in situations where the first state allows a
very large number of possible actions.
■ In this kind of situation, it can be very inefficient to attempt to formulate a plan using
forward chaining because it involves examining every possible action, without paying
any attention to which action might be the best one to lead to the goal state.
■ Backward chaining ensures that each action that is taken is one that will definitely lead
to the goal, and in many cases this will make the planning process far more efficient.

Rule based system

  • 1.
    RULE-BASED SYSTEM Dr. C.V. SureshBabu (CentreforKnowledgeTransfer) institute
  • 2.
    (CentreforKnowledgeTransfer) institute Objective ■ As youlook to automate parts of your business, you’ve no doubt come across the term ‘rule-based system’. (Alongside other, flashier terms like AI, RPA and software “robots”.) But what is a rule-based system, exactly? ■ Rule-based logic is at the heart of most automated software processes. Unfortunately, there are a lot of easy-to-make misconceptions of what a rule-based system is and does. ■ So, to help clarify any confusion, here’s a closer look at rule-based systems and how they work.
  • 3.
    (CentreforKnowledgeTransfer) institute What is arule-based system? ■ A rule-based system or production systems is a computer system that applies human-made rules to store, sort and manipulate data to provide recommendations or diagnoses, or to determine a course of action in a particular situation or to solve a particular problem. In doing so, it mimics human intelligence.
  • 4.
    (CentreforKnowledgeTransfer) institute Components of RBS Arule-based system consists of a number of components: 1. Database of rules (also called a knowledge base) – It consists of a set of rules that represent the knowledge that the system has. 2. Database of facts – It represents inputs to the system that are used to derive conclusions, or to cause actions. 3. Interpreter, or inference engine – It is the part of the system that controls the process of deriving conclusions. It uses the rules and facts, and combines them together to draw conclusions.
  • 5.
    (CentreforKnowledgeTransfer) institute So, what isa rule-based system? It’s a logical program that uses pre-defined rules to make deductions and choices to perform automated actions.
  • 6.
    (CentreforKnowledgeTransfer) institute How rule-based systemworks? ■ To work, rule-based systems require a set of facts or source of data, and a set of rules for manipulating that data. These rules are sometimes referred to as ‘If statements’ as they tend to follow the line of ‘IF X happens THEN do Y’. ■ It automates processes by breaking them down into steps. – First comes the data or new business event – Then comes the analysis: the part where the system conditionally processes the data against its rules – Then comes any subsequent automated follow-up actions
  • 7.
    (CentreforKnowledgeTransfer) institute Example ■ Rule-based systems,unsurprisingly, work based on rules. These rules outline triggers and the actions that should follow (or are triggered). For example, a trigger might be an email containing the word “invoice”. An action might then be to forward the email to the finance team. ■ These rules most often take the form of if statements. ‘IF’ outlines the trigger, ‘THEN’ specifies the action to complete. So, if you want to create a rule-based system capable of handling 100 different actions, you’d have to write 100 different rules. If you want to then update the system and add actions, then you would need to write new rules. ■ In short, you use rules to tell a machine what to do, and the machine will do exactly as you tell it. From there, rule-based systems will execute the actions until you tell it to stop. ■ But remember: if you tell it to do something incorrectly, it will do it incorrectly.
  • 8.
    (CentreforKnowledgeTransfer) institute What is arule-based system not? ■ Due to early use in the fields, rule-based systems are commonly confused with artificial intelligence and machine learning. However, they are not AI, and they are not machine learning. ■ It’s easy to confuse the two as they can look very similar. Both involve machines completing tasks, seemingly on their own. The difference is that AI can determine the action to take itself; it can learn and adapt. Meanwhile, rule-based systems do exactly as instructed by a human. ■ In other words, unlike artificial intelligence and machine learning, the actions carried out by rule-based systems (the rules that they follow) are determined by a human. ■ The system doesn’t work it out for itself, or intelligently make decisions.
  • 9.
    (CentreforKnowledgeTransfer) institute A rule-based systemwon’t change or update on its own, and it won’t ‘learn’ from mistakes.
  • 10.
    (CentreforKnowledgeTransfer) institute Summary ■ What isa rule-based system? It’s not AI, and it’s not machine learning. (Thought it might be used within them, to power certain aspects.) ■ Rather, rule-based systems simply follow rules laid out by humans. But in doing so, they are incredibly useful. https://www.youtube.com/watch?v=bes9e96stk8
  • 11.
    (CentreforKnowledgeTransfer) institute Types of RBS Usingdeduction to reach a conclusion from a set of antecedents is called forward chaining. An alternative method, backward chaining, starts from a conclusion and tries to show it by following a logical path backward from the conclusion to a set of antecedents that are in the database of facts.
  • 12.
    (CentreforKnowledgeTransfer) institute Forward Chaining ■ Forwardchaining employs the system starts from a set of facts, and a set of rules, and tries to find a way of using those rules and facts to deduce a conclusion or come up with a suitable course of action. ■ This is known as data-driven reasoning because the reasoning starts from a set of data and ends up at the goal, which is the conclusion. ■ When applying forward chaining, the first step is to take the facts in the fact database and see if any combination of these matches all the antecedents of one of the rules in the rule database. ■ When all the antecedents of a rule are matched by facts in the database, then this rule is triggered. ■ Usually, when a rule is triggered, it is then fired, which means its conclusion is added to the facts database. ■ If the conclusion of the rule that has fired is an action or a recommendation, then the system may cause that action to take place or the recommendation to be made.
  • 13.
    (CentreforKnowledgeTransfer) institute For example, considerthe following set of rules that is used to control an elevator in a three-story building: Rule 1 IF on first floor and button is pressed on first floor THEN open door Rule 2 IF on first floor AND button is pressed on second floor THEN go to second floor Rule 3 IF on first floor AND button is pressed on third floor THEN go to third floor Rule 4 IF on second floor AND button is pressed on first floor AND already going to third floor THEN remember to go to first floor later This represents just a subset of the rules that would be needed, but we can use it to illustrate how forward chaining works. Let us imagine that we start with the following facts in our database: Fact 1: At first floor Fact 2: Button pressed on third floor Fact 3: Today is Tuesday • Now the system examines the rules and finds that Facts 1 and 2 match the antecedents of Rule 3. • Hence, Rule 3 fires, and its conclusion “Go to third floor” is added to the database of facts. • Presumably, this results in the elevator heading toward the third floor. • Note that Fact 3 was ignored altogether because it did not match the antecedents of any of the rules.
  • 14.
    (CentreforKnowledgeTransfer) institute Now let usimagine that the elevator is on its way to the third floor and has reached the second floor, when the button is pressed on the first floor. The fact Button pressed on first floor Is now added to the database, which results in Rule 4 firing. Now let us imagine that later in the day the facts database contains the following information: Fact 1: At first floor Fact 2 : Button pressed on second floor Fact 3: Button pressed on third floor In this case, two rules are triggered—Rules 2 and 3. In such cases where there is more than one possible conclusion, conflict resolution needs to be applied to decide which rule to fire.
  • 15.
    (CentreforKnowledgeTransfer) institute Conflict Resolution In asituation where more than one conclusion can be deduced from a set of facts, there are a number of possible ways to decide which rule to fire. For example, consider the following set of rules: IF it is cold THEN wear a coat IF it is cold THEN stay at home IF it is cold THEN turn on the heat If there is a single fact in the fact database, which is “it is cold,” then clearly there are three conclusions that can be derived. In some cases, it might be fine to follow all three conclusions, but in many cases the conclusions are incompatible.
  • 16.
    (CentreforKnowledgeTransfer) institute In one conflictresolution method, rules are given priority levels, and when a conflict occurs, the rule that has the highest priority is fired, as in the following example: IF patient has pain THEN prescribe painkillers priority 10 IF patient has chest pain THEN treat for heart disease priority 100 • Here, it is clear that treating possible heart problems is more important than just curing the pain. • An alternative method is the longest-matching strategy. • This method involves firing the conclusion that was derived from the longest rule.
  • 17.
    (CentreforKnowledgeTransfer) institute IF patient haspain THEN prescribe painkiller IF patient has chest pain AND patient is over 60 AND patient has history of heart conditions THEN take to emergency room • Here, if all the antecedents of the second rule match, then this rule’s conclusion should be fired rather than the conclusion of the first rule because it is a more specific match. • A further method for conflict resolution is to fire the rule that has matched the facts most recently added to the database. For example: In each case, it may be that the system fires one rule and then stops, but in many cases, the system simply needs to choose a suitable ordering for the rules because each rule that matches the facts needs to be fired at some point.
  • 18.
    (CentreforKnowledgeTransfer) institute Meta Rules In designingan expert system, it is necessary to select the conflict resolution method that will be used, and quite possibly it will be necessary to use different methods to resolve different types of conflicts. For example, in some situations it may make most sense to use the method that involves firing the most recently added rules. This method makes most sense in situations in which the timeliness of data is important. It might be, for example, that as research in a particular field of medicine develops, and new rules are added to the system that contradicts some of the older rules. It might make most sense for the system to assume that these newer rules are more accurate than the older rules. It might also be the case, however, that the new rules have been added by an expert whose opinion is less trusted than that of the expert who added the earlier rules. In this case, it clearly makes more sense to allow the earlier rules priority. This kind of knowledge is called meta knowledge—knowledge about knowledge. The rules that define how conflict resolution will be used, and how other aspects of the system itself will run, are called meta rules.
  • 19.
    (CentreforKnowledgeTransfer) institute Knowledge engineer ■ Theknowledge engineer who builds the expert system is responsible for building appropriate meta knowledge into the system (such as “expert A is to be trusted more than expert B” or “any rule that involves drug X is not to be trusted as much as rules that do not involve X”). ■ Meta rules are treated by the expert system as if they were ordinary rules but are given greater priority than the normal rules that make up the expert system. ■ In this way, the meta rules are able to override the normal rules, if necessary, and are certainly able to control the conflict resolution process
  • 20.
    (CentreforKnowledgeTransfer) institute Backward Chaining ■ Forwardchaining applies a set of rules and facts to deduce whatever conclusions can be derived, which is useful when a set of facts are present, but you do not know what conclusions you are trying to prove. ■ Forward chaining can be inefficient because it may end up proving a number of conclusions that are not currently interesting. ■ In such cases, where a single specific conclusion is to be proved, backward chaining is more appropriate. ■ In backward chaining, we start from a conclusion, which is the hypothesis we wish to prove, and we aim to show how that conclusion can be reached from the rules and facts in the database. ■ The conclusion we are aiming to prove is called a goal, and so reasoning in this way is known as goal-driven reasoning. ■ Backward chaining is often used in formulating plans. ■ A plan is a sequence of actions that a program decides to take to solve a particular problem. ■ Backward chaining can make the process of formulating a plan more efficient than forward chaining.
  • 21.
    (CentreforKnowledgeTransfer) institute ■ Backward chainingin this way starts with the goal state, which is the set of conditions the agent wishes to achieve in carrying out its plan. It now examines this state and sees what actions could lead to it. For example, ■ if the goal state involves a block being on a table, then one possible action would be to place that block on the table. ■ This action might not be possible from the start state, and so further actions need to be added before this action in order to reach it from the start state. ■ In this way, a plan can be formulated starting from the goal and working back toward the start state. ■ The benefit in this method is particularly clear in situations where the first state allows a very large number of possible actions. ■ In this kind of situation, it can be very inefficient to attempt to formulate a plan using forward chaining because it involves examining every possible action, without paying any attention to which action might be the best one to lead to the goal state. ■ Backward chaining ensures that each action that is taken is one that will definitely lead to the goal, and in many cases this will make the planning process far more efficient.