eyeling 1.5.37 → 1.5.39

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,38 @@
1
+ # =================================
2
+ # List iteration
3
+ # Example from Patrick Hochstenbach
4
+ # =================================
5
+
6
+ @prefix : <urn:example:> .
7
+ @prefix list: <http://www.w3.org/2000/10/swap/list#> .
8
+
9
+ :Let :param ( "Huey" "Dewey" "Louie" ) .
10
+
11
+ {
12
+ :Let :param ?X .
13
+
14
+ # For each in list X generate a new triple
15
+ # ?X a list
16
+ # ?Y variable or any
17
+ ?X list:iterate ?Y .
18
+
19
+ # E.g. this evaluates to true
20
+ ?X list:iterate ( 1 "Dewey" ) .
21
+
22
+ # We even capture the index
23
+ ?X list:iterate ( ?Z "Dewey" ) .
24
+ }
25
+ =>
26
+ {
27
+ ?X :iterate ?Y .
28
+ "Dewey" :hasIndex ?Z .
29
+ } .
30
+
31
+ {
32
+ ?X :iterate ?Y .
33
+ "Dewey" :hasIndex 1 .
34
+ }
35
+ =>
36
+ {
37
+ :test :is true .
38
+ } .
@@ -0,0 +1,288 @@
1
+ # =======================================================================================
2
+ # OSLO-STEPS — minimal “Library / Scholarly access” workflow composition example
3
+ #
4
+ # Purpose
5
+ # A compact, representative test case for Eyeling/EYE workflow composition in the
6
+ # OSLO-STEPS style, without SHACL or shape machinery.
7
+ #
8
+ # What it models
9
+ # A scholar (Alice) wants access to a scholarly item. The workflow progresses through
10
+ # five “state flags”:
11
+ # 1) identityVerified
12
+ # 2) affiliationVerified
13
+ # 3) requestSubmitted
14
+ # 4) itemLocated
15
+ # 5) accessGranted
16
+ #
17
+ # OSLO-STEPS core used
18
+ # - Each step is an o-steps:Step with:
19
+ # o-steps:requiresState (precondition state)
20
+ # o-steps:producesState (postcondition state)
21
+ # plus simple costs:
22
+ # cost:duration, cost:monetaryCost, cost:success, cost:usersatifaction
23
+ #
24
+ # State representation
25
+ # - Each “State” is stored as a quoted N3 formula term in state:si :formula { ... }.
26
+ # - We use var:x inside formulas as a stable placeholder to avoid variable-renaming
27
+ # explosions and to keep formula-term matching predictable.
28
+ #
29
+ # Compilation and planning
30
+ # - A small compiler turns each o-steps:Step into a gps:description transition:
31
+ # (FROM true TO STEP duration cost success satisfaction)
32
+ # - A minimal planner composes gps:description transitions into a gps:path by chaining
33
+ # them and aggregating metrics:
34
+ # duration + monetaryCost = sum
35
+ # success * satisfaction = product
36
+ # - No “fuel” bound is used here; termination is ensured because the workflow graph is
37
+ # acyclic (s0 -> s1 -> s2 -> s3 -> s4 -> s5) and has a finite number of alternatives.
38
+ #
39
+ # Output
40
+ # - Derives :alice gps:path ( ?Steps ?Duration ?Cost ?Success ?Satisfaction ).
41
+ #
42
+ # Run (examples)
43
+ # eye --quiet --nope --pass-only-new oslo-steps-library-scholarly-min.n3
44
+ # node eyeling.js oslo-steps-library-scholarly-min.n3
45
+ # =======================================================================================
46
+
47
+ @prefix math: <http://www.w3.org/2000/10/swap/math#>.
48
+ @prefix list: <http://www.w3.org/2000/10/swap/list#>.
49
+ @prefix gps: <https://eyereasoner.github.io/eye/reasoning/gps/gps-schema#>.
50
+ @prefix : <https://eyereasoner.github.io/eye/reasoning#>.
51
+
52
+ @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
53
+ @prefix var: <http://www.w3.org/2000/10/swap/var#>.
54
+ @prefix foaf: <http://xmlns.com/foaf/0.1/>.
55
+
56
+ @prefix o-steps: <https://fast.ilabt.imec.be/ns/oslo-steps#>.
57
+
58
+ @prefix ex: <https://example.org/vocab#>.
59
+ @prefix cost: <https://example.org/cost#>.
60
+ @prefix state: <https://example.org/states#>.
61
+ @prefix step: <https://example.org/steps#>.
62
+
63
+ # -----------------------------------------------------------------------------
64
+ # 1) States as formula terms (no SHACL)
65
+ #
66
+ # State signature booleans (5):
67
+ # ex:identityVerified (can the scholar authenticate?)
68
+ # ex:affiliationVerified (is membership/affiliation confirmed?)
69
+ # ex:requestSubmitted (has the access request been submitted?)
70
+ # ex:itemLocated (did we locate a route to the item?)
71
+ # ex:accessGranted (final: scholar can access/download)
72
+ # -----------------------------------------------------------------------------
73
+
74
+ state:s0 :formula {
75
+ var:x a foaf:Person.
76
+ var:x ex:identityVerified false.
77
+ var:x ex:affiliationVerified false.
78
+ var:x ex:requestSubmitted false.
79
+ var:x ex:itemLocated false.
80
+ var:x ex:accessGranted false.
81
+ }.
82
+
83
+ state:s1 :formula {
84
+ var:x a foaf:Person.
85
+ var:x ex:identityVerified true.
86
+ var:x ex:affiliationVerified false.
87
+ var:x ex:requestSubmitted false.
88
+ var:x ex:itemLocated false.
89
+ var:x ex:accessGranted false.
90
+ }.
91
+
92
+ state:s2 :formula {
93
+ var:x a foaf:Person.
94
+ var:x ex:identityVerified true.
95
+ var:x ex:affiliationVerified true.
96
+ var:x ex:requestSubmitted false.
97
+ var:x ex:itemLocated false.
98
+ var:x ex:accessGranted false.
99
+ }.
100
+
101
+ state:s3 :formula {
102
+ var:x a foaf:Person.
103
+ var:x ex:identityVerified true.
104
+ var:x ex:affiliationVerified true.
105
+ var:x ex:requestSubmitted true.
106
+ var:x ex:itemLocated false.
107
+ var:x ex:accessGranted false.
108
+ }.
109
+
110
+ state:s4 :formula {
111
+ var:x a foaf:Person.
112
+ var:x ex:identityVerified true.
113
+ var:x ex:affiliationVerified true.
114
+ var:x ex:requestSubmitted true.
115
+ var:x ex:itemLocated true.
116
+ var:x ex:accessGranted false.
117
+ }.
118
+
119
+ state:s5 :formula {
120
+ var:x a foaf:Person.
121
+ var:x ex:identityVerified true.
122
+ var:x ex:affiliationVerified true.
123
+ var:x ex:requestSubmitted true.
124
+ var:x ex:itemLocated true.
125
+ var:x ex:accessGranted true.
126
+ }.
127
+
128
+ # -----------------------------------------------------------------------------
129
+ # 2) Steps (OSLO-STEPS core) + costs
130
+ #
131
+ # Costs:
132
+ # cost:duration (minutes)
133
+ # cost:monetaryCost (arbitrary units)
134
+ # cost:success (0..1)
135
+ # cost:usersatifaction (0..1) (keep spelling consistent with earlier examples)
136
+ # -----------------------------------------------------------------------------
137
+
138
+ # s0 -> s1 (identity)
139
+ step:verifyIdentitySSO a o-steps:Step;
140
+ rdfs:label "Verify identity (SSO)"@en;
141
+ o-steps:requiresState state:s0; o-steps:producesState state:s1;
142
+ cost:duration 2.0; cost:monetaryCost 0.0; cost:success 0.97; cost:usersatifaction 0.97.
143
+
144
+ step:verifyIdentityDesk a o-steps:Step;
145
+ rdfs:label "Verify identity (library desk)"@en;
146
+ o-steps:requiresState state:s0; o-steps:producesState state:s1;
147
+ cost:duration 20.0; cost:monetaryCost 0.0; cost:success 0.995; cost:usersatifaction 0.85.
148
+
149
+ # s1 -> s2 (affiliation)
150
+ step:verifyAffiliationAuto a o-steps:Step;
151
+ rdfs:label "Verify affiliation (automatic)"@en;
152
+ o-steps:requiresState state:s1; o-steps:producesState state:s2;
153
+ cost:duration 3.0; cost:monetaryCost 0.0; cost:success 0.98; cost:usersatifaction 0.95.
154
+
155
+ step:verifyAffiliationManual a o-steps:Step;
156
+ rdfs:label "Verify affiliation (manual approval)"@en;
157
+ o-steps:requiresState state:s1; o-steps:producesState state:s2;
158
+ cost:duration 240.0; cost:monetaryCost 0.0; cost:success 0.995; cost:usersatifaction 0.80.
159
+
160
+ # s2 -> s3 (submit request)
161
+ step:submitRequestSelfService a o-steps:Step;
162
+ rdfs:label "Submit request (self-service form)"@en;
163
+ o-steps:requiresState state:s2; o-steps:producesState state:s3;
164
+ cost:duration 5.0; cost:monetaryCost 0.0; cost:success 0.97; cost:usersatifaction 0.94.
165
+
166
+ step:submitRequestLibrarian a o-steps:Step;
167
+ rdfs:label "Submit request (with librarian)"@en;
168
+ o-steps:requiresState state:s2; o-steps:producesState state:s3;
169
+ cost:duration 15.0; cost:monetaryCost 0.0; cost:success 0.99; cost:usersatifaction 0.90.
170
+
171
+ # s3 -> s4 (locate item)
172
+ step:locateViaCatalogue a o-steps:Step;
173
+ rdfs:label "Locate item (catalogue + resolver)"@en;
174
+ o-steps:requiresState state:s3; o-steps:producesState state:s4;
175
+ cost:duration 2.0; cost:monetaryCost 0.0; cost:success 0.96; cost:usersatifaction 0.92.
176
+
177
+ step:locateViaDiscovery a o-steps:Step;
178
+ rdfs:label "Locate item (discovery index)"@en;
179
+ o-steps:requiresState state:s3; o-steps:producesState state:s4;
180
+ cost:duration 3.0; cost:monetaryCost 0.0; cost:success 0.97; cost:usersatifaction 0.93.
181
+
182
+ # s4 -> s5 (grant access)
183
+ step:grantAccessOpenAccess a o-steps:Step;
184
+ rdfs:label "Grant access (open access)"@en;
185
+ o-steps:requiresState state:s4; o-steps:producesState state:s5;
186
+ cost:duration 1.0; cost:monetaryCost 0.0; cost:success 0.92; cost:usersatifaction 0.97.
187
+
188
+ step:grantAccessSubscription a o-steps:Step;
189
+ rdfs:label "Grant access (subscription)"@en;
190
+ o-steps:requiresState state:s4; o-steps:producesState state:s5;
191
+ cost:duration 2.0; cost:monetaryCost 0.5; cost:success 0.97; cost:usersatifaction 0.94.
192
+
193
+ step:grantAccessInterlibraryLoan a o-steps:Step;
194
+ rdfs:label "Grant access (interlibrary loan)"@en;
195
+ o-steps:requiresState state:s4; o-steps:producesState state:s5;
196
+ cost:duration 2880.0; cost:monetaryCost 5.0; cost:success 0.985; cost:usersatifaction 0.80.
197
+
198
+ # -----------------------------------------------------------------------------
199
+ # 3) Compile OSLO-STEPS core -> internal gps:description transitions
200
+ # -----------------------------------------------------------------------------
201
+
202
+ {
203
+ ex:libmap gps:description ( ?FROM true ?TO ?STEP ?DUR ?MC ?SUC ?SAT ).
204
+ } <=
205
+ {
206
+ ?STEP a o-steps:Step.
207
+ ?STEP o-steps:requiresState ?REQ.
208
+ ?STEP o-steps:producesState ?PROD.
209
+
210
+ ?REQ :formula ?FROM.
211
+ ?PROD :formula ?TO.
212
+
213
+ ?STEP cost:duration ?DUR.
214
+ ?STEP cost:monetaryCost ?MC.
215
+ ?STEP cost:success ?SUC.
216
+ ?STEP cost:usersatifaction ?SAT.
217
+ }.
218
+
219
+ # -----------------------------------------------------------------------------
220
+ # 4) Start + planner (NO fuel; terminates because workflow is acyclic)
221
+ # -----------------------------------------------------------------------------
222
+
223
+ :alice :start {
224
+ var:x a foaf:Person.
225
+ var:x ex:identityVerified false.
226
+ var:x ex:affiliationVerified false.
227
+ var:x ex:requestSubmitted false.
228
+ var:x ex:itemLocated false.
229
+ var:x ex:accessGranted false.
230
+ }.
231
+
232
+ # Base: one step is a path
233
+ { (?From ?To (?Act) ?Dur ?Cost ?Suc ?Sat) :path true. }
234
+ <=
235
+ { ex:libmap gps:description (?From true ?To ?Act ?Dur ?Cost ?Suc ?Sat). }.
236
+
237
+ # Recursive: step + rest, aggregate
238
+ { (?From ?To ?Acts ?Dur ?Cost ?Suc ?Sat) :path true. }
239
+ <=
240
+ {
241
+ ex:libmap gps:description (?From true ?Mid ?Act ?Dur1 ?Cost1 ?Suc1 ?Sat1).
242
+ (?Mid ?To ?Rest ?Dur2 ?Cost2 ?Suc2 ?Sat2) :path true.
243
+
244
+ ((?Act) ?Rest) list:append ?Acts.
245
+ (?Dur1 ?Dur2) math:sum ?Dur.
246
+ (?Cost1 ?Cost2) math:sum ?Cost.
247
+ (?Suc1 ?Suc2) math:product ?Suc.
248
+ (?Sat1 ?Sat2) math:product ?Sat.
249
+ }.
250
+
251
+ # Wrapper: OSLO-like findpath with bounds
252
+ {
253
+ :scope gps:findpath ( ?GOAL ?PATH ?DUR ?COST ?SUC ?SAT (?DL ?CL ?SL ?AL) ).
254
+ } <=
255
+ {
256
+ :alice :start ?START.
257
+ (?START ?GOAL ?PATH ?DUR ?COST ?SUC ?SAT) :path true.
258
+
259
+ ?DUR math:lessThan ?DL.
260
+ ?COST math:lessThan ?CL.
261
+ ?SUC math:greaterThan ?SL.
262
+ ?SAT math:greaterThan ?AL.
263
+ }.
264
+
265
+ # -----------------------------------------------------------------------------
266
+ # 5) Goal query -> output
267
+ # -----------------------------------------------------------------------------
268
+
269
+ {
270
+ state:s5 :formula ?GOAL.
271
+
272
+ :scope gps:findpath
273
+ (
274
+ ?GOAL
275
+ ?PATH ?DUR ?COST ?SUC ?SAT
276
+ (
277
+ 5000.0 # duration limit (minutes)
278
+ 10.0 # monetary cost limit
279
+ 0.75 # success lower bound
280
+ 0.60 # satisfaction lower bound (product shrinks fast)
281
+ )
282
+ ).
283
+ }
284
+ =>
285
+ {
286
+ :alice gps:path (?PATH ?DUR ?COST ?SUC ?SAT).
287
+ }.
288
+