Show/Hide Toolbars

RiverSoftAVG Products Help

Rules have the following syntax:

 

(defrule [<module-name>::]<symbol-name> 

         [<string-comment>]

         [(declare [(auto-focus <boolean-expression>])|

                   [(salience <integer-expression>)]|

                   [(oneshot <boolean-expression>])|

                   [(enabled <boolean-expression>])]

    <conditional-element>*

    =>

    <action>*)

 

<conditional-element>   = <pattern> | ?<variable-name> <- <pattern> |

          (test <function-call>) | 

          (not <conditional-element>) |

          (unique <conditional-element>) |

          (explicit <conditional-element>) |

          (exists <conditional-element>+)

<pattern>     = (<template-name> <slot>*)

<slot>       = (<slot-name> <constraint>*)

<constraint>     = ? | $? | <connected-constraint>

<connected-constraint>   = <single-constraint> | <<single-constraint>&<connected-constraint>> |

          <<single-constraint>|<connected-constraint>>

<single-constraint>   = <constant> | <variable> | :<function-call> | =<function-call> |

         ~<constant> | ~<variable> | ~:<function-call> | ~=<function-call>

<action>     = <constant>|<variable>|<function-call>

::       = Module separator.  Module name is optional.  If not specified, a rule belongs to the currently active module

 

Note: Brackets ([) and (]) define optional elements of the construct.  The (|) character defines an or condition.  An asterisk (*) defines zero or more of the preceding element (or disjunction of elements).  A plus sign (+) defines one or more of the preceding element.

 

Valid Rule Definitions

 

Assuming the following fact templates:

 

(deftemplate employee (slot name) (slot company) (slot salary (type float)) (slot position) (slot yearsofservice (type integer)))

(deftemplate benefits (slot name) (multislot awards) (multislot raises))

 

valid rules are:

 

(defrule five-year-raise

    "automatic five year raise"

    (declare (salience 0))

    ?employee1 <- (employee (name ?name1) (salary ?salary1) (yearsofservice ?yearsofservice1&:(> ?yearsofservice1 5)) )

    (not (benefits (name ?name1) (raises 5-year) ))

    =>

    (assert (benefits (name ?name1) (raises 5-year)))

    (modify ?employee1 (salary (* ?salary1 1.1))))

 

(defrule Printout-all-programmers

    "list all programmers"

    (declare (salience 0))

    ?employee <- (employee (position "Programmer") )

    =>

    (printout t ?employee))

 

RiverSoftAVG Products Help © 1996-2016 Thomas G. Grubb