You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
330 lines
11 KiB
330 lines
11 KiB
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta name="generator" content=
|
|
"HTML Tidy for Mac OS X (vers 31 October 2006 - Apple Inc. build 13), see www.w3.org" />
|
|
<title>
|
|
Reification of RDF and N3 - Design Issues
|
|
</title>
|
|
<link rel="Stylesheet" href="di.css" type="text/css" />
|
|
<meta http-equiv="Content-Type" content=
|
|
"text/html; charset=us-ascii" />
|
|
</head>
|
|
<body bgcolor="#DDFFDD" text="#000000" lang="en" xml:lang="en">
|
|
<address>
|
|
Tim Berners-Lee<br />
|
|
Date: 2004/12/17, last change: $Date: 2005/02/17 15:39:27
|
|
$<br />
|
|
Status: personal view only. Editing status: first draft. An
|
|
understanding of <a href="Notation3.html">Notation 3</a> is
|
|
assumed for this article.
|
|
</address>
|
|
<p>
|
|
<a href="./">Up to Design Issues</a>
|
|
</p>
|
|
<hr />
|
|
<h1>
|
|
Reifying RDF (properly), and N3
|
|
</h1>
|
|
<p>
|
|
Reification in this context means the expression of something
|
|
in a language using the language, so that it becomes
|
|
treatable by the language. RDF graphs consist of RDF
|
|
statements. If one wants to look objectively at an RDF graph
|
|
and reason about it is using RDF tools, then it is useful, at
|
|
least in theory, to have an ontology for describe RDF
|
|
statements. This note described one suitable ontology.
|
|
</p>
|
|
<p>
|
|
When RDF extended to N3, then one way of discussing the
|
|
semantics is to describe N3 documents in RDF. This document
|
|
does both.
|
|
</p>
|
|
<p>
|
|
The namespace used is
|
|
<code><http://www.w3.org/2004/06/rei#></code> , for
|
|
which here we use the <code>rei:</code> prefix. Also, we use
|
|
the ex<em>:</em> prefix for the namespace
|
|
<code><http://example.com/ex#></code>.
|
|
</p>
|
|
<h2>
|
|
RDF Terms
|
|
</h2>
|
|
<p>
|
|
RDF terms are nodes in the RDF Graph. In RDF, these can be of
|
|
three types: named nodes, blank nodes, and literals. We will
|
|
also call named nodes <em>symbols</em>.
|
|
</p>
|
|
<h3>
|
|
Symbols
|
|
</h3>
|
|
<p>
|
|
Named nodes are named by URI strings, so a named node can be
|
|
defined simply by its URI string. The symbol which in N3 is
|
|
written as <http://example.com/> would be described as
|
|
the RDF node:
|
|
</p>
|
|
<pre>
|
|
[ a rei:Symbol; rei:uri "http://example.com/ex#joe" ]
|
|
</pre>
|
|
<h3>
|
|
Blank nodes
|
|
</h3>
|
|
<p>
|
|
Blank nodes (or Bnodes for short) are nodes do not have URIs.
|
|
When describing a graph, we can say that a node is blank by
|
|
saying that it is in the class rei:BNode.
|
|
</p>
|
|
<pre>
|
|
[ a rei:Bnode ]
|
|
</pre>
|
|
<p>
|
|
This blank node in the description is a description of a
|
|
blank node in the original graph. They are node the same
|
|
blank node. We could in fact name the blank node for the
|
|
purposes of description:
|
|
</p>
|
|
<pre>
|
|
ex:bnode1 a rei:BNode.
|
|
</pre>
|
|
<h3>
|
|
Literals
|
|
</h3>
|
|
<p>
|
|
Literals in an RDF graph are defined only by their value,
|
|
just as symbols are defined by their URIs. When using RDF to
|
|
describe RDF, RDF literals can clearly be used to give the
|
|
value:
|
|
</p>
|
|
<pre>
|
|
[ a rei:Literal, rei:value "The quick brown fox"]
|
|
</pre>
|
|
<p>
|
|
In fact, the domain of rei:value is rei:Literal, so it is not
|
|
necessary to explicitly state that something is a literal,
|
|
one can just write:
|
|
</p>
|
|
<pre>
|
|
[rei:value "The quick brown fox"]
|
|
</pre>
|
|
<h2>
|
|
RDF Statements
|
|
</h2>
|
|
<p>
|
|
A RDF statement is defined by its three parts, known as
|
|
subject, predicate and object, each of which is a term. In
|
|
RDF, neither the subject nor the predicate may be a Literal.
|
|
The statement which in N3 is <code>ex:joe ex:name "James
|
|
Doe".</code> would be described as
|
|
</p>
|
|
<pre>
|
|
[ a rei:Statement;
|
|
rei:subject [rei:uri "http://example.com/ex#joe"];
|
|
rei:predicate [rei:uri "http://example.com/ex#name"];
|
|
rei:object [rei:value "James Doe"]
|
|
]
|
|
</pre>
|
|
<p>
|
|
In fact, the fact that it is a rei:Statement would have been
|
|
clear as the domains of rei:subject, rei:predicate and
|
|
rei:object are all rei:Statement.
|
|
</p>
|
|
<h2>
|
|
RDF Graphs
|
|
</h2>
|
|
<p>
|
|
An RDF graph is a set of statements. RDF itself doesn't have
|
|
the concept of a set, it only has the concept of an ordered
|
|
list (RDF collection). However, the OWL relation owl:oneOf
|
|
related a class to a list of its members, and so we can form
|
|
a set the set containing 3 4 and 5 as <code>[ owl:oneOf (3 4
|
|
5)]</code> . using this convention, we can describe an RDF
|
|
Graph as the set of statements. For example, the graph whose
|
|
contents which would be written, in N3 as
|
|
</p>
|
|
<pre>
|
|
ex:joe ex:name "James Doe".
|
|
ex:jane ex:name "Jane Doe".
|
|
</pre>
|
|
<p>
|
|
would be described in this ontology as:
|
|
</p>
|
|
<pre>
|
|
{ a rei:RDFGraph;
|
|
statements [ owl:oneof (
|
|
[ a rei:Statement;
|
|
rei:subject [rei:uri "http://example.com/ex#joe"];
|
|
rei:predicate [rei:uri "http://example.com/ex#name"];
|
|
rei:object [rei:value "James Doe"]
|
|
]
|
|
[ a rei:Statement;
|
|
rei:subject [rei:uri "http://example.com/ex#jane"];
|
|
rei:predicate [rei:uri "http://example.com/ex#name"];
|
|
rei:object [rei:value "Jane Doe"]
|
|
] )
|
|
</pre>
|
|
<p>
|
|
Using the set may be ungainly, but it ensures that two
|
|
RDFGraphs which contain the same statements are demonstrably
|
|
the same in their reified form. (We envisage that further
|
|
developments systems may have explicit processing for sets,
|
|
and N3 syntax could even be extended to include set literal
|
|
syntax, which would of course make this easier.)
|
|
</p>
|
|
<h2>
|
|
The quoting of URIs
|
|
</h2>
|
|
<p>
|
|
The use of an explicit string as the URI for the subject
|
|
above is also ungainly, compared with the use in the original
|
|
N3 where a prefixed symbol can be used. Why is the string
|
|
given explicitly, instead of writing it as symbol?
|
|
</p>
|
|
<p>
|
|
Let's suppose for a moment that we just use the symbol, not
|
|
the string for the URI:
|
|
</p>
|
|
<pre>
|
|
#Wrong:
|
|
[ a rei:Statement;
|
|
rei:subject ex:joe;
|
|
rei:predicate ex:name;
|
|
rei:object [rei:value "James Doe"]
|
|
]
|
|
</pre>
|
|
<p>
|
|
This should be a description of an RDF statement. It must
|
|
preserve the original graph, including the URIs it used. The
|
|
statements which would be described as
|
|
</p>
|
|
<pre>
|
|
[ rei:subject ex:joe; # Wrong
|
|
rei:predicate ex:name;
|
|
rei:object [rei:value "James Doe"]]
|
|
</pre>
|
|
<p>
|
|
and
|
|
</p>
|
|
<pre>
|
|
[ rei:subject ex:jd1; # Wrong
|
|
rei:predicate ex:name;
|
|
rei:object [rei:value "James Doe"]]
|
|
</pre>
|
|
<p>
|
|
are different graphs, even if "http://example.com/ex#joe" and
|
|
"http://example.com/ex#jd1" are two URIs for the same person.
|
|
However, if the system knows that <ex:jd1> and
|
|
<ex:joe> are in fact thhe same person, then the second
|
|
statement can be derived from the first. It is important (in
|
|
our application) to be able to know which name a graph used
|
|
for something. The form of reification which is provided by
|
|
the original RDF specification is not suitable, because it
|
|
loses that information.
|
|
</p>
|
|
<h2>
|
|
N3 Formulae
|
|
</h2>
|
|
<p>
|
|
N3 extends RDF to allow graphs themselves to be another form
|
|
of literal node. A graph can be quoted inside another graph,
|
|
as one of the terms of a statement:
|
|
</p>
|
|
<pre>
|
|
ex:jane ex:knows { ex:joe ex:name "James Doe" }.
|
|
</pre>
|
|
<p>
|
|
Jane knows "joe's name is '<em>James Doe</em>'". As above,
|
|
the quotation effect is important. Jane's knowledge is in
|
|
these terms. Even though ex:jd1 and ex:joe may be the same
|
|
person, Jane might not know that, and so may not know that
|
|
ex:jd1's name is <em>James Doe</em>.
|
|
</p>
|
|
<p>
|
|
An N3 formula also introduces quantification. Variables are
|
|
introduced by allowing a given set of symbols to be
|
|
universally quantified over the formula, and another set to
|
|
be universally quantified.
|
|
</p>
|
|
<p>
|
|
A formula is described by three sets: the set of statements
|
|
(the graph), the set of universals and the set of
|
|
existentials. The semantics of an N3 formula are that the
|
|
universal quantification is applied to the result of applying
|
|
the existential quantification to the conjunction of the
|
|
statements. (a la <em>forall x: exists c such that ...</em>).
|
|
The N3 formula
|
|
</p>
|
|
<pre>
|
|
@keywords a.
|
|
[] a car. { ?x a car } => { ?x a vehicle }.
|
|
</pre>
|
|
<p>
|
|
(roughly, <em>There is a car. Anything which is a car is a
|
|
vehicle</em>) is shorthand for
|
|
</p>
|
|
<pre>
|
|
@keywords a.
|
|
@forAll :x.
|
|
@forSome :c.
|
|
:c a car.
|
|
{x a car } => {x a vehicle}.
|
|
</pre>would be described as a formula whose universals were just x,
|
|
whose existentials were just c, and whose statements was the
|
|
implication - a statement whose subject and object were themselves
|
|
formulae. This follows in the code below, obtained by passing the
|
|
code above through <code>cwm --reify.</code> The output is:
|
|
<pre>
|
|
@prefix : <http://www.w3.org/2004/06/rei#> .
|
|
@prefix owl: <http://www.w3.org/2002/07/owl#> .
|
|
@keywords a.
|
|
|
|
[ a <http://www.w3.org/2000/10/swap/log#Truth>;
|
|
universals[owl:oneOf(
|
|
"http://www.w3.org/2000/10/swap/test/reify/ex1.n3#x" ) ];
|
|
existentials [owl:oneOf(
|
|
"http://www.w3.org/2000/10/swap/test/reify/ex1.n3#c" ) ];
|
|
statement [ owl:oneOf([
|
|
object [uri "http://www.w3.org/2000/10/swap/test/reify/ex1.n3#car" ];
|
|
predicate [uri "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" ];
|
|
subject [uri "http://www.w3.org/2000/10/swap/test/reify/ex1.n3#c" ]
|
|
] [
|
|
object [
|
|
universals [ owl:oneOf () ] ];
|
|
existentials [ owl:oneOf () ];
|
|
statements [ owl:oneOf (
|
|
[ object [uri "http://www.w3.org/2000/10/swap/test/reify/ex1.n3#vehicle" ];
|
|
predicate [uri "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" ];
|
|
subject[ uri "http://www.w3.org/2000/10/swap/test/reify/ex1.n3#x" ] ] ) ];
|
|
predicate [uri "http://www.w3.org/2000/10/swap/log#implies" ];
|
|
subject [
|
|
universals [owl:oneOf ()];
|
|
existentials [owl:oneOf () ];
|
|
statements [owl:oneOf (
|
|
[ object [uri "http://www.w3.org/2000/10/swap/test/reify/ex1.n3#car" ];
|
|
predicate [uri "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" ];
|
|
subject [uri "http://www.w3.org/2000/10/swap/test/reify/ex1.n3#x" ] ] ) ]] ] ) ] ].
|
|
|
|
</pre>
|
|
<h2>
|
|
Asserting truth
|
|
</h2>
|
|
<p>
|
|
Note that in this mode, the formula is not only described,
|
|
but it is also stated to be a Truth. To simply describe a
|
|
formula as existing doesn't say anything. Formulae are
|
|
abstract things, to say one exists doesn't add anything. Some
|
|
would say, all formulae exist, just as all lists exist.
|
|
However, to assert that one is true asserts its contents. The
|
|
RDF file output above has, by definition of the terms in the
|
|
reification namespace, the same meaning as the full N3
|
|
formula from which it is produced. It does to any agent which
|
|
understands the meaning of the reification namespace.
|
|
</p>
|
|
<hr />
|
|
<p>
|
|
<a href="Overview.html">Up to Design Issues</a>
|
|
</p>
|
|
<p>
|
|
<a href="../People/Berners-Lee">Tim BL</a>
|
|
</p>
|
|
</body>
|
|
</html>
|