Copyright © 2008 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability, trademark and document use rules apply.
This document, developed by the Rule Interchange Format (RIF) Working Group, specifies RIF-Core, a common subset of RIF-BLD and RIF-PRD based on RIF-DTB 1.0. The RIF-Core presentation syntax and semantics are specified. The XML serialization syntax of RIF-BLD is specified via a mapping from the presentation syntax. A normative XML schema is also provided.
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 8 documents:
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.
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.
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.
This specification develops RIF-Core (the Core of the Rule Interchange Format). From a theoretical perspective, RIF-Core corresponds to the language of definite Horn rules without function symbols ('Datalog') and a standard first-order semantics. RIF-Core thus is a subset of RIF-BLD [#***]. At the same time, RIF-Core is a language of production rules permitting only assert actions. RIF-Core thus also is a subset of RIF-PRD [#***]. Moreover, RIF-Core is based on the built-ins of RIF-DTB 1.0 [#***]. The common subset of RIF-BLD and RIF-PRD is specified based on RIF-DTB 1.0.
Syntactically, RIF-Core has a number of Datalog extensions to support features such as objects and frames as in F-logic [KLW95], internationalized resource identifiers (or IRIs, defined by [RFC-3987]) as identifiers for concepts, and XML Schema datatypes [XML-SCHEMA2]. In addition, RIF RDF and OWL Compatibility [RIF-RDF+OWL] defines the syntax and semantics of integrated RIF-Core/RDF and RIF-Core/OWL languages. These features make RIF-Core a Web-aware language. However, it should be kept in mind that RIF is designed to enable interoperability among rule languages in general, and its uses are not limited to the Web.
RIF-Core is defined in two different ways -- both normative:
To give a preview, here is a simple complete RIF-Core example deriving a ternary relation from its inverse.
Example 1 (An introductory RIF-Core example).
A rule can be written in English to derive the buy relationships (rather than store them) from the sell relationships that are stored as facts (e.g., as exemplified by the English statement below):
The fact Mary buys LeRif from John can be logically derived by a modus ponens argument. Assuming Web IRIs for the predicates buy and sell, as well as for the individuals John, Mary, and LeRif, the above English text can be represented in RIF-Core Presentation Syntax as follows.
Document( Prefix(cpt http://example.com/concepts#) Prefix(ppl http://example.com/people#) Prefix(bks http://example.com/books#) Group ( Forall?Buyer?Item?Seller ( cpt:buy(?Buyer?Item?Seller):- cpt:sell(?Seller?Item?Buyer) ) cpt:sell(ppl:John bks:LeRif ppl:Mary) ) )
For the interchange of such rule (and fact) documents, an equivalent RIF-Core XML Syntax is given in this specification. To formalize their meaning, a RIF-Core Semantics is specified.
Until now, we have used mathematical English to specify the syntax of RIF-Core. Tool developers, however, may prefer EBNF notation, which provides a more succinct overview of the syntax. Several points should be kept in mind regarding this notation.
The Condition Language represents formulas that can be used in the premises of RIF-Core rules (also called rule bodies). The EBNF grammar for a superset of the RIF-Core condition language is as follows.
Editor's Note: Stylistic comment only. Please could we just have one section for the combined condition and rule language and just talk about the rule language? The value of separating out the condition language for reuse seems to primarily apply to FLD. Separating condition/rule syntax makes it harder to read and duplicating the condition part after the rule part is not entirely satisfying. Dave
FORMULA ::= IRIMETA? 'And' '(' FORMULA* ')' | IRIMETA? 'Or' '(' FORMULA* ')' | IRIMETA? 'Exists' Var+ '(' FORMULA ')' | ATOMIC | IRIMETA? 'External' '(' Atom | Frame ')' ATOMIC ::= IRIMETA? (Atom | Member | Subclass | Frame) Atom ::= UNITERM UNITERM ::= Const '(' (TERM* | (Name '->' TERM)*) ')' Member ::= TERM '#' TERM Subclass ::= TERM '##' TERM Frame ::= TERM '[' (TERM '->' TERM)* ']' TERM ::= IRIMETA? (Const | Var) Const ::= '"' UNICODESTRING '"^^' SYMSPACE | CONSTSHORT Name ::= UNICODESTRING Var ::= '?' UNICODESTRING SYMSPACE ::= ANGLEBRACKIRI | CURIE IRIMETA ::= '(*' IRICONST? (Frame | 'And' '(' Frame* ')')? '*)'
Editor's Note: There was concern over disjunction and NAU, weaker concern over member and subclass. So a conservative version is as below. I realize you did qualify the ENBF as a superset. Dave:
FORMULA ::= IRIMETA? 'And' '(' FORMULA* ')' | IRIMETA? 'Exists' Var+ '(' FORMULA ')' | ATOMIC | IRIMETA? 'External' '(' Atom ')' ATOMIC ::= IRIMETA? (Atom | Frame) Atom ::= UNITERM UNITERM ::= Const '(' (TERM* ')' Frame ::= TERM '[' (TERM '->' TERM)* ']' TERM ::= IRIMETA? (Const | Var) Const ::= '"' UNICODESTRING '"^^' SYMSPACE | CONSTSHORT Name ::= UNICODESTRING Var ::= '?' UNICODESTRING SYMSPACE ::= ANGLEBRACKIRI | CURIE IRIMETA ::= '(*' IRICONST? (Frame | 'And' '(' Frame* ')')? '*)'
The production rule for the non-terminal FORMULA represents RIF condition formulas (defined earlier). The connectives And and Or define conjunctions and disjunctions of conditions, respectively. Exists introduces existentially quantified variables. Here Var+ stands for the list of variables that are free in FORMULA. RIF-Core conditions permit only existential variables. A RIF-Core FORMULA can also be an ATOMIC term, i.e. an Atom, External Atom, Equal, Member, Subclass, or Frame. A TERM can be a constant or variable.
The RIF-Core presentation syntax does not commit to any particular vocabulary and permits arbitrary Unicode strings in constant symbols, argument names, and variables. Constant symbols can have this form: "UNICODESTRING"^^SYMSPACE, where SYMSPACE is a ANGLEBRACKIRI or CURIE that represents the identifier of the symbol space of the constant, and UNICODESTRING is a Unicode string from the lexical space of that symbol space. ANGLEBRACKIRI and CURIE are defined in Section Shortcuts for Constants in RIF's Presentation Syntax of [RIF-DTB]. Constant symbols can also have several shortcut forms, which are represented by the non-terminal CONSTSHORT. These shortcuts are also defined in the same section of [RIF-DTB]. One of them is the CURIE shortcut, which is extensively used in the examples in this document. Names are Unicode character sequences. Variables are composed of UNICODESTRING symbols prefixed with a ?-sign.
Membership and subclass terms are self-explanatory. An Atom can either be positional or with named arguments. A frame term is a term composed of an object Id and a collection of attribute-value pairs. An External(Atom) is a call to an externally defined predicate; External(Frame) is a call to an externally defined frame.
As explained in Section #***, RIF-Core formulas and terms can be prefixed with optional annotations, IRIMETA, for identification and metadata. IRIMETA is represented using (*...*)-brackets that contain an optional IRI constant, IRICONST, as identifier followed by an optional Frame or conjunction of Frames as metadata. An IRICONST is the special case of a Const with the symbol space rif:iri, again permitting the shortcut forms defined in [RIF-DTB]. One such specialization is '"' IRI '"^^' 'rif:iri' from the Const production, where IRI is a sequence of Unicode characters that forms an internationalized resource identifier as defined by [RFC-3987].
Example 2 (RIF-Core conditions).
This example shows conditions that are composed of atoms, expressions, frames, and existentials. In frame formulas variables are shown in the positions of object Ids, object properties, and property values. For brevity, we use the CURIE shortcut notation prefix:suffix for constant symbols, which is understood as a macro that expands into an IRI obtained by concatenation of the prefix definition and suffix. Thus, if bks is a prefix that expands into http://example.com/books# then bks:LeRif is an abbreviation for "http://example.com/books#LeRif"^^rif:iri. This and other shortcuts are defined in [RIF-DTB]. Assume that the following prefix directives appear in the preamble to the document:
Prefix(bks http://example.com/books#) Prefix(auth http://example.com/authors#) Prefix(cpt http://example.com/concepts#)
Positional terms: cpt:book(auth:rifwg bks:LeRif) Exists?X (cpt:book(?X bks:LeRif)) Terms with named arguments: cpt:book(cpt:author->auth:rifwg cpt:title->bks:LeRif) Exists?X (cpt:book(cpt:author->?X cpt:title->bks:LeRif)) Frames: bks:wd1[cpt:author->auth:rifwg cpt:title->bks:LeRif] Exists?X (bks:wd2[cpt:author->?X cpt:title->bks:LeRif]) Exists?X (And (bks:wd2#cpt:book bks:wd2[cpt:author->?X cpt:title->bks:LeRif])) Exists?I?X (?I[cpt:author->?X cpt:title->bks:LeRif]) Exists?I?X (And (?I#cpt:book?I[cpt:author->?X cpt:title->bks:LeRif])) Exists?S (bks:wd2[cpt:author->auth:rifwg?S->bks:LeRif]) Exists?X?S (bks:wd2[cpt:author->?X?S->bks:LeRif]) Exists?I?X?S (And (?I#cpt:book ?I[author->?X?S->bks:LeRif]))
The presentation syntax for RIF-Core rules extends the syntax in Section EBNF for RIF-Core Condition Language with the following productions.
Document ::= IRIMETA? 'Document' '(' Base? Prefix* Import* Group? ')' Base ::= 'Base' '(' IRI ')' Prefix ::= 'Prefix' '(' Name IRI ')' Import ::= IRIMETA? 'Import' '(' IRICONST PROFILE? ')' Group ::= IRIMETA? 'Group' '(' (RULE | Group)* ')' RULE ::= (IRIMETA? 'Forall' Var+ '(' CLAUSE ')') | CLAUSE CLAUSE ::= Implies | ATOMIC Implies ::= IRIMETA? (ATOMIC | 'And' '(' ATOMIC* ')') ':-' FORMULA PROFILE ::= TERM
Editor's Note: PRD only permits Atom and Frame in the head so if member/subclass are retained in ATOMIC this needs modification. PRD/BLD syntactic intersection currently only works for one ASSERT in head, not with And. So PRD compatible version seems be as below. Dave
Document ::= IRIMETA? 'Document' '(' Base? Prefix* Import* Group? ')' Base ::= 'Base' '(' IRI ')' Prefix ::= 'Prefix' '(' Name IRI ')' Import ::= IRIMETA? 'Import' '(' IRICONST PROFILE? ')' Group ::= IRIMETA? 'Group' '(' (RULE | Group)* ')' RULE ::= (IRIMETA? 'Forall' Var+ '(' CLAUSE ')') | CLAUSE CLAUSE ::= Implies | ATOMIC Implies ::= IRIMETA? (Atom | Frame ) ':-' FORMULA PROFILE ::= TERM
Recall that an IRI has the form of an internationalized resource identifier as defined by [RFC-3987].
A RIF-Core Document consists of an optional Base, followed by any number of Prefixes, followed by any number of Imports, followed by an optional Group. Base and Prefix serve as shortcut mechanisms for IRIs. An Import indicates the location of a document to be imported and an optional profile. A RIF-Core Group is a collection of any number of RULE elements along with any number of nested Groups.
Rules are generated using CLAUSE elements. The RULE production has two alternatives:
Frame, Var, ATOMIC, and FORMULA were defined as part of the syntax for positive conditions in Section EBNF for RIF-Core Condition Language. In the CLAUSE production, an ATOMIC is what is usually called a fact. An Implies rule can have an ATOMIC or a conjunction of ATOMIC elements as its conclusion; it has a FORMULA as its premise. Note that, by a definition in Section Formulas, formulas that query externally defined atoms (i.e., formulas of the form External(Atom(...))) are not allowed in the conclusion part of a rule (ATOMIC does not expand to External).
Example 3 (RIF-Core rules).
This example shows a business rule borrowed from the document RIF Use Cases and Requirements:
As before, for better readability we use the compact URI notation defined in [RIF-DTB], Section Constants and Symbol Spaces. Again, prefix directives are assumed in the preamble to the document. Then, two versions of the main part of the document are given.
Prefix(ppl http://example.com/people#) Prefix(cpt http://example.com/concepts#) Prefix(func http://www.w3.org/2007/rif-builtin-function#) Prefix(pred http://www.w3.org/2007/rif-builtin-predicate#) a. Universal form: Forall?item?deliverydate?scheduledate?diffduration?diffdays ( cpt:reject(ppl:John?item):- And(cpt:perishable(?item) cpt:delivered(?item?deliverydate ppl:John) cpt:scheduled(?item?scheduledate) ***replace with equality-less version***?diffduration = External(func:subtract-dateTimes(?deliverydate?scheduledate)) ***replace with equality-less version***?diffdays = External(func:days-from-duration(?diffduration)) External(pred:numeric-greater-than(?diffdays 10))) ) b. Universal-existential form: Forall?item ( cpt:reject(ppl:John?item ):- Exists?deliverydate?scheduledate?diffduration?diffdays ( And(cpt:perishable(?item) cpt:delivered(?item?deliverydate ppl:John) cpt:scheduled(?item?scheduledate) ***replace with equality-less version***?diffduration = External(func:subtract-dateTimes(?deliverydate?scheduledate)) ***replace with equality-less version***?diffdays = External(func:days-from-duration(?diffduration)) External(pred:numeric-greater-than(?diffdays 10))) ) )
Example 4 (A RIF-Core document containing an annotated group).
This example shows a complete document containing a group formula that consists of two RIF-Core rules. The first of these rules is copied from Example 3a. The group is annotated with an IRI identifier and frame-represented Dublin Core metadata.
Document( Prefix(ppl http://example.com/people#) Prefix(cpt http://example.com/concepts#) Prefix(dc http://purl.org/dc/terms/) Prefix(func http://www.w3.org/2007/rif-builtin-function#) Prefix(pred http://www.w3.org/2007/rif-builtin-predicate#) Prefix(xs http://www.w3.org/2001/XMLSchema#) (* "http://sample.org"^^rif:iri pd[dc:publisher -> http://www.w3.org/ dc:date -> "2008-04-04"^^xs:date] *) Group ( Forall?item?deliverydate?scheduledate?diffduration?diffdays ( cpt:reject(ppl:John?item):- And(cpt:perishable(?item) cpt:delivered(?item?deliverydate ppl:John) cpt:scheduled(?item?scheduledate) ***replace with equality-less version***?diffduration = External(func:subtract-dateTimes(?deliverydate?scheduledate)) ***replace with equality-less version***?diffdays = External(func:days-from-duration(?diffduration)) External(pred:numeric-greater-than(?diffdays 10))) ) Forall?item ( cpt:reject(ppl:Fred?item):- cpt:unsolicited(?item) ) ) )
The RIF-Core XML serialization defines
Recall that the syntax of RIF-Core is not context-free and thus cannot be fully captured by EBNF or XML Schema. Still, validity with respect to XML Schema can be a useful test. To reflect this state of affairs, we define two notions of syntactic correctness. The weaker notion checks correctness only with respect to XML Schema, while the stricter notion represents "true" syntactic correctness.
Definition (Valid Core document in XML syntax). A valid Core document in the XML syntax is an XML document that is valid with respect to the XML schema in Appendix XML Schema for Core. ☐
Definition (Conformant Core document in XML syntax). A conformant Core document in the XML syntax is a valid Core document in the XML syntax that is the image of a well-formed RIF-Core document in the presentation syntax (see Definition Well-formed formula in Section Formulas) under the presentation-to-XML syntax mapping core defined in Section Mapping from the Presentation Syntax to the XML Syntax. ☐
The XML serialization for RIF-Core is alternating or fully striped [ANF01]. A fully striped serialization views XML documents as objects and divides all XML tags into class descriptors, called type tags, and property descriptors, called role tags [TRT03]. We follow the tradition of using capitalized names for type tags and lowercase names for role tags.
The all-uppercase classes in the presentation syntax, such as FORMULA, become XML Schema groups in Appendix XML Schema for Core. They act like macros and are not visible in instance markup. The other classes as well as non-terminals and symbols (such as Exists or =) become XML elements with optional attributes, as shown below.
RIF-Core uses [XML1.0] for its XML syntax.
XML serialization of RIF-Core in Section EBNF for RIF-Core Condition Language uses the following elements.
- And (conjunction) - Or (disjunction) - Exists (quantified formula for 'Exists', containing declare and formula roles) - declare (declare role, containing a Var) - formula (formula role, containing a FORMULA) - Atom (atom formula, positional or with named arguments) - External (external call, containing a content role) - content (content role, containing an Atom) - Member (member formula) - Subclass (subclass formula) - Frame (Frame formula) - object (Member/Frame role, containing a TERM or an object description) - op (Atom role for predicates/functions as operations) - args (Atom positional arguments role, with fixed 'ordered' attribute, containing n TERMs) - instance (Member instance role) - class (Member class role) - sub (Subclass sub-class role) - super (Subclass super-class role) - slot (Atom or Frame slot role, with fixed 'ordered' attribute, containing a Name or TERM followed by a TERM) - Const (individual, function, or predicate symbol, with optional 'type' attribute) - Name (name of named argument) - Var (logic variable) - id (identifier role, containing IRICONST) - meta (meta role, containing metadata as a Frame or Frame conjunction)
The id and meta elements, which are expansions of the IRIMETA element, can occur optionally as the initial children of any Class element.
For the XML Schema definition of the RIF-Core condition language see Appendix XML Schema for Core.
The XML syntax for symbol spaces uses the type attribute associated with the XML element Const. For instance, a literal in the xs:dateTime datatype is represented as <Consttype="&xs;dateTime">2007-11-23T03:55:44-02:30</Const>. RIF-Core also uses the ordered attribute to indicate that the children of args and slot elements are ordered.
Example 5 (A RIF condition and its XML serialization).
This example illustrates XML serialization for RIF conditions. As before, the compact URI notation is used for better readability. Assume that the following prefix directives are found in the preamble to the document:
Prefix(bks http://example.com/books#) Prefix(cpt http://example.com/concepts#) Prefix(curr http://example.com/currencies#) Prefix(rif http://www.w3.org/2007/rif#) Prefix(xs http://www.w3.org/2001/XMLSchema#)
RIF condition And (Exists?Buyer (cpt:purchase(?Buyer ?Seller cpt:book ?Author bks:LeRif curr:USD 49)) pred:string-equal(?Seller?Author) ) *** ED Note in DTB 4.5.1.1. Add pred Prefix. Or: Replace?Seller with?Author *** XML serialization *** TBD as in PS *** <And> <formula> <Exists> <declare><Var>Buyer</Var></declare> <formula> <Atom> <op><Const type="&rif;iri">&cpt;purchase</Const></op> <args ordered="yes"> <Var>Buyer</Var> <Var>Seller</Var> <Expr> <op><Const type="&rif;iri">&cpt;book</Const></op> <args ordered="yes"> <Var>Author</Var> <Const type="&rif;iri">&bks;LeRif</Const> </args> </Expr> <Expr> <op><Const type="&rif;iri">&curr;USD</Const></op> <args ordered="yes"><Const type="&xs;integer">49</Const></args> </Expr> </args> </Atom> </formula> </Exists> </formula> <formula> <Equal> <left><Var>Seller</Var></left> <right><Var>Author</Var></right> </Equal> </formula> </And>
Example 6 *** TBD ***
We now extend the set of RIF-Core serialization elements from Section XML for RIF-Core Condition Language by including rules, along with their enclosing groups and documents, as described in Section EBNF for RIF-Core Rule Language. The extended set includes the tags listed below. While there is a RIF-Core element tag for the Import directive, there are none for the Prefix and Base directives: they are handled as discussed in Section Mapping of the RIF-Core Rule Language.
- Document (document, containing optional directive and payload roles) - directive (directive role, containing Import) - payload (payload role, containing Group) - Import (importation, containing location and optional profile) - location (location role, containing IRICONST) - profile (profile role, containing PROFILE) - Group (nested collection of sentences) - sentence (sentence role, containing RULE or Group) - Forall (quantified formula for 'Forall', containing declare and formula roles) - Implies (implication, containing if and then roles) - if (antecedent role, containing FORMULA) - then (consequent role, containing ATOMIC or conjunction of ATOMICs)
The XML Schema Definition of RIF-Core is given in Appendix XML Schema for Core.
Example 7 (Serializing a RIF-Core document containing an annotated group).
This example shows a serialization for the document from Example 4. For convenience, the document is reproduced at the top and then is followed by its serialization.
Presentation syntax: Document( Prefix(ppl http://example.com/people#) Prefix(cpt http://example.com/concepts#) Prefix(dc http://purl.org/dc/terms/) Prefix(func http://www.w3.org/2007/rif-builtin-function#) Prefix(pred http://www.w3.org/2007/rif-builtin-predicate#) Prefix(xs http://www.w3.org/2001/XMLSchema#) (* "http://sample.org"^^rif:iri pd[dc:publisher -> http://www.w3.org/ dc:date -> "2008-04-04"^^xs:date] *) Group ( Forall?item?deliverydate?scheduledate?diffduration?diffdays ( cpt:reject(ppl:John?item):- And(cpt:perishable(?item) cpt:delivered(?item?deliverydate ppl:John) cpt:scheduled(?item?scheduledate) ***replace with equality-less version***?diffduration = External(func:subtract-dateTimes(?deliverydate?scheduledate)) ***replace with equality-less version***?diffdays = External(func:days-from-duration(?diffduration)) External(pred:numeric-greater-than(?diffdays 10))) ) Forall?item ( cpt:reject(ppl:Fred?item):- cpt:unsolicited(?item) ) ) ) XML syntax: *** TBD as in PS *** <!DOCTYPE Document [ <!ENTITY ppl "http://example.com/people#"> <!ENTITY cpt "http://example.com/concepts#"> <!ENTITY dc "http://purl.org/dc/terms/"> <!ENTITY rif "http://www.w3.org/2007/rif#"> ***???***<!ENTITY func "http://www.w3.org/2007/rif-builtin-function#"> <!ENTITY pred "http://www.w3.org/2007/rif-builtin-predicate#"> <!ENTITY xs "http://www.w3.org/2001/XMLSchema#"> ]> <Document xmlns="http://www.w3.org/2007/rif#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema#"> <payload> <Group> <id> <Const type="&rif;iri">http://sample.org</Const> </id> <meta> <Frame> <object> <Const type="&rif;local">pd</Const> </object> <slot ordered="yes"> <Const type="&rif;iri">&dc;publisher</Const> <Const type="&rif;iri">http://www.w3.org/</Const> </slot> <slot ordered="yes"> <Const type="&rif;iri">&dc;date</Const> <Const type="&xs;date">2008-04-04</Const> </slot> </Frame> </meta> <sentence> <Forall> <declare><Var>item</Var></declare> <declare><Var>deliverydate</Var></declare> <declare><Var>scheduledate</Var></declare> <declare><Var>diffduration</Var></declare> <declare><Var>diffdays</Var></declare> <formula> <Implies> <if> <And> <formula> <Atom> <op><Const type="&rif;iri">&cpt;perishable</Const></op> <args ordered="yes"><Var>item</Var></args> </Atom> </formula> <formula> <Atom> <op><Const type="&rif;iri">&cpt;delivered</Const></op> <args ordered="yes"> <Var>item</Var> <Var>deliverydate</Var> <Const type="&rif;iri">&ppl;John</Const> </args> </Atom> </formula> <formula> <Atom> <op><Const type="&rif;iri">&cpt;scheduled</Const></op> <args ordered="yes"> <Var>item</Var> <Var>scheduledate</Var> </args> </Atom> </formula> <formula> <Equal> <left><Var>diffduration</Var></left> <right> <External> <content> <Expr> <op><Const type="&rif;iri">&func;subtract-dateTimes</Const></op> <args ordered="yes"> <Var>deliverydate</Var> <Var>scheduledate</Var> </args> </Expr> </content> </External> </right> </Equal> </formula> <formula> <Equal> <left><Var>diffdays</Var></left> <right> <External> <content> <Expr> <op><Const type="&rif;iri">&func;days-from-duration</Const></op> <args ordered="yes"> <Var>diffduration</Var> </args> </Expr> </content> </External> </right> </Equal> </formula> <formula> <External> <content> <Atom> <op><Const type="&rif;iri">&pred;numeric-greater-than</Const></op> <args ordered="yes"> <Var>diffdays</Var> <Const type="&xs;integer">10</Const> </args> </Atom> </content> </External> </formula> </And> </if> <then> <Atom> <op><Const type="&rif;iri">&cpt;reject</Const></op> <args ordered="yes"> <Const type="&rif;iri">&ppl;John</Const> <Var>item</Var> </args> </Atom> </then> </Implies> </formula> </Forall> </sentence> <sentence> <Forall> <declare><Var>item</Var></declare> <formula> <Implies> <if> <Atom> <op><Const type="&rif;iri">&cpt;unsolicited</Const></op> <args ordered="yes"><Var>item</Var></args> </Atom> </if> <then> <Atom> <op><Const type="&rif;iri">&cpt;reject</Const></op> <args ordered="yes"> <Const type="&rif;iri">&ppl;Fred</Const> <Var>item</Var> </args> </Atom> </then> </Implies> </formula> </Forall> </sentence> </Group> </payload> </Document>
This section defines a normative mapping, core, from the presentation syntax to the XML syntax of RIF-Core. The mapping is given via tables where each row specifies the mapping of a particular syntactic pattern in the presentation syntax. These patterns appear in the first column of the tables and the bold-italic symbols represent metavariables. The second column represents the corresponding XML patterns, which may contain applications of the mapping core to these metavariables. When an expression core(metavar) occurs in an XML pattern in the right column of a translation table, it should be understood as a recursive application of core to the presentation syntax represented by the metavariable. The XML syntax result of such an application is substituted for the expression core(metavar). A sequence of terms containing metavariables with subscripts is indicated by an ellipsis. A metavariable or a well-formed XML subelement is marked as optional by appending a bold-italic question mark, ?, on its right.
The core mapping from the presentation syntax to the XML syntax of the RIF-Core Condition Language is specified by the table below. Each row indicates a translation core(Presentation) = XML. Since the presentation syntax of RIF-Core is context sensitive, the mapping must differentiate between the terms that occur in the position of the individuals and the terms that occur as atomic formulas. To this end, in the translation table, the positional and named argument terms that occur in the context of atomic formulas are denoted by the expressions of the form pred(...) and the terms that occur as individuals are denoted by expressions of the form func(...). In the table, each metavariable for an (unnamed) positional argumenti is assumed to be instantiated to values unequal to the instantiations of named arguments unicodestringj -> fillerj. Regarding the last but first row, we assume that shortcuts for constants [RIF-DTB] have already been expanded to their full form ("..."^^symspace).
Presentation Syntax | XML Syntax |
---|---|
And ( conjunct1 . . . conjunctn ) |
<And> <formula>core(conjunct1)</formula> . . . <formula>core(conjunctn)</formula> </And> |
Or ( disjunct1 . . . disjunctn ) |
<Or> <formula>core(disjunct1)</formula> . . . <formula>core(disjunctn)</formula> </Or> |
Exists variable1 . . . variablen ( body ) |
<Exists> <declare>core(variable1)</declare> . . . <declare>core(variablen)</declare> <formula>core(body)</formula> </Exists> |
External ( atomframexpr ) |
<External> <content>core(atomframexpr)</content> </External> |
pred ( argument1 . . . argumentn ) |
<Atom> <op>core(pred)</op> <args ordered="yes"> core(argument1) . . . core(argumentn) </args> </Atom> |
pred ( unicodestring1 -> filler1 . . . unicodestringn -> fillern ) |
<Atom> <op>core(pred)</op> <slot ordered="yes"> <Name>unicodestring1</Name> core(filler1) </slot> . . . <slot ordered="yes"> <Name>unicodestringn</Name> core(fillern) </slot> </Atom> |
inst [ key1 -> filler1 . . . keyn -> fillern ] |
<Frame> <object>core(inst)</object> <slot ordered="yes"> core(key1) core(filler1) </slot> . . . <slot ordered="yes"> core(keyn) core(fillern) </slot> </Frame> |
inst # class |
<Member> <instance>core(inst)</instance> <class>core(class)</class> </Member> |
sub ## super |
<Subclass> <sub>core(sub)</sub> <super>core(super)</super> </Subclass> |
"unicodestring"^^symspace |
<Const type="symspace">unicodestring</Const> |
?unicodestring |
<Var>unicodestring</Var> |
The core mapping from the presentation syntax to the XML syntax of the RIF-Core Rule Language is specified by the table below. It extends the translation table of Section Translation of RIF-Core Condition Language. While the Import directive is handled by the presentation-to-XML syntax mapping, the Prefix and Base directives are not. Instead, these directives should be handled by macro-expanding the associated shortcuts (compact URIs). Namely, a prefix name declared in a Prefix directive is expanded into the associated IRI, while relative IRIs are completed using the IRI declared in the Base directive. The mapping core applies only to such macro-expanded documents. RIF-Core also allows other treatments of Prefix and Base provided that they produce equivalent XML documents. One such treatment is employed in the examples in this document, especially Example 7. It replaces prefix names with definitions of XML entities as follows. Each Prefix declaration becomes an ENTITY declaration [XML1.0] within a DOCTYPE DTD attached to the RIF-Core Document. The Base directive is mapped to the xml:base attribute [XML-Base] in the XML Document tag. Compact URIs of the form prefix:suffix are then mapped to &prefix;suffix.
Presentation Syntax | XML Syntax |
---|---|
Document( Import(loc1 prfl1?) . . . Import(locn prfln?) group ) |
<Document> <directive> <Import> <location>core(loc1)</location> <profile>core(prfl1)</profile>? </Import> </directive> . . . <directive> <Import> <location>core(locn)</location> <profile>core(prfln)</profile>? </Import> </directive> <payload>core(group)</payload> </Document> |
Group( clause1 . . . clausen ) |
<Group> <sentence>core(clause1)</sentence> . . . <sentence>core(clausen)</sentence> </Group> |
Forall variable1 . . . variablen ( rule ) |
<Forall> <declare>core(variable1)</declare> . . . <declare>core(variablen)</declare> <formula>core(rule)</formula> </Forall> |
conclusion:- condition |
<Implies> <if>core(condition)</if> <then>core(conclusion)</then> </Implies> |
The core mapping from RIF-Core annotations in the presentation syntax to the XML syntax is specified by the table below. It extends the translation tables of Sections Translation of RIF-Core Condition Language and Translation of RIF-Core Rule Language. The metavariable Typetag in the presentation and XML syntaxes stands for any of the class names And, Or, External, Document, or Group, and Quantifier for Exists or Forall. The dollar sign, $, stands for any of the binary infix operator names #, ##, =, or :-, while Binop stands for their respective class names Member, Subclass, Equal, or Implies. Again, each metavariable for an (unnamed) positional argumenti is assumed to be instantiated to values unequal to the instantiations of named arguments unicodestringj -> fillerj.
Presentation Syntax | XML Syntax |
---|---|
(* iriconst? frameconj? *) Typetag ( e1 . . . en ) |
<Typetag> <id>core(iriconst)</id>? <meta>core(frameconj)</meta>? e1' . . . en' </Typetag> where e1', . . ., en' are defined by the equation core(Typetag(e1 . . . en)) = <Typetag>e1' . . . en'</Typetag> |
(* iriconst? frameconj? *) Quantifier variable1 . . . variablen ( body ) |
<Quantifier> <id>core(iriconst)</id>? <meta>core(frameconj)</meta>? <declare>core(variable1)</declare> . . . <declare>core(variablen)</declare> <formula>core(body)</formula> </Quantifier> |
(* iriconst? frameconj? *) pred ( argument1 . . . argumentn ) |
<Atom> <id>core(iriconst)</id>? <meta>core(frameconj)</meta>? <op>core(pred)</op> <args ordered="yes"> core(argument1) . . . core(argumentn) </args> </Atom> |
(* iriconst? frameconj? *) pred ( unicodestring1 -> filler1 . . . unicodestringn -> fillern ) |
<Atom> <id>core(iriconst)</id>? <meta>core(frameconj)</meta>? <op>core(pred)</op> <slot ordered="yes"> <Name>unicodestring1</Name> core(filler1) </slot> . . . <slot ordered="yes"> <Name>unicodestringn</Name> core(fillern) </slot> </Atom> |
(* iriconst? frameconj? *) inst [ key1 -> filler1 . . . keyn -> fillern ] |
<Frame> <id>core(iriconst)</id>? <meta>core(frameconj)</meta>? <object>core(inst)</object> <slot ordered="yes"> core(key1) core(filler1) </slot> . . . <slot ordered="yes"> core(keyn) core(fillern) </slot> </Frame> |
(* iriconst? frameconj? *) e1 $ e2 |
<Binop> <id>core(iriconst)</id>? <meta>core(frameconj)</meta>? e1' e2' </Binop> where Binop, e1', e2' are defined by the equation core(e1 $ e2) = <Binop>e1' e2'</Binop> |
(* iriconst? frameconj? *) unicodestring^^symspace |
<Const type="symspace"> <id>core(iriconst)</id>? <meta>core(frameconj)</meta>? unicodestring </Const> |
(* iriconst? frameconj? *) ?unicodestring |
<Var> <id>core(iriconst)</id>? <meta>core(frameconj)</meta>? unicodestring </Var> |
RIF-Core does not require or expect conformant systems to implement the RIF-Core presentation syntax. Instead, conformance is described in terms of semantics-preserving transformations.
Let be a set of datatypes that includes the datatypes specified in [RIF-DTB], and suppose is a set of external predicates and functions that includes the built-ins listed in [RIF-DTB]. We say that a formula is a Core, formula iff
A RIF processor is a conformant Core, consumer iff it implements a semantics-preserving mapping, , from the set of all Core, formulas to the language L of the processor.
Formally, this means that for any pair , of Core, formulas for which |=Core is defined, |=Core iff () |=L (). Here |=Core denotes the logical entailment in RIF-Core and |=L is the logical entailment in the language L of the RIF processor.
A RIF processor is a conformant Core, producer iff it implements a semantics-preserving mapping, , from a subset of the language L of the processor to a set of Core, formulas.
Formally, this means that for any pair , of formulas in the aforesaid subset of L for which |=L is defined, |=L iff () |=Core ().
A conformant document is one which conforms to all the syntactic constraints of RIF-Core, including ones that cannot be checked by an XML Schema validator (cf. Definition Conformant Core document in XML syntax).
A round-tripping of a conformant Core document is its semantics-preserving mapping to a document in any language L followed by a semantics-preserving mapping from the L document back to a conformant Coredocument. While semantically equivalent, the original and the round-tripped Core documents need not be identical. Metadata should survive Core round-tripping.
The above definitions are specializations to Core of the general conformance clauses defined in the RIF framework for logic dialects [RIF-FLD]. The following clauses are further restrictions that are specific to RIF-Core.
RIF-Core specific clauses
Feature At Risk #3: Strictness Requirement
Note: This feature is "at risk" and may be removed from this specification based on feedback. Please send feedback to public-rif-comments@w3.org.
The two preceding clauses are features AT RISK. In particular, the "strictness" requirement is under discussion.
This normative section describes RIF-Core by specializing RIF-BLD. The reader is assumed to be familiar with RIF-BLD as described in [#***]. The reader who is not interested in how RIF-Core is derived from BLD can skip this section.
The following specifies RIF-Core by removing certain syntactic constructs from RIF-BLD and by corresponding restrictions on the semantics (hence, by further specializing RIF-BLD, which itself specializes RIF-FLD).
The syntactic structure of RIF-BLD permits its specialization to the following RIF-Core dialect, obtained from RIF-BLD by removing support for:
Editor's Note: The related qualifications in parentheses are under discussion. The alternative is built-in predicate calls. See the annotations in the table of the section on "Intersection of RIF-PRD and RIF-BLD".
This normative section describes RIF-Core by specializing RIF-PRD . The reader is assumed to be familiar with RIF-PRD as described in [#***]. The reader who is not interested in how RIF-Core is derived from PRD can skip this section.
RIF-PRD and RIF-BLD share essentially the same presentation syntax and XML syntax.
The differences between the two dialects are summarized below:
For context, the table below lists the constructs which are in the maximal common subset (intersection) of BLD and PRD, marks certain rows as not being in Core, or annotates them w.r.t. restrictions making them part of Core.
Presentation syntax | XML syntax | |
---|---|---|
TERM::= | ||
Core |
[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> |
External (as TERM)::= | Remark: only used for external built-in calls; no logical functions | |
Core |
'External' '(' Expr ')' |
<External> <content> Expr </content> </External> |
ATOMIC::= | Remark: Equal, Member, Subclass are under discussion to be included in Core or not | |
Core |
[Atom | Equal | Member | Subclass | Frame] | |
Atom::= | Remark: likely no named arguments in RIF, but only positional arguments | |
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::= | Remark: under discussion; restricted equality only needed for single-assigning values of external built-in function calls to logic variables | |
Core |
TERM = TERM |
<Equal> <left> TERM </left> <right> TERM </right> </Equal> |
Member::= | Remark: under discussion; might be not part of Core | |
Core |
TERM # TERM |
<Member> <instance> TERM </instance> <class> TERM </class> </Member> |
Subclass::= | Remark: under discussion; might be not part of Core | |
Core |
TERM ## TERM |
<Subclass> <sub> TERM </sub> <super> TERM </super> </Subclass> |
Frame::= | Remark: under discussion; Core might have frames and user predicates plus built-in predicates, or frames and built-in predicates, or frames, user predicates, and built-in functions (with restricted equality), or frames and built-in functions (with restricted equality) | |
Core |
TERM ' [ ' (TERM ' -> ' TERM)* ' ] ' |
<Frame> <object> TERM </object> <slot rif:ordered="yes"> TERM TERM </slot>* </Frame> |
FORMULA::= | Remark: Disjunctions in the body and conjunctions in the head might not be part of Core. | |
Core |
[ATOMIC | External | And | Or | Exists] | |
External (as FORMULA)::= | ||
Core |
'External '(' [Atom | Frame] ')' |
<External> <content> [ Atom | Frame ] </content> </External> |
And::= | ||
Core |
'And' '(' FORMULA* ')' |
<And> <formula> FORMULA </formula>* </And> |
Or::= | Remark: Disjunctions in the body might be not part of Core | |
Core |
'Or' '(' FORMULA* ')' |
<Or> <formula> FORMULA </formula>* </Or> |
Exists::= | ||
Core |
'Exists' Var+ '(' FORMULA ')' |
<Exists> <declare> Var </declare>+ <formula> FORMULA </formula> </Exists> |
RULE::= | Remark: There is an implicit assert assumption for production rules | |
Core |
[ Forall | Implies | ATOMIC ] | |
Forall::= | Remark: There is an implicit assert assumption for production rules | |
Core |
' Forall ' Var+ ' ( ' [Implies | ATOMIC] ' ) ' |
<Forall> <declare> Var </declare>+ <formula> [Implies | ATOMIC ] </formula> </Forall> |
Implies::= | Remark: There is an implicit assert assumption for production rules; there might be no conjunction in the head | |
Core |
(ATOMIC | 'And' '(' ATOMIC* ')') '=>' FORMULA |
<Implies> <if> FORMULA </if> <then> [ ATOMIC | <And> <formula> ATOMIC </formula>* </And> ] </then> </Implies> |
Group::= | ||
Core |
METADATA? 'Group' '(' ([RULE | Group])* ')' |
<Group> <sentence> [ RULE | Group ] </sentence>* </Group> |
Core |
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> |
This document is the product of the Rules Interchange Format (RIF) Working Group (see below) whose members deserve recognition for their time and commitment. The editors extend special thanks to: ***, for their thorough reviews and insightful discussions; the working group chairs, Chris Welty and Christian de Sainte-Marie, for their invaluable technical help and inspirational leadership; and W3C staff contact Sandro Hawke, a constant source of ideas, help, and feedback.
The regular attendees at meetings of the Rule Interchange Format (RIF) Working Group at the time of the publication were:
Adrian Paschke (REWERSE),
Axel Polleres (DERI),
Chris Welty (IBM),
Christian de Sainte Marie (ILOG),
Dave Reynolds (HP),
Gary Hallmark (ORACLE),
Harold Boley (NRC),
Hassan Aït-Kaci (ILOG),
Igor Mozetic (JSI),
John Hall (OMG),
Jos de Bruijn (FUB),
Leora Morgenstern (IBM),
Michael Kifer (Stony Brook),
Mike Dean (BBN),
Sandro Hawke (W3C/MIT), and
Stella Mitchell (IBM).
We would also like to thank *** past members of the working group, ***.
The namespace of RIF is http://www.w3.org/2007/rif#.
XML schemas for the RIF-Core sublanguages are defined below and are also available here with additional examples.
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>