51.clp -------------------------------- Demostrates the use of "not" and "exists" used on facts (so in the LHS of the rule) "not" will produce the triggering of the no-emergency rule only if we remove the 2 emergencies from the working memory (using retract to do so). So if we want to see it work, after (reset), we need to (assert report-status) then (retract 1 2). The asserted fact is the trigger for both rules report-emergency and no-emergency, and most likely the 2 emergency facts will have the indexes 1 and 2. If not, we can find their correct indexes by looking in the facts window. "exists" will work by simply loading the code (using load buffer) the reset, then run, and the desired effect here is that it only print once thta there is an emergency, although there are 2 emergency facts present in the working memory To see the report-emergency rule work, we need to add manually, in the dialog window the fact (report-status), of course, by writing in the command prompt (assert (report-status)) --------------------------------- 52.clp. This is a more complicated exemple that will use a control mechanism to cycle infinitely through a set of operations. We achieve that by using a circular list called "lista", which the rule cycle-it manipulates in the following manner: it extracts the first element and then inserts it back at the end of the list. It doest that with a lower priority than other rules because otherwise, maybe only this cycle will happen, and no other rule would be triggered. We obtain a lower priority for that rule by decalring the salience of the rule to be -30, compared to the default zero for the other rules. Thus a negative salience makes that rule fire with a lower priority than normal (which is zero). A positive salience will make the rule trigger with a higher priority than normal. Saliences can be between -10000 and +10000. +10000 corresponds to the higher priority. The rule cycle-it asserts a (phase) fact in the working memory, this fact will be used as a trigger for the other rules. No real actions are included in this example, the other rules just print some messages and retract the (phase) fact, by that giving, practically, back the control to the cycle-it rule, because that is the only one that can be matched on facts. Tha rule will work, because the (lista) fact is a new one than the previous time it had matched this rule. Lines 26 and 27 in the code will assure that by deleting the old (lista) fact in line 26 and asserting the rotated one on line 27.