Example expert system

This example is taken from Negnevitsky – Artificial Intelligence A guide to intelligent Systems (Addison Wesley 2002)

THERMOSTAT: a demonstration rule-based expert system

Knowledge base (Warning – Negnevitsky lives in Australia)

Rule: 1

ifthe day is Monday

orthe day is Tuesday

orthe day is Wednesday

orthe day is Thursday

orthe day is Friday

thentoday is a workday

Rule: 2

ifthe day is Saturday

orthe day is Sunday

thentoday is the weekend

Rule: 3

iftoday is a workday

andthe time is `between 9 am and 5 pm'

thenoperation is `during business hours'

Rule: 4

iftoday is a workday

andthe time is `before 9 am'

thenoperation is `not during business hours'

Rule: 5

iftoday is a workday

andthe time is 'after 5 pm'

thenoperation is 'not during business hours'

Rule: 6

iftoday is the weekend

thenoperation is 'not during business hours'

Rule: 7

ifthe month is January

orthe month is February

orthe month is December

thenthe season is summer

Rule: 8

ifthe month is March

orthe month is April

orthe month is May

then the season is autumn

Rule: 9

ifthe month is June

orthe month is July

orthe month is August

then the season is winter

Rule: 10

ifthe month is September

orthe month is October

orthe month is November

then the season is spring

Rule: 11

if the season is spring

and operation is `during business hours'

then thermostat setting is `20 degrees'

Rule: 12

if the season is spring

andoperation is `not during business hours'

then thermostat setting is `15 degrees'

Rule: 13

if the season is summer

and operation is `during business hours'

then thermostat setting is `24 degrees’

Rule: 14

if the season is summer

andoperation is `not during business hours'

then thermostat setting is `27 degrees'

Rule: 15

if the season is autumn

and operation is `during business hours'

then thermostat setting is `20 degrees'

Rule: 16

ifthe season is autumn

andoperation is `not during business hours'

then thermostat setting is `16 degrees'

Rule: 17

if the season is winter

and operation is 'during business hours'

then thermostat setting is '18 degrees'

Rule: 18

if the season is winter

and operation is 'not during business hours'

then thermostat setting is `14 degrees'

Objects

THERMOSTAT uses seven linguistic objects: month, day, time, today, operation, season and thermostat setting. Each object can take one of the allowed values (for example, object month can take the value of January, February, March, April, May, June, July, August, September, October, November or December). An object and its value constitute a fact (for instance, the month is January, the day is Monday, the time is 'after 5 pm'). All facts are placed in the database.

Object / Allowed values / Object / allowed values
Month / Jan / Day / Mon
Feb / Tues
etc / etc.
Season / Summer / today / workday
Autumn / weekend
Winter / time / between 9 and 5
Spring / before 9
after 5
operation / during bus hours
not during bus hours

The goal of the expert system is to produce a solution to the problem of thermostat setting based on input data i.e. to select one of the following options:

thermostat setting is `20 degrees'

thermostat setting is `15 degrees'

thermostat setting is `24 degrees'

thermostat setting is `27 degrees'

thermostat setting is `20 degrees'

thermostat setting is `16 degrees'

thermostat setting is `18 degrees'

thermostat setting is `14 degrees'.