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?
- Hint 1: What does Mrs Okafor know about each kind of plant?
- Hint 2: How does she turn the customer’s answers into advice?
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
| Plant | Water need | Light need |
|---|---|---|
| Cactus | little | bright |
| Fern | lots | shade |
| Basil | medium | bright |
Rules for giving advice
| Rule | IF | THEN |
|---|---|---|
| R1 | soil is wet AND the plant’s water need is little | the problem is too much water |
| R2 | soil is dry AND the plant’s water need is lots | the problem is too little water |
| R3 | the problem is too much water | advice: stop watering until the soil is dry |
| R4 | the problem is too little water | advice: water until it drains from the pot |
| R5 | the plant’s light need is bright AND its position is shade | advice: 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.
- Hint 1: Look up the plant first: what is its water need?
- Hint 2: One rule can lead to another: R3 starts with the conclusion that another rule reached.
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.
Each step shows who is acting: the customer, the facts, or the part of the program that reasons.
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.
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.
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”.
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.
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?
| Item | Part 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 |
- Four parts: knowledge base, rule base, inference engine, user interface.
Show the completed table
| Item | Part 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 R3 | Inference engine |
| The menus where the customer chooses the soil and the screen showing the advice | User interface |
Check your understanding
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.
| Plant | Soil | Position | Rule that finds the problem | Rule that gives the advice |
|---|---|---|---|---|
| Fern | dry | shade | ||
| Basil | wet | shade | ||
| Cactus | wet | bright | ||
| Fern | wet | bright |
- Look up the plant’s needs, then test R1 and R2, then R3 to R5.
Show the completed table
| Plant | Soil | Position | Rule that finds the problem | Rule that gives the advice |
|---|---|---|---|---|
| Fern | dry | shade | R2 | R4 |
| Basil | wet | shade | none | R5 |
| Cactus | wet | bright | R1 | R3 |
| Fern | wet | bright | none | none |
Apply it
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?
- Hint 1: Could Mrs Okafor have missed a case when she wrote the rules?
- Hint 2: Who could add to the rule base?
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
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?
- Hint 1: Think about what she knows, what she works out, and whether she ever gets better at her job.
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
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.
- Hint 1: Start with 7. Apply the rule after each week’s report.
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.
| Week | Days between waterings used | Owner reports | Days used next time |
|---|---|---|---|
| 1 | 7 | droopy | |
| 2 | 6 | droopy | |
| 3 | 5 | fine | |
| 4 | 5 | fine |
Show the completed table
| Week | Days between waterings used | Owner reports | Days used next time |
|---|---|---|---|
| 1 | 7 | droopy | 6 |
| 2 | 6 | droopy | 5 |
| 3 | 5 | fine | 5 |
| 4 | 5 | fine | 5 |
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
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
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
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
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?.
Computer systems designed to do tasks that would normally need human reasoning, such as recognising, predicting, deciding or producing content.
A computer system that gives advice or decisions in one subject by applying rules from human experts to facts. It has a knowledge base, a rule base, an inference engine and an interface.
Using a trained model to produce an output, such as a reply. The model does not learn during inference.
The part of an expert system that matches the facts in the knowledge base against the rules in the rule base to reach a conclusion.
The part of an expert system that stores the facts about its subject.
A model that predicts which piece of text is likely to come next, and so can produce text one piece at a time.
Building systems that learn patterns from examples (data) instead of being given every rule by a person.
A model made of many simple connected units in layers, whose connection strengths are adjusted during training. Loosely inspired by the brain, but not a copy of it.
The part of an expert system that stores its rules, each written as IF a condition THEN a conclusion.
A program that stores data in a grid of rows and columns and can calculate with it using formulas.
The part of a system that lets a person give it commands and see its results, such as windows and icons or typed commands.
Your progress on this lesson
Saved in this browser only. It is not sent anywhere, does not follow you to another device, and is lost if you clear this site’s data.
This browser is not allowing the site to save progress, so it will be forgotten when you leave the page.