BLD

From RIF

Jump to: navigation, search


Document title:
RIF Basic Logic Dialect
Editors
Harold Boley, National Research Council, Canada
Michael Kifer, State University of New York at Stony Brook, USA
Abstract

This document, developed by the Rule Interchange Format (RIF) Working Group, specifies the Basic Logic Dialect, RIF-BLD, a format that allows logic rules to be exchanged between rule systems. The RIF-BLD presentation syntax and semantics are specified both directly and as specializations of the RIF Framework for Logic Dialects, or RIF-FLD. The XML serialization syntax of RIF-BLD is specified via a mapping from the presentation syntax. A normative XML schema is also provided.

Status of this Document
@@update This is an automatically generated Mediawiki page, made from some sort of W3C-style spec.

Copyright © 2008 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability, trademark and document use rules apply.


Contents

1 Overview

This specification develops RIF-BLD (the Basic Logic Dialect of the Rule Interchange Format). From a theoretical perspective, RIF-BLD corresponds to the language of definite Horn rules with equality and a standard first-order semantics [CL73]. Syntactically, RIF-BLD has a number of 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-BLD/RDF and RIF-BLD/OWL languages. These features make RIF-BLD 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.

While rule interchange (and not, e.g. execution) is the principle design goal for RIF-BLD, the design clearly indicates a decision to avoid solving the (probably impossible) problem of rule interchange in general. Instead, the design of RIF reflects the rationale of identifying specific kinds of rules within existing rule systems, called RIF dialects, that can be translated into other rule systems without changing their meaning. RIF-BLD is just the first in a series of such dialects. It is not expected that most rule systems will be able to translate all their rules into RIF-BLD, rather it is expected that only certain kinds of rules will be translatable. Since there are many existing rule languages with useful features that are not supported in RIF-BLD, it is expected that RIF-BLD translators will not translate rules that use such features. This could drive the design of "BLD-specific" rule sets in which rules are specifically written by the implementor to be within the BLD dialect and thus be portabile between many rule system implementations.

Among its many influences, RIF shares certain characteristics with ISO Common Logic (CL) [ISO-CL], itself an evolution of KIF [KIF] and Conceptual Graphs [CG]. Like CL, RIF employs XML as its primary normative syntax, uses IRIs as identifiers, specifies integrated RIF-BLD/RDF and RIF-BLD/OWL languages for Semantic Web Compatibility [RIF-RDF+OWL], and provides a rich set of datatypes and builtins that are designed to be well aligned with web-aware rule system implementations [RIF-DTB]. Unlike CL, RIF-BLD was designed to be a simple dialect with limited expressiveness that lies within the intersection of first-order and logic-programming systems. This is why RIF-BLD does not support negation. More generally, RIF-BLD is part of a consistent array of RIF rule dialects, which encompasses both logic rules -- including a variety of rule languages based on non-monotonic theories -- and production rules, as defined in [RIF-PRD]. CL, on the other hand, is strictly first-order; it does not account for non-monotonic semantics (e.g. negation as failure, defaults, priorities, etc.). For rule interchange between CL and RIF dialects, partial RIF-CL mappings will eventually be defined.

RIF-BLD also bears some similarity to SPARQL, in particular with respect to RDF Compatibility [RIF-RDF+OWL]. As with the well-known correspondence between a fragment of SQL and Datalog, SPARQL can be partially mapped to Datalog (and thus to RIF-BLD), see [AP07] and [AG08] for details. A full mapping of SPARQL would need constructs beyond RIF-BLD, such as non-monotonic negation. Likewise, not all of SPARQL's FILTER functions are expressible in RIF-DTB built-in predicates. Not all of RIF-BLD is expresible in SPARQL either, for instance recursive rules over RDF Data are not expressible as SPARQL CONSTRUCT statements.

RIF-BLD is defined in two different ways -- both normative:

  • As a direct specification, independently of the RIF framework for logic dialects [RIF-FLD], for the benefit of those who desire a direct path to RIF-BLD, e.g., as prospective implementers, and are not interested in extensibility issues. This version of the RIF-BLD specification is given first.
  • As a specialization of the RIF framework for logic dialects [RIF-FLD], which is part of the RIF extensibility framework. Building on RIF-FLD, this version of the RIF-BLD specification is comparatively short and is presented in Section RIF-BLD as a Specialization of the RIF Framework at the end of this document. This is intended for the reader who is already familiar with RIF-FLD and does not need to go through the much longer direct specification of RIF-BLD. This section is also useful for dialect designers, as it is a concrete example of how a non-trivial RIF dialect can be derived from the RIF framework for logic dialects.

Logic-based RIF dialects that specialize or extend RIF-BLD in accordance with the RIF framework for logic dialects [RIF-FLD] will be developed in other specifications by the RIF working group.

To give a preview, here is a simple complete RIF-BLD example deriving a ternary relation from its inverse.

Example 1 (An introductory RIF-BLD 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):

  • A buyer buys an item from a seller if the seller sells the item to the buyer.
  • John sells LeRif to Mary.

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-BLD 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-BLD XML Syntax is given in this specification. To formalize their meaning, a RIF-BLD Semantics is specified.


2 Direct Specification of RIF-BLD Presentation Syntax

This normative section specifies the syntax of RIF-BLD directly, without relying on [RIF-FLD]. We define both the presentation syntax (below) and an XML syntax in Section XML Serialization Syntax for RIF-BLD. The presentation syntax is normative, but is not intended to be a concrete syntax for RIF-BLD. It is defined in "mathematical English," a special form of English for communicating mathematical definitions, examples, etc. The presentation syntax deliberately leaves out details such as the delimiters of the various syntactic components, escape symbols, parenthesizing, precedence of operators, and the like. Since RIF is an interchange format, it uses XML as its concrete syntax and RIF-BLD conformance is described in terms of semantics-preserving transformations.

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


