HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
Artificial Intelligence: Expert Systems and Machine Learning
  1. 1What artificial intelligence is
  2. 2Expert systems
  3. 3Machine learning
  1. Computer Science
  2. /Artificial Intelligence: Expert Systems and Machine Learning
  3. /Expert systems

Course 6.3·Lesson 2 of 3

Expert systems

An expert system asks questions, applies rules to the answers, and gives the advice a human expert would give. It has four parts: a knowledge base, a rule base, an inference engine and an interface. This lesson explains each part and follows a diagnosis from the first question to the conclusion.

about 25 min1 simulation1 practice question
Lesson 2 of 3Show all lessonsHide
Artificial Intelligence: Expert Systems and Machine Learning
  1. 1What artificial intelligence is
  2. 2Expert systems
  3. 3Machine learning

Try the code and the simulations beside the lesson.

A doctor who is not there

A farmer finds brown spots on her tomato plants. No plant expert lives nearby. On a computer, she answers a few questions: Are the spots on the old leaves or the new ones? Are there rings inside the spots? Then the program names the likely disease and the treatment. It behaves like the expert, so it is an expert system.

An expert system is one of the two kinds of AI system in the syllabus. It simulates the knowledge and the reasoning of a human expert in one subject. Expert systems are used to diagnose illnesses, find faults in cars and machines, identify plants and animals, and suggest where to search for minerals.

The four parts

A diagram of an expert system. The user talks to the interface, which asks questions and shows the conclusion. The interface passes the answers to the inference engine and receives its conclusion. The inference engine reads from two stores: the knowledge base, which holds the facts, and the rule base, which holds IF THEN rules.

Knowledge base. This stores the facts about the subject, collected from human experts: the diseases, their signs, the treatments.

Rule base. This stores the rules for using those facts. Each rule has the form IF ... THEN ..., for example:

pseudocode
IF Spots = "rings" AND Leaves = "old"
  THEN
    Disease ← "early blight"
ENDIF

Inference engine. This is the part that reasons. It takes the user's answers, looks through the knowledge base, and applies the rules to reach a conclusion. It also chooses the next question to ask, based on the answers so far.

Interface. This is how the user and the system talk to each other. It asks the questions, takes in the answers, and shows the conclusion, often with how likely it is and the reasons.

How a diagnosis works

  1. The interface asks a question, and the user answers.
  2. The inference engine adds the answer to what it knows.
  3. It applies the rules from the rule base to the facts in the knowledge base and the answers.
  4. If no rule gives a conclusion yet, it picks the next useful question, and the steps repeat.
  5. When a rule gives a conclusion, the interface shows it to the user, often with a probability and an explanation.

One rule can use the conclusion of another. In the Python program below, the rule "too much water" fires first, and then a second rule uses it to conclude "root rot". This is the inference engine reasoning in two steps.

Try it in Python

The program has all four parts. The knowledge base is the set facts. The rule base is the list rules. The interface is the list of questions and answers. The inference engine is the while loop that keeps applying rules until nothing new is found.

Read it first. Then run it. Which two rules fire?

1. Change the answers so that the soil is dry, not wet. Predict the conclusion, then run it.

2. Add a rule of your own to the rule base and an answer that makes it fire.

Practise with new numbers

Common mistakes

  • Mixing up the knowledge base and the rule base. Facts go in the knowledge base. IF ... THEN rules go in the rule base.
  • The interface reasons. It only asks and shows. The inference engine reasons.
  • An expert system learns by itself. A simple expert system does not change its own rules. People update its knowledge and rules.
  • It is always right. If the facts are incomplete, or the user answers wrongly, the conclusion can be wrong.

Remember these

  • An expert system has a knowledge base, a rule base, an inference engine and an interface.
  • Knowledge base: facts. Rule base: IF ... THEN rules. Inference engine: applies the rules to the facts and answers. Interface: asks questions and shows conclusions.
  • It simulates a human expert in one subject.

Check yourself

Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.

  1. Name the four parts of an expert system.
  1. Where is this stored: "IF the engine will not start AND the lights are dim THEN the battery is flat"?
  1. Which part of an expert system decides which question to ask next?
  1. Give two reasons why an expert system could give a wrong conclusion.
  1. A fault has 666 signs. The user says yes to 333 of them. What percentage match?

Enroll free in Artificial Intelligence: Expert Systems and Machine Learning

Every lesson is open to read. Enrolling also lets you:

  • Mark lessons done and carry on where you stopped.
  • Take the tests of this lesson and its course.
  • Count the course towards the certificate for its chapter.
No payment. You can leave at any time.

Problems (3)

A garage uses an expert system to help mechanics find faults in car engines…Medium · High School (9–10) · by StemPy Lab
A small expert system for identifying animals has five rules…Hard · High School (9–10) · by StemPy Lab
A health centre in a remote area uses an expert system to help a nurse decide whether a patient…Hard · High School (9–10) · by StemPy Lab
Next: lesson 3Machine learning
← Artificial Intelligence: Expert Systems and Machine Learning
← What artificial intelligence isMachine learning →

Discussion (0)

Log in to join the discussion.

Loading…

1 Python program
5 questions to check yourself

This lesson is free to read. Enroll free to keep your place and take the tests.

Python Labs (1)

A small expert systemPython Lab · by StemPy Lab