Study Guide

Expert Systems and Machine Learning

How a computer can simulate intelligent behaviour: what AI is and what it needs, how an expert system uses a knowledge base, a rule base, an inference engine and an interface to give advice, how machine learning adapts its own data, and how the two compare.

Lesson 8.5 AI Foundations

For: Cambridge IGCSE Computer Science learners (about ages 14 to 16), or anyone who has met the idea of AI and wants to see how two kinds of AI system work

Stage: Think

The plant expert

At Fern & Friends, a fictional garden centre, a customer walks up with a drooping plant. The plant expert, Mrs Okafor, does not guess. She asks which plant it is, whether the soil is wet or dry, and where it has been sitting. Then she says what to do.

Think it through

Mrs Okafor retires, and the garden centre wants a computer program to give the same advice. What would the program need to know, and what would it have to do with it?

Show what happens

The program needs her facts (what each kind of plant needs) and her rules for turning a customer’s answers into advice. It also needs a way to reason: to put the answers, the facts and the rules together. Finally, it needs a way to ask the questions and show the advice. Those four jobs are the four parts of an expert system.

Stage: Discover

Be the advice program

Here is what the garden centre has written down. All of it is invented for this lesson.

Facts about each plant

PlantWater needLight need
Cactuslittlebright
Fernlotsshade
Basilmediumbright

Rules for giving advice

RuleIFTHEN
R1soil is wet AND the plant’s water need is littlethe problem is too much water
R2soil is dry AND the plant’s water need is lotsthe problem is too little water
R3the problem is too much wateradvice: stop watering until the soil is dry
R4the problem is too little wateradvice: water until it drains from the pot
R5the plant’s light need is bright AND its position is shadeadvice: move it to a bright windowsill

A customer’s plant is a Cactus. Its soil is wet. It sits on a bright windowsill.

Think it through

Using only the facts and the rules above, what advice should the customer be given, and which rules did you use to reach it? Work through them in order.

Show what happens

R1 applies: the soil is wet and a Cactus needs little water, so the problem is too much water. R3 then applies, because that is now the problem, so the advice is stop watering until the soil is dry. R2 does not apply (the soil is not dry) and R5 does not apply (the cactus is already in a bright place).

You have just done what a computer does in an expert system: a computer system that gives advice or decisions in one subject by applying rules from human experts to facts. Watch it again, one step at a time.

Advice for a wet Cactus on a bright windowsill

Each step shows who is acting: the customer, the facts, or the part of the program that reasons.

  1. The customer

    Step 1 of 5: Gives the facts about their plant

    The program asks and the customer chooses: the plant is a Cactus, the soil is wet, the position is a bright windowsill.

  2. Stored facts

    Step 2 of 5: The plant’s needs are looked up

    The program finds Cactus in its table of facts: water need little, light need bright.

  3. The reasoning part

    Step 3 of 5: Rule R1 is tested and fires

    Soil is wet AND water need is little: both are true, so it concludes “the problem is too much water”.

  4. The reasoning part

    Step 4 of 5: Rule R3 is tested using the new conclusion

    The conclusion from R1 is now a fact, so R3 fires and gives the advice: stop watering until the soil is dry. R2 and R5 are tested and do not fire.

  5. The program

    Step 5 of 5: The advice is shown to the customer

    The customer sees “Stop watering until the soil is dry” on the screen.

Stage: Explain

The four parts of an expert system

Every expert system, whatever its subject, is built from the same four parts. The plant adviser shows each of them.

  • The knowledge base stores the facts about the subject. Here, it is the table of what each plant needs.
  • The rule base stores the rules, each written IF a condition THEN a conclusion. Here, it is R1 to R5.
  • The inference engine is the part that does the reasoning: it matches the facts against the rules, and uses each conclusion as a new fact, until it reaches advice. In the steps above, it is the part that tested R1, then R3.
  • The user interface is how the person gives the facts and reads the result: here, the questions with choices, and the screen showing the advice.

You may have met the word inference in the lessons on language models, where it means using a trained model to produce an output. An expert system’s inference engine is different: it contains no trained model. It applies rules that people wrote, step by step, and can show which rules it used.

Complete the table: which part of the expert system is each item?