2.1 Alphabet of RIF-BLD

Definition (Alphabet). The alphabet of the presentation language of RIF-BLD consists of

  • a countably infinite set of constant symbols Const
  • a countably infinite set of variable symbols Var (disjoint from Const)
  • a countably infinite set of argument names, ArgNames (disjoint from Const and Var)
  • connective symbols And, Or, and :-
  • quantifiers Exists and Forall
  • the symbols =, #, ##, ->, External, Import, Prefix, and Base
  • the symbols Group and Document
  • the auxiliary symbols (, ), [, ], <, >, and ^^

The set of connective symbols, quantifiers, =, etc., is disjoint from Const and Var. The argument names in ArgNames are written as unicode strings that must not start with a question mark, "?". Variables are written as Unicode strings preceded with the symbol "?".

Constants are written as "literal"^^symspace, where literal is a sequence of Unicode characters and symspace is an identifier for a symbol space. Symbol spaces are defined in Section Constants and Symbol Spaces of [RIF-DTB].

The symbols =, #, and ## are used in formulas that define equality, class membership, and subclass relationships. The symbol -> is used in terms that have named arguments and in frame formulas. The symbol External indicates that an atomic formula or a function term is defined externally (e.g., a built-in) and the symbols Prefix and Base enable abridged representations of IRIs [RFC-3987].

The symbol Document is used to specify RIF-BLD documents, the symbol Import is an import directive, and the symbol Group is used to organize RIF-BLD formulas into collections.   ☐

The language of RIF-BLD is the set of formulas constructed using the above alphabet according to the rules given below.


2.2 Terms

RIF-BLD defines several kinds of terms: constants and variables, positional terms, terms with named arguments, plus equality, membership, subclass, frame, and external terms. The word "term" will be used to refer to any of these constructs.

To simplify the next definition, we will use the phrase base term to refer to simple, positional, or named-argument terms, or to terms of the form External(t), where t is a positional or a named-argument term.

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 base terms then t(t1 ... tn) is a positional term.
  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 base terms and s1, ..., sn are pairwise distinct symbols from the set ArgNames.

    The constant t here represents a predicate or 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.

  4. Equality terms. t = s is an equality term, if t and s are base terms.
  5. Class membership terms (or just membership terms). t#s is a membership term if t and s are base terms.
  6. Subclass terms. t##s is a subclass term if t and s are base terms.
  7. Frame terms. t[p1->v1 ... pn->vn] is a frame term (or simply a frame) if t, p1, ..., pn, v1, ..., vn, n ≥ 0, are base terms.

    Membership, subclass, and frame terms are used to describe objects and class hierarchies.

  8. Externally defined terms. If t is a positional, named-argument, or a frame term then External(t) is an externally defined term.

    Such terms are used for representing built-in functions and predicates as well as "procedurally attached" terms or predicates, which might exist in various rule-based systems, but are not specified by RIF.

    Note that not only predicates and functions, but also frame terms 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 representation of an externally defined method "http://example.com/mycompany/president"^^rif:iri in an external object "http://example.com/acme"^^rif:iri.   ☐

    Feature At Risk #1: External frames

    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.

Observe that the argument names of frame terms, p1, ..., pn, are base terms and so, as a special case, can be variables. In contrast, terms with named arguments can use only the symbols from ArgNames to represent their argument names. They cannot be constants from Const or variables from Var. The reason for this restriction has to do with the complexity of unification, which is used by several inference mechanisms of first-order logic.

2.3 Formulas

RIF-BLD distinguishes certain subsets of the set Const of symbols, including the subset of predicate symbols and function symbols. Section Well-formed Formulas gives more details, but we do not need those details yet.

Any term (positional or with named arguments) of the form p(...), where p is a predicate symbol, is also an atomic formula. Equality, membership, subclass, and frame terms are also atomic formulas. An externally defined term of the form External(φ), where φ is an atomic formula, is also an atomic formula, called an externally defined atomic formula.

