The Jekejeke Prolog programming language provides the usual logical operators. The given example shows a small expert system. The knowledge of the expert systems is represented as a Prolog text. The Prolog text will consists of facts about a particular animal and rules about animals in general. After reading the Prolog text by the Prolog system it will be possible to pose a query to the Prolog system and guess the type of an animal.
The Prolog text starts with the facts. To guess another animal these facts have to be changed and the Prolog text has to be re-read by the Prolog system. A Prolog fact consists of a predi-cate name followed by a number of arguments. For our example we will only make use of predicates with a single argument that is an atom, but in general predicate can have more arguments and their argument types can differ from an atom:
The Prolog text then continues with the rules. This order is not mandatory for a Prolog text since rules can have references to predicates either occurring before or after the rule itself. A Prolog rule makes use of the turnstile operator (:-)/2. This operator will separate the head of the rule from the body of the rule. The body itself will make use of the comma operator (,)/2. This operator will separate the goals in the body of the rule:
class(mamal) :- motion(walk), skin(fur).
animal(rodent) :- class(mamal), diet(plant).
The Prolog text is found in the support .zip under the file name ‘animals.p’. The Prolog text can be read-in for the first time or re-read a second time by the consult command. The con-sult command can be issued from the Prolog top-level by enclosing the file name in square brackets. If you don’t have your file name in the class path, you can fully qualify the file name and consult it this way. Otherwise it is enough to use the file name only:
Upon successful consult the Prolog system will respond with a Yes. The Prolog system is now ready to respond to a query. We can now ask the Prolog system to guess the animal. The Prolog system will search through the Prolog rules and facts and try to find a variable binding so that the query is satisfied:
X = cat ;
Typing the semicolon instruct the Prolog system searching for an additional solution, which would not be found in the present case.