Longer example of backward chaining

Next: Longer example of forward chaining
Up: How the inference engine works
Previous: Backward chaining
Back: to main list of student notes

## Longer example of backward chaining

Start with this knowledge base. A simple set of rules to infer which resort a skier should go to, given his purpose (to have fun or to practise serious skiing), the number of lessons he's had so far, and the number of press-ups he can do without collapsing. Scenario: this knowledge base is built into an expert system. A client comes along for a consultation.

```1 Resort = st sartre if
Rating = beginner and
Purpose = fun.

2 Resort = schloss heidegger if
Rating = beginner and
Purpose = serious.

3 Resort = chateau derrida if
Rating = advanced and
Purpose = serious.

4 Resort = wittgenstein gladbach if
Rating = advanced and
Purpose = fun.

5 Rating = beginner if
Lessons < 30.

6 Rating = beginner if
Lessons >= 30 and
Fitness = poor.

7 Rating = advanced if
Lessons >= 30 and
Fitness = good.

8 Fitness = poor if
Pressups < 10.

9 Fitness = good if
Pressups >= 10.```

In an expert system, we have to distinguish between observable or askable data which the client can supply, and computable data which the system calculates using the rules. Let's suppose that `Pressups`, `Fitness`, `Purpose` are askable. A real expert system language would make you specify that with the rules. Suppose also that the goal is to find a value for `Resort`.

So: goal is to find `Resort`. Do we know it already? No. So start by locating all rules which can tell you about `Resort`, i.e. which have it in their conclusions. These are rules 1, 2, 3, and 4.

Now, we have to investigate one or more of these rules. There are many possible orders: serially from top to bottom; serially from bottom to top; in parallel; etc. For simplicity, assume serial top to bottom. So we start with rule 1.

Test its conditions next. Do we know a value for `Rating`? No. Is `Rating` askable? No. So we have to calculate it from another rule; we can't ask the client for it.

So we now set a subgoal of calculating `Rating`. Locate all rules which have it in their conclusions. These are 5, 6, 7. Start with rule 5.

Test its conditions next. Do we have a value for `Lessons`? No. Is `Lessons` askable? Yes. So we ask the client for it. He types in `178`. We store this in STM. Now, is `Lessons` less than 30? No. So the condition fails. Rule 5 can't tell us anything, so we go on to rule 6.

Test its conditions next. Do we have a value for `Lessons`? Yes, we do now. Is `Lessons` 30 or more? Yes. So the first part of the condition succeeds. Go on to `Fitness`. Do we have a value for `Fitness`? No. Is it askable? No. So we have to calculate it.

So we now set another subgoal of calculating `Fitness`. Locate all rules which have it in their conclusions. These are 8 and 9. Start with 8.

Test its conditions. Have we a value for `Pressups`? No. Is it askable? Yes. Ask the client. He types `15`. Store it in STM. The condition fails, so abandon rule 8 and go on to 9. That condition succeeds, so we conclude `Fitness` = `good`. Store that in STM.

Now we've finished with the latest subgoal, so we return up a level, to rule 6. Its condition fails. So we go on to rule 7. Its condition succeeds. So we have now achieved the subgoal of calculating `Rating`. We can back up another level, to rule 1. Its conditions fail. Go on to rule 2, which also fails. Go on to rule 3. The first part of its condition succeeds; what about the second? Do we know `Purpose`? No. Is it askable? Yes. Ask the client. He types `fun`. So the condition fails. Go on to rule 4. This one's conditions succeed, we now have a value for `Resort`, and everyone's happy, especially me because I know I can always get a job as an expert system if all else fails.

Next: Longer example of forward chaining
Up: How the inference engine works
Previous: Backward chaining
Back: to main list of student notes

Jocelyn Ireson-Paine
Wed Feb 14 23:39:25 GMT 1996