This is an archive of an inactive wiki and cannot be modified.

This section specifies the RIF-PRD constructs that are required, in addition to the [ RIF-PRD condition language] and the [ RIF-PRD action language], to represent, and interchange, complete production rules and rule sets.

In the first part of this section, the syntax that is used to represent production rules and rule sets is presented non-normatively: the normative reference for the XML syntax is the [ XML schema].

In the second part, the normative semantics for RIF-PRD rules and rulesets is specified.

Syntax

The overall structure of the syntax used to represent production rules and rule sets in RIF-PRD is depicted on the following diagram.

The RULE construct is an abstract class: in RIF-PRD instance documents, it is either visible as a ConditionalStatement or as a Forall:

The RuleSet construct has zero or more constructs of the RULE group associated as rules.

The following sections specify each construct separately, grouped by abstract syntactic classes. Each element is given an XML syntax, in the form of a BNF pseudo schema; a presentation syntax, in the form of an EBNF production; and an informal semantics. None of these is normative: the normative XML syntax is given in the [ RIF-PRD XML schema] and the normative semantics is given in the section [ Operational semantics].

RULE

In RIF-PRD, the RULE class of constructs is used to represent rules, that is "if-then" statements, possibly universally quantified.

XML syntax. As an abstract class, RULE is not associated with specific XML markup in RIF-PRD instance documents. It is specified in the normative schema as a substitution group.

    [ ConditionalStatement | Forall ]

Presentation syntax.

   RULE ::= ConditionalStatement | Forall

ConditionalStatement

The ConditionalStatement construct is used to represent the conditional statement (that is, the "if-then", or condition-conclusion, or antecedent-consequent pair) that is at the core of a rule.

XML syntax. The ConditionalStatement element contains zero or one if sub-element and one then sub-element:

    <ConditionalStatement>
       <if> CONDITION </if>?
       <then>
          ACTION
          ACTION*
       </then>
    </ConditionalStatement>

Presentation syntax.

    ConditionalStatement ::= (' IF ' CONDITION ' THEN ')? ACTIONS
    ACTIONS              ::= ACTION (' ; ' ACTION)*

Informal semantics. The ConditionalStatement is used to represent a conditional statement that is true iff:

Forall

The Forall construct is used to represent universally quantified rules.

In addition to being a construct of the RULE class, Forall is also a construct of the QUANTIFICATION class: it inherits the syntactic features that are common to that class, as specified in [ section QUANTIFICATION].

XML syntax. The Forall element contains:

    <Forall>
       <formula> CONDITION </formula>
       <declare>
          [ Var | Aggregation ]
       </declare>+
       <pattern> CONDITION </pattern>*
    </Forall>

Presentation syntax.

    Forall ::= ' FORALL ' [ Var | Aggregation ]+ (' SUCH THAT ' CONDITION)* ' ( ' RULE ' ) '

Informal semantics. The Forall construct is used to represent rules that are true iff the RULE content of the formula sub-element is true for all the combinations of bindings of the variables declared by the Forall that verify the CONDITION content of the pattern sub-elements, if any.

RuleSet

The RuleSet construct is used to represent a set of rules that have to be considered together from a semantic or operational viewpoint (e.g. a knowledge base, a rule base, a ruleset).

XML syntax. The RuleSet element contains zero or more rule element. Each rule element contains an element from the RULE group of constructs that represents one of the rules contained in the rule set.

    <RuleSet>
       <rule> RULE </rule>*
    </RuleSet>

Presentation syntax.

    RuleSet ::= RULE*

Informal semantics. The RuleSet construct is used to represent sets of rules that is true iff the RULE content of all its rule sub-elements is true.

Operational semantics