Note that simple terms (constants and variables) are not formulas.

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

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

  1. Atomic: If φ is an atomic formula then it is also a formula.
  2. Condition formula: A condition formula is either an atomic formula or a formula that has one of the following forms:
    • 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.
    • 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.
    • Existentials: If φ is a condition formula and ?V1, ..., ?Vn, n>0, are variables then Exists ?V1 ... ?Vn(φ) is an existential formula.

    Condition formulas are intended to be used inside the premises of rules. Next we define the notion of RIF-BLD rules, sets of rules, and RIF documents.

  3. Rule implication: φ :- ψ is a formula, called rule implication, if:
    • φ is an atomic formula or a conjunction of atomic formulas,
    • ψ is a condition formula, and
    • none of the atomic formulas in φ is an externally defined term (i.e., a term of the form External(...)). (Note: external terms can occur in the arguments of atomic formulas in the rule conclusion.)

    Feature At Risk #2: Equality in the rule conclusion (φ in the above)

    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.

  4. Universal rule: If φ is a rule implication and ?V1, ..., ?Vn, n>0, are variables then Forall ?V1 ... ?Vn(φ) is a formula, called a universal rule. It is required that all the free variables in φ occur among the variables ?V1 ... ?Vn in the quantification part. An occurrence of a variable ?v is free in φ if it is not inside a substring of the form Q ?v (ψ) of φ, where Q is a quantifier (Forall or Exists) and ψ is a formula. Universal rules will also be referred to as RIF-BLD rules.
  5. Universal fact: If φ is an atomic formula then Forall ?V1 ... ?Vn(φ) is a formula, called a universal fact, provided that all the free variables in φ occur among the variables ?V1 ... ?Vn.

    Universal facts are often considered to be rules without premises (or having true as their premises).

  6. Group: If φ1, ..., φn are RIF-BLD rules, universal facts, variable-free rule implications, variable-free atomic formulas, or group formulas then Group(φ1 ... φn) is a group formula.

    Group formulas are used to represent sets of rules and facts. Note that some of the φi's can be group formulas themselves, which means that groups can be nested.

  7. Document: An expression of the form Document(directive1 ... directiven Γ) is a RIF-BLD document formula (or simply a document formula), if
    • Γ is an optional group formula; it is called the group formula associated with the document.
    • directive1, ..., directiven is an optional sequence of directives. A directive can be a base directive, a prefix directive or an import directive.
      • A base directive has the form Base(iri), where iri is a unicode string in the form of an IRI [RFC-3987].

        The Base directive defines a syntactic shortcut for expanding relative IRIs into full IRIs, as described in Section Constants and Symbol Spaces of [RIF-DTB].

      • A prefix directive has the form Prefix(p v), where p is an alphanumeric string that serves as the prefix name and v is an expansion for p -- a string that forms an IRI. (An alphanumeric string is a sequence of ASCII characters, where each character is a letter, a digit, or an underscore "_", and the first character is a letter.)

        Like the Base directive, the Prefix directives define shorthands to allow more concise representation of constants that come from the symbol space rif:iri (we will call such constants rif:iri constants). This mechanism is explained in [RIF-DTB], Section Constants and Symbol Spaces.

      • An import directive can have one of these two forms: Import(t) or Import(t p). Here t is a rif:iri constant and p is a term. The constant t indicates the location of another document to be imported and p is called the profile of import.

        Section Direct Specification of RIF-BLD Semantics of this document defines the semantics for the directive Import(t) only. The two-argument directive, Import(t p), is intended for importing non-RIF-BLD documents, such as rules from other RIF dialects, RDF data, or OWL ontologies. The profile, p, indicates what kind of entity is being imported and under what semantics (for instance, the various RDF entailment regimes have different profiles). The semantics of Import(t p) (for various p) are expected to be given by other specifications on a case-by-case basis. For instance, [RIF-RDF+OWL] defines the semantics for the profiles that are recommended for importing RDF and OWL.

      A document formula can contain at most one Base directive. The Base directive, if present, must be first, followed by any number of Prefix directives, followed by any number of Import directives.

In the definition of a formula, the component formulas φ, φi, ψi, and Γ are said to be subformulas of the respective formulas (condition, rule, group, etc.) that are built using these components.   ☐


2.4 RIF-BLD Annotations in the Presentation Syntax

RIF-BLD allows every term and formula (including terms and formulas that occur inside other terms and formulas) to be optionally preceded by an annotation of the form (* id φ *), where id is a rif:iri constant and φ is a frame formula or a conjunction of frame formulas. Both items inside the annotation are optional. The id part represents the identifier of the term or formula to which the annotation is attached and φ is the metadata part of the annotation. RIF-BLD does not impose any restrictions on φ apart from what is stated above. This means that it may include variables, function symbols, constants from the symbol space rif:local (often referred to as local or rif:local constants), and so on.

Document formulas with and without annotations will be referred to as RIF-BLD documents.

A convention is used to avoid a syntactic ambiguity in the above definition. For instance, in (* id φ *) t[w -> v] the metadata annotation could be attributed to the term t or to the entire frame t[w -> v]. The convention in RIF-BLD is that the above annotation is considered to be syntactically attached to the entire frame. Yet, since φ can be a conjunction, some conjuncts can be used to provide metadata targeted to the object part, t, of the frame. For instance, (* And(_foo[meta_for_frame->"this is an annotation for the entire frame"] _bar[meta_for_object->"this is an annotation for t" meta_for_property->"this is an annotation for w"] *) t[w -> v]. Generally, the convention associates each annotation to the largest term or formula it precedes.

We suggest to use Dublin Core, RDFS, and OWL properties for metadata, along the lines of Section 7.1 of [OWL-Reference]-- specifically owl:versionInfo, rdfs:label, rdfs:comment, rdfs:seeAlso, rdfs:isDefinedBy, dc:creator, dc:description, dc:date, and foaf:maker.

2.5 Well-formed Formulas

Not all formulas and thus not all documents are well-formed in RIF-BLD: 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:

  • A subset of individuals.

    The symbols in Const that belong to the primitive datatypes are required to be individuals.

  • A number of subsets for predicate symbols such that there is one subset per symbol arity (defined below) for externally defined predicates and one for non-external predicates.

    Note that this implies that symbols used for external predicate names cannot be used for other predicates. Also, the definition of arity, below, implies that the arities for positional predicate symbols and for predicate symbols with named arguments are distinct even if the numbers of arguments are the same. Therefore, symbols that are used for positional predicates cannot be used for predicates with named arguments, and vice versa.

  • A number of subsets of function symbols. As with predicate symbols, there are disjoint subsets for symbols with different arities; function symbols with named arguments and externally defined functions are in their own subsets. The only exception is the case of nullary symbols, which take zero arguments as in f(), since they are considered to be both positional and named-argument symbols.

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:

  • If s occurs as a predicate in an atomic subformula of the form s(...) with arity α then s occurs in the context of a predicate symbol with arity α.
  • If s occurs as a function symbol in a term (not subformula) of the form s(...) with arity α then s occurs in the context of a function symbol with arity α.
  • If s occurs as a predicate in an atomic subformula External(s(...)) with arity α then s occurs in the context of an external predicate symbol with arity α.
  • If s occurs as a function in a term (not subformula) External(s(...)) with arity α then s occurs in the context of an external function symbol with arity α.
  • If s occurs in any other context (in a frame: s[...], ...[s->...], or ...[...->s]; or in a positional/named argument term: p(...s...), q(...->s...)), it is said to occur as an individual.   ☐

Definition (Imported document). Let Δ be a document formula and Import(t) be one of its import directives, where t is a rif:iri constant that identifies another document formula, Δ'. We say that Δ' is directly imported into Δ.

A document formula Δ' is said to be imported into Δ if it is either directly imported into Δ or it is imported (directly or not) into some other formula that is directly imported into Δ.     ☐

The above definition deals only with one-argument import directives, since only such directives can be used to import other RIF-BLD documents. Two-argument import directives are provided to enable import of other types of documents, and their semantics are supposed to be covered by other specifications, such as [RIF-RDF+OWL].


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

  • every constant symbol (whether coming from the symbol space rif:local or not) mentioned in φ occurs in exactly one context.
  • if φ is a document formula and Δ'1, ..., Δ'k are all of its imported documents, then every non-rif:local constant symbol mentioned in φ or any of the imported Δ'is must occur in exactly one context (in all of the Δ'is).
  • whenever a formula contains a term or a subformula of the form External(t), t must be an instance of a schema in the coherent set of external schemas (Section Schemas for Externally Defined Terms of [RIF-DTB]) associated with the language of RIF-BLD.
  • if t is an instance of a schema in the coherent set of external schemas associated with the language then t can occur only as External(t), i.e., as an external term or atomic formula.   ☐


