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 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-based Dialects. The XML serialization syntax of RIF-BLD, obtained via a mapping from the presentation syntax, is specified using XML Schema.
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 6 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-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.
RIF-BLD is defined in two different ways -- both normative:
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 buy relationships (rather than store any of them) from sell relationships (e.g., stored as facts, as exemplified by the second line):
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.
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"mathematical English," a special form of
English and is meant to be used in the definitions and examples.for communicating mathematical definitions, examples, etc.
This 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].
Definition (Alphabet). The alphabet of the presentation language of RIF-BLD consists of
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 are used in abridged representations of IRIs.
The symbol Document is used to specify RIF-BLD documents, 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.
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 language in thenext definition, we will use the following terminology: Internalbase term : Ato
refer to simple, positional, or named-argument term. Base term : An internal base termterms, or to terms
of the form External(t), where t is a positional
or a named-argument term.
Definition (Term).
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() isis,
trivially, both a positional term and a term with named
arguments.
Membership, subclass, and frame terms are used to describe objects and class hierarchies.
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 frame terms are allowed to be externally defined. Therefore, externally defined objects can be accessed using the more natural frame-based interface. For instance, External("http://example.com/acme"^^rif:iri["http://example.com/mycompany/president"^^rif:iri(?Year) -> ?Pres]) could be an interface provided to access an externally defined method "http://example.com/mycompany/president"^^rif:iri of 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, 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.)
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 is a statement that has one of the following forms:
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.
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.
Universal facts are often considered to be rules without premises (or having true as their premises).
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.
Like prefix directives,The Base directives dodirective does not affect the semantics. They are used asIt
defines a syntactic shortcutsshortcut for expanding relative IRIs into full
IRIs, as described in Section Constants and
Symbol Spaces of [RIF-DTB].
Like the Base directive, the Prefix directives
do not affect the semantics of RIF documents. Instead, they are used asdefine
shorthands to allow more concise representation of IRI constants.
This mechanism is explained in [RIF-DTB], Section Constants and
Symbol Spaces.
Section Direct Specification of RIF-BLD Semantics of this document defines the semantics for the directive Import(t) only. The semantics of the directive Import(t p) is given in [RIF-RDF+OWL]. It is used for importing non-RIF-BLD logical entities, such as RDF data and OWL ontologies. The profile specifies what kind of entity is being imported and under what semantics (for instance, the various RDF entailment regimes).
ThereA document formula can becontain at most one Base
directive in the sequence of directives in a document formula. It must be the first directive indirective. The sequence,Base directive, if present, must be first,
followed by a sequenceany number of Prefix directives (again, if present),directives, followed by
a sequenceany number of Import directives.
All parts of a document formula -- the directives and the group formula -- are optional and can be omitted.In this definition, the component formulas φ,
φi, ψi, and Γ are
said to be subformulas of the respective
formulas (condition, rule, group, etc.) that are built with the help ofusing these
components. ☐
The above definitions endow RIF-BLD with a wide variety of
syntactic forms for terms and formulas, which creates
infrastructure for exchanging syntactically diverse rule languages.
Systems that do not support some of the syntax directly can still
support it through syntactic transformations. For instance,
disjunctions in the rule body can be eliminated through a standard
transformation, such as replacing p :- Or(q r) with a
pair of rules p :- q, p :- r. Terms with
named arguments can be reduced to positional terms by ordering the
arguments by their names and incorporating themthe ordered argument
names into the predicate name. For instance, p(bb->1
aa->2) can be represented as p_aa_bb(2,1).
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/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. In particular, it may include variables, function symbols, 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 φ
iscan be a conjunction, some conjuncts can be used to provide
metadata targeted to the object part, t, of the frame.
Generally, the convention associates each annotation to the largest
term or formula it precedes.
It is suggestedWe 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.
Not all formulas and thus not all documents are well-formed in
RIF-BLD: a requirementit is required that no constant is allowed toappear 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:
The symbols for externally defined predicates arein their own subsets. SubsetsConst that belong to the primitive
datatypes are required to be individuals.
As before,with predicate symbols, there is one subset per symbol arity andarity.
Symbols with named arguments and forexternally defined predicatesfunctions are
in their own subsets.
A subset of individuals. The symbols in Const that belong to the primitive datatypes are required to be individuals.Each predicate and function symbol has precisely one
arity. For positional 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
(si ∈ ArgNames) that are allowed for
that symbol.
An important point is that neither the above partitioning of constant symbols nor the arity are specified explicitly. Instead, the arity of a symbol and its type is determined by the context in which the symbol is used.
Definition (Context of a symbol). The context of an occurrence of a symbol, s∈Const, in a formula, φ, is determined as follows:
Definition (Imported document). Let Δ be a document formula and Import(t) be one of its import directives, where t is an 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 Δ. ☐
Definition
(Well-formed formula). A formula φ is
well-formed iff:
Definition
(Language of RIF-BLD). The language of RIF-BLD
consists of the set of all well-formed formulas and is determined
by:
So far,Until now, we have been using mathematical English to specify
the syntax of RIF-BLD has been specified in mathematical English.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 Condition Language represents formulas that can be used in the body of RIF-BLD rules. The EBNF grammar for a superset of the RIF-BLD condition language is as follows.
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
IRICONST ::= '"' IRI '"^^' 'rif:iri'Name ::= UNICODESTRING
Var ::= '?' UNICODESTRING
SYMSPACE ::= ANGLEBRACKIRI | CURIE
IRIMETA ::= '(*' IRICONST? (Frame | 'And' '(' Frame* ')')? '*)'
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 IRI constant, IRICONST , as identifier followed by an optional Frame or conjunction of Frame s as metadata. The IRI of an IRICONST has the form of an internationalized resource identifier as defined by [ RFC-3987 ].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 a ANGLEBRACKIRI or CURIE
that represents an 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.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.
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 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-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 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-BLD rules extends the syntax in Section EBNF for RIF-BLD 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
For convenience, we reproduce the condition language part of the EBNF below.
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
IRICONST ::= '"' IRI '"^^' 'rif:iri'Name ::= UNICODESTRING
Var ::= '?' UNICODESTRING
SYMSPACE ::= ANGLEBRACKIRI | CURIE
IRIMETA ::= '(*' IRICONST? (Frame | 'And' '(' Frame* ')')? '*)'
Recall that an IRI has the form of an internationalized resource identifier as defined by [RFC-3987].
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 justserve as shortcut mechanisms for
(long)IRIs. An Import indicates the location of a document to be
imported and an optional profile. A RIF-BLD Group is a
nestedcollection 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-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:
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)))
)
)
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/
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)
)
)
)
This normative section specifies the semantics of RIF-BLD directly, without relying on [RIF-FLD].
Recall that the presentation syntax of RIF-BLD allows the use of
macros, which are specified via the Prefix and
Base directives.directives, and various shortcuts for integers,
strings, and rif:local symbols. The semantics, below, is
described using the full syntax, i.e., the description assumeswe assume that all shortcuts
and macros have already been expanded as explaineddefined in [RIF-DTB], Section Constants and
Symbol Spaces.
The set TV of truth values in RIF-BLD consists of just two values, t and f.
The key concept in a model-theoretic semantics of a logic language is the notion of a semantic structure. The definition, below, is a little 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,
I SFNF, 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:
This mapping interprets constant symbols. In addition:
This mapping interprets variable symbols.
This mapping interprets positional terms. In addition:
This mapping interprets function symbols with named arguments. In addition:
This mapping interprets frame terms. An argument, d ∈
Dind, to Iframe
representrepresents 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.
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.
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.
It gives meaning to the equality operator.
It is used to define truth valuation for formulas.
For every external schema, σ, associated with the language, Iexternal(σ) is assumed to be specified externally in some document (hence the name external schema). In particular, if σ is a schema of a RIF built-in predicate or function, Iexternal(σ) is specified in [RIF-DTB] so that:
For convenience, we also define the following mapping I from terms to D:
Here we use {...} to denote a set of argument/value pairs.
Here {...} denotes a bag of attribute/value pairs.
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 dt ∈ DTS, let
LSdt denote the lexical space of
dt, VSdt denote its value space,
and Ldt: LSdt →
VSdt the lexical-to-value-space mapping
(for the definitions of these concepts, see Section Primitive
Datatypes of [RIF-DTB].
Then the following must hold:
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 mentioned in DTS. ☐
RIF-BLD annotations are stripped before the mappings that
constitueconstitute RIF-BLD semantic structures are applied. Likewise, they
are stripped before applying the truth valuation,
TValI, 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 into other RIF-BLD rules, thus enabling reasoning about metadata.
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.
To this end,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:
To ensure that the operator ## is transitive, i.e., c1 ## c2 and c2 ## c3 imply c1 ## c3, the following is required:
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:
Since the bag of attribute/value pairs represents the conjunctions of all the pairs, the following is required, if k > 0:
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 empty conjunction is treated as a tautology, so TValI(And()) = t.
The empty disjunction is treated as a contradiction, so TValI(Or()) = f.
Here I* is a semantic structure of the form
<TV, DTS, D,
Dind, Dfunc,
IC, I*V,
IF, Iframe,
I SFNF, 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.
If Γ is a group formula of the form Group(φ1 ... φn) then
This means that a group of rules is treated as a conjunction. ☐
Document formulas are interpreted using semantic multi-structures.
Definition (Semantic multi-structure). A semantic
multi-structure is a set
{IΔ1, ...,
IΔn}, n>0, where
IΔ1, ...,
IΔn are semantic
structures labeledadorned with document formulas. These structures must be
identical in all respects except that the mappings
ICΔ1, ...,
ICΔn might
differ on the constants in Const that belong to the
rif:local symbol space. The above set is allowed to
have at most one semantic structure with the same label.adornment.
☐
With the help of semantic multi-structures we can now explain the semantics of RIF documents.
Definition (Truth valuation of a document formula). 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. If any
of these Γi is missing (which is a possibility,
since every part of a document is optional), assume that it is a
tautology, such as a = a, so that every TVal
function maps such a Γi to the truth value
t. Let I =
{IΔ,
IΔ1, ...,
IΔk, ...} be a
semantic multi-structure, whichmulti-structure that contains semantic structures labeledadorned
with at least the documents Δ, Δ1,
..., Δk. Then we define:
Note that this definition considers only those document formulas
that are reachable via the one-argument import directives. Two
argument import directives are ignorednot covered here. Their semantics is
defined by the document RIF RDF and OWL Compatibility [RIF-RDF+OWL].
☐
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.
We now define what it means for a set of RIF-BLD rules (such as 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. Therefore, entailment of condition formulas provides formal underpinning to RIF-BLD queries.
From now on, every formula is assumed to be part of some document.
If it is not physically part of any document, it will be said to
belong to a special query document. If I is a
semantic multi-structure, Δ is the document of φ,
and IΔ is the component structure
in I that corresponds to Δ, then
TValI(φ) is defined as
TValIΔ(φ). Otherwise,
TValI(φ) is undefined.
Definition (Models). A multi-structure I is a model of a formula, φ, written as I |= φ, iff TValI(φ) is defined and equals t. ☐
Definition (Logical entailment). Let Γ and φ be RIF-BLD 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. In particular, they cannot be
returned as query answers. 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 "abc"^^rif:local in
Δ' and "abc"^^rif:local in the query on the
right-hand side of |= are treated as different constants
by semantic multi-structures.
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 and 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 w.r.t.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 Translation BetweenMapping from the
RIF-BLDPresentation andSyntax to the XML SyntaxesSyntax. ☐
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 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-BLD uses [XML1.0] for its XML syntax.
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 utilizesuses the type
attribute associated with the XML term elements such aselement Const. For
instance, a literal in the xs:dateTime datatype can beis
represented as
<Const type="&xs;dateTime">2007-11-23T03:55:44-02:30</Const>.
RIF-BLD also utilizesuses the ordered attribute to indicate that
the orderedness ofchildren of the elementsargs and slot it is associated with.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&