Reify.html
11.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
<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>