Definition (Language of RIF-BLD). The language of RIF-BLD consists of the set of all well-formed formulas and is determined by:

  • the alphabet of the language and
  • a set of coherent external schemas, which determine the available built-ins and other externally defined predicates and functions.   ☐


2.6 EBNF Grammar for the Presentation Syntax of RIF-BLD

Until now, we have used mathematical English to specify the syntax of RIF-BLD. 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 syntax of first-order logic is not context-free, so EBNF cannot capture the syntax of RIF-BLD precisely. For instance, it cannot capture the section on well-formedness conditions, i.e., the requirement that each symbol in RIF-BLD can occur in at most one context. As a result, the EBNF grammar defines a strict superset of RIF-BLD: not all formulas that are derivable using the EBNF grammar are well-formed formulas in RIF-BLD.
  • The EBNF grammar does not address all details of how constants (defined in [RIF-DTB]) and variables are represented, and it is not sufficiently precise about the delimiters and escape symbols. White space is informally used as a delimiter, and is implied in productions that use Kleene star. For instance, TERM* is to be understood as TERM TERM ... TERM, where each space abstracts from one or more blanks, tabs, newlines, etc. This is so because RIF's presentation syntax is a tool for specifying the semantics and for illustration of the main RIF concepts through examples. It is not intended as a concrete syntax for a rule language. RIF defines a concrete syntax only for exchanging rules, and that syntax is XML-based, obtained as a refinement and serialization of the presentation syntax.
  • For all the above reasons, the EBNF grammar is not normative. Recall, however, that the RIF-BLD presentation syntax, as specified in mathematical English, is normative.

The EBNF for the RIF-BLD presentation syntax is given as follows, showing the entire (top-down) context of its three parts for rules, conditions, and annotations.

Rule Language:

  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

Condition Language:

  FORMULA        ::= IRIMETA? 'And' '(' FORMULA* ')' |
                     IRIMETA? 'Or' '(' FORMULA* ')' |
                     IRIMETA? 'Exists' Var+ '(' FORMULA ')' |
                     ATOMIC |
                     IRIMETA? 'External' '(' Atom | Frame ')'
  ATOMIC         ::= IRIMETA? (Atom | Equal | Member | Subclass | Frame)
  Atom           ::= UNITERM
  UNITERM        ::= Const '(' (TERM* | (Name '->' TERM)*) ')'
  Equal          ::= TERM '=' TERM
  Member         ::= TERM '#' TERM
  Subclass       ::= TERM '##' TERM
  Frame          ::= TERM '[' (TERM '->' TERM)* ']'
  TERM           ::= IRIMETA? (Const | Var | Expr | 'External' '(' Expr ')')
  Expr           ::= UNITERM
  Const          ::= '"' UNICODESTRING '"^^' SYMSPACE | CONSTSHORT
  Name           ::= UNICODESTRING
  Var            ::= '?' UNICODESTRING
  SYMSPACE       ::= ANGLEBRACKIRI | CURIE

Annotations:

  IRIMETA        ::= '(*' IRICONST? (Frame | 'And' '(' Frame* ')')? '*)'

The following subsections explain and exemplify these parts, starting with the basic language of positive conditions.


2.6.1 EBNF for the Condition Language

The Condition Language represents formulas that can be used in the premises of RIF-BLD rules (also called rule bodies). The EBNF grammar for a superset of the RIF-BLD condition language is shown in the above conditions part.

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-BLD conditions permit only existential variables. A RIF-BLD FORMULA can also be an ATOMIC term, i.e. an Atom, External Atom, Equal, Member, Subclass, or Frame. A TERM can be a constant, variable, Expr, or External Expr.

The RIF-BLD 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 an 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.

Equality, membership, and subclass terms are self-explanatory. An Atom and Expr (expression) 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. Likewise, External(Expr) is a call to an externally defined function.


Example 2 (RIF-BLD 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 shortcut notation prefix:suffix for constant symbols, which is understood as a shorthand for 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].

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]))


2.6.2 EBNF for the Rule Language

The presentation syntax for RIF-BLD rules is based on the syntax in Section EBNF for RIF-BLD Condition Language with the productions shown in the above rules part.

A RIF-BLD 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. IRI has the form of an internationalized resource identifier as defined by [RFC-3987]. An Import indicates the location of a document to be imported and an optional profile. A RIF-BLD 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:

  • In the first, a CLAUSE is in the scope of the Forall quantifier. In that case, all variables mentioned in CLAUSE are required to also appear among the variables in the Var+ sequence.
  • In the second alternative, CLAUSE appears on its own. In that case, CLAUSE cannot have variables.

