此内容没有您所选择的语言版本。
4.19. Implementing Inference and TruthMaintenance
Procedure 4.1. Task
- Open a set of rules. In this example, a buss pass issuing system will be used:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Insert the fact
insertLogical
and add the terms you wish to be inferred.Copy to Clipboard Copied! Toggle word wrap Toggle overflow The fact has been logically inserted. This fact is dependent on the truth of the "when" clause. It means that when the rule becomes false the fact is automatically retracted. This works particularly well as the two rules are mutually exclusive. In the above rules, the IsChild fact is inserted if the child is under 16. It is then automatically retracted if the person is over 16 and the IsAdult fact is inserted. - Insert the code to issue the passes. These can also be logically inserted as the TMS supports chaining of logical insertions for a cascading set of retracts.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Now when the person changes from being 15 to 16, not only is the IsChild fact automatically retracted, so is the person's ChildBusPass fact. - Insert the 'not' conditional element to handle notifications. (In this situation, a request for the returning of the pass.) When the TMS automatically retracts the ChildBusPass object, this rule triggers and sends a request to the person:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow