Importing RIF

From SPARQL Working Group
Jump to: navigation, search

Importing RIF into RDF

RIF RDF and OWL Compatibility <bibref ref="RIF-RDF"/> defines the entailments of combinations (R, G) where R (a RIF rule set) includes an import of G (an RDF graph).


For the inverse of such a reference, i.e., the import of a RIF document into an RDF graph the designated RDF predicate rif:usedWithProfile enables an import to be specified from the graph G instead of from R.

In the simple usage the graph G is a plain RDF graph and rif:usedWithProfile is used to combine that graph with one or more externally defined RIF rule sets. In this usage each subject of a rif:usedWithProfile assertion should be the URI for a RIF rule set (which may be encoded in RIF-XML or RIF-in-RDF) and the object should be an import profile as defined in RIF RDF and OWL Compatibility <bibref ref="RIF-RDF"/>.

The semantics of rif:usedWithProfile is explained in the following subsection.

Semantics of RIF in RDF

A RIF-aware processor shall treat any RDF graph G as a RIF-RDF or RIF-OWL combination (cf. <bibref ref="RIF-RDF"/>) as follows:

Let G' be the graph obtained from G by removing all triples with predicate rif:usedWithProfile.

Then G is to be treated by a RIF-aware processor as the ruleset R:

   Document (
     Imports(R1') 
     ...
     Imports(Rn')
     Imports(G' P1)
     ...
     Imports(G' Pn)
   )

Where Ri and Pi are the subjects/objects respectively of triples of form:

  Ri rif:usedWithProfile Pi     

and Ri' denotes the RIF document referred to by the IRI Reference Ri.

Remark: Note that the fact that G' is treated as being imported with all profiles P1 ... Pn enforces G' to be treated according to the highest profiles among P1 ... Pn, cf. Section 5.2 of <bibref ref="RIF-RDF"/>.

Dereferencing RIF documents (non-normative)

Note that this specification does not define how an RDF store refers to or stores the RIF document Ri' corresponding to a IRI Reference Ri. Alternative methods include, but are not limited to:

  1. HTTP dereferencing
  2. Encoding RIF documents within named graphs within the dataset

We will sketch both methods in the following.

HTTP Dereferencing

This method assumes that Ri is an HTTP dereferenceable IRI which returns a RIF/XML document Ri'.

Encoding RIF documents within named graphs in the dataset

This method assumes an encoding of RIF documents into an RDF graph, such as for instance the one sketched in <bibref ref="RIF-in-RDF"/>, which allows to store RIF documents as RDF graphs within the data store and retrieve the RIF ruleset encoded in an RDF graph by a respective mapping (such as the inverse mapping XTr described in Section 6 of <bibref ref="RIF-in-RDF"/>). In this setting, RDF encoded RIF documents Ri' can simply be made available as named graphs with graph name Ri within the dataset.

For instance, assuming that the IRI reference <r1> denotes an RDF encoded RIF document R1, consisting of the single RIF rule

Document(
 Prefix(foaf <http://xmlns.com/foaf/0.1/>)
 Prefix(rel <http://purl.org/vocab/relationship/>)

 Group
 (
   Forall ?S ?O (
       ?S [ foaf:knows ?O ] :- ?S [ rel:worksWith ?O ]
   )
 )
)


encoded in RDF according to <bibref ref="RIF-in-RDF"/> as follows:

@@@ RIF-in-RDF-encoding of the RIF document consisting of the single rule above

and <g> is a data Graph consisting of the two triples

 @prefix : <http://www.example.org/> . 
 @prefix rel: <http://purl.org/vocab/relationship/> . 
 @prefix rif: <http://www.w3.org/2007/rif#> .

 :bob rel:worksWith :alice .
 <r1> rif:usedWithProfile <http://www.w3.org/ns/entailment/Simple>

then the SPARQL query

 SELECT * 
 FROM <g>
 FROM NAMED <r1>
 WHERE { ?S ?P ?O }

returns

 ?S  ?P  ?O
 :bob foaf:knows  :alice
 :bob rel:worksWith  :alice