Var, ATOMIC, and FORMULA were defined as part of the syntax for positive conditions in Section EBNF for RIF-BLD 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-BLD rules).

This example shows a business rule borrowed from the document RIF Use Cases and Requirements:

  • If an item is perishable and it is delivered to John more than 10 days after the scheduled delivery date then the item will be rejected by him.

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)
                ?diffduration = External(func:subtract-dateTimes(?deliverydate ?scheduledate))
                ?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)
                     ?diffduration = External(func:subtract-dateTimes(?deliverydate ?scheduledate))
                     ?diffdays = External(func:days-from-duration(?diffduration))
                     External(pred:numeric-greater-than(?diffdays 10)))
            )
   )


2.6.3 EBNF for Annotations

The EBNF grammar production for RIF-BLD annotations is shown in the above annotations part.

As explained in Section RIF-BLD Annotations in the Presentation Syntax, RIF-BLD formulas and terms can be prefixed with optional annotations, IRIMETA, for identification and metadata. IRIMETA is represented using (*...*)-brackets that contain an optional rif: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 4 (A RIF-BLD document containing an annotated group).

This example shows a complete document containing a group formula that consists of two RIF-BLD 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/"^^rif:iri
                                     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)
                ?diffduration = External(func:subtract-dateTimes(?deliverydate ?scheduledate))
                ?diffdays = External(func:days-from-duration(?diffduration))
                External(pred:numeric-greater-than(?diffdays 10)))
    )
 
    Forall ?item (
        cpt:reject(ppl:Fred ?item) :- cpt:unsolicited(?item)
    )
  )
)



3 Direct Specification of RIF-BLD Semantics

This normative section specifies the semantics of RIF-BLD directly, without relying on [RIF-FLD].

Recall that the presentation syntax of RIF-BLD allows shorthand notation, which is specified via the Prefix and Base directives, and various shortcuts for integers, strings, and rif:local symbols. The semantics, below, is described using the full syntax, i.e., we assume that all shortcuts have already been expanded as defined in [RIF-DTB], Section Constants and Symbol Spaces.

3.1 Truth Values

The set TV of truth values in RIF-BLD consists of just two values, t and f.

3.2 Semantic Structures

The key concept in a model-theoretic semantics of a logic language is the notion of a semantic structure [Enderton01, Mendelson97]. The definition, below, is a bit more general than necessary. This is done in order to better see the connection with the semantics of the RIF framework described in [RIF-FLD].