Which part of the plant adviser is each item?
ItemPart of the expert system
The line “Fern: water need lots, light need shade”
“IF soil is dry AND water need is lots THEN too little water”
The part that tests R1, finds it true and then tests R3
The menus where the customer chooses the soil and the screen showing the advice

    Show the completed table
    ItemPart of the expert system
    The line “Fern: water need lots, light need shade”Knowledge base
    “IF soil is dry AND water need is lots THEN too little water”Rule base
    The part that tests R1, finds it true and then tests R3Inference engine
    The menus where the customer chooses the soil and the screen showing the adviceUser interface

    Check your understanding

    The garden centre decides that, for too much water, the advice should also say to check the pot has drainage holes. Which part of the expert system must be edited?
    Show the answer

    Answer: A. The rule base, because the advice is part of a rule (R3).

    Changing what the system concludes means changing its rules; the inference engine does not need to change.

    Stage: Apply

    Your turn as the inference engine

    Now apply the rules without help. For each customer, give the rule that finds the problem (R1 or R2, or none) and the rule that gives the advice (R3, R4 or R5, or none). Use the facts and rules in the earlier tables.

    What the inference engine does for four customers
    PlantSoilPositionRule that finds the problemRule that gives the advice
    Ferndryshade
    Basilwetshade
    Cactuswetbright
    Fernwetbright

      Show the completed table
      PlantSoilPositionRule that finds the problemRule that gives the advice
      FerndryshadeR2R4
      BasilwetshadenoneR5
      CactuswetbrightR1R3
      Fernwetbrightnonenone

      Apply it

      A customer enters: plant Cactus, soil dry, position shade. What does the plant adviser output?
      Show the answer

      Answer: B. Move it to a bright windowsill, because it needs bright light.

      Rules fire only when every part of their IF is true for the facts given.

      Stage: Predict

      When no rule fits

      Look again at the last customer in the table: a Fern with wet soil on a bright windowsill, and no advice. The program has not said that the plant is fine. It has said nothing.

      Think it through

      Why might an expert system give no answer? Think about who wrote its rules and what they included. What could the garden centre do about it?

      Show what happens

      Its rules cover only the cases that someone wrote down. A Fern with wet soil and bright light is a real situation, but no rule matches. The garden centre can add rules to the rule base. Until someone does, the program cannot work them out by itself.

      Apply it

      A garden-centre assistant says: “No advice means the Fern is healthy.” Which reply is most accurate?
      Show the answer

      Answer: C. Wrong: it means only that no rule matched; a person should check or add one.

      An expert system gives answers only as far as its knowledge base and rule base reach.

      Stage: Discover

      What makes it AI?

      Is a plant adviser really “artificial intelligence”? A spreadsheet of plant facts is not.

      Think it through

      What does Mrs Okafor do that makes her seem intelligent, and which of those things can the plant adviser do?

      Show what happens

      She knows facts and rules, she works out advice from what the customer says (reasoning), and over the years she may learn from plants that did and did not recover. The plant adviser does the first two. It does not learn: it never changes its own rules.

      Artificial intelligence (AI) is the branch of computer science that deals with simulating intelligent behaviour in computers. A system simulates intelligent behaviour by showing three main characteristics:

      • the collection of data and the rules for using that data;
      • the ability to reason, that is, to draw conclusions from the data and rules;
      • and it can include the ability to learn and adapt.

      An expert system has the first two, and it is AI because of them. The third is “can include”: a system does not have to learn to count as AI, which is why a rule-based expert system still counts.

      Check your understanding

      Which part of the plant adviser shows the AI characteristic “the ability to reason”?
      Show the answer

      Answer: C. The inference engine, because it draws conclusions from facts.

      Data and rules are stored; reasoning uses them to reach a conclusion.

      Stage: Experiment

      A program that changes itself

      Fern & Friends also sells a watering-reminder app. It tells the owner how many days to leave between waterings, and starts with 7. After each watering, the owner reports whether the plant looked droopy or fine. The app then changes the number it will use next time. If the plant was droopy, the app takes away 1 day. If it was fine, the app keeps the number.

      Think it through

      A plant is droopy in weeks 1 and 2, and fine in weeks 3 and 4. Predict the number of days the app uses in each of the four weeks.

      Show what happens

      Week 1 uses 7, and the plant is droopy, so week 2 uses 6. Week 2 is droopy again, so week 3 uses 5. Weeks 3 and 4 are fine, so week 4 and the next week still use 5.

      The reminder app adjusting its stored number of days
      WeekDays between waterings usedOwner reportsDays used next time
      17droopy
      26droopy
      35fine
      45fine

        Show the completed table
        WeekDays between waterings usedOwner reportsDays used next time
        17droopy6
        26droopy5
        35fine5
        45fine5

        The app was never told that this plant needs watering every 5 days. It found that number by adapting its own stored data from what happened. That is the idea behind machine learning: a program that has the ability to automatically adapt its own processes and/or data. Real machine-learning systems adapt from far more data and in far more complicated ways than this app, but the principle is the same. The program changes how it works from experience; nobody edits its numbers by hand.

        Check your understanding

        In the reminder app, what does the program change by itself?
        Show the answer

        Answer: B. Its own stored number of days, because of what the owner reports.

        Machine learning is the program changing its own data or processes without a person editing them.

        Stage: Explain

        Expert system or machine learning?

        The plant adviser and the reminder app are both AI, but they get their knowledge in different ways.

        Do not confuse: Two kinds of AI system

        Where does the knowledge come from?Expert system
        People, an expert’s facts and rules, written into the knowledge base and rule base.Mrs Okafor’s rules R1 to R5.
        Where does it come from?Machine learning
        Data and outcomes: the program adapts its own processes and/or data.The reminder app’s number of days, changed after each report.
        How does it change?Expert system
        Only when a person edits the facts or rules.The garden centre adds a rule for a wet Fern.
        How does it change?Machine learning
        By itself, as it meets more data.The reminder app finds a better number of days.

        Expert systems can show which rules gave an answer, which makes their reasoning easy to check. Learning systems often cannot explain their results as clearly.

        Check your understanding

        A school’s fictional revision app records which quiz questions a pupil gets wrong, and asks those questions more often in later weeks, with no teacher changing anything. Which kind of system is the part that adjusts how often each question appears?
        Show the answer

        Answer: B. Machine learning, because the app adapts its own data.

        If a program changes its own data or processes from experience, it is machine learning; if only a person changes its rules, it is not.

        Apply it

        A fictional website asks a user a series of questions about their income and gives advice using IF … THEN rules written by accountants, and shows which rules led to the advice. Which description fits best?
        Show the answer

        Answer: A. An expert system: the knowledge comes from experts and nothing adapts by itself.

        Ask: who supplies the knowledge, and does the system change itself?

        Stage: Consolidate

        Show what you know

        Think it through

        In your own words, explain how an expert system and a machine-learning system differ in how they come to know what to do. Use an example of your own, not the plant adviser.

        Show a model answer

        A good answer says that an expert system’s knowledge and rules are written by people and change only when people change them, while a machine-learning system adapts its own data or processes from what happens. For example: “A fictional bus-delay predictor that follows rules written by timetable staff is an expert system; one that adjusts its predictions after comparing each day’s delays with what actually happened is machine learning.”

        Apply it

        A fictional medical helpline program stores facts about illnesses and rules such as IF fever AND rash THEN advise a doctor’s visit. A reviewer says: “This system is not AI, because it never learns.” What is the best response?
        Show the answer

        Answer: B. The reviewer is wrong: it uses data, rules and reasoning, so it is AI.

        Data and rules, the ability to reason, and optionally learning: that is the test.

        • Artificial intelligence is the branch of computer science that simulates intelligent behaviour. Its main characteristics are collecting data and the rules for using it, the ability to reason, and, sometimes, the ability to learn and adapt.
        • An expert system has four parts: a knowledge base (facts), a rule base (IF … THEN rules), an inference engine (matches facts to rules to reach a conclusion) and a user interface.
        • It knows only what its rules and facts cover; when no rule matches, it gives no answer, and a person must change it.
        • Machine learning is when a program has the ability to automatically adapt its own processes and/or data.
        • Expert systems get their knowledge from people and change when people edit them; machine-learning systems adapt by themselves from data and outcomes.

        Sources and scope

        • What this lesson is. The fifth AI Foundations lesson, written for this site and aimed at Cambridge IGCSE Computer Science (0478, point 6.3). It is a draft awaiting the site owner’s editorial review. Its curriculum links are provisional: the wording of each linked specification point has been checked against the published specification, but no link has yet been verified by the site owner. The links show where the lesson may help with a course; they do not imply that any examination board has reviewed or endorsed it. They were written against the 0478 syllabus for examination in 2026 to 2028.
        • Original material. Fern & Friends, Mrs Okafor, the plant facts and rules, the reminder app, the revision app, the tax website and the medical helpline are fictional, and the rules are written for teaching, not for real plant care or real advice.
        • Simplified on purpose. The rule base is small and applies each rule at most once, in a fixed order. Real expert systems hold thousands of rules and may handle uncertain answers. The reminder app adapts by a rule it was given; real machine learning finds its own patterns in much more data, and its types (such as supervised learning and neural networks) are left to later study. The syllabus limits 6.3 to expert systems and machine learning, so other kinds of AI system are not covered here. The lesson covers all of point 6.3 only together with What Counts as AI?.