The operational semantics of RULEs and `RuleSets is specified, in RIF-PRD, based on the operational semantics of the condition language, as specified in [ section Operational semantics of the condition language], and of the action language, as specified in [ section Operational semantcsi of action language.

Implementors are responsible for making sure that the RIF-PRD translation of rules and rulesets preserves their native semantics, according to the operational semantics for RIF-PRD RULEs and RuleSets that is specified below, and subject to a consistent translation of the specified data sources.

Conformant implementations MUST translate RULEs and RuleSets retrieved from RIF-PRD in such a way that their native evaluation against the specified data sources preserves their semantics, according to the operational semantics for RIF-PRD RULEs and RuleSets that is specified below, and subject to a consistent translation of the specified data sources.

The following sections specify the normative operational semantics of each construct separately, grouped by abstract syntactic classes.

RULE

A construct of the RULE class does not have an operational semantics if one of its components does not have an operational semantics.

The sections below specifies the operational semantics of the constructs of the RULE class, where they have one.

ConditionalStatement

A ConditionalStatement is true iff any of the following is true:

Forall

A Forall is true iff all its instances are true or it does not have any instance.

The instances of a Forall QUANTIFICATION are as specified in [ section Instances of a formula], where, for the purpose of specifying the accepted bindings of the Vars that are declared by a Forall, the additional conditions mentionned in the [ section Candidate and accepted bindings] are the CONDITIONs containted in the Forall's pattern sub-elements, if any.

The accepted bindings of a Var declared by a Forall are:

RuleSet

Except if the RULE content of one of its rule sub-elements does not have an operational semantics in RIF-PRD, in which case it does not have an operational semantics in RIF-PRD itself, a RuleSet is true iff:

The operational semantics of the RuleSet construct is based on the specification of an agenda and of an inference cycle.

Agenda. The Agenda is defined, for the purpose of specifying the operational semantics of a RuleSet, as an ordered list of pairs, each composed of an instance of a RULE and a mark that can be: true or firable.

Inference cycle. The inference cycle is the process that determines the truth value of every instances of the RULE content of each rule sub-element of a RuleSet, and, thus, of the RuleSet itself.

The process is a cyclic rather than a linear one because the implementation of the ACTIONs in the then-part of an instance being fired may change the set of the instances of the RULE content of one or more of the RuleSet's rule sub-elements.

For the purpose of specifying the operational semantics of a RIF-PRD RuleSet, the inference cycle is defined in three steps:

  1. Update agenda: The RULE content of each of the rule sub-elements of the RuleSet are instantiated as specified in [ section Instances of a formula] and [ section Forall], the CONDITION content of the if sub-element of the ConditionalStatement part of all the resulting instances is evaluated, and the Agenda is updated accordingly. To update the Agenda, each instance i resulting from the instantiation is compared with the instance part of the elements in the Agenda:

    • if there is an element i_a in the Agenda with an instance part that is equal to i and if the CONDITION content of the if sub-element of the ConditionalStatement part of i is false, the element i_a is removed from the Agenda;

    • if the instance part of no element in the Agenda is equal to i and if the CONDITION content of the if sub-element of the ConditionalStatement part of i is true, a new element is added to the Agenda consisting of i paired with the mark: firable;

    The RuleSet is true iff the Agenda contains only elements marked true after it has been updated. The process stops when the RuleSet is true or another ending condition is met.

    *** How are "other ending conditions" specified? Are they need in this version of RIF-PRD? ***

  2. Sort agenda: The instances in the Agenda are sorted according to the specified algorithm.

    *** Issue: Which agenda-sorting algo? How is it specified? Also see ACTION-378 ***

  3. Fire rules: The first instance marked firable in the sorted Agenda is fired, or all the instances marked firable in the sorted agenda are fired in order, depending on the specified algorithm.

    *** Issue: Which rule-firing algo? How is it specified? Any requirement for RIF-PRD to cover more than "forward-chaining" (first instance only is fired) and "sequential" (all fireable instances are fired)? ***

  4. When an instance of a RULE is fired, the ACTIONs contained in the then sub-element of the ConditionalStatement part of the instance are implemented in the specified order with the associated Var bindings, if any. After and if all the ACTIONs have been implemented successfully, the instance is marked true in the Agenda (replacing the firable mark).