Description
Run a set of rules to infer more findings from a set of input facts.
The rules process is relatively simple.
It takes as its inputs:
- A set of rules, each one of which:
- Describes a condition based on one or more facts combined with AND, NOT and OR conditions.
- Lists a set of findings which should be made if the condition is true
- A set of input facts
As its output, it lists new findings that have been inferred by the rules.
Input
<RunRules>
<RuleList> <Rule> <name/> <salience/> <condition> : condition </condition> <FindingList> <finding>reference</finding> </FindingList> </Rule> </RuleList>
<FactList> <fact>reference</fact> </FactList> </RunRules>
<name> is a name for the rule, which will be used for any error reporting. It does not have to be unique, but obviously it helps if it is.
<salience> is a number which provides a priority for the rule, in which higher numbers are applied first. This can usually be left to the default value of 0.
<condition> holds a boolean condition, which, if true, sets the findings in the finding list.
At its simplest, the <condition> element lists one or more facts, all of which must be present for the condition to fire. Each fact is surrounded by <fact>.
The <condition> element may contain other elements which evaluate to true or false:
- <fact> - true if the contained fact is present
- <or> - true if any of the contained elements are true
- <and> - true if all of the contained elements are true
- <not> - if the contained element (of which there must be only one) is not true
These elements may be nested. For example:
<condition>
<or>
<fact>a</fact>
<not>
<and>
<fact>b</fact>
<fact>c</fact>
</and>
</not>
<or>
<fact>d</fact>
</condition>This is "(a or not(b and c)) and d"
Logically, <condition> is the same as a high-level <and>.
Once a finding has been made, it will not be re-made.
Output findings can be referred to by reference as facts, i.e. once the finding is inferred it is treated as a fact. You can think of a fact as a input finding, or a finding as an output fact.
Example call:
<RunRules>
<RuleList>
<Rule>
<name>Identify Mammal</name>
<condition>
<or>
<fact>fur</fact>
<and>
<fact>suckles.young</fact>
<fact>breathes.air</fact>
</and>
</or>
</condition>
<FindingList>
<finding>mammal</finding>
</FindingList>
</Rule>
<Rule>
<name>Identify Reptile</name>
<condition>
<fact>scales</fact>
<fact>breathes.air</fact>
</condition>
<FindingList>
<finding>reptile</finding>
</FindingList>
</Rule>
</RuleList>
<FactList>
<fact>scales</fact>
<fact>breathes.air</fact>
</FactList>
</RunRules>Output is:
<RunRules>
<errorNumber>0</errorNumber>
<FindingList>
<finding>reptile</finding>
</FindingList>
</RunRules>Output
<RunRules>
<errorNumber>0</errorNumber>
<FindingList> <finding>reference</finding> </FindingList> </RunRules>
The service outputs the new findings inferred by the rules.
Errors
103 - Parameter error