W3C home > Mailing lists > Public > public-sparql-dev@w3.org > July to September 2010

Re: First order logic and SPARQL

From: Chimezie Ogbuji <chimezie@gmail.com>
Date: Sun, 5 Sep 2010 23:38:08 -0400
Message-ID: <AANLkTin7KDh8iR529kaZU9ZsvXtjnQWyUoAdV7d4ogVU@mail.gmail.com>
To: Bijan Parsia <bparsia@cs.man.ac.uk>
Cc: Bob MacGregor <bob.macgregor@gmail.com>, Semantic Web <semantic-web@w3.org>, public-sparql-dev@w3.org
On Sun, Sep 5, 2010 at 6:17 PM, Bijan Parsia <bparsia@cs.man.ac.uk> wrote:
>> I would  be interested to learn of a datalog-with-negation implemented by
>> translating to SPARQL,
>> since datalog and its variants is IMO intuitive.

The reasoner I use [1] does *some* of that.  Basically, the internal,
abstract representation of a set of clauses is RIF Core (which I like
to crudely think of as Datalog for RDF) and is serialized as SPARQL
(mostly for query answering).

So, using an example to illustrate.  Given the following OWL:

Class: first:r
    ## Primitive Type  ##
    SubClassOf: ( first:p only first:c )


first:i a first:r;
     first:p first:o.

If you query for:

PREFIX test: <http://www.w3.org/2002/03owlt/allValuesFrom/premises001#>
ASK { test:o  a  test:c }

The subClassOf axiom is converted into the following RIF internally

Forall ?X ?BPvXmuSG133 ( first:c(?BPvXmuSG133) :- And( first:r(?X)
first:p(?X ?BPvXmuSG133) ) )

and the query unifies against the head, and triggers the following
SPARQL (resulting from transforming the rule body via the mechanisms
outlined in those papers):

	?X first:p first:o .
	?X  a first:r
} -> True

Which returns True for the top answer.  So, this way I can do SPARQL
entailment with a RIF ruleset, but all the queries, and the clauses
are managed internally as RIF Core.  Negated literals can also be
transformed into SPARQL via the mechanisms also described in the 'The
Expressive Power of SPARQL' paper (despite the fact that, in the end
RIF-BLD left out negation from the syntax).

> That seems like an unlikely direction, since datalog engines are generally
> at least somewhat older and perceived (correctly I think) as more
> fundamental. (I.e., if I were starting such an implementation, I'd start
> with Datalog, then reduce SPARQL to it.)
> Perhaps people will do RIF to SPARQL.

I do quite a bit of this - again by exploiting the correspondence
between the languages outlined in those papers.

>> Are the results that show a mapping between
>> a datalog variant and SPARQL just papers, or has someone actually
>> implemented a Datalog-like
>> front end that translates to SPARQL?

See example above.  The reasoner does exactly like, but rather than
Datalog it manages the clauses internally as RIF, so the translation
is much more straightforward.

>>> I'd like to see that.  Note: Axel
>> cites a paper that translates
>> in the other direction -- that's not what I'm after.

Basically, for the framework I use, the rules are in RIF-Core (mostly
extracted from OWL 2 RL ontologies), the queries can be posed as
SPARQL or as conjuncts (in the end they are converted into an RIF-Core
frames), the 'reasoning' is done via datalog algorithms over RIF Core
(Generalized Magic Sets, Backwards Fixpoint Procedure, or SLD with
NAF), queries against the Extensional Database (i.e., the RDF dataset)
are converted from RIF-Core frames into SPARQL, evaluated against the
RDF, and the answers are propagated upwards

[1] http://code.google.com/p/fuxi/
Received on Monday, 6 September 2010 03:38:42 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:15:50 UTC