Definition (Semantic structure). A semantic structure, I, is a tuple of the form <TV, DTS, D, Dind, Dfunc, IC, IV, IF, Iframe, INF, Isub, Iisa, I=, Iexternal, Itruth>. Here D is a non-empty set of elements called the domain of I, and Dind, Dfunc are nonempty subsets of D. Dind is used to interpret the elements of Const that are individuals and Dfunc is used to interpret the elements of Const that are function symbols. As before, 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-DTB] for the semantics of datatypes).

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

  1. IC maps Const to D.

    This mapping interprets constant symbols. In addition:

    • If a constant, c ∈ Const, is an individual then it is required that IC(c) ∈ Dind.
    • If c ∈ Const, is a function symbol (positional or with named arguments) then it is required that IC(c) ∈ Dfunc.
  2. IV maps Var to Dind.

    This mapping interprets variable symbols.

  3. IF 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. In addition:

    • If dDfunc then IF(d) must be a function D*indDind.
    • This means that when a function symbol is applied to arguments that are individual objects then the result is also an individual object.
  4. INF maps D to the set of total functions of the form SetOfFiniteSets(ArgNames × Dind) → D.

    This mapping interprets function symbols with named arguments. In addition:

    • If dDfunc then INF(d) must be a function SetOfFiniteSets(ArgNames × Dind) → Dind.
    • This is analogous to the interpretation of positional terms with two differences:
      • Each pair <s,v> ∈ ArgNames × Dind represents an argument/value pair instead of just a value in the case of a positional term.
      • The arguments of a term with named arguments constitute a finite set of argument/value pairs rather than a finite ordered sequence of simple elements. So, the order of the arguments does not matter.
  5. Iframe maps Dind to total functions of the form SetOfFiniteBags(Dind × Dind) → D.

    This mapping interprets frame terms. 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 how Iframe 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. (We shall see later that o[a->b a->b] is equivalent to o[a->b].)

  6. 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. This is ensured by a restriction in Section Interpretation of 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 Formulas.

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

    It gives meaning to the equality operator.

  9. Itruth is a mapping of the form DTV.

    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, 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:

    • If σ is a schema of a built-in function then Iexternal(σ) must be the function defined in the aforesaid document.
    • If σ is a schema of a built-in predicate then Itruth ο (Iexternal(σ)) (the composition of Itruth and Iexternal(σ), a truth-valued function) must be as specified in [RIF-DTB].

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

  • I(k) = IC(k), if k is a symbol in Const
  • I(?v) = IV(?v), if ?v is a variable in Var
  • I(f(t1 ... tn)) = IF(I(f))(I(t1),...,I(tn))
  • I(f(s1->v1 ... sn->vn)) = INF(I(f))({<s1,I(v1)>,...,<sn,I(vn)>})

    Here we use {...} to denote a set of argument/value pairs.

  • I(o[a1->v1 ... ak->vk]) = Iframe(I(o))({<I(a1),I(v1)>, ..., <I(an),I(vn)>})

    Here {...} denotes a bag of attribute/value pairs. Jumping ahead, we note that duplicate elements in such a bag do not affect the value of Iframe(I(o)) -- see Section Interpretation of Non-document Formulas. For instance, I(o[a->b a->b]) = I(o[a->b]).

  • I(c1##c2) = Isub(I(c1), I(c2))
  • I(o#c) = Iisa(I(o), I(c))
  • I(x=y) = I=(I(x), I(y))
  • I(External(t)) = Iexternal(σ)(I(s1), ..., I(sn)), if t is an instance of the external schema σ = (?X1 ... ?Xn; τ) by substitution ?X1/s1 ... ?Xn/s1.

    Note that, by definition, External(t) is well-formed only if t is an instance of an external schema. Furthermore, by the definition of coherent sets of external schemas, t can be an instance of at most one such schema, so I(External(t)) is well-defined.

The effect of datatypes. The set DTS must include the datatypes described in Section Primitive Datatypes of [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-DTB]. Then the following must hold:

  • VSdtDind; and
  • For each constant "lit"^^dt such that litLSdt, IC("lit"^^dt) = Ldt(lit).

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

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


3.3 RIF-BLD Annotations in the Semantics

RIF-BLD annotations are stripped before the mappings that constitute RIF-BLD semantic structures are applied. Likewise, they are stripped before applying the truth valuation, TValI, defined in the next section. Thus, identifiers and metadata have no effect on the formal semantics.

Note that although identifiers and metadata associated with RIF-BLD formulas are ignored by the semantics, they can be extracted by XML tools. The frame terms used to represent RIF-BLD metadata can then be fed to other RIF-BLD rules, thus enabling reasoning about metadata.


3.4 Interpretation of Non-document Formulas

This section defines how a semantic structure, I, determines the truth value TValI(φ) of a RIF-BLD formula, φ, where φ is any formula other than a document formula. Truth valuation of document formulas is defined in the next section.

We define a mapping, TValI, from the set of all non-document 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 formulas in RIF-BLD is determined using the following function, denoted TValI:

  1. Positional atomic formulas: TValI(r(t1 ... tn)) = Itruth(I(r(t1 ... tn)))
  2. Atomic formulas with named arguments: TValI(p(s1->v1 ... sk->vk)) = Itruth(I(p(s1->v1 ... sk->vk))).
  3. Equality: TValI(x = y) = Itruth(I(x = y)).
    • To ensure that equality has precisely the expected properties, it is required that:
      • Itruth(I(x = y)) = t if I(x) = I(y) and that Itruth(I(x = y)) = f otherwise.
    • This is tantamount to saying that TValI(x = y) = t if and only if I(x) = I(y).
  4. Subclass: TValI(sc ## cl) = Itruth(I(sc ## cl)).

    To ensure that the operator ## is transitive, i.e., c1 ## c2 and c2 ## c3 imply c1 ## c3, the following is required:

    • For all c1, c2, c3D,   if TValI(c1 ## c2) = TValI(c2 ## c3) = t   then TValI(c1 ## c3) = t.
  5. Membership: TValI(o # cl) = Itruth(I(o # cl)).

    To ensure that all members of a subclass are also members of the superclass, i.e., o # cl and cl ## scl implies o # scl, the following is required:

    • For all o, cl, sclD,   if TValI(o # cl) = TValI(cl ## scl) = t   then   TValI(o # scl) = t.
  6. Frame: TValI(o[a1->v1 ... ak->vk]) = Itruth(I(o[a1->v1 ... ak->vk])).

    Since the bag of attribute/value pairs represents the conjunctions of all the pairs, the following is required, if k > 0:

    • TValI(o[a1->v1 ... ak->vk]) = t if and only if TValI(o[a1->v1]) = ... = TValI(o[ak->vk]) = t.
  7. Externally defined atomic formula: TValI(External(t)) = Itruth(Iexternal(σ)(I(s1), ..., I(sn))), if t is an atomic formula that is an instance of the external schema σ = (?X1 ... ?Xn; τ) by substitution ?X1/s1 ... ?Xn/s1.

    Note that, by definition, External(t) is well-formed only if t is an instance of an external schema. Furthermore, by the definition of coherent sets of external schemas, t can be an instance of at most one such schema, so I(External(t)) is well-defined.

  8. Conjunction: TValI(And(c1 ... cn)) = t if and only if TValI(c1) = ... = TValI(cn) = t. Otherwise, TValI(And(c1 ... cn)) = f.

    The empty conjunction is treated as a tautology, so TValI(And()) = t.

  9. Disjunction: TValI(Or(c1 ... cn)) = f if and only if TValI(c1) = ... = TValI(cn) = f. Otherwise, TValI(Or(c1 ... cn)) = t.

    The empty disjunction is treated as a contradiction, so TValI(Or()) = f.

  10. Quantification:
    • TValI(Exists ?v1 ... ?vn (φ)) = t if and only if for some I*, described below, TValI*(φ) = t.
    • TValI(Forall ?v1 ... ?vn (φ)) = t if and only if for every I*, described below, TValI*(φ) = t.

    Here I* is a semantic structure of the form <TV, DTS, D, Dind, Dfunc, IC, I*V, IF, Iframe, INF, Isub, Iisa, I=, Iexternal, Itruth>, which is exactly like I, except that the mapping I*V, is used instead of IV.   I*V is defined to coincide with IV on all variables except, possibly, on ?v1,...,?vn.

  11. Rule implication:
    • TValI(conclusion :- condition) = t, if either TValI(conclusion)=t or TValI(condition)=f.
    • TValI(conclusion :- condition) = f   otherwise.
  12. Groups of rules:

    If Γ is a group formula of the form Group(φ1 ... φn) then

    • TValI(Γ) = t if and only if TValI(φ1) = t, ..., TValI(φn) = t.
    • TValI(Γ) = f   otherwise.

    This means that a group of rules is treated as a conjunction.   ☐


3.5 Interpretation of Documents

Document formulas are interpreted using semantic multi-structures. Semantic multi-structures are essentially similar to regular semantic structures but, in addition, they allow to interpret rif:local symbols that belong to different documents differently.

Definition (Semantic multi-structure). A semantic multi-structure is a set {Iφ1, ..., Iφn, ...} of semantic structures adorned with distinct RIF-BLD formulas φ1, ..., φn. These structures must be identical in all respects except that the mappings ICφ1, ..., ICφn, ... may differ on the constants in Const that belong to the rif:local symbol space.     ☐

We can now define the semantics of RIF documents.

Definition (Truth valuation of document formulas). Let Δ be a document formula and let Δ1, ..., Δk be all the RIF-BLD document formulas that are imported (directly or indirectly, according to Definition Imported document) into Δ. Let Γ, Γ1, ..., Γk denote the respective group formulas associated with these documents. Let I = {IΔ, IΔ1, ..., IΔk, ...} be a semantic multi-structure that contains semantic structures adorned with at least the documents Δ, Δ1, ..., Δk. Then we define:

  • TValI(Δ) = t if and only if TValIΔ(Γ) = TValIΔ1(Γ1) = ... = TValIΔk(Γk) = t.         ☐

Note that this definition considers only those document formulas that are reachable via the one-argument import directives. Two argument import directives are not covered here. Their semantics is defined by the document RIF RDF and OWL Compatibility [RIF-RDF+OWL].

Also note that some of the Γi above may be missing since all parts in a document formula are optional. In this case, we assume that Γi is a tautology, such as a = a, and every TVal function maps such a Γi to the truth value t.

For non-document formulas, we extend TValI(φ) from regular semantic structures to multi-structures as follows: if I is a multi-structure that has a component structure Iφ adorned with φ then TValI(φ) = TValIφ(φ). Otherwise, TValI(φ) is undefined.


The above definitions make the intent behind the rif:local constants clear: occurrences of such constants in different documents can be interpreted differently even if they have the same name. Therefore, each document can choose the names for the rif:local constants freely and without regard to the names of such constants used in the imported documents.


3.6 Logical Entailment

We now define what it means for a set of RIF-BLD rules (embedded in a group or a document formula) to entail another RIF-BLD formula. In RIF-BLD we are mostly interested in entailment of RIF condition formulas, which can be viewed as queries to RIF-BLD documents. Entailment of condition formulas provides formal underpinning to RIF-BLD queries.


Definition (Models). A multi-structure I is a model of a formula, φ, written as I |= φ, iff TValI(φ) = t. Here φ can be a document or a non-document formula.   ☐

Definition (Logical entailment). Let φ and ψ be (document or non-document) formulas. We say that φ entails ψ, written as φ |= ψ, if and only if for every multi-structure, I, for which both TValI(φ) and TValI(ψ) are defined, I |= φ implies I |= ψ.   ☐


Note that one consequence of the multi-document semantics of RIF-BLD is that local constants specified in one document cannot be queried from another document. For instance, if one document, Δ', has the fact "http://example.com/ppp"^^rif:iri("abc"^^rif:local) while another document formula, Δ, imports Δ' and has the rule "http://example.com/qqq"^^rif:iri(?X) :- "http://example.com/ppp"^^rif:iri(?X) , then Δ |= "http://example.com/qqq"^^rif:iri("abc"^^rif:local) does not hold. This is because the symbol "abc"^^rif:local in Δ' and Δ is treated as different constants by semantic multi-structures.


4 XML Serialization Syntax for RIF-BLD

The RIF-BLD XML serialization defines

Recall that the syntax of RIF-BLD 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 BLD document in XML syntax). A valid BLD document in the XML syntax is an XML document that is valid with respect to the XML schema in Appendix XML Schema for BLD.   ☐

Definition (Conformant BLD document in XML syntax). A conformant BLD document in the XML syntax is a valid BLD document in the XML syntax that is the image of a well-formed RIF-BLD document in the presentation syntax (see Definition Well-formed formula in Section Formulas) under the presentation-to-XML syntax mapping χbld defined in Section Mapping from the Presentation Syntax to the XML Syntax.   ☐

The XML serialization for RIF-BLD 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 BLD. They 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-BLD uses [XML1.0] for its XML syntax.


4.1 XML for the Condition Language

XML serialization of RIF-BLD in Section EBNF for RIF-BLD 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, for predicates, or Expr, for functions)
- Member    (member formula)
- Subclass  (subclass formula)
- Frame     (Frame formula)
- object    (Member/Frame role, containing a TERM or an object description)
- op        (Atom/Expr role for predicates/functions as operations)
- args      (Atom/Expr 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/Expr or Frame slot role, with fixed 'ordered' attribute, containing a Name or TERM followed by a TERM)
- Equal     (prefix version of term equation '=')
- Expr      (expression formula, positional or with named arguments)
- left      (Equal left-hand side role)
- right     (Equal right-hand side role)
- 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-BLD condition language see Appendix XML Schema for BLD.

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 <Const type="&xs;dateTime">2007-11-23T03:55:44-02:30</Const>. RIF-BLD 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)))
        ?Seller=?Author )

