-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.bs
912 lines (694 loc) · 25.7 KB
/
index.bs
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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
<pre class='metadata'>
Title: RDF Surfaces Primer
Level: 1
Status: LD
Editor: Patrick Hochstenbach, [KNoWS](https://knows.idlab.ugent.be/team/), patrick.hochstenbach@ugent.be
Editor: Jos De Roo, [KNoWS](https://knows.idlab.ugent.be/team/), jos.deroo@ugent.be
Abstract: This document specifies a Notation3 sublanguage to express RDF Surfaces: RDF with first-order logic semantics.
Markup Shorthands: markdown yes
Logo: images/logo.svg
Boilerplate:
</pre>
<style>
table {
margin: 25px auto;
border-collapse: collapse;
border: 1px solid #eee;
border-bottom: 2px solid #005A9C;
}
table tr:hover {
background: #f4f4f4;
}
table tr:hover td {
color: #555;
}
table th, table td {
color: #999;
border: 1px solid #eee;
padding: 12px 12px;
border-collapse: collapse;
}
table th {
background: #005A9C;
color: #fff;
}
table tbody > tr > th {
background: #fff;
color: #005A9C;
}
table th.last {
border-right: none;
}
</style>
<div boilerplate="copyright">
<a href="http://creativecommons.org/publicdomain/zero/1.0/" rel="license"><img alt="CC0" src="https://licensebuttons.net/p/zero/1.0/80x15.png" width="80" height="15"></a> To the extent possible under law, the editors have waived all copyright and related or neighboring rights to this work. In addition, as of [DATE], the editors have made this specification available under the <a href="https://www.openwebfoundation.org/the-agreements/the-owf-1-0-agreements-granted-claims" rel="license">Open Web Foundation Agreement Version 1.0</a>, which is available at https://www.openwebfoundation.org/the-agreements/the-owf-1-0-agreements-granted-claims. Parts of this work may be from another specification document. If so, those parts are instead covered by the license of that specification document.
</div>
Introduction {#Introduction}
=====================
<img src="[LOGO]" alt="Logo" width="100" style="float: left; margin: 5px;"/>
This document presents a [Notation3](https://w3c.github.io/N3/spec/) sublanguage
to express a revised RDF logic as envisioned by [Pat Hayes](https://www.ihmc.us/groups/phayes/)
in his 2009 ISWC Invited Talk:
[BLOGIC](https://www.slideshare.net/PatHayes/blogic-iswc-2009-invited-talk).
RDF Surfaces logic can be thought as an implementation of
[Charles Sanders Peirce](https://en.wikipedia.org/wiki/Charles_Sanders_Peirce)'s
[Existential Graphs](http://www.jfsowa.com/peirce/ms514.htm) in RDF.
An RDF surface is a kind of sheet of paper on which RDF graphs can be written.
All triples that are part of an RDF graph are then on this sheet of paper, including all
[[URI]]s, literals, and [Blank nodes](https://www.w3.org/TR/rdf11-mt/#blank-nodes).
A sheet of paper can contain more than one RDF graph. An RDF graph can't be split
over multiple sheets of paper. However, one can *copy* an RDF graph from one sheet of
paper to another sheet of paper.
[Blank nodes](https://www.w3.org/TR/rdf11-mt/#blank-nodes) are special. They can't
be copied to a new piece of paper. They can be thought of as scratches on a piece of
paper. These scratches, or graffiti, are engraved into the piece of paper and can't
be transferred. When copying data with blank nodes onto a new sheet of paper,
new scratches need to be made.
<div class=example>
An empty *positive surface* is a tautology.
<img alt="blank surface" src="images/positive_surface.svg" width="300"/>
</div>
<div class=example>
A *positive surface* with one triple `:Gent a :City`, which means *"Ghent is a city"*.
<img alt="blank surface" src="images/one_assertion.svg" width="300"/>
</div>
<div class=example>
A *positive surface* with one triple containing a blank node `[] a :City`, which
means *"There is something that is a city"*.
<img alt="blank surface" src="images/blank_node.svg" width="300"/>
</div>
<div class=example>
Two *positive surfaces*, one with the triple `[] a :City` (which means *"There is something that is a city"*),
and another one with the triple `[] a :Cat` (which means *"There is something that is a cat"*).
<img alt="blank surface" src="images/two_sheets.svg" width="600"/>
One can copy these two RDF graphs to a new surface. This will contain two graphs with
two blank nodes:
<pre highlight="turtle">
@prefix : <http://example.org/ns#> .
[] a :City .
[] a :Cat .
</pre>
This means, "There is something that is a city AND There is something that is a cat."
<img alt="blank surface" src="images/city_cat.svg" width="300"/>
</div>
**Positive surface**
The default surface on which RDF graphs are written is a **positive surface**.
For instance, the sheet of paper in Example 1 is an example of a **positive surface**.
(In this document, we use a paper with a black border as a positive surface.) Any
RDF triple written on this surface is interpreted as logical assertion (true). An empty
sheet of positive paper is an empty claim and is treated as a logical tautology (true).
When there is more than one RDF triple on the surface, it is a logical conjunction (AND).
If we interpret the sheets of paper with black borders in the examples above as
positive surfaces, then they express:
- Example 1: true.
- Example 2: It is true that: Ghent a City.
- Example 3: It is true that: ∃ x : x a City.
- Example 4: It is true that: ∃ x , y : ( x a City ) AND ( y a Cat ).
The [blank nodes](https://www.w3.org/TR/rdf11-mt/#blank-nodes) need to be interpreted
as existential quantified variables on logical paper.
**Negative surface**
In the same way that a *positive surface* asserts a logical truth, a **negative surface**
asserts a logical negation. The examples below will use a sheet of paper with a red border
as a negative surface.
An empty *negative surface* on the default positive surface expresses a logical contradiction. When one
or more RDF graphs are written on a *negative* surface, they mean the negation of those RDF graphs.
A blank node on a negative surface is interpreted as a universal quantified variable. The reason is
as follows:
```
NOT(∃ x : P(x)) ⇔ ∀ x : NOT(P(x))
```
<div class=example>
An empty *negative surface* (on a default positive surface) is a contradiction.
<img alt="blank surface" src="images/negative_surface.svg" width="300"/>
</div>
<div class=example>
A *negative surface* with one triple `:Ghent a :Cat` means *"It is not the case that Ghent is a cat"*.
<img alt="blank surface" src="images/city_not_cat.svg" width="300"/>
</div>
<div class=example>
A *negative surface* with one triple `[] a :City` means
*"It is not the case that something is a city"* , or *"Nothing is a city"*.
<img alt="blank surface" src="images/nothing_a_city.svg" width="300"/>
</div>
**Propositional logic**
With combinations of conjunction, by putting triples on a *positive surface*,
and negation, by putting triples on a *negative surface*, any **compound
truth-functional statement** can be symbolized with positive and negative sheets
of paper:
- The logical conjunction **AND** is given by putting RDF triples on a *positive surface*.
- The logical negation **NOT** is given by putting RDF triples on a *negative surface*.
- The logical disjunction **OR** can be made by a combination of *positive* and *negative surfaces*:
- `NOT ( P AND Q ) = NOT ( P ) OR NOT ( Q )`
- `NOT ( NOT ( P ) AND NOT ( Q ) ) = P OR Q`
- The logical implication **→** can be made with a combination of **AND** and **OR**:
- `P → Q = NOT ( P ) OR Q = NOT ( P AND NOT ( Q ) )`
<div class=example>
Propositional logic using *positive* and *negative* surfaces.
<img alt="blank surface" src="images/propositional_logic.svg" width="500"/>
</div>
**First-order logic**
First-order logic can be added to the RDF surfaces by interpreting a blank node as
an existential quantified variable, and using the rule that a universal quantified variable can be made from an
existential quantified variable by placing it in an enclosing negative surface:
- A blank node on a *positive surface* references an existential quantified variable.
- A blank node on a *negative surface* references a universal quantified variable.
<div class=example>
First-order logic using *positive* and *negative* surfaces.
<img alt="blank surface" src="images/first_order_logic.svg" width="500"/>
</div>
**First-order logic in Notation3**
RDF Surfaces provide a way to express the notion of *positive* and *negative surfaces*
in Notation3 with help of the built-in `log:onNegativeSurface`. A `log:onNegativeSurface`
is true when at least one of the nested triples in the object is false. A *negative* surface
can be constructed from a single `log:onNegativeSurface` built-in. A *positive* surface
can be constructed from double-nested `log:onNegativeSurface` built-ins.
The subjects of both built-ins are the blank nodes that need to be put on the
surfaces (so that they become existential or universal quantified variables,
depending on the nesting level of the surface).
<div class=example>
*"Something is a city"* in Notation3.
<pre highlight="turtle">
@prefix : <http://example.org/ns#> .
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
() log:onNegativeSurface {
(_:X) log:onNegativeSurface {
_:X a :City .
}
} .
</pre>
</div>
<div class=example>
*"Something is a city"* in Notation3, version 2: because the default surface
is defined as a positive surface.
<pre highlight="turtle">
@prefix : <http://example.org/ns#> .
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
_:X a :City .
</pre>
</div>
<div class=example>
*"Everything is a city"* in Notation3. Note that we can make universal or existential
quantified variables by placing blank nodes on an oddly- or evenly-nested surface.
<pre highlight="turtle">
@prefix : <http://example.org/ns#> .
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
( _:X ) log:onNegativeSurface {
() log:onNegativeSurface {
_:X a :City .
}
} .
</pre>
</div>
<div class=example>
*"Nothing is a problem"* in Notation3.
<pre highlight="turtle">
@prefix : <http://example.org/ns#> .
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
( _:X ) log:onNegativeSurface {
_:X a :Problem .
} .
</pre>
</div>
<div class=example>
*"All cats are alive OR dead"* in Notation3. These are Schrödinger cats: logical OR can
mean alive, or dead, or both alive and dead.
<pre highlight="turtle">
@prefix : <http://example.org/ns#> .
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
( _:X ) log:onNegativeSurface {
_:X a :Cat .
() log:onNegativeSurface {
_:X :is :Alive .
} .
() log:onNegativeSurface {
_:X :is :Dead .
} .
} .
</pre>
</div>
<div class=example>
*"If any cat X is alive, then X says meow"* in Notation3.
<pre highlight="turtle">
@prefix : <http://example.org/ns#> .
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
( _:X ) log:onNegativeSurface {
_:X a :Cat ;
:is :Alive .
() log:onNegativeSurface {
_:X :says :Meow .
} .
} .
</pre>
</div>
A surface can be queried by providing a query surface with the `log:onNegativeAnswerSurface`
built-in. The results of this query will be the final results of the reasoning engine
interpreting the surfaces.
<div class=example>
`:Ghent a :City` is a triple on the implicit positive surface. The two nested
negative surfaces express that for any subject `_:S` on the positive surface
that is a `:City`, it is implied that `_:S` if also a `:HumanCommunity`.
<pre highlight="turtle">
@prefix ex: <http://example.org/ns#> .
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
ex:Ghent a ex:City.
# Every city is a human community
( _:S ) log:onNegativeSurface {
_:S a ex:City .
() log:onNegativeSurface {
_:S a ex:HumanCommunity .
}.
}.
# Query
( _:S _:C ) log:onNegativeSurface {
_:S a _:C .
() log:onNegativeAnswerSurface {
_:S a _:C .
} .
} .
</pre>
When this surface is executed by a reasoner, the result would be:
<pre highlight="turtle">
@prefix ex: <http://example.org/ns#> .
ex:Ghent a ex:City .
ex:Ghent a ex:HumanCommunity .
</pre>
</div>
More test cases can be found at
[https://github.com/eyereasoner/rdfsurfaces-tests](https://github.com/eyereasoner/rdfsurfaces-tests).
Document Conventions
=====================
Within this document, the following namespace prefix bindings to [[URI]]s are used:
<table>
<thead>
<tr>
<th>Prefix
<th>Namespace
<tbody>
<tr>
<td>ex
<td>http://example.org/ns#
<tr>
<td>rdf
<td>http://www.w3.org/1999/02/22-rdf-syntax-ns#
<tr>
<td>log
<td>http://www.w3.org/2000/10/swap/log#
<tr>
<td>list
<td>http://www.w3.org/2000/10/swap/list#
<tr>
<td>string
<td>http://www.w3.org/2000/10/swap/string#
</table>
Surface {#Surface}
==============================
Surfaces are written as triples where the `subject` is a list of zero or more blank nodes.
The `object` is a graph term or a boolean literal. The blank nodes in the
subject list are treated as marks on the object RDF graph. The `predicate` specifies
the kind of surface. Any kind of surface may be used, but the following built-ins have
special semantics:
<table>
<thead>
<tr>
<td>built-in
<td>semantics
</tr>
</thead>
<tbody>
<tr>
<td>`log:onNegativeSurface`
<td>Negative surface claim that any RDF graph in the object position is false.
</tbody>
</table>
A surface can contain zero or more other surfaces. These contained surfaces are "nested".
Nested surfaces can share the same [[URIs]] and literals (by copying the data),
but can't share blank nodes. Any blank nodes that are written inside a surface
(not as subject of an RDF Surface) are to be interpreted as *coreferences* to the
blank node graffiti defined on a parent RDF Surface. If no such parent RDF Surface
exists, then it is assumed that the blank node is a coreference to an implicitly declared
blank node graffiti on the default positive surface.
</div>
<div class=example>
An `ex:myFirstSurface` is created which contains two triples and a nested surface. The
blank node in `_:X a ex:OtherStatement` is a co-reference to the `_:X` graffiti on
`ex:myFirstSurface`.
In the nested surface `ex:mySecondSurface`, the blank node in `_:X ex:is true` is also a
reference to the `_:X` blank node graffiti on `ex:myFirstSurface`.
The blank node `_:Y` co-reference in `ex:mySecondSurface` doesn't refer to a parent blank
node graffiti. It is assumed that the default positive surface contains that graffiti.
In the nested surface `ex:myThirdSurface`, the blank node in `_:X ex:is false` is a
co-reference to the `_:X` blank node graffiti on `ex:myThirdSurface`. The new graffiti
shields the `_:X` that was defined on `ex:myFirstSurface`: the scope of `_:X`
co-references is now limited to `ex:myThirdSurface`.
<pre highlight="turtle">
@prefix ex: <http://example.org/ns#> .
( _:X ) ex:myFirstSurface {
ex:Statement1 a ex:NiceStatement .
_:X a ex:OtherStatement .
() ex:mySecondSurface {
_:X ex:is true .
_:Y a ex:AnotherStatement .
( _:X ) ex:myThirdSurface {
_:X ex:is false .
} .
}.
} .
</pre>
</div>
## Default Positive Surface ## {#PositiveSurface}
The default positive surface claims that any RDF Graph that is placed on it is true.
This is the current interpretation of [RDF Semantics](https://www.w3.org/TR/rdf11-mt/).
When no surfaces are provided in an RDF document, the implicit default positive surface is assumed.
<div class=example>
The two surfaces below are equal (because a double negation of a statement is the same as
claiming the statement is true, i.e., positive):
<pre highlight="turtle">
@prefix : <http://example.org/ns#> .
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
:Alice a :Person .
</pre>
and
<pre highlight="turtle">
@prefix : <http://example.org/ns#> .
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
() log:onNegativeSurface {
() log:onNegativeSurface {
:Alice a :Person .
} .
}
</pre>
</div>
The semantics of the default positive surface are interpreted as a logical truth:
- An empty RDF graph on the default positive surface is a tautology.
- When a triple is placed on the default positive surface, the surface is valid when the triple is true.
- When two or more triples are placed on the default positive surface, the surface is valid when the
logical conjunction of all triples is true.
<div class="example">
The surface below should be interpreted as: "Alice is a person and knows Bob, and Bob is a
person and knows Alice".
As a logical statement:
```
:Alice a :Person AND
:Alice :knows :Bob AND (
:Bob a :Person AND
:Bob :knows :Alice
)
```
As RDF Surface:
<pre highlight="turtle">
@prefix : <http://example.org/ns#> .
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
:Alice a :Person .
:Alice :knows :Bob .
() log:onNegativeSurface {
() log:onNegativeSurface {
:Bob a :Person .
:Bob :knows :Alice .
} .
} .
</pre>
</div>
When a blank node is marked on an evenly-nested negative surface, it is interpreted
as an existential quantified variable in the scope of the nested surface.
<div class="example">
The surface below should be interpreted as: "There is a person that knows Alice".
As a logical statement:
```
∃ _:X : _:X a :Person AND _:X :knows :Alice
```
Or, rewritten using NOT:
```
NOT ( NOT ( ∃ _:X : _:X a :Person AND _:X :knows :Alice ) )
```
We make use of the logical rule that a negation of a negation cancels, and creates a positive statement.
As RDF Surface:
<pre highlight="turtle">
@prefix : <http://example.org/ns#> .
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
() log:onNegativeSurface {
( _:X ) log:onNegativeSurface {
_:X a :Person .
_:X :knows :Alice .
} .
} .
</pre>
</div>
In RDF Surfaces, a default positive surface is implicitly assumed for each
RDF document. On this default positive surface, all existential variables
are implicitly quantified. Example 20 can be rewritten as:
<div class="example">
A default positive surface with an implicit `_:X` existential variable.
<pre highlight="turtle">
@prefix : <http://example.org/ns#> .
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
_:X a :Person .
_:X :knows :Alice .
</pre>
</div>
When a blank node is marked on an oddly-nested negative surface, it is interpreted
as a universal quantified variable in the scope of the nested surface.
<div class="example">
The surface below should be interpreted as: "Everything is a person and knows Alice".
As a logical statement:
```
∀ _:X : _:X a :Person AND _:X :knows :Alice
```
Or, rewritten using NOT:
```
NOT( ∃ _:X : NOT ( _:X a :Person AND _:X :knows :Alice ) )
```
We make here use of the logical rule that `NOT ( ∃ _:X ... )` is equal to `∀ _:X NOT ( ... )`.
As RDF Surface:
<pre highlight="turtle">
@prefix : <http://example.org/ns#> .
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
(_:X) log:onNegativeSurface {
() log:onNegativeSurface {
_:X a :Person .
_:X :knows :Alice .
} .
} .
</pre>
</div>
## Negative Surface ## {#NegativeSurface}
A negative surface claims that any RDF Graph that is placed on it is false. The interpretation of the
negative surface is the negation of the RDF Graph that is placed on it.
The semantics of a negative surface are interpreted as a logical falsehood:
- An empty negative surface is a contradiction.
- When a triple is placed on a negative surface, the surface is valid when the triple is false.
- When two or more triples are placed on a negative surface, the surface is valid when the logical
conjunction of all triples is false.
<div class="example">
The surface below should be interpreted as: "Alice is a person and knows Bob, and Bob is
not a person and does not know Alice".
As a logical statement:
```
:Alice a :Person AND
:Alice :knows :Bob AND NOT (
:Bob a :Person AND
:Bob :knows :Alice
)
```
As RDF Surface:
<pre highlight="turtle">
@prefix : <http://example.org/ns#> .
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
:Alice a :Person .
:Alice :knows :Bob .
() log:onNegativeSurface {
:Bob a :Person .
:Bob :knows :Alice .
} .
</pre>
</div>
When a blank node is marked on a negative surface, it should be interpreted as an existential
quantified variable in the scope of the negative surface.
<div class="example">
The surface below should be interpreted as "Alice is a Person and knows Bob,
and there isn't a person that knows Alice".
As a logical statement:
```
:Alice a :Person AND
:Alice :knows :Bob AND NOT (
∃ _:X :
_:X a :Person AND
_:X :knows :Alice
)
```
which is the same as:
```
:Alice a :Person AND
:Alice :knows :Bob AND
( ∀ _:X :
NOT (
_:X a :Person AND
_:X :knows :Alice
)
)
)
```
As RDF Surface:
<pre highlight="turtle">
@prefix : <http://example.org/ns#> .
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
:Alice a :Person .
:Alice :knows :Bob .
( _:X ) log:onNegativeSurface {
_:X a :Person .
_:X :knows :Alice .
} .
</pre>
</div>
When two or more negative surfaces are nested in a parent negative surface, it should
be interpreted as a logical disjunction.
<div class="example">
The surface below should be interpreted as "Alice is a Person OR Bob is a Person
OR Charly is a person".
As a logical statement:
```
:Alice a :Person OR
:Bob a :Person OR
:Charly a :Person
```
which is the same as:
```
NOT (
NOT ( :Alice a :Person ) AND
NOT ( :Bob a :Person ) AND
NOT ( :Charly a :Person )
)
```
As RDF Surface:
<pre highlight="turtle">
@prefix : <http://example.org/ns#> .
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
:Alice a :Person .
:Alice :knows :Bob .
() log:onNegativeSurface {
() log:onNegativeSurface {
:Alice a :Person .
} .
() log:onNegativeSurface {
:Bob a :Person .
} .
() log:onNegativeSurface {
:Charly a :Person .
} .
}.
</pre>
</div>
Other logical truth functions can be built with combinations of `AND` and `NOT`, such as the following:
- Disjunction: `P ∨ Q` : `NOT ( NOT ( P ) AND NOT ( Q ) )`
- Material implication `P → Q` : `NOT ( P AND NOT Q )` .
- Converse implication `P ← Q` : `NOT ( NOT ( P ) AND Q )` .
- Biconditional `(P → Q) ∧ (Q → P)` : `NOT ( P AND NOT Q ) AND NOT ( Q AND NOT P )`
Negative surfaces should also follow the law of double negation elimination: `P = NOT ( NOT ( P ) )`.
## Answer Surface
Issue: TODO
Examples {#Examples}
================
As an illustration of RDF Surface, we offer a graph traversal example. Example 26 provides information
about French roads where some roads are blocked due to road works. In this example, we use the predicate
`:oneway` to indicate that a connection is possible from one city to another. To deny this connection,
we use a negative surface.
<div class="example">
Possible connections between the French cities including a blocked connection between Chartes and Lemans.
```
@prefix : <urn:example:> .
:Paris :oneway :Orleans .
:Paris :oneway :Chartres .
:Paris :oneway :Amiens .
:Orleans :oneway :Blois .
:Orleans :oneway :Bourges .
:Blois :oneway :Tours .
:Lemans :oneway :Angers .
:Lemans :oneway :Tours .
:Angers :oneway :Nantes .
# blocking some roads
() log:onNegativeSurface {
:Chartres :oneway :Lemans .
}.
```
</div>
Next, we would like to provide the logic of a "path" through the French road system. We would
like to share an RDF document that states: "When there is a `:oneway` from one city to another
city, then there is a `:path` from the first to the second". Or, expressed in a symbolic form:
```
∀ _:A, _:B : ( _:A :oneway _:B ) IMPLIES ( _:A :path _:B )
```
These paths are transitive. When there is a path from A to B and a path from B to C, there
is a path from A to C. Or, expressed in a symbolic form:
```
∀ _:A, _:B, _:C : ( ( _:A :path _:B ) AND ( _:B :path _:C ) ) IMPLIES ( _:A :path _:C )
```
Using the patterns for `IMPLIES` from the previous sections these logical formulas can be written
as RDF Surfaces in Example 27.
<div class="example">
The RDF Surfaces of a path algorithm.
```
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
@prefix : <urn:example:> .
# oneway subproperty of path
( _:A _:B ) log:onNegativeSurface {
_:A :oneway _:B .
() log:onNegativeSurface {
_:A :path _:B .
} .
} .
# path transitive property
( _:A _:B _:C ) log:onNegativeSurface {
_:A :path _:B .
_:B :path _:C .
() log:onNegativeSurface {
_:A :path _:C .
} .
} .
```
</div>
Based on the RDF documents in Example 26 and 27, we can construct a query to find out which paths are
possible that end in Nantes. For this, we use a specialized answer surface that expresses: "If there is
some path from A to Nantes, then this is an answer". This is expressed as RDF Surfaces in Example 28.
<div class="example">
Query for a possible path from A to Nantes.
```
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
@prefix : <urn:example:> .
(_:A) log:onNegativeSurface {
_:A :path :nantes .
() log:onNegativeAnswerSurface {
_:A :path :nantes .
:test :is :true .
} .
} .
```
</div>
Combining the RDF documents from Examples 26, 27, and 28, an RDF Surfaces reasoner should give as answers:
```
:Angers :path :Nantes .
:Lemans :path :Nantes .
```
If we remove the negative surface around `:Chartes :oneway :Lemans`, an RDF Surfaces reasoner
should provide more answers:
```
:Angers :path :Nantes .
:Lemans :path :Nantes .
:Chartres :path :Nantes .
:Paris :path :Nantes .
```
For more RDF Surfaces examples, see:
- [https://github.com/eyereasoner/rdfsurfaces-tests](https://github.com/eyereasoner/rdfsurfaces-tests)
<pre class=biblio>
{
"N3": {
"authors": [
"Dörthe Arndt",
"William Van Woensel",
"Dominik Tomaszuk",
"Gregg Kellogg"
],
"href": "https://w3c.github.io/N3/spec/",
"title": "Notation3",
"status": "Draft Community Group Report"
}
}
</pre>