The final step in creating your expert system is to populate it with the initial facts describing the state of your domain. Facts define the world of your expert system, i.e., the people in it, the objects in it, etc. The rules that you define manipulate facts to infer new facts (or new knowledge) and to act. Facts can be asserted into the world or retracted from the world. Facts consist of a relation name and zero or more slots and their associated values. If fact templates define the types of objects in your domain, facts are instantiations of these type of objects.
There are two basic ways to create facts in your expert system: fact sets and assertions. Both methods assert facts, the only difference is when. Asserting a fact means to add the fact to the fact base. The inference engine will then take that assertion and pattern match it with the rules in your rule base, which can cause rule activations.
If you want to define initial facts (such as current interest rates or occupations and their risks for the example we have been developing), you use fact sets (Deffacts in CLIPS terminology). Facts sets are a collection of facts which are automatically asserted every time the inference engine is reset (and only when it is reset. Defining a fact set does not automatically assert the facts within it). Fact sets look like the following:
(deffacts people "some people"
(customer (id 1234) (salary 40000) (credit-history poor))
(customer (id 237) (age 40) (salary 30000))
The other way to define facts is to assert them. Unlike fact sets, you can assert or retract facts at any time (except in the left hand side of a rule). However, once the inference engine is reset or the fact retracted, it is gone and will not be automatically added back. To assert a fact, type the following:
(assert (customer (id 1234) (salary 40000) (credit-history poor))
(customer (id 237) (age 40) (salary 30000)))
Alternatively, from code you use the Assert method of the inference engine.
When you create a fact, you only have to define the slots you are interested in. Any undefined slots take the defaults specified when you created the fact template.
There are also a few tips to writing expert systems.