W3C


RIF Production Rule Dialect

W3C Editor's Draft 25 November18 December 2008

This version:
http://www.w3.org/2005/rules/wg/draft/ED-rif-prd-20081125/http://www.w3.org/2005/rules/wg/draft/ED-rif-prd-20081218/
Latest editor's draft:
http://www.w3.org/2005/rules/wg/draft/rif-prd/
Previous version:
http://www.w3.org/2005/rules/wg/draft/ED-rif-prd-20081121/http://www.w3.org/2005/rules/wg/draft/ED-rif-prd-20081125/ (color-coded diff)
Editors:
Christian de Sainte Marie, ILOG
Adrian Paschke, Free University Berlin
Gary Hallmark, Oracle

This document is also available in these non-normative formats: PDF version.



Abstract

This document specifies RIF-PRD, a Rule Interchange Format (RIF) dialect to enable the interchange of production rules.

Status of this Document

May Be Superseded

This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.

This document is being published as one of a set of 5 documents:

  1. RIF Use Cases and Requirements
  2. RIF Core
  3. RIF Datatypes and Built-Ins 1.0
  4. RIF Production Rule Dialect (this document)
  5. RIF (Rule Interchange Format)Test Cases

Please Comment By 2008-11-2823 January 2009

The Rule Interchange Format (RIF) Working Group seeks public feedback on these Working Drafts. Please send your comments to public-rif-comments@w3.org (public archive). If possible, please offer specific changes to the text that would address your concern. You may also wish to check the Wiki Version of this document for internal-review comments and changes being drafted which may address your concerns.

No Endorsement

Publication as a Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.

Patents

This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.


Contents

1 Overview

This document specifies the production rule dialect of the W3C rule interchange format (RIF-PRD), a commonstandard XML serialisationserialization format for many production rule languages.

Production rules are rules withrule statements defined in terms of both individual facts or objects, and groups of facts or classes of objects. They have an "if" partif part, or condition, and a "then" part. The "if"then part, also called a "condition",or action. The condition is like the condition part of logic rules (as covered by the basic logic dialect of the W3C rule interchange format, RIF-BLD ).RIF-BLD). The "then"then part of production rules may containcontains actions, unlikewhich is different to the conclusion part of logic rules that may containwhich contains only a logical statement. Actions can add, delete, or modify the facts, not onlyfacts in the knowledge base;base, and they canhave other side-effects.

Example 1.1. «A customer becomes a "Gold" customer as soon as his cumulative purchases during the current year top $5000»; «Customers that become "Gold" customers must be notified immediately, and a golden customer card will be printed and sent to them within one week»; «For shopping carts worth more than $1000, "Gold" customers receive an additional discount of 10% of the total amount», are all examples of production rules.   ☐

As a production rule interchange format, RIF-PRD specifies an abstract syntax that is shared byshares most features with many concrete production rule languages for the most widely used features,languages, and it associates each abstract construct with normative semantics (section 2, Abstract syntax and Semantics )and a normative XML concrete syntax (section 3, XML syntax ).syntax.

Production rules are statements of programming logic that specify the execution of one or more actions in the case that their conditions are satisfied. Production rules therefore have an operational semantic (formalizing state changes, e.g., on the basis of a state transition system formalism). The OMG Production Rule Representation specification [PRR] summarizes it as follows:

  1. Match: the rules are instantiated based on the definition of the rule conditions and the current state of the data source;
  2. Conflict resolution: a decision algorithm, often called the conflict resolution strategy, is applied to select the rule instances to be executed, per strategy;executed;
  3. Act: changethe state of the data source,source is changed, by executing the selected rule instances’ actions. If a terminal state has not been reached, the control loops back to the first step (Match).

In the section Operational semantics of rules and rule sets, the semantics for rules and rule sets is specified, accordingly, as a labellabeled terminal transition system [ref Plotkin]. However, as a RIF dialect, RIF-PRD has also been designed(PLO04), where state stransitions result from executing the action part of instantiated rules. When several rules are deemed able to maximize interoperability between rule languages overbe executed during the rule execution process, a conflict resolution strategy is used to determine the order of rules to execute Sub-section Instance Selection specifies how an intended conflict resolution strategy can be attached to a rule set interchanged with RIF-PRD, and defines a default conflict resolution strategy.

However, as a RIF dialect, RIF-PRD has also been designed to allow interoperability between rule languages over the World Wide Web. In RIF, this is achieved by sharing the same syntax for constructs that have the same semantics across multiple dialects. As a consequence, RIF-PRD shares most of the syntax for rule conditions with RIF-BLD ,[RIF-BLD], and the semantics associated to the syntactic constructs used for representing the condition part of rules in RIF-PRD is specified, in theSection Semantics of conditionscondition formulas, in terms of a model theory, as it is in the specification of RIF-BLD as well. In addition to emphasizing the similarityexploiting similarities between the two dialects, it allows them to share the same definition for data types and built-ins by reference to theRIF definitions for data types and built-ins specification.[RIF-DTB].

In the section Operational semantics of actions, the semantics associated with the constructs used to represent the action part of rules in RIF-PRD is specified in terms of a transition relation between successive states of the data source, as defined by the condition formulaeformulas that they entail, thus making the link between the model-theoretic semantics of conditions and the operational semantics of rules and rulesets.

The abstract syntax is specified in mathematical english, and the abstract syntactic constructs defined in section 2,the sections Abstract Syntax of Conditions, Abstract Syntax of Actions and SemanticsAbstract Syntax of Rules and Rulesets, are mapped one to one onto the concrete XML syntax in Section 3,XML syntax. A lightweight notation is also defined along with the abstract syntax, to allow for a human-friendlier specification of the semantics. A more complete presentation syntax is specified using an EBNF in Section 4.Presentation Syntax. However, only the XML syntax and the associated semantics are normative. A normative XML schema will also be provided in future versions of the document;document.

Example 1.2. In RIF-PRD presentation syntax, the first rule in example 1.1. might be represented as follows:

Prefix(ex1 http://rif.example.com/2008/prd#)
(* ex1:rule_1 *)
Forall ?customer ?purchasesYTD (
 If      And( ?customer#ex1:Customer
                ?customer[ex1:purchasesYTD->?purchasesYTD]
                External(pred:numeric-greater-than(?purchasesYTD 5000)))
 Then ex1:Gold(?customer) )

The condition languages of RIF-PRD and RIF-BLD share more than parthave much in common, including much of their condition language,semantics. Although their abstract syntax and whole RIF documents haverule semantics are different, due to the same syntaxoperational nature of the actions in production rules, there is a subset for which they are equivalent: essentially, rules with no negation and no uninterpreted functions in the same intended meaningcondition, and with only assertions in the action part. For that subset, the XML syntax is the same, so many XML documents are valid in both dialects.dialects and have the same meaning. The correspondence between RIF-PRD and RIF-BLD is detailed in Appendix:Appendix Compatibility with RIF-BLD.

This document is mostly intended for the designers and developers of RIF-PRD implementations, that is, applications that serialize production rules as RIF-PRD XML (producer applications) and/or that deserialize RIF-PRD XML documents into production rules (consumer applications).

2 Abstact syntax and Semantics 2.1Conditions

This section specifies the language of the rule conditions that can be serialized using RIF-PRD, by specifying:

Note to the reader: this section depends on Section Constants, Symbol Spaces, and Datatypes of RIF data types and builtins [RIF-DTB].

2.1.12.1 Abstract syntax

For a production rule language to be able to interchange rules using RIF-PRD, its alphabet for expressing the condition parts of a rule must, at the abstract syntax level, consist of:

For the sake of readibility and simplicity, this specification introduces a notation for these constructs. That notation is not intended to be a concrete syntax andsyntax, so it leaves out many details that are not needed for its purpose:details: the only concrete syntax for RIF-PRD is the XML syntax.

Notice that the production rule systems for which RIF-PRD aims to provide a common XML serialization use only externally specified functions, e.g. builtins. RIF-BLD specifies, in addition, a construct to denote uninterpreted function symbols, which RIF-PRD does not require: this is one of two points wheredifferences between the syntaxes for conditionsalphabets used in the condition languages of RIF-PRD and RIF-BLD differ, since RIF-BLD specifies, in addition, a construct for serializing the logic functions that logic languages also use..

The second point of difference between the syntaxes for conditions in RIF-PRD and RIF-BLDis that, unlike RIF-PRD, RIF-BLDthat RIF-PRD does not specifysupport a construct forform of negation. This isRIF-BLD does not support negation because logic rule languages use many different kinds of negations, none of them prevalent enough to justify inclusion in the basic logic dialect of RIF (see also the RIF framework for logic dialects).

2.1.1.12.1.1 Terms

The most basic construct that can be serialized using RIF-PRD is the term. RIF-PRD provides for the representation and interchange of several kinds of terms: constants, variables, positional terms and terms with named arguments

Definition (Term).

  1. Constants and variables. If tConst or tVar then t is a simple term.
  2. Positional terms. If tConst and t1, ..., tn, n≥0, are terms then t(t1 ... tn) is a positional term.
    Here, the constant t represents a function and t1, ..., tn represent argument values.
  3. Terms with named arguments. A term with named arguments is of the form t(s1->v1 ... sn->vn), where n≥0, tConst and v1, ..., vn are terms and s1, ..., sn are pairwise distinct symbols from the set ArgNames.
    The constant t here represents a function; s1, ..., sn represent argument names; and v1, ..., vn represent argument values. The argument names, s1, ..., sn, are required to be pairwise distinct. Terms with named arguments are like positional terms except that the arguments are named and their order is immaterial. Note that a term of the form f() is, trivially, both a positional term and a term with named arguments. 2.1.1.2 Atomics  ☐

2.1.2 Atomic formulas

The atomic truth-valued constructs that can be serialized using RIF-PRD are called atomicsatomic formulas.

Definition (Atomic)(Atomic formula). An atomic formula can have several different forms and is defined as follows:

  1. Positional atomicsatomic formulas. If tConst and t1, ..., tn, n≥0, are terms then t(t1 ... tn) is a positional atomic formula (or simply a positional atom).
  2. AtomicsAtomic formulas with named arguments. An atomic formula with named arguments (or simply a atom with named arguments) is of the form t(s1->v1 ... sn->vn), where n≥0, tConst and v1, ..., vn are terms and s1, ..., sn are pairwise distinct symbols from the set ArgNames.
    The constant t here represents a predicate; s1, ..., sn represent argument names; and v1, ..., vn represent argument values. The argument names, s1, ..., sn, are required to be pairwise distinct. Atoms with named arguments are like positional Atoms except that the arguments are named and their order is immaterial. Note that an atom of the form t() is, trivially, both a positional atom and an atom with named arguments.
  3. Equality atomicsatomic formulas. t = s is an equality atomic ,formula (or, simply, an equality), if t and s are terms.
  4. Class membership atomicsatomic formulas (or just membership atomics). t#s is a membership atomic formula if t and s are terms. the term t is the object and the term s is the class.
  5. Subclass atomicsatomic formulas. t##s is a subclass atomic formula if t and s are terms.
  6. Frame atomicsatomic formulas. t[p1->v1 ... pn->vn] is a frame atomic formula (or simply a frame) if t, p1, ..., pn, v1, ..., vn, n ≥ 0, are terms. The term t is the object of the frame; the pi are the property or attribute names; and the vi are the property or attribute values. In this document, an attribute/value pair is sometimes called a slot.
    Membership, subclass, and frame atomicsatomic formulas are used to describe objects, classifications and class hierarchies.
  7. Externally defined atomics.atomic formulas. If t is a positional, named-argument, or a frame atomic formula then External(t) is an externally defined atomic formula. Such atomicsatomic formulas are used for representing built-in predicates as well as "procedurally attached" predicates, which might exist in various rule-based systems or applications, but are not specified by RIF-PRD.predicates.   ☐

Note that not only predicates, but also frame atomicsatomic formulas can be externally defined. Therefore, external information sources can be modeled in an object-oriented way via frames.

For instance, External("http://example.com/acme"^^rif:iri["http://example.com/mycompany/president"^^rif:iri(?Year) -> ?Pres]) could be a representationEditor's Note: Objects are commonly used in PR systems. In this draft, we reuse frame, membership, and subclass formulas (from RIF-BLD) to model objects. We are aware of an externally defined method "http://example.com/mycompany/president"^^rif:iricurrent limits, such as difficulty expressing datatype and cardinality constraints. Future drafts will address that problem. We are interested in an external object "http://example.com/acme"^^rif:iri .   ☐feedback on the merits and limitations of this approach.

Observe that the argument names of frames, p1, ..., pn, are terms and so, as a special case, can be variables. In contrast, atoms with named arguments can use only the symbols from ArgNames to represent their argument names. They cannotnames, which can neither be constants from Const ornor variables from Var.

Note that atomicsatomic formulas are sometimes also called terms, e.g. in the realm of logic languages: the specification of RIF-BLD, in particular, follows that usage. The abstract syntactic elements that are called terms in this specification, are called basic terms in the specification of RIF-BLD.

2.1.1.32.1.3 Formulas

Composite truth-valued constructs that can be serialized using RIF-PRD are called formulas.

Any atomic is also an atomic formula .Note that terms (constants, variables and functions) are not formulas.

More general formulas are constructed out of the atomic formulas with the help of logical connectives.

Definition (Condition formula). A condition formula can have several different forms and is defined as follows:

  1. Atomic formula: If φ is an atomic formula then it is also a condition formula.
  2. Conjunction: If φ1, ..., φn, n ≥ 0, are condition formulas then so is And(φ1 ... φn), called a conjunctive formula. As a special case, And() is allowed and is treated as a tautology, i.e., a formula that is always true.
  3. Disjunction: If φ1, ..., φn, n ≥ 0, are condition formulas then so is Or(φ1 ... φn), called a disjunctive formula. As a special case, Or() is permitted and is treated as a contradiction, i.e., a formula that is always false.
  4. Negation: If φ is a condition formula, then so is Not(φ), called a negative formula.
  5. Existentials: If φ is a condition formula and ?V1, ..., ?Vn, n>0, are variables then Exists ?V1 ... ?Vn(φ) is an existential formula.   ☐

In the definition of a formula, the component formulas φ and φi are said to be subformulas of the respective condition formulas that are built using these components.

The function Var(e) that maps a term, atomic formula or formula e to the set of its free variables is defined as follows:

Definition (Ground formula). A condition formula φ is a ground formula if and only if Varφ = {} and φ does not contain any existential subformula.   ☐

In other words, a ground formula does not contain any variable term.

2.1.1.42.1.4 Well-formed formulas

The specification of RIF-PRD does not assign a standard meaning to all the formulas that can be serialized using its concrete XML syntax: formulas that can be meaningfully serialized are called well-formed. Not all formulas are well-formed with respect to RIF-PRD: it is required that no constant appear in more than one context. What this means precisely is explained below.

The set of all constant symbols, Const, is partitioned into several subsets as follows:

Each predicate and function symbol that take at least one argument has precisely one arity. For positional predicate and function symbols, an arity is a non-negative integer that tells how many arguments the symbol can take. For symbols that take named arguments, an arity is a set {s1 ... sk} of argument names (siArgNames) that are allowed for that symbol. Nullary symbols (which take zero arguments) are said to have the arity 0.

An important point is that neither the above partitioning of constant symbols nor the arity are specified explicitly. Instead, the arity of a symbol and its type is determined by the context in which the symbol is used.


Definition (Context of a symbol). The context of an occurrence of a symbol, s∈Const, in a formula, φ, is determined as follows:

Definition (Well-formed formula). A formula φ is well-formed iff:

Definition (RIF-PRD condition language). The RIF-PRD condition language consists of the set of all well-formed formulas that can be serialized using the RIF-PRD XML syntax. 2.1.2formulas.   ☐

2.2 Semantics of condition formulas

This section specifies the intended semantics of the condition formulas in a RIF-PRD document.

For compatibility with other RIF specifications (in particular, RIF data types and builtins), and to make the interoperability with RIF logic dialects (in particular RIF Core [RIF-Core] and RIF-BLD), the intended semantics for RIF-PRD condition formulas is specified in terms of a model theory.

2.1.2.12.2.1 Semantic structures

The key concept in a model-theoretic semantics of a logic language is the notion of a semantic structure [ Enderton01 , Mendelson97 ].Definition (Semantic structure). A semantic structure, I, is a tuple of the form <TV, DTS, D, Dind, Dfunc, IC, IV, I PF, I NPframe, I frameNF, Isub, Iisa, I=, Iexternal, Itruth>. Here D is a non-empty set of elements called the Herbrand domain of 'I, andi.e., the set of all ground terms which can be formed by using the elements of Const. Dind is a, Dfunc are nonempty subsetsubsets of D. Dind is used to interpret the elements of Const that are individuals. As before,individuals and Dfunc is used to interpret the elements of Const that are function symbols. Const denotes the set of all constant symbols and Var the set of all variable symbols. TV denotes the set of truth values that the semantic structure uses and DTS is a set of identifiers for primitive datatypes (please refer to Section Datatypes of RIF data types and builtins [RIF-DTB] for the semantics of datatypes). The set of all ground (positional|named|frame|external) formulas which can be formed by using the function symbols with the ground terms in the Herbrand domain is the Herbrand base, HB. A semantic structure I is a Herbrand interpretation, IH, if the corresponding subset of HB is the set of all ground formulas which are true with respect to I.   ☐

As far as the assignementassignment of a standard meaning to formulas in the RIF-PRD condition language is concerned, the set TV of truth values consists of just two values, t and f.

The other components of I are total mappings defined as follows:

  1. IC maps Const to D.

    This mapping interprets constant symbols;symbols. In addition:

  2. IV maps Var to Dind.

    This mapping interprets variable symbols;symbols.

  3. I PF maps D to functions D*indD (here D*ind is a set of all sequences of any finite length over the domain Dind).

    This mapping interprets positional terms and gives meaning to positional predicate symbols;function.

  4. I NPNF maps D to the set of total functions of the form SetOfFiniteSets(ArgNames × Dind) → D.

    This mapping interprets predicatefunction symbols with named arguments.arguments and gives meaning to named argument functions. This is analogous to the interpretation of positional predicate symbolsterms with two differences:

  5. Iframe maps Dind to total functions of the form SetOfFiniteBags(Dind × Dind) → D.

    This mapping interprets frame terms.terms and gives meaning to frame functions. An argument, dDind, to Iframe represents an object and the finite bag {<a1,v1>, ..., <ak,vk>} represents a bag of attribute-value pairs for d. We will see shortly howIframe is used to determine the truth valuation of frame terms.

    Bags (multi-sets) are used here because the order of the attribute/value pairs in a frame is immaterial and pairs may repeat: o[a->b a->b]. Such repetitions arise naturally when variables are instantiated with constants. For instance, o[?A->?B ?C->?D] becomes o[a->b a->b] if variables ?A and ?C are instantiated with the symbol a and ?B, ?D with b.

  6. (We shall see later that o[a->b a->b] is equivalent to o[a->b] ;)Isub gives meaning to the subclass relationship. It is a mapping of the form Dind × DindD.

    The operator ## is required to be transitive, i.e., c1 ## c2 and c2 ## c3 must imply c1 ## c3. ThisTThis is ensured by a restriction in Section Interpretation of condition formulas;

  7. Iisa gives meaning to class membership. It is a mapping of the form Dind × DindD.

    The relationships # and ## are required to have the usual property that all members of a subclass are also members of the superclass, i.e., o # cl and cl ## scl must imply o # scl. This is ensured by a restriction in Section Interpretation of condition formulas;

  8. I= is a mapping of the form Dind × DindD.

    It gives meaning to the equality operator;operator.

  9. Itruth is a mapping of the form D TV.

    It is used to define truth valuation for formulas.

  10. Iexternal is a mapping from the coherent set of schemas for externally defined functions to total functions D* → D. For each external schema σ = (?X1 ... ?Xn; τ) in the coherent set of external schemas associated with the language ,language, Iexternal(σ) is a function of the form DnD.

    For every external schema, σ, associated with the language, Iexternal(σ) is assumed to be specified externally in some document (hence the name external schema). In particular, if σ is a schema of a RIF built-in predicate or function, Iexternal(σ) is specified in [RIF-DTB] so that:

For convenience, we also define the following mapping I from terms to D:

The effect of datatypes. The set DTS must include the datatypes described in Section Primitive Datatypes of RIF data types and builtins [RIF-DTB].

The datatype identifiers in DTS impose the following restrictions. Given dtDTS, let LSdt denote the lexical space of dt, VSdt denote its value space, and Ldt: LSdtVSdt the lexical-to-value-space mapping (for the definitions of these concepts, see Section Primitive Datatypes of RIF data types and builtins [RIF-DTB]. Then the following must hold:

That is, IC must map the constants of a datatype dt in accordance with Ldt.

RIF-PRD does not impose restrictions on IC for constants in symbol spaces that are not datatypes included in DTS.

2.1.2.22.2.2 Interpretation of condition formulas

This section defines how a semantic structure, I, determines the truth value TValI(φ) of a condition formula, φ. In PRD a semantic structure is represented as a Herbrand interpretation.

We define a mapping, TValI, from the set of all condition formulas to TV. Note that the definition implies that TValI(φ) is defined only if the set DTS of the datatypes of I includes all the datatypes mentioned in φ and Iexternal is defined on all externally defined functions and predicates in φ.

Definition (Truth valuation). Truth valuation for well-formed condition formulas in RIF-PRD is determined using the following function, denoted TValI:

2.2.3 Satisfaction of a condition

We now define what it means for a set of ground formulas to satisfy a condition formula. The satisfaction of condition formulas by a set of ground formulas provides formal underpinning to the operational semantics of rulesets interchanged using RIF-PRD.


Definition (Models).(State). A semantic structure Istate S is a model ofHerbrand Interpretation IH.   ☐

Definition (Condition Satisfaction). A condition formula, φ is satisfied under variable assignment σ in a state S, written as I  |= φ ,S |= φ[σ], iff TVal IS(φ )[σ]) = t. Definition (Logical entailment). Let φ and ψ be formulas. We say that φ entails ψ , written as φ |= ψ , if and only if for every semantic structure, I , for which both TVal I ( φ ) and TVal I ( ψ ) are defined, I  |= φ implies  ☐


2.2.4 Matching substitution

At the syntactic level, the interpretation of the variables by a valuation function I  |= ψ .V is realized by extension, in this document,a setsubstitution. The matching substitution of formulas, Φ = { φ 1 , ..., φ n }, n 1, is saidconstants to entail a formula ψ , written as Φ |= ψ , if and only if for every semantic structure, I , for which TVal I ( φ 0 ), ..., TVal I ( φ n ), and TVal I ( ψ ) are defined, I  |= φ 0 and ... and I  |= φ n implies I  |= ψ . Definition (Condition Satisfaction). Let Φ = { φ 1 , ..., φ m }, m 1, be a set of ground formulas and ψ be a condition formula. We say that Φ satisfies ψ if and only if, for every semantic structure I that is a model of all the ground formulas φ i in Φ : I  |= φ i , i= 1..m, there is at least one semantic structure I * such that: I *  |= ψ , and I * is exactly like I , except that a mapping I * V is used instead of I V , such that   I * V is defined to coincide with I V on all variables except, possibly, on the variables ?v 0 ... ?v n , n 0, that are free in ψ , that is, such that: Var( ψ ) = { ?v 0 ... ?v n }. In other words, a set of ground formulas Φ = { φ 1 , ..., φ m } m 1 satisfies a condition formula ψ iff Φ |= Exists ?v 0 ... ?v n (ψ) , where { ?v 0 , ..., ?v n } n 0 = Var( ψ ). 2.1.2.4 Matching substitution At the syntactic level, the interpretation of the variables by a valuation function I V is realized by a substitution . The matching substitution of constants to variables,variables, as defined below, provides the formal link between the model-theoretic semantics of condition formulas and the operational semantics of rule sets in RIF-PRD.

Let Term be the set of the terms in the RIF-PRD condition language (as defined in section Terms).

Definition (Substitution). A substitution is a finitely non-identical assignment of terms to variables; i.e., a function σ from Var to Term such that the set {xVar | x ≠ σ(x)} is finite. This set is called the domain of σ and denoted by Dom(σ). Such a substitution is also written as a set such as σ = {ti/xi}i=0..n where Dom(σ) = {xi}i=0..n and σ(xi) = ti, i = 0..,n.   ☐

Definition (Ground Substitution). A ground substitution is a substitution σ that assigns only constantsground terms to the variables in Dom (σ) :(σ):xDom(σ), σ(Var(σ(x ) Const . Definition (Matching Substitution). Let ψ)) =   ☐

Notice that since RIF-PRD covers only externally defined interpreted functions, a ground term can always be replaced by a condition formula; let σconstant. In the remainder of this document, it will always be assumed that a ground substitution forassigns only constants to the freevariables of ψ, that is, such that: Var (in its domain.

Definition (Matching Substitution). Let ψ ) Dom (σ);be a condition formula, and letφ be a set of ground formulas that satisfies ψ. We say that σ is matchingψ tomatches φ (or simply, matching , when there is no ambiguitywith respect to Ψ and Φ )substitution σ : Var -> Terms if anand only if, for every semantic structure I that is a model of all the ground formulas φ i in Φ ,if there is at least one semantic structure I *, such that: I * is a model of ψ : I *  |= ψ ; I * is exactly like I , except thata mapping I * V is used instead ofsyntactic interpretation I V ,such that   I * V is defined to coincide withfor all ?xi V on all variables except, possibly, on the variables ?v 0 ... ?v n that are freein ψVar(σ), that is, such that: Var( ψ ) = { ?v 0 ... ?v n };I * V (?x(?xi) = I(σ(?xi C (σ(?x i )), for all ?x i in Var ( ψ ). In)).   ☐

3 Actions

This section specifies the definitionaction part of a matching substitution, conditions 1 and 2 are the same as inthe definition of Condition Satisfaction , and they guaranteerules that the Φ -consistency of a substitution for the free variables in ψcan be serialized using RIF-PRD (the conclusion of a production rule is definedoften called the action part, or, simply, the action; the then part, with respectreference to the same semantic structures that make Φ satisfy ψ . Condition 3 guarantees that Φ |= ψ[σ] , where ψ[σ] denotes the ground condition formula obtained by substituting σ( ?x ) for every occurenceif-then form of ?x in ψ , for every variable ?x in Var ( ψ ). In other words, a formula ψ matchesa ground formula And(φ 1 , ..., φ n ) , n > 0rule statement; or the right-hand side, with respect to a ground substitution σ,or RHS. In the usual sense of pattern matching algorithms, e.g. [REFERENCE], if and only if σlatter case, the condition is a matching substitution forusually called the free variablesleft-hand side of ψ with respect tothe set of ground formulas Φ = { φ 1 , ..., φ n }. 2.2 Actionsrule, or LHS). Specifically, this section specifies the actions that can be serialized using RIF-PRD, by specifying:specifies:

(See also: Proposed modified abstract syntax and semantics for option 3 ) 2.2.1 Abstract Syntax For aIn production rule language to be able to interchange rules using RIF-PRD, its alphabet for expressingsystems, the action part of a rule must, atthe abstract syntax level, consist of syntactic constructsrules is used, in particular, to denote:add, delete or modify facts in the assertion of a positional atom, an atomdata source with named arguments, or a frame, membership, or subclass atomic;respect to which the retractioncondition of rules are evaluated and the rules instantiated. As a positional atom, an atomrule interchange format, RIF-PRD does not make any assumption regarding the nature of the data source that the producer or the consumer of a RIF-PRD document uses (e.g. a rule engine's working memory, an external data base, etc). As a consequence, the syntax of the actions that RIF-PRD supports are defined with respect to the RIF-PRD condition formulas that represents the facts that the actions are intended to affect. In the same way, the semantics of the actions is specified in terms of how the effects of their execution are intended to affect the evaluation of rule condition.

Editor's Note: This version of the draft specifies only a very limited set of basic atomic actions. Future draft will extend that set, in particular to support actions whose effect is not, or not only, to modify the fact base.

3.1 Abstract syntax

For a production rule language to be able to interchange rules using RIF-PRD, its alphabet for expressing the action part of a rule must, at the abstract syntax level, consist of syntactic constructs to denote:

Editor's Note: ... and/or others. We are especially interested in feedback aboutThese actions that cannot be decomposed intomay seem foreign to a sequence of the above. For the sakereader who is familiar with typical production rule language actions, such as assert an object, modify/update a field of readabilityan object, and simplicity,retract/remove an object. As noted in Section Atomic formulas, in this specification introduces a non-normative notation for these constructs.draft, objects are modeled using frame, membership, and subclass formulas that notation is not intendedare re-used from RIF-BLD and RIF-Core. Therefore, the object-oriented actions are defined to beact upon frame, membership, and subclass relations. Mappings from a concrete syntaxtypical Java-like object model to RIF-PRD maps "instanceof" to membership, "extends" and it leaves out many details that"implements" to subclass, and object properties/fields to frame slots. To assert an object requires asserting both its class membership and its frame slots. To modify a slot, e.g. change color from red to blue, requires retracting the old frame slot and asserting the new frame slot. Indeed, frame slots are multi-valued and, therefore, merely asserting a frame slot does not needed for its purpose.overwrite a prior value, it adds to the only normative concrete syntax for RIF-PRD isset of values. Frame slots do not inherently constrain either the XML syntax. 2.2.1.1datatype or the cardinality of their values. Future drafts will address the issue of object representation in RIF-PRD. We are open to suggestions.

3.1.1 Atomic actions

Atomic action constructs take constructs from the RIF-PRD condition language as their arguments.

Definition (Atomic action). An atomic action can have several different forms and is defined as follows:

  1. Assert: If φ is a positional atom, an atom with named arguments, a frame, a membership atomic,atomic formula, or a subclass atomic formula in the RIF-PRD condition language, then Assert(φ) is an atomic action. φ is called the target of the action.
  2. Retract: If φ is a positional atom, an atom with named arguments, or a frame in the RIF-PRD condition language, then Retract(φ) is an atomic action. φ is called the target of the action.
  3. Retract object: If t is a term in the RIF-PRD condition language, then Retract(t) is an atomic action. t is called the target of the action. 2.2.1.2  ☐

Editor's Note: Whether and under what restrictions, if any, membership and subclass atomic formulas are allowable targets for atomic assert actions is still under discussion in the working group. We welcome feedback on that issue.

Definition (Ground atomic action). An atomic action with target t is a ground atomic action if and only if Var(t) = ∅.   ☐

3.1.2 Action blocks

The action block is the top level construct to represent the conclusions of the production rules that can be serialized using RIF-PRD. An action block contains a non-empty sequence of atomic actions. It may also include action variable bindingsdeclarations.

The action variable bindings providedeclaration construct is used to declare variables that are local to the action block, called action variables, and to assign them a value within the action block.

Editor's Note: This version of RIF-PRD supports only a limited mechanism to initialize local action variables. Action variables may be bound to newly created frame objects or to slot values of frames. Definition (ActionFuture versions may support different or more elaborate mechanisms.

Definition (Action variable binding).declaration). An action variable binding can have two forms and is defined as follows: New : if ?odeclaration is a variable defined inpair, (v p) made of an enclosingaction block (described below), then New(?o) isvariable, v, and an action variable binding.binding (or, simply, binding), p, where p has one of two forms:

  1. frame slot valueobject declaration: if fthe action variable, v, is to be assigned the identifier of a new frame, then the action variable binding is a frame object declaration: New(v). In that case, the notation for the RIF-PRD condition language, then f is anaction variable binding. 2.2.1.3declaration is: (?o New(?o));
  2. frame slot value: if the action blocks A sequencevariable, v, is to be assigned the value of zero or more variables followed bya sequenceslot of zero or morea ground frame, then the action variable bindings followed bybinding is a sequenceframe: p = o[s->v], where o is a term that represents the identifier of one or more atomic actionsthe ground frame and s is called an action blocka term that represents the name of the slot. The associaed notation is: (?value o[s->?value]).   ☐

Definition (Action block). If v(v1 ,p1), ..., v(vn 1 ,pn 1 0, are variables (sometimes called action variables) and b 1 , ..., b n 2, n 20,0, are action variable bindingsdeclarations, and if a1, ..., a n 3m, n 3m1,1, are atomic actions, if n 1 = 0then
Do(aDo((v1 ... a n 3 ) is an action block . else Do vp1 ... v), ..., (vn 1 (b 1 ... bpn 2 ;) a1 ... a n 3l) isdenotes an action block. Definition (Well-formed action block). An action block is  ☐

3.1.3 Well-formed if and only if: every action variable occurs in exactly oneaction variable binding contained inblocks

The specification fo RIF-PRD does not assign a standard meaning to all the action block if fblocks that can be standardized using its concrete XML syntax. Action blocks that can be meaningfully serialized are called well-formed. The notion of well-formedness, already defined for condition formulas, is both a frameextended to atomic actions, action variable declarations and anaction blocks.

The main restrictions are that one and only one action variable binding, nobindings can assign a value to each action variable occurs inbinding, and that the object position or a slot key positionassertion of f .a membership atomic formula is meaningful only if for a new frame object.

Definition (Ground(Well-formed atomic action). An atomic action is well-formed if and only if one of the following is true:

Definition (Well-formed action (or, simply, a groundvariable declaration). An action variable declaration (?v p) is well-formed if and only if Var ( t ) bv , where bvone of the following is true:

For Externally Defined Terms of [ RIF-DTB ]) associated withthe languagedefinition of RIF-PRDa well-formed action block, the function Var(f), that has been defined for condition formulas, is extended to atomic actions and frame object declarations as follows:

Definition (RIF-PRD(Well-formed action language). The RIF-PRDblock). An action language consists of the set of all theblock is well-formed actions. 2.2.2 Operational semantics of actions This section specifies the intended semantics of the actions in a RIF-PRD document. The effect intendedif and only if all of the ground actions infollowing is true:

Definition (RIF-PRD action language). The RIF-PRD action language consists of the set of all the well-formed action blocks.   ☐

3.2 Operational semantics of atomic actions

This section specifies the intended semantics of the atomic actions in a RIF-PRD document.

The effect intended of the ground atomic actions in the RIF-PRD action language is to changemodify the state of the fact base, in such a way that it changes the set of conditions that are satisfied before and after each atomic action is implemented.performed.

As a consequence, the intended semantics of the ground atomic actions in the RIF-PRD action language determines a relation, called the RIF-PRD transition relation: →RIF-PRD P(W)W × L × P(W)W, where W denotes the set of all the ground condition formulas in the RIF-PRD condition languages; where P(W) denotes the power setstates of W ;the fact base, and where L denotes the set of all the ground atomic actions in the RIF-PRD action language.

Definition (RIF-PRD transition relation).Since the intended semanticssatisfaction of RIF-PRD actionscondition formulas is completely specified bydefined with respect to the transition relation RIF-PRD P(W) × L × P(W) . (w, α , w') RIF-PRD if and only if w W , w' W , and oneHerbrand interpretation of ground formulas (Section Satisfaction of a condition), we will assume in the following is true: α is Assert(φ) andthat the states of the fact base are represented by such sets, for every ground formula ψ inthe purpose of specifying the intended operational semantics of atomic actions, or rules and of rule sets serialized using RIF-PRD.

Definition (RIF-PRD transition relation). The intended semantics of RIF-PRD atomic actions is completely specified by the transition relation RIF-PRD W × L × W. (w, α, w' |= ψw') RIF-PRD if and only if And(w, φ) |= ψ α is Retract(φ) and for every ground formula ψwW, w' |= ψ if and only if W |= ψ and ψ |≠ φ, α is Retract(o)a ground atomic action, and oone of the following is true:

  1. α is Assert(φ), where φ is a constantground atomic formula, and f 1 , ..., f nw' = w + φ;
  2. α is Retract(φ), n 0, are ground frameswhere oφ is the object,a ground atomic formula, and m 1 , ..., m n'w' = w - φ;
  3. α is Retract(o), n' 0, are ground member atomicswhere o is the object,a constant, and w' = w - {o[s->v] | for every ground formula φ W , w' |= φ if and only if w |= φall the values of terms s and φ |≠ Or (f 1 , ..., f n , m 1 , ..., m n' ) α is Do v 1 ...v nv (b 1 ...b n b ; α} - {o#c | for all the values of term c}.   ☐

Rule 1 ...α n a ) suchsays that each variable v i is replaced everywhere in the actions α 1 ...α n a with constant c i , determined as follows. Let b j be the action variable binding that references v i , which is guaranteed to exist and be unique if α is well-formed: if b j is New(v i ) , then c i is a constant such that for every constant k in W , w |≠ c i #k and for every frame f in W , c i does not occur in the object position of f if b j is a frame, then c i comes from the substitution of v i as specified by the extractActions function. (w 1 , α 1 , w' 1 ) RIF-PRD and ... and (w n a , α n a , w' n a ) RIF-PRD and w = w 1 and w i+1 = w' i and w' n a = w' Rule 1 says that allall the condition formulas that were satisfied before an assertion will be satisfied after, and thatthat, in addition, the condition formulas that are satisfied by the asserted ground formula will be satisfied after the assertion.

Rule 2 says that all the condition formulas that were satisfied before a retraction will be satisfied after, except if they are satisfied only by the retracted fact.

Rule 3 says that all the condition formulas that were satisfied before the removal of a frame object will be satisfied after, except if they are satisfied only by one of the frame or membership formulas about the removed object or a conjunction of such formulas.

Rule4 says that the effect of a block of actions is the effect of executing each action one after the other. 2.3Production rules and rulesets

This section specifies the rules and rulesets that can be serialized using RIF-PRD, by specifying:

In addition, this section specifies additional concrete XML syntax for wrapping a ruleset in a RIF-PRD document and for adding meta-data to elements in a RIF-PRD document. 2.3.14.1 Abstract syntax

For a production rule language to be able to interchange rules using RIF-PRD, in addition to the RIF-PRD condition and action languages, its alphabet must, at the abstract syntax level, contain syntactic constructs:

For the sake of readability and simplicity, this specification introduces a notation for these constructs. That notation is not intended to be a concrete syntax and it leaves out many details that are not needed for its purpose: the only concrete syntax for RIF-PRD is the XML syntax. 2.3.1.14.1.1 Rules

Definition (Rule). A rule can be either:

RIF-BLD compatibility. A rule If condition, Then action can be equivalently notedwritten action :- condition, that is, using RIF-BLD logic programmingnotation. Indeed, the normative XML syntax is the same for a conditional assertion in RIF-BLD and for a conditional action in RIF-PRD. The use of RIF-BLD notation is especially useful if the condition formula, condition, contains no negation, and if the action is an atomic conclusion or a conclusionblock, to emphasizeaction, contains only Assert atomic actions. The use of the same notation emphasizes that such a rule has the same semantics in RIF-PRD and RIF-BLD.

Editor's Note: At this stage, the above assertion regarding the equivalence of a specific fragment of RIF-PRD and RIF-BLD is mostly the statement of an objective of the working group. That issue will be addressed more completely in a future version of this document.

To emphasize that equivalence even further, an action block can be written as simply And(φ1 ... φn), if it contains only atomic assert actions: Do(Assert(φ1) ... Assert(φn)), n 1. If the action block consists of a single atomic assert action: Do(Assert(φ)), then it can be written as simply φ.

Notice that the notation for a rule with bound variables uses the keyword Forall for the same reasons, that is, to emphasize the overlap with RIF-BLD. Indeed, althoughForall does not indicate the universal quantification of the declared variables, in RIF-PRD, but merely that the execution of the rule must be considered for all their bindings as constrained by the binding patterns,patterns. However, when no negation is used in the semanticsconditions and only assertions in the actions, the XML serialization of a RIF-PRD rule with bound variables andis exactly the semanticssame as the XML serialization of a RIF-BLD universally quantified rule coincide whenever they have the same RIF XML syntax. 2.3.1.2rule, and their semantics coincide.

4.1.2 Groups

Definition (Group). If strategy denotes a conflict resolution strategy, if priority isAs was already mentioned in Section Overview, production rules have an integer,operational semantics that can be described in terms of matching rules against states of the fact base, selecting rule instances to be executed, and if each rg j , 0 j n , is either aexecuting rule or a group, then anyinstances' actions to transition to new states of the following is a group : Group rg 0 ... rg n , n 0 ; Group strategy rg 0 ... rg n ,fact base.

When production rules are interchanged, the intended rule instance selection strategy, often called the conflict resolution strategy, need be interchanged along with the rules : in RIF-PRD, the group is the construct that is used to group sets of rules and to associate them with a conflict resolution strategy. Many production rule systems use priorities associated with rules as part of their conflict resolution strategy: in RIF-PRD, the group is also used to carry the priority information that may be associated to the interchanged rules.

Definition (Group). If strategy is an IRI that denotes a conflict resolution strategy, if priority is an integer, and if each rgj, 0 j n, is either a rule or a group, then any of the following is a group:

4.1.3 Well-formed rules and groups

The function Var(f), that has been defined for condition formulaeformulas and extended to actions, is further extended to rules, as follows:

Definition (Well-formed rule). A rule, r, is a well-formed rule if and only if it contains no free variable, that is, Var(r) = 0, and either:

Definition (Well-formed group). A well-formed group is either a group that contains only well-formed rules and well-formed groups, or a group that contains no rule or group (an empty group).   ☐

The set of the well-formed groups contains all the production rulesets that can be meaningfully interchanged using RIF-PRD.

2.3.24.2 Operational semantics of rules and rule sets

For the purpose of specifying4.2.1 Motivation and example

As already mentioned in Section Overview, the semantics of a RIF-PRD rule or groupdescription of rules ,a production rule system PRS is definedas a labeled terminal transition system (e.g. PLO04 ). Definition (labeled terminal transition system): A labeled terminaltransition system can be used to specify the intended semantics that is associated with production rules and rulesets interchanged using RIF-PRD.

The intuition of describing a structure { C , L , →, T }, where C isproduction rule system as a set of elements, c , called configurations, or state; Ltransition system is that, given a set of elements,production rules RS and a , called actions (or labels); C × L × C is the transition relation, that is: ( c, a, c' ) iff there is a transition labelled a from the state c to the state c' or, more appropriately in the case of a PRS, the execution of action a in the state c causes a transition to state c' . We note: c + a c' or c a c' ; T C is the set of final states, that is, the set of all the states c from which there are no transitions: T = { c C | a L, c' C, ( c, a, c' ) →}. A labeled transition system is a structure {C, L, →} (without a set T of final states). The idea of describing a PRS as a labeled terminal transition system is that, given a set of production rules RS and a set of facts w 0fact base w0, the rules in RS that are satisfied, in some sense, in w0 determine an action a1, whichwhose execution results in a new set of factsfact base w1; the rules in RS that are satisfied in w1 determine an action a2 to execute in w1, and so on, until the system reaches a final state and stops. The result is the set of factsfact base wn when the system stops.

Example 3.1. Judicael, one followera chicken and potato farmer, uses a rule based system to decide on the daily grain allowance for each of Joeher chicken. Currently, Judicael's rule base contains one single rule, the Hen Public's method,chicken and mashed potatoes rule:

(* ex:ChickenAndMashedPotatoes *)
Forall ?chicken ?potato ?weight
      (And(?chicken#ex:Chicken
           (Exists ?age
                   And(?chicken[ex:age->?age]
                       External(pred:numeric-greater-than(?age, 8)))))
       And(?potato#ex:Potato          
           ex:owns(?chicken ?potato)
           (Exists ?weight
                   And(?potato[ex:weight->?weight]
                       External(pred:numeric-greater-than(?weight External(func:numeric-divide(?age 2)))))))
  If And(External(pred:string-not-equals(External(ex:today()), "Tuesday"))
         Not(External(ex:foxAlarm())))
  Then Do( (?allowance ?chicken[ex:allowance->?allowance])
           Execute(ex:mash(?potato))
           Retract(?potato)
           Retract(ex:owns(?chicken ?potato))
           Retract(?chicken[ex:allowance->?allowance])
           Assert(?chicken[ex:allowance->External(func:numeric-multiply(?allowance 1.1))]))

Judicael has four chickens, Joe,Jim, Jack, Joe and Julia, that own three potatoes (BigPotato, SmallPotato, UglyPotato) among them:

That is the initial set of facts w0.

Paula's rule set contains one single rule, that is, Joe's CMP rule: (* joe:ChickenAndMashedPotatoes *) Forall ?chicken ?potato ?allowance ?age ?weight ( Do( Execute(joe:mash(?potato)) Retract(?chicken[joe:allowance->?allowance]) ?chicken[joe:allowance->External(func:numeric-multiply(?allowance 1.1))] Retract(joe:owns(?chicken ?potato)) ) :- And( ?chicken#joe:Chicken ?chicken[joe:age->?age joe:allowance->?allowance] External(pred:numeric-greater-than(?age, 8)) ?potato#joe:Potato ?potato[joe:weight->?weight] joe:owns(?chicken ?potato) External(pred:numeric-greater-than(?weight External(func:numeric-divide(?age 2)))) External(pred:string-not-equals(External(joe:today()), "Tuesday")) Not(External(joe:foxAlarm())) ))When the rule is applied to w0:

Suppose that Judicael's implementation of today() returns Monday and that the foxAlarm() is false when the CMPChicken and mashed potatoes rule is applied: the condition is satisfied, and the actions in the conclusion are executed with BigPotato substituted for ?potato, JoeJim substituted for ?chicken, and 10 substituted for ?allowance. This results in the following changes in the set of facts:

The resulting set of facts w1 is thus:

When the CMPChicken and mashed potatoes rule in applied to w1, the first External predicatepattern still selects {Joe/?chicken,{Jim/?chicken, Jack/?chicken, Julia/?chicken} as possible values for variable ?chicken, but the joe:own relation and thesecond External predicate dopattern does not select any possible substitution for the couple (?chicken, ?potato) anymore: the rule cannot be satisfied, and the system, having detected a final state, stops.

The result of the execution of the system is w1. In the remainder of this section,  ☐

4.2.2 Definitions and notational conventions

More precisely, a production rule system is defined as ina labeled terminal transition system (e.g. PLO04), for the section onpurpose of specifying the operationalintended semantics of actionsa RIF-PRD rule or group of rules.

Definition (labeled terminal transition system): A labeled terminal transition system is a structure {C, W denotes theL, →, T}, where

For many purposes, a ground substitution such that Var(r) Dom(σ) . Givenrepresentation of the states of the fact base is an appropriate representation of the states a production rule instance ri = (r id , σ) , rule(ri) denotessystem seen as a transition system. However, the most widely used conflict resolution strategies require information about the history of the system, in particular with respect to the rule instances that is uniquely identified by r id , and substitution(ri) denotes σ . Similarly, an instancehave been selected for execution in previous states. Therefore, each state of the transition system used to represent a production rule set RS issystem must keep a setmemory of the previous states and the rule instances ri i ,that where i , rule(ri i ) RS . Given a rule set RS , Inst(RS) denotesselected and triggered the settransition in those states.

To avoid the confusion between the states of allthe possible instancesfact base and the states of RSthe transition system, the latter will be called production rule system states.

Definition (Production rule system state). A RIF-PRDproduction rule system is defined as a labelled terminal transition system: givenstate (or, simply, a rule set RS Rsystem state), s, let C RS P(W) × S(Inst(RS)) be a set of states, whereis characterized by

In the idea isfollowing, we will write previous(s) = NIL to denote that a state, c ,system state s is made of a set, w , of ground FORMULA e that representthe initial state.

Here, a state of facts; andrule instance is defined as the result of the ordered list, ri c ,substitution of constants for all the instancesrule variables in a rule.

Let R denote the set of all the rules in the considered ruleset RS that are fired, in some sense to be further specified, inrule language under consideration.

Definition (Rule instance). Given a rule, r R and a ground substitution, σ, such that state of facts. Further, let H RSVar(r)S(C RS ) be aDom(σ), where Var(r) denotes the set of histories, where a historythe rule variables in r, hthe result, ri = σ(r), of the substitution of the constant σ(?x) for each variable ?x ∈ Var(r) is a rule instance (or, simply, an ordered listinstance) of states c i : h = (c n ...c 1 ), n≥ 0 .r.  ☐

Given a history, h H RSrule instance ri, current(h) will be used to denotelet rule(ri) identify the first elementrule from which ri is derived by substitution of hconstants for the rule variables, and let substitution(ri) denote the substitution by which ri is derived from rule(ri).

In the following, two rule instances ri1 and history(h)ri2 of a same rule r will be used to denote h minus current(h) :considered different if h = (c n ...c 1 ), n≥ 1 , current(h) denotes c nand history(h) denotes the ordered list (c n-1 ...c 1 ), n≥ 1 .only if h = () issubstitution(ri1) and substitution(ri2) substitute a different constant for at least one of the empty list, current(h) = history(h) = rule variables in Var(r).

In the idea is that a history, h , represents the stackdefinition of the states that have been successively traversed bya production rule system, in the current run, from its initialsystem state, a rule instance, ri, is said to the current state: current(h) represents the currentmatch a state of the system; history(h) representsa fact base, w, if its history,defining substitution, substitution(ri), matches the RIF-PRD condition formula that is,represents the statescondition of facts that held andthe instancesinstantiated rule, rule(ri), to the ground formula that were fired inrepresents the previous cycles, ordered from most recent to initial. Let further assume three functions: INSTANTIATE : P(W) × P(R) P(Inst(R)) , that, given a setstate of facts,facts w and a set of rules, RS , returns.

Let W denote the set of all the instancespossible states of a fact base.

Definition (Matching rule instance). Given a rule, ri, and a state of the rules in RS that are satisfied infact base, w W, in a sense thatri is determined by the specificationsaid to match w if and only if one of the function; PICKfollowing is true:

Definition (Conflict set). Given a historyrule set, RS R, and a set of rules, returns true or falsesystem, s, depending on whether or notthe history is terminal. Let extractActions : S(Inst(R)) S(L) , be a helper function that, given an orderedset, ori ,conflictSet(RS, s) of rule instances, returnsall the sequencedifferent instances of ACTION s that is the concatenation, preservingthe orderrules in ori , ofRS that match the sequencesstate of ground actionsthe fact base, facts(s) W is called the conflict set determined by each of the rule instancesRS in oris. Editor's Note: extractActions is underdefined. Need be fixed at some point. Given a ruleset RS and the associated conflict resolution strategy LS  ☐

In each non-final state, s, of a RIF-PRDproduction rule system is defined assystem, a labelled terminal transition system PRS RS,LS = {H RS , S(L), RS,LS , T RS,LS }subset, picked(s), where : H RSof the rule instances in the conflict set is selected and ordered; their action parts are instantiated, and they are executed. This is sometimes called: firing the selected instances.

Definition (Action instance). Given a setsystem state, s; given a rule instance, ri, of histories; S(L) isa rule in a rule set, RS; and given the setaction block in the action part of labels;the transition relation RS,LS H RS × S(L) × H RS , is defined as follows: ( h , s h'rule rule(ri): Do((v1 p1)...(vn pn) a1...am) H RS × S(L) × H RS, ( hn 0, sm 1, h'where the (v1 p1) RS,LS if, 0 i n, represent the action variable declarations and only if all ofthe following hold: s = extractACTIONS(picked(current(h)) ; (facts(current(h)), s, facts(current(h'))) * RIF-PRDaj, where * RIF-PRD denotes1 j m, represent the transitive closuresequence of atomic actions in the transition relation RIF-PRD thataction block; if ri is defined bya matching instance in the specification ofconflict set determined by RS in system state s: ri conflictSet(RS, s), the semantics of actions ; picked(c')substitution σ = PICK(facts(current(c'), history(c'), RS, LS) and h T RS,LS A history hsubstitution(ri) is final iff FINAL(h, RS, LS) = true : T RS,LS = {h H RS | FINAL(h, RS, LS) = true} . Intuitively,extended to the first conditionaction variables v1...vn, n 0, in the definition of the transition relation RS,LS says that a RIF-PRD production rule system can transition from one history to another onlyfollowing way:

The allowed transition paths outsequence of a given state. And condition 3 guaranteesground atomic actions that is the system halts as soon as it encountersresult of substituting a terminal state.constant for each variable in the input function is defined as: Eval(RS, LS, w) RS,LS h H RS , where facts(current(h)) = watomic actions of the action block of the rule instance, ri, picked(current(h)) = PICK(w, ∅, RS, LS) and history(h) = according to the output functionextended substitution, is defined as: h' T RS,LS RS,LS facts(current(h')) = w' Or, using * RS,LS to denotethe transitive closure ofaction instance associated to ri.   ☐

Let actions(ri) denote the transition relation: Eval(RS, w) * RS,LS w'action instance that is associated to a rule instance ri. By extension, given the specificationan ordered set of PRS RS,LSrule instances, ori, actions(ori) denotes the intended operational semanticssequence of a production ruleset represented by a RIF-PRD Group RSground atomic actions that is completely specified bythe specification ofconcatenation, preserving the three functions INSTANTIATEorder in ori, PICK and FINAL . 2.3.2.1 Rules instantiation: INSTANTIATE The evaluationof the function INSTANTIATE correspondsaction instances associated to the step that is often called matchingrule instances in the descriptionori.

4.2.3 Operational semantics of a production rule systems (e.g. PRR07 ). Given a collection of rules, it considerssystem

All possible ground rule instances, obtained by assigning ground terms to the variables occuring in them. Its semantics is defined, in accordance withthe semantics of the RIF-PRD condition language . Let ExtractCONDITIONS: R LC beelements that are required to define a function that, givenproduction rule system as a rule, r R , returnslabeled terminal transition system have now been defined.

Definition (RIF-PRD Production Rule System). A well-formed condition formulaRIF-PRD production rule system is defined recursivelyas follows: if r is of the form ACTION , then ExtractCONDITIONS(r)a labeled terminal transition system PRS = And() ; if r is of the form if FORMULA then ACTION_BLOCK{S, A, PRS, then ExtractCONDITIONS(r) = FORMULA ; if rT}, where :

Intuitively, the first condition in the definition of the associated substitutiontransition relation PRS states that a production rule system can transition from one system state to another only if the variablesstate of facts in the ACTION s inlatter system state can be reached from the then componentstate of facts in the instantiated rule. The decisionformer by performing a sequence of ground atomic actions supported by RIF-PRD, according to implementthe sequencesemantics of the atomic actions that a rule instance determines is often called: firing.

The rule instance. More than one rulesecond condition states that the allowed paths out of any given system state are determined only by how rules instances are picked from a rulethe conflict set may be instantiated in afor execution by the conflict resolution strategy.

Given a ruleset RS R, the associated conflict resolution strategy LS, and an initial state of facts, and, forthe fact base, w W, the input function to a RIF-PRD production rule system is defined as:
Eval(RS, LS, w) PRS s S, such that facts(s) = w and previous(s) = NIL.
Given rule, there may be several different instances. Thea set T of allfinal system states, the output function is defined as:
s' T, s' PRS w'= facts(s')
Or, using *PRS to denote the transitive closure of the transition relation PRS:
w W, s' T, w' W, w'= facts(s') and Eval(RS, LS, w) *PRS w'

Therefore, the exact behavior of a RIF-PRD production rule system depends on:

  1. the conflict resolution strategy, that is, how rule instances are, precisely, selected for execution from the rule instances that are satisfied inmatch a given state is often called:of the conflict set ;fact base;
  2. and how the set T of final system states is, precisely, defined.

4.2.4 Conflict resolution

The process of selecting one or more rule instances from the conflict set for firing is often called: conflict resolution.

In RIF-PRD the conflict resolution algorithm (or conflict resolution strategy) that is intended for a set of rules is denoted by a keyword or a set of keywords that is attached to the rule set. In this version of the RIF-PRD specification, a single conflict resolution strategy is specified normatively: it is denoted by the RIF-PRDkeyword rif:standardForward ,rif:forwardChaining (a constant of type rif:IRI), for it accounts for a common conflict resolution strategy used in most forward-chaining production rule systems.

Editor's Note: Name of the standard CR strategy to be discussed and agreed upon... standardForward used here as a placeholder.Future versions of the RIF-PRD specification may specify normatively the intended conflict resolution strategies to be attached to additional keywords. In addition, RIF-PRD documents may include non-standard keywords: it is the responsability of the producers and consumers of such document to agree on the intended conflict resolution strategies that are denoted by such non-standard keywords.

2.3.2.2.1Conflict resolution: rif:standardForwardresolution strategy: rif:forwardChaining

Most existing production rule systems implement conflict resolution algorithms that are a combination of the following elements (under these or other, idiosyncratic names; and possibly combined with additional, idiosyncratic rules):

The RIF-PRD keyword rif:standardForwardrif:forwardChaining denotes the common conflict resolution strategy that can be summarized as follows: given a conflict set, as returned by the function INSTANTIATEset

  1. Refraction is applied to the conflict set, that is, all the refracted rule instances are removed from the conflict set;
  2. The remaining rule instances are ordered by decreasing priority, and only the rule instances with the highest priority are kept in the conflict set;
  3. The remaining rule instances are ordered by decreasing recency, and only the most recent rule instances are kept in the conflict set;
  4. Any remaining tie is broken arbitrarily, and a single rule instance is kept for firing.

Accordingly, given a state of fact, w W , a history, h H RS , and a rule set RS , the function PICK(w, h, RS, rif:standardForward ) returns a list that contain a single rule instance, selected from the conflict set generated by INTANTIATE(w, RS) as specified below.As specified earlier, picked(c)picked(s) denotes the ordered list of the rule instances that were picked in state c.a system state, s. Under the conflict resolution strategy denoted by rif:standardForwardrif:forwardChaining, the list denoted by picked(c)picked(s) contains a single rule instance, for any given system state, cs.

For the purpose of this specification, an extended test, inst , is specified for the membership of a rule instance in a set of rule instances:Given a rule instance, ri Inst(RS)system state, s, anda set ofrule instance, RI Inst(RS)set, RS, ri ∈ inst  RI ifand only if there isa rule instance, ri' ri such that rule(ri) = rule(ri') and, for each variable ?v Var(rule(ri)) , σ(?v) = σ'(?v)conflictSet(RS, s), where σ = substitution(ri) and σ' = substitution(ri') . Furthermore,let recency: Inst(RS) × H RS N , where N denotes the set of the positive integers, be an integer function that, given a rule instance, ri , and a history, h , returnsrecency(ri, s) denote the number of system states in hbefore s, starting from the first one,in which ri ishas been continuously satisfied:a matching instance: if hs is the history of thecurrent system state, recency(ri, h)s) provides a measure of the recency of the rule instance ri. The functionrecency(ri, s) is specified recursively as follows:

In the positive integers, be an integer function that,same way, given aan rule instance, ri, and a history, hsystem state, s, returnslet lastPicked(ri, s) denote the number of system states in hbefore s, starting from the first one,since ri has been last fired. The functionlastPicked(ri, s) is specified recursively as follows:

Finally, given a rule instance, ri Inst(RS), let priority(ri) denote the priority that is associated to rule(ri) in RS, or zero, if no priority is associated to rule(ri) in RS. If rule(ri) is inside nested Group s in RS ,s, priority(ri) denotes the priority that is associated with the innermost Group to which a priority is explicitely associated, or zero.

Given a state of facts, w W , a history, h H RS , and a ruleconflict set, RScs, PICK(w, h, RS, rif:standardForward )the conflict resolution strategy rif:forwardChaining can now be defineddescribed with the help of a terminal transition system {A, sF , T sF }, where: A is the set of all the possible sets of rule instances for consideration; The transition relation, sF A × A , is defined as follows: for all pairs (a, a') A × A , (a, a') sF iffour rules, where ri and only if: there is ari' are rule instance,instances:

  1. Refraction rule: if ri ∈ Inst(RS) , such that a' = a\ri ,cs and Either (refraction)lastPicked(ri, h)s) ≤ recency(ri, h); or (priority) there is as), then cs = cs - ri;
  2. Priority rule instance,: if ri cs and ri' ∈ a' , such thatcs and priority(ri) < priority(ri'), then cs = cs - ri;
  3. or (recency there is aRecency rule instance,: if ri cs and ri' ∈ a' , such that recency(ri', h) <cs and recency(ri, h)s) > recency(ri', s), then cs = cs - ri;
  4. A set ofTie-break rule instance, a A , is terminal: a: if riT sFcs, if and only if there is no set ofthen cs = {ri}.

The refraction rule removes the instances a' A suchthat (a, a') sF . The input function is defined as: PICK(w, h, RS; rif:standardForward ) sF a = INSTANTIATE(w, RS)have been in the output function is defined as: a' T sF sF keepOneFrom(a') where keepOneFrom breaks any remaining tie by removing arbirarilyconflict set in all the elements butsystem states at least since they were last fired, that is, it removes the refracted instances from the current conflict set; the priority rule removes the instances such that there is at least one instance with a higher priority; the recency rule removes the instances such that there is at least one instance that is more recent; and the tie-break rule keeps one rule from its argument list. 2.3.2.3the set, arbitrarily.

To select the singleton rule instance, picked(s), to be fired in a system state, s, given a rule set, RS, the conflict resolution strategy denoted by the keyword rif:forwardChaining consists in the following sequence of steps:

  1. start with the conflict set, cs, that a rule set RS determines in a system state s: cs = conflictSet(RS, s);
  2. apply the refraction rule to all the rule instances in cs;
  3. then apply the priority rule to all the remaining instances in cs;
  4. then apply the recency rule to all the remaining instances in cs;
  5. then apply the tie-break rule.

4.2.5 Halting test: FINALtest

Editor's Note: This section is still under discussion (see ISSUE-65). This version specifies a single, default halting test: future version of this draft may specify additional halting tests, and/or a different default. The Working Group seeks feedback on which halting tests and which combinations of tests should be supported by RIF-PRD and/or required from RIF-PRD implementations; and which halting test should be the default, if any.

By default, the specification fora terminalsystem state thatis intended forfinal, given a set of production rules, when no halting test is explicitely associated to its representation asrule set, RS, and a RIF-PRD Rulesetconflict resolution strategy, LS, if there is whenno rule instance available for firing after application of the conflict resolution strategy.

For the conflict resolution strategy identified by the RIF-PRD keyword rif:forwardChaining, a system state, s, is fireable: this isfinal given a rule set, RS if and only if the case when INSTANTIATE returns an emptyremaining conflict set is empty after application of the refraction rule instances, or whento all the rule instances that are satisfiedin the state, according to the semantics of INSTANTIATE , have already been fired in a state that has not since changed significantly. That latter condition guarantees, in particular, thatconflictSet(RS, s). In particular, all the system halts when it reaches a fixpoint. Formally, RS R, c C RSstates, s, PICK(c, RS) = true if and only if instance(c) - history(c)such that conflictSet(RS, s) = ∅ . Otherwise, PICK(c, RS) = false . 3are final.

5 XML Syntax

This section specifies a common concrete XML syntax to serialize any production rule set written in a language that share the abstract syntax speicifed in section 4.1, provided that its intended semantics agrees with the semantics that is described in section 4.2.

In the following, after the notational conventions are introduced, we specify the RIF-PRD XML constructs that carry a normative semantics with respect to the intended interpretation of the interchanged rules. They are specified with respect to the abstract syntax, and their specification is structured according to the specification of the abstract syntax in sections 2.1, 3.1 and 4.1.

The root element of any RIF XML document, Document and other XML constructs that do not carry a normative semantics with respect to the intended interpretation of the interchanged rules are specified in the last sub-section.

3.15.1 Notational conventions

3.1.15.1.1 Namespaces

Throughout this document, the xsd: prefix stands for the XML Schema namespace URI http://www.w3.org/2001/XMLSchema#, the rdf: prefix stands for http://www.w3.org/1999/02/22-rdf-syntax-ns#, and rif: stands for the URI of the RIF namespace, http://www.w3.org/2007/rif#.

Syntax such as xsd:string should be understood as a compact URI (CURIE) -- a macro that expands to a concatenation of the character sequence denoted by the prefix xsd and the string string. The compact URI notation is used for brevity only, and xsd:string should be understood, in this document, as an abbreviation for http://www.w3.org/2001/XMLSchema#string.

3.1.25.1.2 BNF pseudo-schemas

The XML syntax of RIF-PRD is specified for each component as a pseudo-schema, as part of the description of the component. The pseudo-schemas use BNF-style conventions for attributes and elements: "?" denotes optionality (i.e. zero or one occurrences), "*" denotes zero or more occurrences, "+" one or more occurrences, "[" and "]" are used to form groups, and "|" represents choice. Attributes are conventionally assigned a value which corresponds to their type, as defined in the normative schema. Elements are conventionally assigned a value which is the name of the syntactic class of their content, as defined in the normative schema.

<!-- sample pseudo-schema -->
    <defined_element
          required_attribute_of_type_string="xs:string"
          optional_attribute_of_type_int="xs:int"? >
      <required_element />
      <optional_element />?
      <one_or_more_of_these_elements />+
      [ <choice_1 /> | <choice_2 /> ]*
    </defined_element>

3.1.35.1.3 Syntactic components

Three kinds of syntactic components are used to specify RIF-PRD:

3.25.2 Conditions

This section specifies the XML constructs that are used in RIF-PRD to serialize condition formulaeformulas.

3.2.15.2.1 TERM

The TERM class of constructs is used to serialize terms, be they simple terms, that is, constants and variables; or positional terms or terms with named arguments, both being, per the definition of a well-formed formula, representations of externally defined functions.

As an abstract class, TERM is not associated with specific XML markup in RIF-PRD instance documents.

    [ Const | Var | External ]

3.2.1.15.2.1.1 Const

In RIF, the Const element is used to serialize a constant.

The Const element has a required type attribute and an optional xml:lang attribute:

The content of the Const element is the constant's litteral, which can be any Unicode character string.

    <Const type=xsd:anyURI [xml:lang=xsd:language]? >
        Any Unicode string
    </Const>

\{\{EdNote|text=The case of non-standard data types, that is, of constants that do not belong or cannot be cast in one of RIF builtin types for interchange purposes, is still under discussion in the WG. The WG seeks feedback on whether they should be allowed and why.\}\}

Example 2.1. In each of the examples below, a constant is first described, followed by its serialization in RIF-PRD XML syntax.

a. A constant with builtin type xsd:integer and value 123:

<Const type="xsd:integer">123</Const>

b. A constant which symbol today is defined in Joe the Hen Public's namespace http://rif.examples.com/2008/joe#http://rif.example.com/2008/joe#. The type of the constant is rif:iri:

<Const type="rif:iri">
    http://rif.examples.com/2008/joe#todayhttp://rif.example.com/2008/joe#today
</Const>

c. A constant with symbol BigPotato that is local to the set of rules where it appears (e.g. a RuleSet specific to Paula's farm). The type of the constant is rif:local:

<Const type="rif:local">BigPotato</Const>

d. A constant with non-builtin type xsd:int and value 123:

<Const type="xsd:int">123</Const>


3.2.1.25.2.1.2 Var

In RIF, the Var element is used to serialize a variable.

The content of the Var element is the variable's name, serialized as an Unicode character string.

    <Var> any Unicode string </Var>

Example 2.2. The example below shows the XML serialization of a reference to a variable named: ?chicken.

<Var> chicken <Var>

3.2.1.35.2.1.3 External

As a TERM, the External element is used to serialize a positional term or a term with named arguments. In RIF-PRD, a positional or a named-argument term represents always a call to an externally specified function, e.g. a builtin, a user-defined function, a query to an external data source...

The External element contains one content element, which in turn contains one Expr element that contains one op element, followed zero or one args element or zero of more slot elements:

    <External>
       <content>
          <Expr>
             <op> Const </op>
             [ <args rif:ordered="yes"> TERM* </args>?
               |
               <slot rif:ordered="yes">
                  <Name> Any Unicode string </Name>
                  TERM
               <slot>* ]
          </Expr>
       </content>
    </External>

Editor's Note: The slotted, or named arguments form of the External TERM construct is still under discussion (see also ISSUE-68). The working group seeks feedback on whether or not it should be included in PRD.

Example 2.3.

a. The first example below shows one way to serialize, in RIF-PRD, the sum of integer 1 and a variable ?x, where the addition conforms to the specification of the builtin fn:numeric-add.

The prefix fn is associated with the namespace http://www.w3.org/2007/rif-builtin-function#.

<External>
   <content>
      <Expr>    
         <op> <Const type="rif:iri"> fn:numeric-add </Const> </op>
         <args rif:ordered="yes"> 
            <Const type="xsd:integer"> 1 </Const>
            <Var> x </Var>
         </args>
      </Expr>
   </content>
</External>

b. Another example, that shows the RIF XML serialization of a call to the application-specific nullary function today(), which symbol is defined in the example's namespace http://rif.examples.com/2008/joe#http://rif.example.com/2008/joe#:

<External>
   <content>
      <Expr>    
         <op>
            <Const type="rif:iri">
                http://rif.examples.com/2008/joe#todayhttp://rif.example.com/2008/joe#today
            </Const>
         </op>
      </Expr>
   </content>
</External>

3.2.25.2.2 ATOMIC

The ATOMIC class is used to serialize atomicsatomic formulas: positional and named-arguments atoms, equality, membership and subclass atomics,atomic formulas, frame atomicsatomic formulas and externally defined atomics..atomic formulas.

As an abstract class, ATOMIC is not associated with specific XML markup in RIF-PRD instance documents.

    [ Atom | Equal | Member | Subclass | Frame | External ]

3.2.2.15.2.2.1 Atom

In RIF, the Atom element is used to serialize a positional atomicsatomic formula or an atomic formula with named arguments.

The Atom element contains one op element, followed by zero or one args element or zero or more slot arguments:

    <Atom>
       <op> Const </op>
       [ <args rif:ordered="yes"> TERM* </args>?
         |
         <slot rif:ordered="yes">
            <Name> Any Unicode string </Name>
            TERM
         <slot>* ]
    </Atom>

Editor's Note: The slotted, or named arguments form of the Atom construct is still under discussion (see also ISSUE-68). The working group seeks feedback on whether or not it should be included in PRD.

Example 2.4. The example below shows the RIF XML serialization of the positional atomicsatom owns(?c ?p), where the predicate symbol owns is defined in the example namespace http://rif.examples.com/2008/joe#http://rif.example.com/2008/joe#.

<Atom>
   <op>
      <Const type="rif:iri">
          http://rif.examples.com/2008/joe#ownshttp://rif.example.com/2008/joe#owns
      </Const>
   </op>
   <args rif:ordered="yes">
      <Var> c </Var>
      <Var> p </Var>
   </args>
</Atom>

3.2.2.25.2.2.2 Equal

In RIF, the Equal element is used to serialize equality atomicsatomic formulas.

The Equal element must contain one left sub-element and one right sub-element. The content of the left and right elements must be a construct from the TERM abstract class. The order of the sub-elements is not significant.

    <Equal>
       <left> TERM </left>
       <right> TERM </right>
    </Equal>

3.2.2.35.2.2.3 Member

In RIF, the Member element is used to serialize membership atomicsatomic formulas.

The Member element contains two unordered sub-elements:

    <Member>
       <instance> TERM </instance>
       <class> TERM </class>
    </Member>

Example 2.5. The example below shows the RIF XML serialization of a boolean expression that tests whether the individual denoted by the variable ?c is a member of the class Chicken that is defined in the example namespace http://rif.examples.com/2008/joe#http://rif.example.com/2008/joe#.

<Member>
   <instance> <Var> c </Var> </instance>
   <class>
      <Const type="rif:iri">
          http://rif.examples.com/2008/joe#Chickenhttp://rif.example.com/2008/joe#Chicken
      </Const>
   </class>
</Member>

3.2.2.45.2.2.4 Subclass

In RIF, the Subclass element is used to serialize subclass atomicsatomic formulas.

The Subclass element contains two unordered sub-elements:

    <Subclass>
       <sub> TERM </sub>
       <super> TERM </super>
    </Subclass>

3.2.2.55.2.2.5 Frame

In RIF, the Frame element is used to serialize frame atomicsatomic formulas.

Accordingly, a Frame element must contain:

    <Frame>
       <object> TERM </object>
       <slot rif:ordered="yes"> TERM TERM </slot>*
    </Frame>

Example 2.6. The example below shows the RIF XML syntax that serializes an expression that states that the object denoted by the variable ?c has the value denoted by the variable ?a for the property Chicken/age that is defined in the example namespace http://rif.examples.com/2008/joe#http://rif.example.com/2008/joe#.

<Frame>
   <object> <Var> c </Var> </object>
   <slot rif:ordered="yes"> 
      <Const type="rif:iri">
          ttp://rif.examples.com/2008/joe#Chicken/agettp://rif.example.com/2008/joe#Chicken/age
      </Const>
      <Var> a </Var>
   </slot>
</Frame>

Editor's Note: The example uses an XPath style for the key. How externally specified data models and their elements should be referenced is still under discussion (see ISSUE-37).

3.2.2.65.2.2.6 External

In RIF-PRD, the External element is also used to serialize an externally defined atomic formula.

When it is a ATOMIC (as opposed to a TERM; that is, in particular, when it appears in a place where an ATOMIC is expected, and not a TERM), the External element contains one content element that contains one Atom element. The Atom element serializes the externally defined atom properly said:

    <External>
       <content>
          Atom
       </content>
    </External>

The op Const in the Atom element must be a symbol of type rif:iri that must uniquely identify the externally defined predicate to be applied to the args TERMs. It can be one of the builtin predicates specified for RIF dialects, as listed in section List of RIF Builtin Predicates and Functions of the RIF data types and builtins document, or it can be application specific. In the latter case, it is up to the producers and consumers of RIF-PRD rulesets that reference non-builtin predicates to agree on their semantics.

Example 2.7. The example below shows the RIF XML serialization of an externally defined atomic formula that tests whether the value denoted by the variable named ?a (e.g. the age of a chicken) is greater than the integer value 8, where the test is intended to behave like the builtin predicate op:numeric-greater-than as specified in XQuery 1.0 and XPath 2.0 Functions and Operators.

In the example, the prefix op: is associated with the namespace http://www.w3.org/2007/rif-builtin-predicate#.

<External>
   <content>
      <Atom>    
         <op> <Const type="rif:iri"> op:numeric-greater-than </Const> </op>
         <args rif:ordered="yes">
            <Var> ?a </Var>
            <Const type="xsd:decimal"> 8 </Const>
         </args>
      </Atom>
   </content>
</External>

3.2.35.2.3 FORMULA

The FORMULA class is used to serialize condition formulas, that is, atomic formulas, conjunctions, disjunctions, negations and existentials.

As an abstract class, FORMULA is not associated with specific XML markup in RIF-PRD instance documents.

    [ ATOMIC | And | Or | NmNot | Exists ]

3.2.3.15.2.3.1 ATOMIC

An atomic formula is serialized using a single ATOMIC statement. See specification of ATOMIC, above.

3.2.3.25.2.3.2 And

A conjunction is serialized using the And element.

The And element contains zero or more formula sub-elements, each containing an element of the FORMULA group.

    <And>
       <formula> FORMULA </formula>*
    </And>


3.2.3.35.2.3.3 Or

A disjunction is serialized using the Or element.

The Or element contains zero or more formula sub-elements, each containing an element of the FORMULA group.

    <Or>
       <formula> FORMULA </formula>*
    </Or>

3.2.3.45.2.3.4 NmNot

A negation is serialized using the NmNot element.

The NnNot element contains exactly one formula sub-element. The formula element contains an element of the FORMULA group, that serializes the negated statement.

    <NmNot>
       <formula> FORMULA </formula>
    </NmNot>

Editor's Note: The name of that construct may change, including the tag of the XML element.

3.2.3.55.2.3.5 Exists

An existentially quantified formula is serialized using the Exists element.

The Exists element contains:

    <Exists>
       <declare> Var </declare>+
       <formula> FORMULA </formula>
    </Exists>

Example 2.8. The example below shows the RIF XML serialization of a boolean expression that tests whether the chicken denoted by variable ?c is older than 8 months, by testing the existence of a value, denoted by variable ?a, that is both the age of ?c, as serialized as a Frame element, as in example 2.6, and greater than 8, as serialized as an External ATOMIC, as in example 2.7.

<Exists>
   <declare> <Var> a </Var> </declare>
   <formula>
      <And>
         <Frame>
            <object> <Var> c </Var> </object>
            <slot rif:ordered="yes"> 
               <Const type="rif:iri">
                   http://rif.examples.com/2008/joe#Chicken/agehttp://rif.example.com/2008/joe#Chicken/age
               </Const>
               <Var> a </Var>
            </slot>
         </Frame>
         <External>
            <content>
               <Atom>    
                  <op> <Const type="rif:iri"> op:numeric-greater-than </Const> </op>
                  <args rif:ordered="yes">
                     <Var> a </Var>
                     <Const type="xsd:decimal"> 8 </Const>
                  </args>
               </Atom>
            </content>
         </External>
      </And>
   </formula>
</Exists>

3.35.3 Actions

This section specifies the XML syntax that is used to serialize the action part of a rule supported by RIF-PRD.

3.3.1 ACTION The ACTION class of constructs is used to represent the actions in the action part of a production rule. As an abstract class, ACTION is not associated with specific XML markup in RIF-PRD instance documents. [ ATOMIC_CONCLUSION | ATOMIC_ACTION | ACTION_BLOCK | CONCLUSION_BLOCK ] 3.3.1.1 ATOMIC_CONCLUSION The ATOMIC_CONCLUSION class of constructs is used to represent the targets of the Assert construct and is also used for compatibility with RIF-Core. [ Atom | Frame | Member | Subclass ] 3.3.1.25.3.1 ATOMIC_ACTION

The ATOMIC_ACTION class of constructselements is used to representserialize the primitive actionsatomic actions: assert and retract.

    [ Assert | Retract ]

3.3.1.2.15.3.1.1 Assert

An Assert constructatomic assertion action is used to represent actionsserialized using the Assert element.

An atom (positional or with named arguments), a frame, a membership atomic formula and a subclass atomic formula can be asserted.

The Assert element has one target sub-element that result in assertingcontains an ATOMIC_CONCLUSION .Atom, a Frame, a Member or a Subclass element that represents the facts to be added on performing the action.


    <Assert>
         <target>  ATOMIC_CONCLUSION[ Atom | Frame | Member | Subclass ] </target>
    </Assert>

3.3.1.2.25.3.1.2 Retract

The Retract construct is used to represent actionsserialize retract atomic actions, that result in removing facts from working memory. An Atom ,a Frame , or a frame object may be retracted. A frame object is denoted using a TERM . A frame object is retracted by removing itfact from the Member relationfact base. Only atoms (positional or with named arguments), frames and removing all itsframe s.objects can be retracted.

The Retract element has one target sub-element that contains an Atom, a Frame, or a TERM construct that represents the facts or the object to be removed on implementingperforming the action.

    <Retract>
       <target> [ Atom | Frame | TERM ] </target>
    </Retract>

Example 2.10. The example below shows the RIF XML representation of an action that updates the chicken-potato ownership table by removing the predicate that states that the chicken denoted by variable ?c owns the potato denoted by variable ?p. The predicate is represented as in example 2.4.

<Retract>
   <target>
      <Atom>
         <op>
            <Const type="rif:iri">
                http://rif.examples.com/2008/joe#ownshttp://rif.example.com/2008/joe#owns
            </Const>
         </op>
         <args rif:ordered="yes">
            <Var> c </Var>
            <Var> p </Var>
         </args>
      </Atom>
   </target>
</Retract>

3.3.1.3 ACTION_BLOCK An ACTION_BLOCK construct5.3.2 INITIALIZATION

The INITIALIZATION class of elements is used to represent optional local variables and their bindings plus several ATOMIC_ACTION s. <Do rif:ordered="yes"> <declare> Var </declare>* <binding>serialized the constructs that specify the initial value assigned an action variable, in an action variable declaration: it can be a new frame identifier or the slot value of a frame.

As an abstract class, INITIALIZATION is not associated with specific XML markup in RIF-PRD instance documents.

    [ New | Frame ]

</binding>* <action> ATOMIC_ACTION </action>+ </Do> 3.3.1.3.15.3.2.1 New

The New constructelement is used to serialize the construct used to create a new frame object.identifer.

The New element has an instance sub-element that contains a Var . A new object is created and bound, which serializes the action variable intended to be assigned the instance variable.new frame identifier.

    <New>
       <instance> Var </instance>?
    </New>
Example 2.9.5.3.2.2 Frame

The example below showsFrame element is used, with restrictions, to the RIF XML representation ofserialize the construct used to assign an action blockvariable the slot value of a frame.

In that assertsposition, a new 100 decigram potato. <Do rif:ordered="yes"> <declare><Var>p</Var></declare> <binding> <New> <instance><Var>p</Var></instance> </New> </binding> <action> <Assert> <target> <Member> <instance><Var>p</Var></instance> <class> <Const type="rif:iri"> http://rif.examples.com/2008/joe#Potato </Const> </class> </Member> </target> </Assert> </action> <action> <Assert> <target>Frame must contain, in addition to its object sub-element, one and only one slot sub-element, that contains a sub-element of the TERM class, serializing the slot name, and a Var sub-element, that serializes the action variable intended to be assigned the slot value.

    <Frame>
        <object><Var>p</Var></object><object> TERM </object>
       <slot rif:ordered="yes">
           <Const type="rif:iri"> http://rif.examples.com/2008/joe#weight </Const> <Const type="xsd:decimal">100</Const>TERM
          Var
       </slot>
    </Frame>

</target> </Assert> </action> </Do> 3.3.1.4 CONCLUSION_BLOCK A CONCLUSION_BLOCK construct is used to represent several ATOMIC_CONCLUSION s in a way that is compatible with RIF-Core. <And> <formula> ATOMIC_CONCLUSION </formula>+ </And> 3.4 Rules and Groups This section specifies the XML constructs that are used, in RIR-PRD, to serialize rules and groups. 3.4.1 RULE In RIF-PRD,5.3.3 ACTION_BLOCK

The RULEACTION_BLOCK class of constructs is used to serializerepresent the conclusion, or action part, of a production rule serialized using RIF-PRD.

If action variables are declared in the action part of a rule, or if some atomic actions are not assertions, the conclusion must be serialized as a full action block, using the Do element. However, simple action blocks that contain only one or more assert actions can be serialized like the conclusions of logic rules using RIF-Core or RIF-BLD, that is, unconditionalas well as conditional actions,a single asserted ATOMIC or rules with bound variables.as a conjunction of the asserted ATOMICs.

As an abstract class, RULEACTION_BLOCK is not associated with specific XML markup in RIF-PRD instance documents.

    [  ImpliesDo |  ForallAnd |  ACTIONATOMIC ]
3.4.1.1 ACTION5.3.3.1 Do

An unconditionalaction block is serialized, in RIF-PRD XML,serialized using the ACTION classDo element.

A Do element contains:

    <Do>
       <actionVar rif:ordered="yes">
          Var
          INITIALIZATION
       </actionVar>*
       <actions rif:ordered="yes">
          ATOMIC_ACTION+
       </actions>
    </Do>

Example 2.9. The uptodate version ofexample below shows the RIF XML syntax for actions. <Implies> <if> FORMULA </if>? <then rif:ordered="yes">representation of an action block that asserts a new 100 decigram potato.

<Do>
   <actionVar>
      <Var>p</Var>
      <New>
         <instance><Var>p</Var></instance>
      </New>
   </actionVar>
   <actions  rif:ordered="yes">
      <Assert>
         <target>
            <Member>
               <instance><Var>p</Var></instance>
               <class>
                  <Const type="rif:iri">http://rif.example.com/2008/joe#Potato</Const>
               </class>
            </Member>
         </target>
      </Assert>
      <Assert>
         <target>
            <Frame>
               <object><Var>p</Var></object>
               <slot rif:ordered="yes">
                  <Const type="rif:iri">http://rif.example.com/2008/joe#weight</Const>
                  <Const type="xsd:decimal">100</Const>
               </slot>
            </Frame>
         </target>
      </Assert>
   </actions>
</Do>
5.3.3.2 And

An action * </then> </Implies> 3.4.1.3 Forallblock that contains only assert atomic actions can be serialized using the Forall construct is used, in RIF-PRD, to represent rulesAnd element, for compatibility with bound variablesRIF-Core and RIF-BLD.

However, the Forall element contains: oneatomic formulas allowed as conjuncts are restricted to atoms (positional or more declare sub-elements, each containing a Var element that represents one of the universally quantified variable; zerowith named arguments), frames, and membership or more pattern sub-elements, each containingsubclass atomic formulas.

In that position, an And element from the FORMULA group of constructs, serializing one binding pattern ; exactlymust contain at least one formula sub-elementsub-element.

    <And>
       <formula> [ Atom | Frame | Member | Subclass ] </formula>+
    </And>
5.3.3.3 ATOMIC

For compatibility with RIF-Core and RIF-BLD, an action block that serializescontains only a single assert atomic action can be serialzed as the formula inATOMIC that serializes the scopetarget of the variables binding, and that contains an element ofassert action.

However, the RULE group. <Forall> <declare> Var </declare>+ <pattern> FORMULA </pattern>* <formula> RULE </formula> </Forall> Editor's Note: Nested Forall s make explicit the scope ofonly atomic formulas allowed in tat position are the declared variables, and, thus, imposeones that are allowed as targets to an order on the evaluation of the patternatomic assert action: atoms (positional or with named arguments), frames, and if FORMULA e in a rule. That orderingmembership or subclass atomic formulas.

    [ Atom | Frame | Member | Subclass ]

5.4 Rules and Groups

This section specifies the use of patterns to constrain the binding of variables may be of practical significance for some production rule systems, but theyXML constructs that are irrelevant with respectused, in RIR-PRD, to the intended semantics of theserialize rules being interchanged (although they would be relevant if RIF-PRD was to be extended to support some kind of "else" or "case" construct). In addition, RIF-BLD does not allow nested Foralland does not supportgroups.

5.4.1 RULE

In RIF-PRD, the associationRULE class of contraining pattern sconstructs is used to declaredserialize rules, that is, unconditional as well as conditional actions, or rules with bound variables.

The working group seeks feedback regarding whether nestedAs an abstract class, RULE is not associated with specific XML markup in RIF-PRD instance documents.

    [ Implies | Forall  and constrainting pattern should be supported| ACTION_BLOCK ]

5.4.1.1 ACTION_BLOCK

An unconditional action block is serialized, in RIF-PRD, toRIF-PRD XML, using the costACTION_BLOCK class of reducingconstruct.

5.4.1.2 Implies

Conditional actions are serialized, in RIF-PRD, using the interoperability with RIF-BLDXML element Implies.

Example 2.10. The example below shows howThe CMP rule extract: "if a chicken owns a potatoImplies element contains an optional if sub-element and ..." could be serialized usinga binding patternthen sub-element:

    <Implies>
       <if> FORMULA </if>?
       <then> ACTION_BLOCK </then>
    </Implies>

5.4.1.3 Forall

The Forall construct is usedused, in RIF-PRD, to serialize a grouprepresent rules with bound variables.

The GroupForall element has zero orcontains:

    <Forall>
       <declare> Var </declare>+
       <pattern> FORMULA </pattern>*
       <formula> RULE  | Group ] </sentence>* </Group> 3.5 Non-semantic carrying constructs 3.5.1 Document</formula>
    </Forall>

Editor's Note: Nested Foralls make explicit the Document isscope of the root elementdeclared variables, and, thus, impose an order on the evaluation of the pattern and if FORMULAs in a RIF-PRD instance document. The Document contains zero or one payload sub-element,rule. That must contain a Group element. <Document> <payload> Group </payload>? </Document> 3.5.2 Metadata Metadata can be associated with any concrete class element in RIF-PRD: those areordering and the elements with a CamelCase tagname starting with an upper-case character: CLASSELT = [ TERM | ATOMIC | FORMULA | ACTION | RULE | Group | Document ] An identifier can be associated to any instance elementuse of patterns to constrain the abstract CLASSELT class of constructs, as an optional id sub-element that MUST contain a Constbinding of type rif:local or rif:iri . Metadata canvariables may be included in any instanceof a concrete class element using the meta sub-element. The RIF-PRD Frame construct is usedpractical significance for some production rule systems, but they are irrelevant with respect to serialize metadata:the contentintended semantics of the Frame 's object sub-element identifies the objectrules being interchanged (although they would be relevant if RIF-PRD was to which the metadata is associated:,be extended to support some kind of "else" or "case" construct). In addition, RIF-BLD does not allow nested Forall and does not support the Frame 's slotassociation of contraining patterns representto declared variables. The metadata properly said as property-value pairs. Ifworking group seeks feedback regarding whether nested Forall and constrainting pattern should be supported in RIF-PRD, to the allcost of reducing the metadata is related tointeroperability with RIF-BLD.

Example 2.10. The same object,example below shows how the meta element can containCMP rule extract: "if a single Frame sub-element. If metadata related to several different objects needchicken owns a potato and ..." could be serialized,serialized using a binding pattern FORMULA:

<Forall>
   <declare><Var>chicken</Var></declare>
   <formula>
      <Forall>
         <declare><Var>potato</Var></declare>
         <pattern>
            <External>
               <content>
                  <Atom>
                     <Const type="rif:iri">
                        http://rif.example.com/2008/joe#owns
                     </Const>
                     <Args rif:ordered="yes">
                        <Var>chicken</Var>
                        <Var>potato</Var>
                     </Args>
                  </Atom>
               </content>
            </External>
         </pattern>
         <formula>
            ...
         </formula>
      </Forall>
   </formula>
</Forall>

5.4.2 Group

The meta roleGroup construct is used to serialize a group.

The Group element can contain anhas zero or one behavior sub-element and element withzero or more formula sub-elements, each containingsentence sub-elements:

    <Group>
       <behavior>
          <ConflictResolution> xsd:anyURI </ConflictResolution>?
          <Priority> -10,000  xsd:int  10,000 </Priority>?
       </behavior>?
       <sentence> [ RULE | Group ] </sentence>*
    </Group>

5.5 Constructs carrying no semantics

5.5.1 Document

The metadata is about, not where itDocument is included inthe root element in a RIF-PRD instance RIFdocument.

It is suggested to use Dublin Core, RDFS, and OWL properties for metadata, alongThe lines of http://www.w3.org/TR/owl-ref/#Annotations -- specifically owl:versionInfo, rdfs:label, rdfs:comment, rdfs:seeAlso, rdfs:isDefinedBy, dc:creator, dc:description, dc:date, and foaf:maker. Example 2.11. TBC 4 Presentation syntax This section specifiesDocument contains zero or one payload sub-element, that must contain a presentation syntax for RIF-PRD.Group element.

    <Document>
       <payload> Group </payload>?
    </Document>

5.5.2 Metadata

Metadata can be associated with any concrete class element in RIF-PRD: those are the presentation syntax is not normative: its main purpose iselements with a CamelCase tagname starting with an upper-case character:

    CLASSELT = [ TERM | ATOMIC | FORMULA | ACTION | RULE | Group | Document ]

An identifier can be associated to help makeany instance element of the normative specificationabstract CLASSELT class of constructs, as an optional id sub-element that MUST contain a Const of type rif:local or rif:iri.

Metadata can be included in any instance of a concrete class element using the semantics easier to read.meta sub-element.

The presentation syntaxRIF-PRD Frame construct is designed to be very closeused to RIF-BLD . A line by line comparison of the EBNF will show these few differences:serialize metadata: the additioncontent of Notthe removal of Expr,Frame's object sub-element identifies the syntactic class of logical functions,object to which the replacement of ATOMIC in rule conclusions with ACTION,metadata is associated:, and the addition of Do(ACTION*) and And(ASSERT*) instead of And(ATOMIC*) in rule conclusions. definition of Assert, New, Retract, and Do actions. It is intended thatFrame's slots represent the syntax and semantics of RIF-BLD and RIF-PRD aremetadata properly said as property-value pairs.

If the all the metadata is related to the same whenobject, the rule conclusion containsmeta element can contain a only Atoms and Frames, "Not" is not used, and logical functions are not used.single Frame sub-element. If metadata related to several different objects need be serialized, the following EBNF is from RIF-BLD ,meta role element can contain an And element with lines prefixed with ! indicating a change for RIF-PRD: FORMULA ::= 'And' '(' FORMULA* ')' | 'Or' '(' FORMULA* ')' | 'Exists' Var+ '(' FORMULA ')' | ATOMIC | 'External' '(' Atom | Frame ')' | ! 'Not' '('zero or more formula ')' ATOMIC ::= Atom | Equal | Member | Subclass |sub-elements, each containing one Frame Atom ::= UNITERM UNITERM ::=element.

   <CLASSELT>
       <id> Const  '(' (TERM* <| (Name '->' TERM)*) ')' Equal ::= TERM ' = ' TERM Member ::= TERM '#' TERM Subclass ::= TERM '##' TERM</id>?
       <meta>
          [ Frame 
             ::= TERM '[' (TERM '->' TERM)* ']' ! TERM ::= Const | Var|
             'External' '(' Expr ')' Expr ::= UNITERM Var ::= '?' UNICODESTRING<And>
               <formula> Frame </formula>*
            </And>
          ]
       </meta>?
       other CLASSELT content
    </CLASSELT>

Notice that the following EBNFcontent of the meta sub-element of an instance of a RIF-PRD class element is taken from RIF-DTB andnot necessarily associated to that same instance element: only the content of the object sub-element of the Frame that represents the metadata specifies what the metadata is unchanged for PRD. Its purposeabout, not where it is to provide shortcuts for constants. ANGLEBRACKIRI ::= '<' IRI_REF '>' STRING ::= '"' UNICODESTRING '"' CURIE ::= PNAME_LN | PNAME_NS see RIF-DTB Const ::= STRING '^^'ANGLEBRACKIRI | STRING '^^' CURIE | ANGLEBRACKIRI shortcut for rif:iri | CURIE shortcut for rif:iri | STRING shortcut for xsd:string | NumericLiteral shortcut for xsd:integer,xsd:decimal,xsd:double | '_' LocalName shortcut for rif:localincluded in the following EBNFinstance RIF document.

It is from RIF-BLD and defines rules, groups of rules,suggested to use Dublin Core, RDFS, and OWL properties for metadata, along the containing document. Changedlines are prefixed with !. Metadata can be associated with Document , Group ,of http://www.w3.org/TR/owl-ref/#Annotations -- specifically owl:versionInfo, rdfs:label, rdfs:comment, rdfs:seeAlso, rdfs:isDefinedBy, dc:creator, dc:description, dc:date, and RULE constructs. ! Document ::= IRIMETA? 'Document' '(' Group? ')' Group ::= IRIMETA? 'Group' '(' (RULE | Group)* ')' ! RULE ::= (IRIMETA? 'Forall' Var+ '(' Implies ')') | Implies | INITIAL_FACT ! INITIAL_FACT ::= ASSERT | Member ! Implies ::= IRIMETA? ACTION ':-' FORMULA IRIMETA ::= '(*' Const? (Frame | 'And' '(' Frame* ')')? '*)' IRI ::= UNICODESTRING Profile ::= UNICODESTRING Finally,foaf:maker.

Example 2.11. TBC

6 Presentation syntax

To make it easier to read, a non-normative, lightweight notation was introduced to complement the following EBNF describesmathematical english specification of the abstract syntax and the semantics of PRD actions. ACTION ::= ATOMIC_CONCLUSION | ATOMIC_ACTION | ACTION_BLOCK | CONCLUSION_BLOCK ATOMIC_CONCLUSION ::= Atom | Frame | Member | Subclass ATOMIC_ACTION ::= Assert | Retract Assert ::= 'Assert' '(' ATOMIC_CONCLUSION ')' Retract ::= 'Retract' '(' Atom | Frame | TERM ')' ACTION_BLOCK ::= 'Do' Var* '(' ( ACTION_VAR_BINDING+ ';' )? ATOMIC_ACTION+ ')' ACTION_VAR_BINDING ::= New | Frame New ::= 'New' '(' Var ')' CONCLUSION_BLOCK ::= 'And' '(' ATOMIC_CONCLUSION ATOMIC_CONCLUSION+ ')' 5RIF-PRD. This section specifies a presentation syntax for RIF-PRD, that extends that notation. The presentation syntax is not normative. However, it may help implementers by providing a more succinct overview of RIF-PRD syntax.

Editor's Note: An uptodate version of the RIF-PRD presentation synatx will be included in a future version of this document.


7 References

[CIR04]
Production Systems and Rete Algorithm Formalisation, Cirstea H., Kirchner C., Moossen M., Moreau P.-E. Rapport de recherche n° inria-00280938 - version 1 (2004).

[CURIE]
CURIE Syntax 1.0 - A compact syntax for expressing URIs, W3C note 27 October 2005, M. Birbeck (ed.).

[HAK07]
Data Models as Constraint Systems: A Key to the Semantic Web, Hassan Ait-Kaci, Constraint Programming Letters, 1:33--88, 2007.

[PLO04]
A Structural Approach to Operational Semantics, Gordon D. Plotkin, Journal of Logic and Algebraic Programming, Volumes 60-61, Pages 17-139 (July - December 2004).

[PRR07]
Production Rule Representation (PRR), OMG specification, version 1.0, 2007.

[RDF-CONCEPTS]
Resource Description Framework (RDF): Concepts and Abstract Syntax, Klyne G., Carroll J. (Editors), W3C Recommendation, 10 February 2004, http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/. Latest version available at http://www.w3.org/TR/rdf-concepts/.

[RDF-SCHEMA]
RDF Vocabulary Description Language 1.0: RDF Schema, Brian McBride, Editor, W3C Recommendation 10 February 2004, http://www.w3.org/TR/2004/REC-rdf-schema-20040210/. Latest version available at http://www.w3.org/TR/rdf-schema/.

[RFC-3066]
RFC 3066 - Tags for the Identification of Languages, H. Alvestrand, IETF, January 2001, http://www.isi.edu/in-notes/rfc3066.txt.

[RFC-3987]
RFC 3987 - Internationalized Resource Identifiers (IRIs), M. Duerst and M. Suignard, IETF, January 2005, http://www.ietf.org/rfc/rfc3987.txt.

[RIF-BLD]
RIF Basic Logic Dialect Harold Boley, Michael Kifer, eds. W3C Working Draft, 30 July 2008, http://www.w3.org/TR/2008/WD-rif-bld-20080730/. Latest version available at http://www.w3.org/TR/rif-bld/.

[RIF-Core]
RIF Core Harold Boley, Gary Hallmark, Michael Kifer, Adrian Paschke, Axel Polleres, Dave Reynolds, eds. W3C Editor's Draft, 18 December 2008, http://www.w3.org/2005/rules/wg/draft/ED-rif-core-20081218/. Latest version available at http://www.w3.org/2005/rules/wg/draft/rif-core/.

[RIF-DTB]
RIF Datatypes and Built-Ins 1.0 Axel Polleres, Harold Boley, Michael Kifer, eds. W3C Editor's Draft, 18 December 2008, http://www.w3.org/2005/rules/wg/draft/ED-rif-dtb-20081218/. Latest version available at http://www.w3.org/2005/rules/wg/draft/rif-dtb/.

[XDM]
XQuery 1.0 and XPath 2.0 Data Model (XDM), W3C Recommendation, World Wide Web Consortium, 23 January 2007. This version is http://www.w3.org/TR/2007/REC-xpath-datamodel-20070123/. Latest version available at http://www.w3.org/TR/xpath-datamodel/.

[XML-SCHEMA2]
XML Schema Part 2: Datatypes Second Edition, W3C Recommendation, World Wide Web Consortium, 28 October 2004, http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/. Latest version available at http://www.w3.org/TR/xmlschema-2/.

[XPath-Functions]
XQuery 1.0 and XPath 2.0 Functions and Operators, W3C Recommendation, World Wide Web Consortium, 23 January 2007, http://www.w3.org/TR/2007/REC-xpath-functions-20070123/. Latest version available at http://www.w3.org/TR/xpath-functions/.


68 Appendix: XML schema

for RIF-PRDTBD

79 Appendix: Compatibility with RIF-BLD

7.19.1 Syntactic compatibility between RIF-PRD and RIF-BLD

Editor's Note: RIF-PRD and RIF-BLD [RIF-BLD]] share essentially the same presentation syntax and XML syntax. The syntactic differences between the two dialects are summarized below: RIF-BLD allows logic and externally specified, fixed-interpretation functions as TERM , whereas RIF-PRD accepts only externally specified functions; RIF-BLD allows ATOMIC or And(ATOMIC*) in rule conclusions, whereas RIF-PRD allows ACTION or Do(ACTION*) . In RIF-PRD it is not possible to conclude equalityFuture versions of this, or class membership. RIF-PRD allows Not(FORMULA) , which RIF-BLD does not accept; RIF-PRD defines ASSERT and Retract actions that are not allowed in RIF-BLD . Below isanother, RIF document will include a complete, construct by construct, comparison table of RIF-PRD and RIF-BLD presentation and XML syntaxes.


A construct is tagged "BLD" or "PRD" if it is specific to the dialect, or tagged "Core" if it is common to both. Editor's Note: RIF-Core will be equal to or included in the intersection of RIF-PRD and RIF-BLD. The exact scope of RIF-Core is still under discussion. Until RIF-Core is specified more precisely, this document assumes that it will be equal to the intersection of RIF-PRD and RIF-BLD. Presentation syntax XML syntax TERM ::= BLD [ Const | Var | Expr | External ] PRD [ Const | Var | External ] Const ::= Core '"' UNICODESTRING '"^^' SYMSPACE <Const type=xsd:anyURI [xml:lang=xsd:language]? > Any Unicode string </Const> Var ::= Core '?' Any Unicode string <Var> Any Unicode string </Var> Expr ::= BLD Const '(' (TERM* | (Name '->' TERM)*) ')' <Expr> <op> Const </op> [ <args rif:ordered="yes"> TERM * </args>? | <slot rif:ordered="yes"> <Name> Any Unicode string </Name> TERM </slot>* ] </Expr> PRD Undefined except when wrapped in an External (as TERM), as follows. External (as TERM) ::= Core 'External' '(' Expr ')' <External> <content> Expr </content> </External> ATOMIC ::= Core [ Atom | Equal | Member | Subclass | Frame ] Atom ::= Core Const '(' (TERM* | (Name '->' TERM)*) ')' <Atom> <op> Const </op> [ <args rif:ordered="yes"> TERM * </args>? | <slot rif:ordered="yes"> <Name> Any Unicode string </Name> TERM </slot>* ] </Atom> Equal ::= Core TERM = TERM <Equal> <left> TERM </left> <right> TERM </right> </Equal> Member ::= Core TERM # TERM <Member> <instance> TERM </instance> <class> TERM </class> </Member> Subclass ::= Core TERM ## TERM <Subclass> <sub> TERM </sub> <super> TERM </super> </Subclass> Frame ::= Core TERM ' [ ' (TERM ' -> ' TERM)* ' ] ' <Frame> <object> TERM </object> <slot rif:ordered="yes"> TERM TERM </slot>* </Frame> FORMULA ::= BLD [ ATOMIC | External | And | Or | Exists ] PRD [ ATOMIC | External | And | Or | NmNot | Exists ] External (as FORMULA) ::= Core 'External '(' [ Atom | Frame ] ')' <External> <content> [ Atom | Frame ] </content> </External> And ::= Core 'And' '(' FORMULA* ')' <And> <formula> FORMULA </formula>* </And> Or ::= Core 'Or' '(' FORMULA* ')' <Or> <formula> FORMULA </formula>* </Or> NmNot ::= BLD Undefined PRD 'Not' '(' FORMULA ')' <NmNot> <formula> FORMULA </formula> </NmNot> Exists ::= Core 'Exists' Var+ '(' FORMULA ')' <Exists> <declare> Var </declare>+ <formula> FORMULA </formula> </Exists> ACTION ::= BLD Undefined PRD [ ASSERT | Retract ] ASSERT ::= BLD Undefined PRD [ Atom | Frame ] Retract ::= BLD Undefined PRD 'Retract' '(' Atom | Frame ' ) ' <Retract> <target> [ Atom | Frame ] </target> </Retract> RULE ::= BLD [ Forall | Implies | ATOMIC ] PRD [ Forall | Implies | ACTION ] Forall ::= BLD ' Forall ' Var+ ' ( ' [Implies | ATOMIC] ' ) ' <Forall> <declare> Var </declare>+ <formula> [Implies | ATOMIC ] </formula> </Forall> PRD ' Forall ' Var+ (' ( ' FORMULA ' ) ')* ' ( ' RULE ' ) ' <Forall> <declare> Var </declare>+ <pattern> FORMULA </pattern>* <formula> RULE </formula> </Forall> Implies ::= BLD (ATOMIC | 'And' '(' ATOMIC* ')') ':-' FORMULA <Implies> <if> FORMULA </if> <then> [ ATOMIC | <And> <formula> ATOMIC </formula>* </And> ] </then> </Implies> PRD (ACTION | 'Do' '(' ACTION* ')') ':-' FORMULA <Implies> <if> FORMULA </if> <then> ACTION ACTION * </then> </Implies> Group ::= Core METADATA? 'Group' '(' ([RULE | Group])* ')' <Group> <sentence> [ RULE | Group ] </sentence>* </Group> Import ::= BLD 'Import' '(' IRI Profile? ')' <Import> <location> lAny Unicode string </location> <profile><Profile> Any Unicode String 1 </Profile></profile> </Import> PRD Undefined in this version of the draft Document ::= BLD METADATA? 'Document' '(' [Import | Prefix | Base]* Group? ')' <Document> <directive> [ Import | Prefix | Base ]* </directive> <payload> Group </payload>? </Document> PRD METADATA? 'Document' '(' Group? ')' <Document> <payload> Group </payload>? </Document> METADATA ::= Core '(*' Const? (Frame | 'And' '(' Frame* ')')? '*)' <AnyClassTag> <id> Const </declare>? <meta> [ Frame | <And> <formula> Frame </formula> </And> ] </meta>? other content of AnyClassTag </AnyClassTag> 7.29.2 Semantic compatibility between RIF-PRD and RIF-BLD

The intended semantics of any RIF XML document which is both a syntactically valid RIF-PRD document and a syntactically valid RIF-BLD document is the same whether it is considered a RIF-PRD or a RIF-BLD document. For any input set of facts, the set of rules contained in the document must produce the same output set of facts whether it is consumed as a RIF-PRD or a RIF-BLD document.

Proof. TBC