24.11.2014 Views

flex Expert System Toolkit - LPIS

flex Expert System Toolkit - LPIS

flex Expert System Toolkit - LPIS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

6. Anatomy of a <strong>flex</strong> Program 55<br />

6. The Anatomy of a <strong>flex</strong> Program<br />

This chapter describes the basic composition of a <strong>flex</strong> program using the<br />

Knowledge Specification Language (KSL). The KSL’s structures and syntax<br />

are described in more detail in the next chapter.<br />

A <strong>flex</strong> program comprises a series of sentences written in the KSL<br />

(Knowledge Specification Language). Each sentence starts with a KSL<br />

keyword and ends with a full stop. These sentences are compiled into Prolog<br />

clauses by the <strong>flex</strong> compiler. (See the Runtime Interpretation of KSL<br />

chapter).<br />

A KSL sentence begins with one of the following keywords:<br />

action<br />

constraint<br />

data<br />

demon<br />

do<br />

frame<br />

function<br />

group<br />

instance<br />

launch<br />

question<br />

relation<br />

rule<br />

ruleset<br />

synonym<br />

template<br />

watchdog<br />

These are all described in detail in the next chapter.<br />

Note that a KSL program does not have to use forward chaining, and may<br />

consist entirely of relations and actions, which are the equivalent of<br />

backward chaining Prolog programs. For example, the following Prolog<br />

program.<br />

sibling( X, Y ):-<br />

parent( Z, X ),<br />

parent( Z, Y ).<br />

may be written using the KSL as follows.<br />

relation sibling( X, Y )<br />

if parent( Z, X )<br />

and parent( Z, Y ).<br />

Either of these may be called from the Prolog command line, e.g.<br />

<strong>flex</strong> toolkit

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!