eyeling 1.5.36 → 1.5.38

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.
@@ -0,0 +1,327 @@
1
+ # =====================================================================================
2
+ # OSLO-STEPS workflow composition — “Library / Scholarly access” (translation pipeline)
3
+ #
4
+ # Story (toy):
5
+ # A scholar wants to obtain access to a scholarly article (PDF).
6
+ #
7
+ # Pipeline style (like OSLO-STEPS docs):
8
+ # 1) Define o-steps:State + SHACL StateShapes (each state is a full signature)
9
+ # 2) Define o-steps:Step with requiresState / producesState + costs
10
+ # 3) Translate:
11
+ # - StateShape -> State constraints (targetClass, path, value)
12
+ # - Step + (required/produced) States -> gps:description transitions
13
+ # 4) Compose transitions into a plan — terminates because the state graph is a DAG
14
+ #
15
+ # Run:
16
+ # npx eyeling examples/oslo-steps-library-scholarly.n3
17
+ #
18
+ # Output:
19
+ # :alice gps:path ( (step:... step:... ...) duration cost success satisfaction ).
20
+ # =====================================================================================
21
+
22
+ @prefix math: <http://www.w3.org/2000/10/swap/math#>.
23
+ @prefix list: <http://www.w3.org/2000/10/swap/list#>.
24
+ @prefix gps: <https://eyereasoner.github.io/eye/reasoning/gps/gps-schema#>.
25
+ @prefix : <https://eyereasoner.github.io/eye/reasoning#>.
26
+
27
+ @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
28
+ @prefix sh: <http://www.w3.org/ns/shacl#>.
29
+ @prefix foaf: <http://xmlns.com/foaf/0.1/>.
30
+
31
+ @prefix o-steps: <https://fast.ilabt.imec.be/ns/oslo-steps#>.
32
+
33
+ @prefix ex: <https://example.org/vocab#>.
34
+ @prefix cost: <https://example.org/cost#>.
35
+ @prefix state: <https://example.org/states#>.
36
+ @prefix step: <https://example.org/steps#>.
37
+ @prefix shape: <https://example.org/shapes#>.
38
+
39
+ # ---------------------------------------------------------------------
40
+ # 1) OSLO-STEPS-like INPUT
41
+ #
42
+ # State signature booleans (5):
43
+ # ex:identityVerified (can the scholar authenticate?)
44
+ # ex:affiliationVerified (is membership/affiliation confirmed?)
45
+ # ex:requestSubmitted (has the access request been submitted?)
46
+ # ex:itemLocated (did we locate a route to the item?)
47
+ # ex:accessGranted (final: scholar can access/download)
48
+ # ---------------------------------------------------------------------
49
+ # States (each has a StateShape with a full 5-boolean signature)
50
+ state:s0 a o-steps:State; rdfs:label "Start"@en; o-steps:hasStateShape shape:s0Shape.
51
+ state:s1 a o-steps:State; rdfs:label "Identity verified"@en; o-steps:hasStateShape shape:s1Shape.
52
+ state:s2 a o-steps:State; rdfs:label "Affiliation verified"@en; o-steps:hasStateShape shape:s2Shape.
53
+ state:s3 a o-steps:State; rdfs:label "Request submitted"@en; o-steps:hasStateShape shape:s3Shape.
54
+ state:s4 a o-steps:State; rdfs:label "Item located"@en; o-steps:hasStateShape shape:s4Shape.
55
+ state:s5 a o-steps:State; rdfs:label "Access granted"@en; o-steps:hasStateShape shape:s5Shape.
56
+
57
+ # StateShapes
58
+ shape:s0Shape a o-steps:StateShape; sh:targetClass foaf:Person;
59
+ sh:property shape:s0ID, shape:s0AFF, shape:s0REQ, shape:s0LOC, shape:s0ACC.
60
+ shape:s1Shape a o-steps:StateShape; sh:targetClass foaf:Person;
61
+ sh:property shape:s1ID, shape:s1AFF, shape:s1REQ, shape:s1LOC, shape:s1ACC.
62
+ shape:s2Shape a o-steps:StateShape; sh:targetClass foaf:Person;
63
+ sh:property shape:s2ID, shape:s2AFF, shape:s2REQ, shape:s2LOC, shape:s2ACC.
64
+ shape:s3Shape a o-steps:StateShape; sh:targetClass foaf:Person;
65
+ sh:property shape:s3ID, shape:s3AFF, shape:s3REQ, shape:s3LOC, shape:s3ACC.
66
+ shape:s4Shape a o-steps:StateShape; sh:targetClass foaf:Person;
67
+ sh:property shape:s4ID, shape:s4AFF, shape:s4REQ, shape:s4LOC, shape:s4ACC.
68
+ shape:s5Shape a o-steps:StateShape; sh:targetClass foaf:Person;
69
+ sh:property shape:s5ID, shape:s5AFF, shape:s5REQ, shape:s5LOC, shape:s5ACC.
70
+
71
+ # s0: all false
72
+ shape:s0ID a sh:PropertyShape; sh:path ex:identityVerified; sh:hasValue false; sh:minCount 1.
73
+ shape:s0AFF a sh:PropertyShape; sh:path ex:affiliationVerified; sh:hasValue false; sh:minCount 1.
74
+ shape:s0REQ a sh:PropertyShape; sh:path ex:requestSubmitted; sh:hasValue false; sh:minCount 1.
75
+ shape:s0LOC a sh:PropertyShape; sh:path ex:itemLocated; sh:hasValue false; sh:minCount 1.
76
+ shape:s0ACC a sh:PropertyShape; sh:path ex:accessGranted; sh:hasValue false; sh:minCount 1.
77
+
78
+ # s1: identity true
79
+ shape:s1ID a sh:PropertyShape; sh:path ex:identityVerified; sh:hasValue true; sh:minCount 1.
80
+ shape:s1AFF a sh:PropertyShape; sh:path ex:affiliationVerified; sh:hasValue false; sh:minCount 1.
81
+ shape:s1REQ a sh:PropertyShape; sh:path ex:requestSubmitted; sh:hasValue false; sh:minCount 1.
82
+ shape:s1LOC a sh:PropertyShape; sh:path ex:itemLocated; sh:hasValue false; sh:minCount 1.
83
+ shape:s1ACC a sh:PropertyShape; sh:path ex:accessGranted; sh:hasValue false; sh:minCount 1.
84
+
85
+ # s2: identity true, affiliation true
86
+ shape:s2ID a sh:PropertyShape; sh:path ex:identityVerified; sh:hasValue true; sh:minCount 1.
87
+ shape:s2AFF a sh:PropertyShape; sh:path ex:affiliationVerified; sh:hasValue true; sh:minCount 1.
88
+ shape:s2REQ a sh:PropertyShape; sh:path ex:requestSubmitted; sh:hasValue false; sh:minCount 1.
89
+ shape:s2LOC a sh:PropertyShape; sh:path ex:itemLocated; sh:hasValue false; sh:minCount 1.
90
+ shape:s2ACC a sh:PropertyShape; sh:path ex:accessGranted; sh:hasValue false; sh:minCount 1.
91
+
92
+ # s3: request submitted
93
+ shape:s3ID a sh:PropertyShape; sh:path ex:identityVerified; sh:hasValue true; sh:minCount 1.
94
+ shape:s3AFF a sh:PropertyShape; sh:path ex:affiliationVerified; sh:hasValue true; sh:minCount 1.
95
+ shape:s3REQ a sh:PropertyShape; sh:path ex:requestSubmitted; sh:hasValue true; sh:minCount 1.
96
+ shape:s3LOC a sh:PropertyShape; sh:path ex:itemLocated; sh:hasValue false; sh:minCount 1.
97
+ shape:s3ACC a sh:PropertyShape; sh:path ex:accessGranted; sh:hasValue false; sh:minCount 1.
98
+
99
+ # s4: item located
100
+ shape:s4ID a sh:PropertyShape; sh:path ex:identityVerified; sh:hasValue true; sh:minCount 1.
101
+ shape:s4AFF a sh:PropertyShape; sh:path ex:affiliationVerified; sh:hasValue true; sh:minCount 1.
102
+ shape:s4REQ a sh:PropertyShape; sh:path ex:requestSubmitted; sh:hasValue true; sh:minCount 1.
103
+ shape:s4LOC a sh:PropertyShape; sh:path ex:itemLocated; sh:hasValue true; sh:minCount 1.
104
+ shape:s4ACC a sh:PropertyShape; sh:path ex:accessGranted; sh:hasValue false; sh:minCount 1.
105
+
106
+ # s5: access granted
107
+ shape:s5ID a sh:PropertyShape; sh:path ex:identityVerified; sh:hasValue true; sh:minCount 1.
108
+ shape:s5AFF a sh:PropertyShape; sh:path ex:affiliationVerified; sh:hasValue true; sh:minCount 1.
109
+ shape:s5REQ a sh:PropertyShape; sh:path ex:requestSubmitted; sh:hasValue true; sh:minCount 1.
110
+ shape:s5LOC a sh:PropertyShape; sh:path ex:itemLocated; sh:hasValue true; sh:minCount 1.
111
+ shape:s5ACC a sh:PropertyShape; sh:path ex:accessGranted; sh:hasValue true; sh:minCount 1.
112
+
113
+ # Steps + costs (branching, but still a DAG)
114
+ # Costs:
115
+ # cost:duration (minutes)
116
+ # cost:monetaryCost (arbitrary units)
117
+ # cost:success (0..1)
118
+ # cost:usersatifaction (0..1) # keep the same spelling you used elsewhere
119
+
120
+ # s0 -> s1 (identity verification)
121
+ step:verifyIdentitySSO a o-steps:Step;
122
+ rdfs:label "Verify identity (SSO)"@en;
123
+ o-steps:requiresState state:s0; o-steps:producesState state:s1;
124
+ cost:duration 2.0; cost:monetaryCost 0.0; cost:success 0.97; cost:usersatifaction 0.97.
125
+
126
+ step:verifyIdentityDesk a o-steps:Step;
127
+ rdfs:label "Verify identity (library desk)"@en;
128
+ o-steps:requiresState state:s0; o-steps:producesState state:s1;
129
+ cost:duration 20.0; cost:monetaryCost 0.0; cost:success 0.995; cost:usersatifaction 0.85.
130
+
131
+ # s1 -> s2 (affiliation / membership)
132
+ step:verifyAffiliationAuto a o-steps:Step;
133
+ rdfs:label "Verify affiliation (automatic)"@en;
134
+ o-steps:requiresState state:s1; o-steps:producesState state:s2;
135
+ cost:duration 3.0; cost:monetaryCost 0.0; cost:success 0.98; cost:usersatifaction 0.95.
136
+
137
+ step:verifyAffiliationManual a o-steps:Step;
138
+ rdfs:label "Verify affiliation (manual approval)"@en;
139
+ o-steps:requiresState state:s1; o-steps:producesState state:s2;
140
+ cost:duration 240.0; cost:monetaryCost 0.0; cost:success 0.995; cost:usersatifaction 0.80.
141
+
142
+ # s2 -> s3 (submit request)
143
+ step:submitRequestSelfService a o-steps:Step;
144
+ rdfs:label "Submit request (self-service form)"@en;
145
+ o-steps:requiresState state:s2; o-steps:producesState state:s3;
146
+ cost:duration 5.0; cost:monetaryCost 0.0; cost:success 0.97; cost:usersatifaction 0.94.
147
+
148
+ step:submitRequestLibrarian a o-steps:Step;
149
+ rdfs:label "Submit request (with librarian)"@en;
150
+ o-steps:requiresState state:s2; o-steps:producesState state:s3;
151
+ cost:duration 15.0; cost:monetaryCost 0.0; cost:success 0.99; cost:usersatifaction 0.90.
152
+
153
+ # s3 -> s4 (locate item / route)
154
+ step:locateViaCatalogue a o-steps:Step;
155
+ rdfs:label "Locate item (catalogue + resolver)"@en;
156
+ o-steps:requiresState state:s3; o-steps:producesState state:s4;
157
+ cost:duration 2.0; cost:monetaryCost 0.0; cost:success 0.96; cost:usersatifaction 0.92.
158
+
159
+ step:locateViaDiscovery a o-steps:Step;
160
+ rdfs:label "Locate item (discovery index)"@en;
161
+ o-steps:requiresState state:s3; o-steps:producesState state:s4;
162
+ cost:duration 3.0; cost:monetaryCost 0.0; cost:success 0.97; cost:usersatifaction 0.93.
163
+
164
+ # s4 -> s5 (grant access)
165
+ step:grantAccessOpenAccess a o-steps:Step;
166
+ rdfs:label "Grant access (open access)"@en;
167
+ o-steps:requiresState state:s4; o-steps:producesState state:s5;
168
+ cost:duration 1.0; cost:monetaryCost 0.0; cost:success 0.92; cost:usersatifaction 0.97.
169
+
170
+ step:grantAccessSubscription a o-steps:Step;
171
+ rdfs:label "Grant access (subscription)"@en;
172
+ o-steps:requiresState state:s4; o-steps:producesState state:s5;
173
+ cost:duration 2.0; cost:monetaryCost 0.5; cost:success 0.97; cost:usersatifaction 0.94.
174
+
175
+ step:grantAccessInterlibraryLoan a o-steps:Step;
176
+ rdfs:label "Grant access (interlibrary loan)"@en;
177
+ o-steps:requiresState state:s4; o-steps:producesState state:s5;
178
+ cost:duration 2880.0; cost:monetaryCost 5.0; cost:success 0.985; cost:usersatifaction 0.80.
179
+
180
+ # -----------------------
181
+ # 2) TRANSLATION PIPELINE
182
+ # -----------------------
183
+ # 2.1) StateShape -> State constraints (targetClass, path, value)
184
+ { ?STATE :constraint (?TARGET ?PATH ?VALUE). } <=
185
+ {
186
+ ?STATE o-steps:hasStateShape ?SHAPE.
187
+ ?SHAPE sh:targetClass ?TARGET.
188
+ ?SHAPE sh:property ?PS.
189
+ ?PS sh:path ?PATH.
190
+ ?PS sh:hasValue ?VALUE.
191
+ ?PS sh:minCount 1.
192
+ }.
193
+
194
+ # 2.2) Step -> internal gps:description transition (compiled)
195
+ # We compile FROM/TO formulas from required/produced state constraints.
196
+ {
197
+ ex:libmap gps:description
198
+ (
199
+ { ?x a ?T.
200
+ ?x ex:identityVerified ?ID1.
201
+ ?x ex:affiliationVerified ?AFF1.
202
+ ?x ex:requestSubmitted ?REQ1.
203
+ ?x ex:itemLocated ?LOC1.
204
+ ?x ex:accessGranted ?ACC1.
205
+ }
206
+ true
207
+ { ?x a ?T.
208
+ ?x ex:identityVerified ?ID2.
209
+ ?x ex:affiliationVerified ?AFF2.
210
+ ?x ex:requestSubmitted ?REQ2.
211
+ ?x ex:itemLocated ?LOC2.
212
+ ?x ex:accessGranted ?ACC2.
213
+ }
214
+ ?STEP
215
+ ?DUR ?MC ?SUC ?SAT
216
+ ).
217
+ } <=
218
+ {
219
+ ?STEP o-steps:requiresState ?REQSTATE.
220
+ ?STEP o-steps:producesState ?PRODSTATE.
221
+
222
+ ?REQSTATE :constraint (?T ex:identityVerified ?ID1).
223
+ ?REQSTATE :constraint (?T ex:affiliationVerified ?AFF1).
224
+ ?REQSTATE :constraint (?T ex:requestSubmitted ?REQ1).
225
+ ?REQSTATE :constraint (?T ex:itemLocated ?LOC1).
226
+ ?REQSTATE :constraint (?T ex:accessGranted ?ACC1).
227
+
228
+ ?PRODSTATE :constraint (?T ex:identityVerified ?ID2).
229
+ ?PRODSTATE :constraint (?T ex:affiliationVerified ?AFF2).
230
+ ?PRODSTATE :constraint (?T ex:requestSubmitted ?REQ2).
231
+ ?PRODSTATE :constraint (?T ex:itemLocated ?LOC2).
232
+ ?PRODSTATE :constraint (?T ex:accessGranted ?ACC2).
233
+
234
+ ?STEP cost:duration ?DUR.
235
+ ?STEP cost:monetaryCost ?MC.
236
+ ?STEP cost:success ?SUC.
237
+ ?STEP cost:usersatifaction ?SAT.
238
+ }.
239
+
240
+ # --------------
241
+ # 3) START STATE
242
+ # --------------
243
+ :alice :start
244
+ {
245
+ ?x a foaf:Person.
246
+ ?x ex:identityVerified false.
247
+ ?x ex:affiliationVerified false.
248
+ ?x ex:requestSubmitted false.
249
+ ?x ex:itemLocated false.
250
+ ?x ex:accessGranted false.
251
+ }.
252
+
253
+ # ----------
254
+ # 4) PLANNER
255
+ # ----------
256
+ # Base: one step is a path
257
+ { (?From ?To (?Act) ?Dur ?Cost ?Suc ?Sat) :path true. }
258
+ <=
259
+ {
260
+ ex:libmap gps:description (?From true ?To ?Act ?Dur ?Cost ?Suc ?Sat).
261
+ }.
262
+
263
+ # Recursive: step + rest, aggregate
264
+ { (?From ?To ?Acts ?Dur ?Cost ?Suc ?Sat) :path true. }
265
+ <=
266
+ {
267
+ ex:libmap gps:description (?From true ?Mid ?Act ?Dur1 ?Cost1 ?Suc1 ?Sat1).
268
+ (?Mid ?To ?Rest ?Dur2 ?Cost2 ?Suc2 ?Sat2) :path true.
269
+
270
+ ((?Act) ?Rest) list:append ?Acts.
271
+ (?Dur1 ?Dur2) math:sum ?Dur.
272
+ (?Cost1 ?Cost2) math:sum ?Cost.
273
+ (?Suc1 ?Suc2) math:product ?Suc.
274
+ (?Sat1 ?Sat2) math:product ?Sat.
275
+ }.
276
+
277
+ # Wrapper: OSLO-like findpath with bounds
278
+ {
279
+ :scope gps:findpath
280
+ (
281
+ ?GOAL
282
+ ?PATH
283
+ ?DURATION
284
+ ?MONETARYCOST
285
+ ?SUCCESS
286
+ ?SATISFACTION
287
+ (?DL ?CL ?SL ?AL)
288
+ ).
289
+ } <=
290
+ {
291
+ :alice :start ?START.
292
+ (?START ?GOAL ?PATH ?DURATION ?MONETARYCOST ?SUCCESS ?SATISFACTION) :path true.
293
+
294
+ ?DURATION math:lessThan ?DL.
295
+ ?MONETARYCOST math:lessThan ?CL.
296
+ ?SUCCESS math:greaterThan ?SL.
297
+ ?SATISFACTION math:greaterThan ?AL.
298
+ }.
299
+
300
+ # -----------------------
301
+ # 5) GOAL QUERY -> OUTPUT
302
+ # -----------------------
303
+ {
304
+ :scope gps:findpath
305
+ (
306
+ {
307
+ ?x a foaf:Person.
308
+ ?x ex:identityVerified true.
309
+ ?x ex:affiliationVerified true.
310
+ ?x ex:requestSubmitted true.
311
+ ?x ex:itemLocated true.
312
+ ?x ex:accessGranted true.
313
+ }
314
+ ?PATH ?DUR ?COST ?SUC ?SAT
315
+ (
316
+ 5000.0 # duration limit (minutes)
317
+ 10.0 # monetary cost limit
318
+ 0.75 # success lower bound
319
+ 0.60 # satisfaction lower bound (product shrinks fast)
320
+ )
321
+ ).
322
+ }
323
+ =>
324
+ {
325
+ :alice gps:path (?PATH ?DUR ?COST ?SUC ?SAT).
326
+ }.
327
+
@@ -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
+