Rules

The rules allow us to perform various actions on facts. Not only it is important to acquire adequate knowledge of experts and its exact systematization of our knowledge base. Another problem is the proper use. Below you will find examples that use rules for building expert systems performing optimally actions on facts.

The basic operations concerning rules include:

  • defrule - defining a new rule
  • undefrule – delete a rule
  • run - start executing rules/li>

Form of each rule is similar to a conditional statement, it works for truth. Keyword 'Then' you can compare to the mark =>.

(defrule name Left-Hand-Side (LHS) => Right-Hand-Side (RHS))

Rules are divided into left and right sides. Understanding of the rules is important in later work with expert systems created in Jess. In the following pages you can find examples of simple and more advanced rules used in real rule-based systems.

(defrule regula1 (student {Informatics}) => (printout file " Knows Jess " crlf))

An example of a simple rule which assumes that students know the Jess language.

(defrule nazwa
(osoba (wiek ?a&:(> ?a 30)&:(< ?a 40))
(imie $?n) )
=>
(printout t "Witaj " ?n ". Masz" ?a "lat" crlf))

A more extensive rule that checks the condition requiring that the person had the range of 30-40 age.

< (less)
<= (less than or equal to)
> (bigger)
<= (bigger than or equal to)
== (equal)
!= (not equal to )
<> (not equal, second version)
&& (and)
|| (or)

Above you see the list of conditions for checking used in the preparation of rules. You can also insert logical operations.

(defrule rule1
(skiType {type == cross})
(imposedWay {way == cold})
(skillLevel {level == entry || level == advanced || level == pro})
(airTemp {temp <= 10 && aTemp > -2})
=> (printout "Wax Nordic Klister Yellow" crlf) (bind ?*zmienna* 1) )

This rule checks to ski lubricating properties, is used in expert system that supports the selection of the optimum lubricant.

Other examples of rules are available in download section.