eyeling 1.5.37 → 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,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,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,131 @@
1
+ @prefix : <urn:example:> .
2
+
3
+ # ----------------------------------------------------------------------
4
+ # Proof for derived triple:
5
+ # ("Huey" "Dewey" "Louie") :iterate (2 "Louie") .
6
+ # It holds because the following instance of the rule body is provable:
7
+ # :Let :param ("Huey" "Dewey" "Louie") .
8
+ # ("Huey" "Dewey" "Louie") list:iterate (2 "Louie") .
9
+ # ("Huey" "Dewey" "Louie") list:iterate (1 "Dewey") .
10
+ # ("Huey" "Dewey" "Louie") list:iterate (1 "Dewey") .
11
+ # via the schematic forward rule:
12
+ # {
13
+ # :Let :param ?X .
14
+ # ?X list:iterate ?Y .
15
+ # ?X list:iterate (1 "Dewey") .
16
+ # ?X list:iterate (?Z "Dewey") .
17
+ # } => {
18
+ # ?X :iterate ?Y .
19
+ # "Dewey" :hasIndex ?Z .
20
+ # } .
21
+ # with substitution (on rule variables):
22
+ # ?X = ("Huey" "Dewey" "Louie")
23
+ # ?Y = (2 "Louie")
24
+ # ?Z = 1
25
+ # Therefore the derived triple above is entailed by the rules and facts.
26
+ # ----------------------------------------------------------------------
27
+
28
+ ("Huey" "Dewey" "Louie") :iterate (2 "Louie") .
29
+
30
+ # ----------------------------------------------------------------------
31
+ # Proof for derived triple:
32
+ # "Dewey" :hasIndex 1 .
33
+ # It holds because the following instance of the rule body is provable:
34
+ # :Let :param ("Huey" "Dewey" "Louie") .
35
+ # ("Huey" "Dewey" "Louie") list:iterate (2 "Louie") .
36
+ # ("Huey" "Dewey" "Louie") list:iterate (1 "Dewey") .
37
+ # ("Huey" "Dewey" "Louie") list:iterate (1 "Dewey") .
38
+ # via the schematic forward rule:
39
+ # {
40
+ # :Let :param ?X .
41
+ # ?X list:iterate ?Y .
42
+ # ?X list:iterate (1 "Dewey") .
43
+ # ?X list:iterate (?Z "Dewey") .
44
+ # } => {
45
+ # ?X :iterate ?Y .
46
+ # "Dewey" :hasIndex ?Z .
47
+ # } .
48
+ # with substitution (on rule variables):
49
+ # ?X = ("Huey" "Dewey" "Louie")
50
+ # ?Y = (2 "Louie")
51
+ # ?Z = 1
52
+ # Therefore the derived triple above is entailed by the rules and facts.
53
+ # ----------------------------------------------------------------------
54
+
55
+ "Dewey" :hasIndex 1 .
56
+
57
+ # ----------------------------------------------------------------------
58
+ # Proof for derived triple:
59
+ # ("Huey" "Dewey" "Louie") :iterate (1 "Dewey") .
60
+ # It holds because the following instance of the rule body is provable:
61
+ # :Let :param ("Huey" "Dewey" "Louie") .
62
+ # ("Huey" "Dewey" "Louie") list:iterate (1 "Dewey") .
63
+ # ("Huey" "Dewey" "Louie") list:iterate (1 "Dewey") .
64
+ # ("Huey" "Dewey" "Louie") list:iterate (1 "Dewey") .
65
+ # via the schematic forward rule:
66
+ # {
67
+ # :Let :param ?X .
68
+ # ?X list:iterate ?Y .
69
+ # ?X list:iterate (1 "Dewey") .
70
+ # ?X list:iterate (?Z "Dewey") .
71
+ # } => {
72
+ # ?X :iterate ?Y .
73
+ # "Dewey" :hasIndex ?Z .
74
+ # } .
75
+ # with substitution (on rule variables):
76
+ # ?X = ("Huey" "Dewey" "Louie")
77
+ # ?Y = (1 "Dewey")
78
+ # ?Z = 1
79
+ # Therefore the derived triple above is entailed by the rules and facts.
80
+ # ----------------------------------------------------------------------
81
+
82
+ ("Huey" "Dewey" "Louie") :iterate (1 "Dewey") .
83
+
84
+ # ----------------------------------------------------------------------
85
+ # Proof for derived triple:
86
+ # ("Huey" "Dewey" "Louie") :iterate (0 "Huey") .
87
+ # It holds because the following instance of the rule body is provable:
88
+ # :Let :param ("Huey" "Dewey" "Louie") .
89
+ # ("Huey" "Dewey" "Louie") list:iterate (0 "Huey") .
90
+ # ("Huey" "Dewey" "Louie") list:iterate (1 "Dewey") .
91
+ # ("Huey" "Dewey" "Louie") list:iterate (1 "Dewey") .
92
+ # via the schematic forward rule:
93
+ # {
94
+ # :Let :param ?X .
95
+ # ?X list:iterate ?Y .
96
+ # ?X list:iterate (1 "Dewey") .
97
+ # ?X list:iterate (?Z "Dewey") .
98
+ # } => {
99
+ # ?X :iterate ?Y .
100
+ # "Dewey" :hasIndex ?Z .
101
+ # } .
102
+ # with substitution (on rule variables):
103
+ # ?X = ("Huey" "Dewey" "Louie")
104
+ # ?Y = (0 "Huey")
105
+ # ?Z = 1
106
+ # Therefore the derived triple above is entailed by the rules and facts.
107
+ # ----------------------------------------------------------------------
108
+
109
+ ("Huey" "Dewey" "Louie") :iterate (0 "Huey") .
110
+
111
+ # ----------------------------------------------------------------------
112
+ # Proof for derived triple:
113
+ # :test :is true .
114
+ # It holds because the following instance of the rule body is provable:
115
+ # ("Huey" "Dewey" "Louie") :iterate (0 "Huey") .
116
+ # "Dewey" :hasIndex 1 .
117
+ # via the schematic forward rule:
118
+ # {
119
+ # ?X :iterate ?Y .
120
+ # "Dewey" :hasIndex 1 .
121
+ # } => {
122
+ # :test :is true .
123
+ # } .
124
+ # with substitution (on rule variables):
125
+ # ?X = ("Huey" "Dewey" "Louie")
126
+ # ?Y = (0 "Huey")
127
+ # Therefore the derived triple above is entailed by the rules and facts.
128
+ # ----------------------------------------------------------------------
129
+
130
+ :test :is true .
131
+