W3C home > Mailing lists > Public > www-rdf-interest@w3.org > August 2001

NQuads

From: Sean B. Palmer <sean@mysterylights.com>
Date: Sat, 11 Aug 2001 01:38:12 +0100
Message-ID: <015b01c12201$b0e51780$9fdd93c3@z5n9x1>
To: <www-rdf-interest@w3.org>, <www-rdf-logic@w3.org>
In writing an inference engine, I found that reifying out tons of
statements and statement sets (contexts) into NTriples was not only
very frustrating on the part of the human that has to write it, but
also quite difficult to process on the side of the tool. I wondered a)
if it would be acceptable to separate data and inferences, and b) use
two different formats for them.

What I came up with, and what I have implemented, is NQuads. It's just
NTriples, but instead of three terms, it has four. The fourth term is
simply a context marker. Here's an example:-

   <#x> <#y> <#z> <#m> .
   <#z> <#y> <#x> <#n> .
   <#m> <#implies> <#n> <#a> .
   <#a> <#forAll> <#x> <#root> .
   <#a> <#forAll> <#z> <#root> .

This is roughly equivalent to writing the following rule in
Notation3:-

   { { :x :y :z } log:implies { :z :y :x } }
   a log:Truth; log:forAll :x, :y .

The main difference is that all contexts have a URI. The question is
what to use as a root context for the document. It is quite fair to
come up with a URI that denotes the current "document" as a resource.
The great thing about NQuads is that there is no guessing to the
context for each of the triples: the author must state it explicitly.

NQuads are totally convertible into NTriples, you just have to reify a
lot. That's basically what it saves you: the reification. Note that
the extra term is not a statement ID, it's a context ID. Thus, you can
have stuff like:-

   <#x> <#y> <#z> <#m> .
   <#a> <#b> <#c> <#m> .

See [1] for a rough translation of this using a model into NTriples.

Now, using this format, I was able to write an inference engine in
Python in just one day. It only handles contexts with single
statements in the "old" context for now, but it can grok universally
quantification and any number of statements in the "new" context.

In short, NQuads are not going to be useful often, only when writing
documents that have lots of contexts, for example rules files. But
when you have those contexts, they save you a lot of time both writing
and parsing because you're moving a certain amount of model into the
syntax. And as the two are perfectly transmutable, there shouldn't be
any inconsistencies except for the usual ratholes of what constitutes
a "document" in NTriples and so forth.

P.S. Please trim (if/any) replies according to topic.

[1] Could be something like (substituting the de_facto terms of the
season, such as the stuff in model.n3):-

_:1 <#context> <#m> .
_:2 <#context> <#m> .
_:1 <#subject> <#x> .
_:1 <#predicate> <#y> .
_:1 <#object> <#z> .
_:2 <#subject> <#a> .
_:2 <#predicate> <#b> .
_:2 <#object> <#c> .

Perhaps you'd have another syntax for explicit statement IDs where you
do a lot of reification? Hmm... but that would conflict with NQuads,
unless you made NQuads NPents. Since I thought of this first, I'll
assume that there is more need for it on the Semantic Web :-)

cf. discussions about NQuads with Bijan et al. starting from
"23:32:37" in:-

   http://ilrt.org/discovery/chatlogs/rdfig/2001-08-10.txt

I also chumped some BLURB about it.

--
Kindest Regards,
Sean B. Palmer
@prefix : <http://webns.net/roughterms/> .
:Sean :hasHomepage <http://purl.org/net/sbp/> .
Received on Friday, 10 August 2001 21:03:34 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 7 December 2009 10:51:51 GMT