eyeling 1.5.35 → 1.5.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/examples/brussels-brew-club.n3 +119 -0
- package/examples/drone-corridor-planner.n3 +146 -40
- package/examples/ev-roundtrip-planner.n3 +189 -0
- package/examples/json-pointer.n3 +5 -0
- package/examples/json-reconcile-vat.n3 +5 -0
- package/examples/oslo-steps-workflow-composition.n3 +305 -0
- package/examples/output/brussels-brew-club.n3 +498 -0
- package/examples/output/drone-corridor-planner.n3 +717 -51
- package/examples/output/ev-roundtrip-planner.n3 +403 -0
- package/examples/output/json-reconcile-vat.n3 +49 -48
- package/examples/output/oslo-steps-workflow-composition.n3 +148 -0
- package/examples/output/skolem.n3 +5 -4
- package/examples/rdf-list.n3 +7 -3
- package/eyeling.js +183 -7
- package/package.json +1 -1
- package/test/api.test.js +30 -0
- package/examples/drone-corridor-planner-v2.n3 +0 -237
- package/examples/output/drone-corridor-planner-v2.n3 +0 -819
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
# =======================================================================================
|
|
2
|
+
# OSLO-STEPS workflow composition — translation pipeline style
|
|
3
|
+
#
|
|
4
|
+
# Goal:
|
|
5
|
+
# Compose an "address change confirmation" workflow from OSLO-STEPS-style input:
|
|
6
|
+
# - o-steps:State + o-steps:hasStateShape (SHACL constraints)
|
|
7
|
+
# - o-steps:Step + o-steps:requiresState / o-steps:producesState + costs
|
|
8
|
+
#
|
|
9
|
+
# Pipeline:
|
|
10
|
+
# 1) StateShape -> State constraints (targetClass, path, value) [SHACL -> constraints]
|
|
11
|
+
# 2) Step + required/produced State -> gps:description [OSLO -> internal]
|
|
12
|
+
# 3) planner composes gps:description [internal -> plan]
|
|
13
|
+
#
|
|
14
|
+
# Notes:
|
|
15
|
+
# - Aggregation:
|
|
16
|
+
# duration + monetaryCost = sum
|
|
17
|
+
# success * satisfaction = product
|
|
18
|
+
# - Pruning is done using math:lessThan / math:greaterThan (known to work in EYE).
|
|
19
|
+
# =======================================================================================
|
|
20
|
+
|
|
21
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
22
|
+
@prefix list: <http://www.w3.org/2000/10/swap/list#>.
|
|
23
|
+
@prefix gps: <https://eyereasoner.github.io/eye/reasoning/gps/gps-schema#>.
|
|
24
|
+
@prefix : <https://eyereasoner.github.io/eye/reasoning#>.
|
|
25
|
+
|
|
26
|
+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
|
|
27
|
+
@prefix sh: <http://www.w3.org/ns/shacl#>.
|
|
28
|
+
|
|
29
|
+
@prefix o-steps: <https://fast.ilabt.imec.be/ns/oslo-steps#>.
|
|
30
|
+
@prefix o-persoon: <https://data.vlaanderen.be/ns/persoon#>.
|
|
31
|
+
|
|
32
|
+
@prefix ex: <https://example.org/vocab#>.
|
|
33
|
+
@prefix cost: <https://example.org/cost#>.
|
|
34
|
+
@prefix state: <https://example.org/states#>.
|
|
35
|
+
@prefix step: <https://example.org/steps#>.
|
|
36
|
+
@prefix shape: <https://example.org/shapes#>.
|
|
37
|
+
|
|
38
|
+
# ----------------------------------------------------------------------
|
|
39
|
+
# 1) OSLO-STEPS-like INPUT
|
|
40
|
+
# We model the user situation with a fixed “signature” of 5 booleans:
|
|
41
|
+
# ex:personalInfoProvided
|
|
42
|
+
# ex:movingDataProvided
|
|
43
|
+
# ex:newAddressProvided
|
|
44
|
+
# ex:addressChangeDeclared
|
|
45
|
+
# ex:confirmationOfAddressChange
|
|
46
|
+
# ----------------------------------------------------------------------
|
|
47
|
+
# States
|
|
48
|
+
state:s0 a o-steps:State; rdfs:label "Start"@en; o-steps:hasStateShape shape:s0Shape.
|
|
49
|
+
state:s1 a o-steps:State; rdfs:label "Personal info provided"@en;o-steps:hasStateShape shape:s1Shape.
|
|
50
|
+
state:s2 a o-steps:State; rdfs:label "Moving data provided"@en; o-steps:hasStateShape shape:s2Shape.
|
|
51
|
+
state:s3 a o-steps:State; rdfs:label "New address provided"@en; o-steps:hasStateShape shape:s3Shape.
|
|
52
|
+
state:s4 a o-steps:State; rdfs:label "Declared"@en; o-steps:hasStateShape shape:s4Shape.
|
|
53
|
+
state:s5 a o-steps:State; rdfs:label "Confirmed"@en; o-steps:hasStateShape shape:s5Shape.
|
|
54
|
+
|
|
55
|
+
# StateShapes (each shape defines the full signature using 5 property shapes)
|
|
56
|
+
shape:s0Shape a o-steps:StateShape; sh:targetClass o-persoon:Inwoner;
|
|
57
|
+
sh:property shape:s0PI, shape:s0MD, shape:s0NA, shape:s0DECL, shape:s0CONF.
|
|
58
|
+
shape:s1Shape a o-steps:StateShape; sh:targetClass o-persoon:Inwoner;
|
|
59
|
+
sh:property shape:s1PI, shape:s1MD, shape:s1NA, shape:s1DECL, shape:s1CONF.
|
|
60
|
+
shape:s2Shape a o-steps:StateShape; sh:targetClass o-persoon:Inwoner;
|
|
61
|
+
sh:property shape:s2PI, shape:s2MD, shape:s2NA, shape:s2DECL, shape:s2CONF.
|
|
62
|
+
shape:s3Shape a o-steps:StateShape; sh:targetClass o-persoon:Inwoner;
|
|
63
|
+
sh:property shape:s3PI, shape:s3MD, shape:s3NA, shape:s3DECL, shape:s3CONF.
|
|
64
|
+
shape:s4Shape a o-steps:StateShape; sh:targetClass o-persoon:Inwoner;
|
|
65
|
+
sh:property shape:s4PI, shape:s4MD, shape:s4NA, shape:s4DECL, shape:s4CONF.
|
|
66
|
+
shape:s5Shape a o-steps:StateShape; sh:targetClass o-persoon:Inwoner;
|
|
67
|
+
sh:property shape:s5PI, shape:s5MD, shape:s5NA, shape:s5DECL, shape:s5CONF.
|
|
68
|
+
|
|
69
|
+
# S0: all false
|
|
70
|
+
shape:s0PI a sh:PropertyShape; sh:path ex:personalInfoProvided; sh:hasValue false; sh:minCount 1.
|
|
71
|
+
shape:s0MD a sh:PropertyShape; sh:path ex:movingDataProvided; sh:hasValue false; sh:minCount 1.
|
|
72
|
+
shape:s0NA a sh:PropertyShape; sh:path ex:newAddressProvided; sh:hasValue false; sh:minCount 1.
|
|
73
|
+
shape:s0DECL a sh:PropertyShape; sh:path ex:addressChangeDeclared; sh:hasValue false; sh:minCount 1.
|
|
74
|
+
shape:s0CONF a sh:PropertyShape; sh:path ex:confirmationOfAddressChange; sh:hasValue false; sh:minCount 1.
|
|
75
|
+
|
|
76
|
+
# S1: PI true
|
|
77
|
+
shape:s1PI a sh:PropertyShape; sh:path ex:personalInfoProvided; sh:hasValue true; sh:minCount 1.
|
|
78
|
+
shape:s1MD a sh:PropertyShape; sh:path ex:movingDataProvided; sh:hasValue false; sh:minCount 1.
|
|
79
|
+
shape:s1NA a sh:PropertyShape; sh:path ex:newAddressProvided; sh:hasValue false; sh:minCount 1.
|
|
80
|
+
shape:s1DECL a sh:PropertyShape; sh:path ex:addressChangeDeclared; sh:hasValue false; sh:minCount 1.
|
|
81
|
+
shape:s1CONF a sh:PropertyShape; sh:path ex:confirmationOfAddressChange; sh:hasValue false; sh:minCount 1.
|
|
82
|
+
|
|
83
|
+
# S2: PI true, MD true
|
|
84
|
+
shape:s2PI a sh:PropertyShape; sh:path ex:personalInfoProvided; sh:hasValue true; sh:minCount 1.
|
|
85
|
+
shape:s2MD a sh:PropertyShape; sh:path ex:movingDataProvided; sh:hasValue true; sh:minCount 1.
|
|
86
|
+
shape:s2NA a sh:PropertyShape; sh:path ex:newAddressProvided; sh:hasValue false; sh:minCount 1.
|
|
87
|
+
shape:s2DECL a sh:PropertyShape; sh:path ex:addressChangeDeclared; sh:hasValue false; sh:minCount 1.
|
|
88
|
+
shape:s2CONF a sh:PropertyShape; sh:path ex:confirmationOfAddressChange; sh:hasValue false; sh:minCount 1.
|
|
89
|
+
|
|
90
|
+
# S3: PI true, MD true, NA true
|
|
91
|
+
shape:s3PI a sh:PropertyShape; sh:path ex:personalInfoProvided; sh:hasValue true; sh:minCount 1.
|
|
92
|
+
shape:s3MD a sh:PropertyShape; sh:path ex:movingDataProvided; sh:hasValue true; sh:minCount 1.
|
|
93
|
+
shape:s3NA a sh:PropertyShape; sh:path ex:newAddressProvided; sh:hasValue true; sh:minCount 1.
|
|
94
|
+
shape:s3DECL a sh:PropertyShape; sh:path ex:addressChangeDeclared; sh:hasValue false; sh:minCount 1.
|
|
95
|
+
shape:s3CONF a sh:PropertyShape; sh:path ex:confirmationOfAddressChange; sh:hasValue false; sh:minCount 1.
|
|
96
|
+
|
|
97
|
+
# S4: declared true
|
|
98
|
+
shape:s4PI a sh:PropertyShape; sh:path ex:personalInfoProvided; sh:hasValue true; sh:minCount 1.
|
|
99
|
+
shape:s4MD a sh:PropertyShape; sh:path ex:movingDataProvided; sh:hasValue true; sh:minCount 1.
|
|
100
|
+
shape:s4NA a sh:PropertyShape; sh:path ex:newAddressProvided; sh:hasValue true; sh:minCount 1.
|
|
101
|
+
shape:s4DECL a sh:PropertyShape; sh:path ex:addressChangeDeclared; sh:hasValue true; sh:minCount 1.
|
|
102
|
+
shape:s4CONF a sh:PropertyShape; sh:path ex:confirmationOfAddressChange; sh:hasValue false; sh:minCount 1.
|
|
103
|
+
|
|
104
|
+
# S5: confirmed true
|
|
105
|
+
shape:s5PI a sh:PropertyShape; sh:path ex:personalInfoProvided; sh:hasValue true; sh:minCount 1.
|
|
106
|
+
shape:s5MD a sh:PropertyShape; sh:path ex:movingDataProvided; sh:hasValue true; sh:minCount 1.
|
|
107
|
+
shape:s5NA a sh:PropertyShape; sh:path ex:newAddressProvided; sh:hasValue true; sh:minCount 1.
|
|
108
|
+
shape:s5DECL a sh:PropertyShape; sh:path ex:addressChangeDeclared; sh:hasValue true; sh:minCount 1.
|
|
109
|
+
shape:s5CONF a sh:PropertyShape; sh:path ex:confirmationOfAddressChange; sh:hasValue true; sh:minCount 1.
|
|
110
|
+
|
|
111
|
+
# Steps (branching alternatives)
|
|
112
|
+
step:providePersonalInfoOnline a o-steps:Step;
|
|
113
|
+
o-steps:requiresState state:s0; o-steps:producesState state:s1;
|
|
114
|
+
cost:duration 30.0; cost:monetaryCost 0.0; cost:success 0.99; cost:usersatifaction 0.95.
|
|
115
|
+
|
|
116
|
+
step:providePersonalInfoDesk a o-steps:Step;
|
|
117
|
+
o-steps:requiresState state:s0; o-steps:producesState state:s1;
|
|
118
|
+
cost:duration 120.0; cost:monetaryCost 0.0; cost:success 0.995; cost:usersatifaction 0.85.
|
|
119
|
+
|
|
120
|
+
step:provideMovingDataOnline a o-steps:Step;
|
|
121
|
+
o-steps:requiresState state:s1; o-steps:producesState state:s2;
|
|
122
|
+
cost:duration 45.0; cost:monetaryCost 2.0; cost:success 0.99; cost:usersatifaction 0.92.
|
|
123
|
+
|
|
124
|
+
step:provideMovingDataDesk a o-steps:Step;
|
|
125
|
+
o-steps:requiresState state:s1; o-steps:producesState state:s2;
|
|
126
|
+
cost:duration 90.0; cost:monetaryCost 2.0; cost:success 0.995; cost:usersatifaction 0.88.
|
|
127
|
+
|
|
128
|
+
step:provideNewAddress a o-steps:Step;
|
|
129
|
+
o-steps:requiresState state:s2; o-steps:producesState state:s3;
|
|
130
|
+
cost:duration 30.0; cost:monetaryCost 0.0; cost:success 0.99; cost:usersatifaction 0.93.
|
|
131
|
+
|
|
132
|
+
step:declareAddressChangeOnline a o-steps:Step;
|
|
133
|
+
o-steps:requiresState state:s3; o-steps:producesState state:s4;
|
|
134
|
+
cost:duration 60.0; cost:monetaryCost 0.0; cost:success 0.98; cost:usersatifaction 0.90.
|
|
135
|
+
|
|
136
|
+
step:declareAddressChangePostal a o-steps:Step;
|
|
137
|
+
o-steps:requiresState state:s3; o-steps:producesState state:s4;
|
|
138
|
+
cost:duration 90.0; cost:monetaryCost 2.0; cost:success 0.95; cost:usersatifaction 0.88.
|
|
139
|
+
|
|
140
|
+
step:confirmAddressChangePolice a o-steps:Step;
|
|
141
|
+
o-steps:requiresState state:s4; o-steps:producesState state:s5;
|
|
142
|
+
cost:duration 20160.0; cost:monetaryCost 0.0; cost:success 0.98; cost:usersatifaction 0.97.
|
|
143
|
+
|
|
144
|
+
step:confirmAddressChangeCityHall a o-steps:Step;
|
|
145
|
+
o-steps:requiresState state:s4; o-steps:producesState state:s5;
|
|
146
|
+
cost:duration 10080.0; cost:monetaryCost 0.0; cost:success 0.90; cost:usersatifaction 0.85.
|
|
147
|
+
|
|
148
|
+
# --------------------------
|
|
149
|
+
# 2) TRANSLATION (docs-like)
|
|
150
|
+
# --------------------------
|
|
151
|
+
# 2.1) StateShape -> State constraints: (targetClass, path, value)
|
|
152
|
+
{ ?STATE :constraint (?TARGET ?PATH ?VALUE). } <=
|
|
153
|
+
{
|
|
154
|
+
?STATE o-steps:hasStateShape ?SHAPE.
|
|
155
|
+
?SHAPE sh:targetClass ?TARGET.
|
|
156
|
+
?SHAPE sh:property ?PS.
|
|
157
|
+
?PS sh:path ?PATH.
|
|
158
|
+
?PS sh:hasValue ?VALUE.
|
|
159
|
+
?PS sh:minCount 1.
|
|
160
|
+
}.
|
|
161
|
+
|
|
162
|
+
# 2.2) Step -> internal gps:description transition (compiled)
|
|
163
|
+
# IMPORTANT: we use ?x inside the formulas so they unify (no existential ?x).
|
|
164
|
+
{
|
|
165
|
+
ex:movemap gps:description
|
|
166
|
+
(
|
|
167
|
+
{ ?x a ?T.
|
|
168
|
+
?x ex:personalInfoProvided ?PI1.
|
|
169
|
+
?x ex:movingDataProvided ?MD1.
|
|
170
|
+
?x ex:newAddressProvided ?NA1.
|
|
171
|
+
?x ex:addressChangeDeclared ?DECL1.
|
|
172
|
+
?x ex:confirmationOfAddressChange ?CONF1.
|
|
173
|
+
}
|
|
174
|
+
true
|
|
175
|
+
{ ?x a ?T.
|
|
176
|
+
?x ex:personalInfoProvided ?PI2.
|
|
177
|
+
?x ex:movingDataProvided ?MD2.
|
|
178
|
+
?x ex:newAddressProvided ?NA2.
|
|
179
|
+
?x ex:addressChangeDeclared ?DECL2.
|
|
180
|
+
?x ex:confirmationOfAddressChange ?CONF2.
|
|
181
|
+
}
|
|
182
|
+
?STEP
|
|
183
|
+
?DUR ?MC ?SUC ?SAT
|
|
184
|
+
).
|
|
185
|
+
} <=
|
|
186
|
+
{
|
|
187
|
+
?STEP o-steps:requiresState ?REQ.
|
|
188
|
+
?STEP o-steps:producesState ?PROD.
|
|
189
|
+
|
|
190
|
+
?REQ :constraint (?T ex:personalInfoProvided ?PI1).
|
|
191
|
+
?REQ :constraint (?T ex:movingDataProvided ?MD1).
|
|
192
|
+
?REQ :constraint (?T ex:newAddressProvided ?NA1).
|
|
193
|
+
?REQ :constraint (?T ex:addressChangeDeclared ?DECL1).
|
|
194
|
+
?REQ :constraint (?T ex:confirmationOfAddressChange ?CONF1).
|
|
195
|
+
|
|
196
|
+
?PROD :constraint (?T ex:personalInfoProvided ?PI2).
|
|
197
|
+
?PROD :constraint (?T ex:movingDataProvided ?MD2).
|
|
198
|
+
?PROD :constraint (?T ex:newAddressProvided ?NA2).
|
|
199
|
+
?PROD :constraint (?T ex:addressChangeDeclared ?DECL2).
|
|
200
|
+
?PROD :constraint (?T ex:confirmationOfAddressChange ?CONF2).
|
|
201
|
+
|
|
202
|
+
?STEP cost:duration ?DUR.
|
|
203
|
+
?STEP cost:monetaryCost ?MC.
|
|
204
|
+
?STEP cost:success ?SUC.
|
|
205
|
+
?STEP cost:usersatifaction ?SAT.
|
|
206
|
+
}.
|
|
207
|
+
|
|
208
|
+
# --------
|
|
209
|
+
# 3) START
|
|
210
|
+
# --------
|
|
211
|
+
:bob :start
|
|
212
|
+
{
|
|
213
|
+
?x a o-persoon:Inwoner.
|
|
214
|
+
?x ex:personalInfoProvided false.
|
|
215
|
+
?x ex:movingDataProvided false.
|
|
216
|
+
?x ex:newAddressProvided false.
|
|
217
|
+
?x ex:addressChangeDeclared false.
|
|
218
|
+
?x ex:confirmationOfAddressChange false.
|
|
219
|
+
}.
|
|
220
|
+
|
|
221
|
+
# ----------------------------------------------------------
|
|
222
|
+
# 4) PLANNER
|
|
223
|
+
# Path tuple:
|
|
224
|
+
# (From To Actions Dur Cost Success Sat)
|
|
225
|
+
# ----------------------------------------------------------
|
|
226
|
+
# Base: one step
|
|
227
|
+
{ (?From ?To (?Act) ?Dur ?Cost ?Suc ?Sat) :path true. }
|
|
228
|
+
<=
|
|
229
|
+
{
|
|
230
|
+
ex:movemap gps:description (?From true ?To ?Act ?Dur ?Cost ?Suc ?Sat).
|
|
231
|
+
}.
|
|
232
|
+
|
|
233
|
+
# Recursive: step + rest (aggregate)
|
|
234
|
+
{ (?From ?To ?Acts ?Dur ?Cost ?Suc ?Sat) :path true. }
|
|
235
|
+
<=
|
|
236
|
+
{
|
|
237
|
+
ex:movemap gps:description (?From true ?Mid ?Act ?Dur1 ?Cost1 ?Suc1 ?Sat1).
|
|
238
|
+
|
|
239
|
+
(?Mid ?To ?Rest ?Dur2 ?Cost2 ?Suc2 ?Sat2) :path true.
|
|
240
|
+
|
|
241
|
+
((?Act) ?Rest) list:append ?Acts.
|
|
242
|
+
(?Dur1 ?Dur2) math:sum ?Dur.
|
|
243
|
+
(?Cost1 ?Cost2) math:sum ?Cost.
|
|
244
|
+
(?Suc1 ?Suc2) math:product ?Suc.
|
|
245
|
+
(?Sat1 ?Sat2) math:product ?Sat.
|
|
246
|
+
}.
|
|
247
|
+
|
|
248
|
+
# OSLO-like wrapper with pruning limits applied at query-time (simple + predictable)
|
|
249
|
+
{
|
|
250
|
+
:scope gps:findpath
|
|
251
|
+
(
|
|
252
|
+
?GOAL
|
|
253
|
+
?PATH
|
|
254
|
+
?DURATION
|
|
255
|
+
?MONETARYCOST
|
|
256
|
+
?SUCCESS
|
|
257
|
+
?SATISFACTION
|
|
258
|
+
(?DL ?CL ?SL ?AL)
|
|
259
|
+
).
|
|
260
|
+
} <=
|
|
261
|
+
{
|
|
262
|
+
:bob :start ?START.
|
|
263
|
+
|
|
264
|
+
(?START ?GOAL ?PATH ?DURATION ?MONETARYCOST ?SUCCESS ?SATISFACTION) :path true.
|
|
265
|
+
|
|
266
|
+
# pruning (strict)
|
|
267
|
+
?DURATION math:lessThan ?DL.
|
|
268
|
+
?MONETARYCOST math:lessThan ?CL.
|
|
269
|
+
?SUCCESS math:greaterThan ?SL.
|
|
270
|
+
?SATISFACTION math:greaterThan ?AL.
|
|
271
|
+
}.
|
|
272
|
+
|
|
273
|
+
# -----------------------------------------------------------------------
|
|
274
|
+
# 5) GOAL QUERY -> OUTPUT
|
|
275
|
+
# (Fully specified goal formula, so formula-term unification is exact)
|
|
276
|
+
# -----------------------------------------------------------------------
|
|
277
|
+
{
|
|
278
|
+
:scope gps:findpath
|
|
279
|
+
(
|
|
280
|
+
{
|
|
281
|
+
?x a o-persoon:Inwoner.
|
|
282
|
+
?x ex:personalInfoProvided true.
|
|
283
|
+
?x ex:movingDataProvided true.
|
|
284
|
+
?x ex:newAddressProvided true.
|
|
285
|
+
?x ex:addressChangeDeclared true.
|
|
286
|
+
?x ex:confirmationOfAddressChange true.
|
|
287
|
+
}
|
|
288
|
+
?PATH
|
|
289
|
+
?DUR
|
|
290
|
+
?COST
|
|
291
|
+
?SUC
|
|
292
|
+
?SAT
|
|
293
|
+
(
|
|
294
|
+
40320.0 # duration limit (4 weeks)
|
|
295
|
+
20.0 # monetary cost limit
|
|
296
|
+
0.80 # success lower bound
|
|
297
|
+
0.65 # satisfaction lower bound (0.8 is too strict for product)
|
|
298
|
+
)
|
|
299
|
+
).
|
|
300
|
+
}
|
|
301
|
+
=>
|
|
302
|
+
{
|
|
303
|
+
:bob gps:path (?PATH ?DUR ?COST ?SUC ?SAT).
|
|
304
|
+
}.
|
|
305
|
+
|