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

Re: NQuads

From: <jos.deroo.jd@belgium.agfa.com>
Date: Mon, 13 Aug 2001 12:24:45 +0100
To: sean@mysterylights.com
Cc: www-rdf-interest@w3.org, www-rdf-logic@w3.org
Message-Id: <OF8069E823.47E95AEA-ON41256AA7.003E165F@bayer-ag.com>

that reminded me about
but I really don't know at the moment... we really like N3!

Jos De Roo, AGFA http://www.agfa.com/w3c/jdroo/

"Sean B. Palmer" <sean@mysterylights.com>@w3.org on 2001-08-11 01:38:12 AM

Sent by:  www-rdf-logic-request@w3.org

To:   <www-rdf-interest@w3.org>, <www-rdf-logic@w3.org>
Subject:  NQuads

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

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


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 Monday, 13 August 2001 06:25:21 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:44:31 UTC