forked from eyereasoner/Notation3-By-Example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
notation.n3
113 lines (100 loc) · 2.26 KB
/
notation.n3
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
@prefix : <urn:example:> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix math: <http://www.w3.org/2000/10/swap/math#> .
# Paths
# :book1 :metadata [
# :author [
# :lastName "Austen"
# :fistName "Jane" .
# ]
# ]
:book1!:metadata!:author
:lastName "Austen" ;
:firstName "Jane" .
# NOTE: This is not equal to:
#
:book2!:metadata!:author :lastName "Austen" . # 1
:book2!:metadata!:author :firstName "Jane" . # 2
#
# Why? #1 and #2 are different paths
# :book3 :metadata [
# :author _:anAuthor
# ] .
# _:somebody :father _:anAuthor ;
# :lastName "Boll" .
:book3!:metadata!:author^:father :lastName "Boll" .
# Paths can also be used in calculations
{
# (2 + 2) * 3
( (2 2)!math:sum 3 ) math:product ?X .
}
=>
{
:result :is ?X .
} .
# Collections
:book4 :readBy ( :Jos :Pat :Ruben ) .
(:book1 :book2) :readBy ( :Jos :Pat :Ruben ).
(:book1 :book3) (:readBy :likedBy) (:Jos :Ruben).
# The equal sign is used to express an owl:sameAs identity.
# This means the subject and object IRI refer to the same
# thing. This does NOT mean that the subject and object IRI
# are equal. This also does NOT mean that any inferences
# you make about the subject are also valid for the object.
#
# This will not work:
#
# :Alice :knows :Bob .
# :Alice = <http://alice.pods.me/profile/card#me> .
# {
# ?A :knows ?B .
# }
# =>
# {
# ?B :knows ?A ,
# } .
#
# and expecting as answer:
#
# <http://alice.pods.me/profile/card#me> :knows :Bob.
:Alice :knows :Bob .
:Alice = <http://alice.pods.me/profile/card#me> .
{
?A :knows ?B .
}
=>
{
?B :knows ?A .
} .
# Test
{
:book1 :metadata [
:author [
:lastName "Austen" ;
:firstName "Jane"
]
] .
:book2 :metadata [
:author [
:lastName "Austen" ;
]
] .
:book2 :metadata [
:author [
:firstName "Jane" ;
]
] .
:book3 :metadata [
:author _:x
] .
_:y :father _:x ;
:lastName "Boll" .
:book4 :readBy (:Jos :Pat :Ruben) .
(:book1 :book2) :readBy (:Jos :Pat :Ruben).
(:book1 :book3) (:readBy :likedBy) (:Jos :Ruben).
:result :is 12 .
}
=>
{
:test :is true .
} .