0% found this document useful (0 votes)
176 views8 pages

SE AI Lab Practical 1

The document outlines the development of an Expert System using Rule-Based Systems in AI, focusing on simple decision-making. It details the roles of team members, the structure of the system, and provides examples of rules and conflict resolution methods. A practical implementation example is included, demonstrating how the system can assist users in making decisions, such as whether to carry an umbrella.

Uploaded by

abhinavsargar1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
176 views8 pages

SE AI Lab Practical 1

The document outlines the development of an Expert System using Rule-Based Systems in AI, focusing on simple decision-making. It details the roles of team members, the structure of the system, and provides examples of rules and conflict resolution methods. A practical implementation example is included, demonstrating how the system can assist users in making decisions, such as whether to carry an umbrella.

Uploaded by

abhinavsargar1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Practical No.

1
Title: Expert System Using Rule-Based Systems in AI.
Problem Statement: Building an Expert System Using Rule-Based Systems – Objective: Develop an
Expert System that provides simple decision-making.

Aim: Building an Expert System Using Rule-Based Systems.


Objective: Develop an Expert System that provides simple decision-making.
Prerequisites: Python/Java/LISP/Prolog/OPS Programming.
Learning Objectives:
 To understand the concept of expert systems and Rule-Based Systems.
 To implement an expert system for simple decision-making.

Outcomes:
 Understanding Expert System and Rule-Based Systems.
 Understanding Use of Expert System in AI.
 Understanding Decision-Making Process.
 Understand and Implement the Expert System concept for simple decision-making.

Theory:
What is knowledge?

Knowledge is a theoretical or practical understanding of a subject or a domain. It is also the sim of what is
currently known, and apparently knowledge is power.

Experts
Those who possess knowledge are called experts. Anyone can be considered a domain expert if he or she
has deep knowledge and strong practical experience in a particular domain. The human mental process is
internal, and it is too complex to be represented as an algorithm. However, most experts are capable of
expressing their knowledge in the form of rules for problem solving.

Example:

IF the ‘traffic light’ is ‘green’


THEN the action is go

IF the ‘traffic light’ is ‘red’


THEN the action is stop

Rules as a Knowledge Representation Technique


The term rule in AI, which is the most commonly used type of knowledge representation, can be defined
as an IF-THEN structure that relates given information or facts in the IF part to some action in the
THEN part. A rule provides some description of how to solve a problem. Rule are relatively easy to
create and understand.

Any rules consists of two parts: the IF part, called the antecedent (premise or condition) and the THEN
part called the consequent (conclusion or action)

IF <antecedent>
THEN <consequent>

A rule can have multiple antecedents joined by the keywords AND (conjunction), OR (disjunction) or a
combination of both.

IF <antecedent 1> IF <antecedent 1>


AND <antecedent 2> OR <antecedent 2>
: :
AND <antecedent n> OR <antecedent n>
THEN <consequent> THEN <consequent>

The antecedent of a rule incorporates two parts: an Object (linguistic object) and its value. The
object And its value are linked by an operator. The operator identifies the object and assigns the
Value. Operators such as is, are, is not, are not are used to assign a symbolic value to a linguistic
object. Expert systems can also used mathematical operators to define an object as numerical and
assign it to the numerical value.
IF ‘age of the customer’ < 18
AND ‘cash withdrawal’ > 1000
THEN ‘signature of the parent’ is required

Rules can represent:

 Relation: IF the ‘fuel tank’ is empty THEN the car is dead.

 Recommendation: IF the season is autumn AND the sky is cloudy AND the forecast is drizzle
THEN the advice is ‘take an umbrella’

 Directive: IF the car is dead AND the ‘fuel tank’ is


empty THEN the action is ‘refuel the car’

 Strategy: IF the car is dead THEN the action is


‘check the fuel tank’; step1 complete
IF step1 is complete AND the ‘fuel tank’ is full THEN the action is ‘check the battery’; step2 is
Complete

 Heuristic: IF the spill is liquid AND the ‘spill pH’< 6 AND the ‘spill smell’ is vinegar THEN the
‘spill material’ is ‘acetic acid’
The main players in the development team

There are five members of the expert system development team:

1. Domain expert
2. Knowledge engineer
3. Programmer
4. Project manager
5. End-user

• Domain Expert:

Domain Expert is a knowledgeable and skilled person capable of solving problems in a specific area or
domain. The person’s expertise is to be captured in the expert system. The person could be more than one
expert that contribute to an expert system. The expert must be able to communicate his or her knowledge,
be willing to participate in the expert system development and commit a substantial amount of time to the
project is the most important person in the expert system development team.

• Knowledge Engineer:

Knowledge Engineer is someone who is capable of designing, building and testing an expert system.
Knowledge Engineer interviews the domain expert to find out how a particular problem is solved.
Knowledge Engineer establishes what reasoning methods the expert uses to handle facts and rules and
decides how to represent them in the expert system. Knowledge Engineer choose some development
software or an expert systems shell, or look at programming languages for encoding the knowledge.
Knowledge Engineer responsible for testing, revising and integrating the expert system into the
workplace.
• Programmer:

Programmer is the person responsible for the actual programming, describing the domain knowledge in
terms that a computer can understand. Programmer needs to have the skills in symbolic programming in
such AI language such as Prolog. Programmer should also know conventional programming language like
C, Pascal, FORTRAN and Basic.

• Project Manager:

Project Manager is the leader of the expert system development team, responsible for keeping the project
on track. Project Manager makes sure that all deliverables and milestones are met, interacts with the
expert, knowledge engineer, Programmer and end-user.

• End-user:

End-user or user is a person who uses the expert system when it is developed. End-user must not only be
confident in the expert system performance but also feel comfortable using it.

Structure of a rule-based expert system

In early 70s, Newell and Simon from Carnegie-Mellon University proposed a production system
model, the foundation of the modern rule-based expert systems. The production model is based on the
idea that humans solve problems by applying their knowledge (expressed as production rules) to a given
problem represented by problem-specific information. The production rules are stored in the long-term
memory and the problem-specific information or facts in the short-term memory.

Basic Structure of a rule-based expert system

 Knowledge base contains the domain knowledge useful for problem solving. In rule-based expert
system, the knowledge is represented as a set of rules. Each rule specifies a relation,
recommendation, directive, strategy or heuristic and has the IF (condition) THEN (action)
structure. When the condition part of a rule is satisfied, the rule said to fire and the action part is
executed.

 The database includes a set of facts used to match against the IF (condition) parts of rules stored
in the knowledge base.
 The inference engineer carries out the reasoning whereby the expert system reaches a solution. It
links. The rules given in the knowledge base with the facts provided in the database.

 The explanation facilities enable the user to ask the expert system how a particular conclusion is
reached and why a specific fact is needed.

 The user interface is the means of communication between a user seeking a solution to the
problem and an expert system.

Conflict Resolution

Let us consider two simple rules for crossing a road. And let us now add the third rule:

Rule 1:

IF the ‘traffic light’ is green


THEN the action is go

Rule 2:

IF the ‘traffic light’ is red


THEN the action is stop

Rule 3:

IF the ‘traffic light’ is red


THEN the action is go

There are two rules, Rule 2 and Rule 3, with the same IF part. Thus both of them can be set to
fire when the condition part is satisfied. These rules represent a conflict set. The inference engine
must determine which rule to fire from such a set.

A method for choosing a rule to fire when more than one rule can be fired in a given cycle is
called conflict resolution.

Methods used for conflict resolution

• Fire the rule with the highest priority. In simple applications, the priority can be established by
placing the rules in an appropriate order in the knowledge base. Usually this strategy works well
for expert systems with around 100 rules.

• Fire the most specific rule. This method is also known as the longest matching strategy. It is
based On the assumption that a specific rule processes more Information than a general one.

• Fire the rule that uses the data most recently entered in the database. This method relies on time
tags attached to each fact in the database. In the conflict set, the expert system first fires the rule whose
antecedent uses the data most recently added to the database.
Implementation in Program

Example Use Case: "Should I carry an umbrella?"

Step 1: Define Rules

Rule 1: IF it is raining THEN carry an umbrella.


Rule 2: IF it is cloudy AND you don’t have a jacket THEN carry an umbrella.
Rule 3: OTHERWISE, no need to carry an umbrella.

Step 2: Knowledge Base

rules = [
{"conditions": {"raining": "yes"}, "decision": "Carry an
umbrella"},
{"conditions": {"raining": "no", "cloudy": "yes", "jacket":
"no"}, "decision": "Carry an umbrella"},
]
Step 3: Inference Engine (Simple Matching Logic)

def make_decision(facts, rules):


for rule in rules:
if all(facts.get(key) == value for key, value in
rule["conditions"].items()):
return rule["decision"]
return "No need to carry an umbrella"

Step 4: Simple User Interface (Command Line)

def main():
print("Simple Umbrella Decision Expert System")

facts = {
"raining": input("Is it raining? (yes/no): ").lower(),
"cloudy": input("Is it cloudy? (yes/no): ").lower(),
"jacket": input("Do you have a jacket? (yes/no):
").lower(),
}

decision = make_decision(facts, rules)


print(f"\nDecision: {decision}")
if __name__ == "__main__":
main()

Working of the Program:


A rule-based system checks facts against predefined rules. This example helps users decide
whether to carry an umbrella. It’s simple, interactive, and easy to extend (e.g., more weather
conditions).

Sample Output:
Is it raining? (yes/no): no
Is it cloudy? (yes/no): yes
Do you have a jacket? (yes/no): no

Decision: Carry an umbrella

Conclusion: An Expert System using Rule-based System for simple decision-making in AI was
implemented and developed successfully.

You might also like