Fc_rule Syntax
Fc_rule
Forward-chaining rules have three parts:
- A unique name.
- An optional foreach clause.
- An assert clause.
fc_rule ::= IDENTIFIER ':' NL INDENT [fc_foreach] fc_assert DEINDENT
The IDENTIFIER uniquely names this rule and is used as the corresponding python function name in the generated <rb_name>_fc.py file.
Foreach clause
fc_foreach ::= 'foreach' NL INDENT {fc_premise NL} DEINDENT fc_premise ::= fact_pattern | python_premise fact_pattern ::= IDENTIFIER '.' IDENTIFIER '(' [{pattern,}] ')'
Here are links to the definitions for pattern and python_premise.
If the foreach clause is not used, the rule is always fired once.
If the foreach clause is used, the rule is fired for each combination of true premises.
Assert clause
fc_assert ::= 'assert' NL INDENT {assertion NL} DEINDENT assertion ::= fact_pattern | 'python' ':' NL INDENT {python_statement NL} DEINDENT
The assert clause lists new facts to assert, and/or python statements to execute each time the rule is fired. Each of these may include pattern variables which should also appear in the foreach clause where they are bound to a value. These values will then be substituted into the facts and python statements.