XML serialization

   <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 (A RIF condition with named arguments and its XML serialization).

This example illustrates XML serialization of RIF conditions that involve terms with named arguments. As in Example 5, we assume the following prefix directives:

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 ?P (
                 And (?P#cpt:purchase
                      ?P[cpt:buyer->?Buyer
                         cpt:seller->?Seller
                         cpt:item->cpt:book(cpt:author->?Author cpt:title->bks:LeRif)
                         cpt:price->49
                         cpt:currency->curr:USD]))
        ?Seller=?Author)


XML serialization:

   <And>
     <formula>
       <Exists>
         <declare><Var>Buyer</Var></declare>
         <declare><Var>P</Var></declare>
         <formula>
           <And>
             <formula>
               <Member>
                 <instance><Var>P</Var></instance>
                 <class><Const type="&rif;iri">&cpt;purchase</Const></class>
               </Member>
             </formula>
             <formula>
               <Frame>
                 <object>
                   <Var>P</Var>
                 </object>
                 <slot ordered="yes">
                   <Const type="&rif;iri">&cpt;buyer</Const>
                   <Var>Buyer</Var>
                 </slot>
                 <slot ordered="yes">
                   <Const type="&rif;iri">&cpt;seller</Const>
                   <Var>Seller</Var>
                 </slot>
                 <slot ordered="yes">
                   <Const type="&rif;iri">&cpt;item</Const>
                   <Expr>
                     <op><Const type="&rif;iri">&cpt;book</Const></op>
                     <slot ordered="yes">
                       <Name>&cpt;author</Name>
                       <Var>Author</Var>
                     </slot>
                     <slot ordered="yes">
                       <Name>&cpt;title</Name>
                       <Const type="&rif;iri">&bks;LeRif</Const>
                     </slot>
                   </Expr>
                 </slot>
                 <slot ordered="yes">
                   <Const type="&rif;iri">&cpt;price</Const>
                   <Const type="&xs;integer">49</Const>
                 </slot>
                 <slot ordered="yes">
                   <Const type="&rif;iri">&cpt;currency</Const>
                   <Const type="&rif;iri">&curr;USD</Const>
                 </slot>
               </Frame>
             </formula>
           </And>
         </formula>
       </Exists>
     </formula>
     <formula>
       <Equal>
         <left><Var>Seller</Var></left>
         <right><Var>Author</Var></right>
       </Equal>
     </formula>
   </And>


4.2 XML for the Rule Language

We now extend the set of RIF-BLD serialization elements from Section XML for RIF-BLD Condition Language by including rules, along with their enclosing groups and documents, as described in Section EBNF for RIF-BLD Rule Language. The extended set includes the tags listed below. While there is a RIF-BLD 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-BLD 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-BLD is given in Appendix XML Schema for BLD.


Example 7 (Serializing a RIF-BLD 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(rif  http://www.w3.org/2007/rif#)
  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/"^^rif:iri
                                     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)
                ?diffduration = External(func:subtract-dateTimes(?deliverydate ?scheduledate))
                ?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:

<!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>


4.3 Mapping from the Presentation Syntax to the XML Syntax

This section defines a normative mapping, χbld, from the presentation syntax to the XML syntax of RIF-BLD. 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 χbld to these metavariables. When an expression χbld(metavar) occurs in an XML pattern in the right column of a translation table, it should be understood as a recursive application of χbld to the presentation syntax represented by the metavariable. The XML syntax result of such an application is substituted for the expression χbld(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.


4.3.1 Mapping of the Condition Language

The χbld mapping from the presentation syntax to the XML syntax of the RIF-BLD Condition Language is specified by the table below. Each row indicates a translation χbld(Presentation) = XML. Since the presentation syntax of RIF-BLD 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>χbld(conjunct1)</formula>
   . . .
  <formula>χbld(conjunctn)</formula>
</And>
Or (
  disjunct1
  . . .
  disjunctn
   )
<Or>
  <formula>χbld(disjunct1)</formula>
   . . .
  <formula>χbld(disjunctn)</formula>
</Or>
Exists
  variable1
  . . .
  variablen (
             premise
            )
<Exists>
  <declare>χbld(variable1)</declare>
   . . .
  <declare>χbld(variablen)</declare>
  <formula>χbld(premise)</formula>
</Exists>
External (
  atomframexpr
         )
<External>
  <content>χbld(atomframexpr)</content>
</External>
pred (
  argument1
  . . .
  argumentn
     )
<Atom>
  <op>χbld(pred)</op>
  <args ordered="yes">
    χbld(argument1)
    . . .
    χbld(argumentn)
  </args>
</Atom>
func (
  argument1
  . . .
  argumentn
     )
<Expr>
  <op>χbld(func)</op>
  <args ordered="yes">
    χbld(argument1)
    . . .
    χbld(argumentn)
  </args>
</Expr>
pred (
  unicodestring1 -> filler1
  . . .
  unicodestringn -> fillern
     )
<Atom>
  <op>χbld(pred)</op>
  <slot ordered="yes">
    <Name>unicodestring1</Name>
    χbld(filler1)
  </slot>
   . . .
  <slot ordered="yes">
    <Name>unicodestringn</Name>
    χbld(fillern)
  </slot>
</Atom>
func (
  unicodestring1 -> filler1
  . . .
  unicodestringn -> fillern
     )
<Expr>
  <op>χbld(func)</op>
  <slot ordered="yes">
    <Name>unicodestring1</Name>
    χbld(filler1)
  </slot>
   . . .
  <slot ordered="yes">
    <Name>unicodestringn</Name>
    χbld(fillern)
  </slot>
</Expr>
inst [
  key1 -> filler1
  . . .
  keyn -> fillern
     ]
<Frame>
  <object>χbld(inst)</object>
  <slot ordered="yes">
    χbld(key1)
    χbld(filler1)
  </slot>
   . . .
  <slot ordered="yes">
    χbld(keyn)
    χbld(fillern)
  </slot>
</Frame>
inst # class
<Member>
  <instance>χbld(inst)</instance>
  <class>χbld(class)</class>
</Member>
sub ## super
<Subclass>
  <sub>χbld(sub)</sub>
  <super>χbld(super)</super>
</Subclass>
left = right
<Equal>
  <left>χbld(left)</left>
  <right>χbld(right)</right>
</Equal>
"unicodestring"^^symspace
<Const type="symspace">unicodestring</Const>
?unicodestring
<Var>unicodestring</Var>


4.3.2 Mapping of the Rule Language

The χbld mapping from the presentation syntax to the XML syntax of the RIF-BLD Rule Language is specified by the table below. It extends the translation table of Section Translation of RIF-BLD 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 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 χbld applies only to such expanded documents. RIF-BLD 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-BLD 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>