eyeleng 1.0.10 → 1.0.11

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/README.md CHANGED
@@ -197,19 +197,24 @@ Common commands:
197
197
  Important options:
198
198
 
199
199
  ```text
200
- --all print input and inferred triples
201
- --check parse and analyze only
202
- --strict warnings become fatal
203
- --deps print dependency edges and layers
204
- --trace show rule firings
205
- --stats show iteration and rule counts
206
- --json structured output
207
- --query run a raw body pattern over the closure
208
- --query-file FILE read a query body from a file
209
- --max-iterations N recursive-layer fixpoint safety guard
210
- --no-imports parse imports but do not load them
211
- --rdf-messages parse input as an RDF Message Log
212
- --stream-messages replay RDF Message Log envelopes
200
+ --all print the full closure, including input facts
201
+ --json print JSON instead of compact triples/bindings
202
+ --trace print derivation trace to stderr, or include it in JSON
203
+ --stats print iteration and triple counts to stderr
204
+ --check parse and analyze only; do not run rules
205
+ --strict treat static warnings as errors
206
+ --deps print rule dependency edges during --check
207
+ --query TEXT run a raw SRL body pattern over the closure
208
+ --query-file FILE read a raw SRL body pattern from a file
209
+ --max-iterations N stop after N fixpoint iterations within a recursive layer
210
+ --no-imports parse IMPORTS/owl:imports but do not load imported rule sets
211
+ --rdf-messages parse input as an RDF Message Log
212
+ --stream-messages replay RDF Message Log envelopes
213
+ --include-message-facts include payload facts while parsing RDF Message Logs
214
+ --syntax MODE use srl, rdf, or auto syntax detection (default auto)
215
+ --ruleset TERM in RDF syntax, run only the selected srl:RuleSet
216
+ --version print version
217
+ -h, --help print help
213
218
  ```
214
219
 
215
220
  ## Public API
@@ -0,0 +1,500 @@
1
+ :answer :machine :add1 .
2
+ :answer :summary "## Turing Machine\nThe generic SRL interpreter runs the :add1 Turing machine from transition facts.\n101001 + 1 = 101010\n101111 + 1 = 110000\n111111 + 1 = 1000000\nempty tape + 1 = 1\n100000 + 1 = 100001" .
3
+ :answer a :TuringRun .
4
+ :answer log:outputString "## Turing Machine\nThe generic SRL interpreter runs the :add1 Turing machine from transition facts.\n101001 + 1 = 101010\n101111 + 1 = 110000\n111111 + 1 = 1000000\nempty tape + 1 = 1\n100000 + 1 = 100001" .
5
+ :case1 :haltedAtStep 9 .
6
+ :case1 :hasStep <http://example/eyeling/turing/case1/step-0> .
7
+ :case1 :hasStep <http://example/eyeling/turing/case1/step-1> .
8
+ :case1 :hasStep <http://example/eyeling/turing/case1/step-2> .
9
+ :case1 :hasStep <http://example/eyeling/turing/case1/step-3> .
10
+ :case1 :hasStep <http://example/eyeling/turing/case1/step-4> .
11
+ :case1 :hasStep <http://example/eyeling/turing/case1/step-5> .
12
+ :case1 :hasStep <http://example/eyeling/turing/case1/step-6> .
13
+ :case1 :hasStep <http://example/eyeling/turing/case1/step-7> .
14
+ :case1 :hasStep <http://example/eyeling/turing/case1/step-8> .
15
+ :case1 :hasStep <http://example/eyeling/turing/case1/step-9> .
16
+ :case1 :output "101010" .
17
+ :case1 :rawOutput "101010#" .
18
+ :case1 :reportLine "101001 + 1 = 101010" .
19
+ :case1 log:outputString "101001 + 1 = 101010" .
20
+ :case2 :haltedAtStep 12 .
21
+ :case2 :hasStep <http://example/eyeling/turing/case2/step-0> .
22
+ :case2 :hasStep <http://example/eyeling/turing/case2/step-1> .
23
+ :case2 :hasStep <http://example/eyeling/turing/case2/step-10> .
24
+ :case2 :hasStep <http://example/eyeling/turing/case2/step-11> .
25
+ :case2 :hasStep <http://example/eyeling/turing/case2/step-12> .
26
+ :case2 :hasStep <http://example/eyeling/turing/case2/step-2> .
27
+ :case2 :hasStep <http://example/eyeling/turing/case2/step-3> .
28
+ :case2 :hasStep <http://example/eyeling/turing/case2/step-4> .
29
+ :case2 :hasStep <http://example/eyeling/turing/case2/step-5> .
30
+ :case2 :hasStep <http://example/eyeling/turing/case2/step-6> .
31
+ :case2 :hasStep <http://example/eyeling/turing/case2/step-7> .
32
+ :case2 :hasStep <http://example/eyeling/turing/case2/step-8> .
33
+ :case2 :hasStep <http://example/eyeling/turing/case2/step-9> .
34
+ :case2 :output "110000" .
35
+ :case2 :rawOutput "110000#" .
36
+ :case2 :reportLine "101111 + 1 = 110000" .
37
+ :case2 log:outputString "101111 + 1 = 110000" .
38
+ :case3 :haltedAtStep 14 .
39
+ :case3 :hasStep <http://example/eyeling/turing/case3/step-0> .
40
+ :case3 :hasStep <http://example/eyeling/turing/case3/step-1> .
41
+ :case3 :hasStep <http://example/eyeling/turing/case3/step-10> .
42
+ :case3 :hasStep <http://example/eyeling/turing/case3/step-11> .
43
+ :case3 :hasStep <http://example/eyeling/turing/case3/step-12> .
44
+ :case3 :hasStep <http://example/eyeling/turing/case3/step-13> .
45
+ :case3 :hasStep <http://example/eyeling/turing/case3/step-14> .
46
+ :case3 :hasStep <http://example/eyeling/turing/case3/step-2> .
47
+ :case3 :hasStep <http://example/eyeling/turing/case3/step-3> .
48
+ :case3 :hasStep <http://example/eyeling/turing/case3/step-4> .
49
+ :case3 :hasStep <http://example/eyeling/turing/case3/step-5> .
50
+ :case3 :hasStep <http://example/eyeling/turing/case3/step-6> .
51
+ :case3 :hasStep <http://example/eyeling/turing/case3/step-7> .
52
+ :case3 :hasStep <http://example/eyeling/turing/case3/step-8> .
53
+ :case3 :hasStep <http://example/eyeling/turing/case3/step-9> .
54
+ :case3 :output "1000000" .
55
+ :case3 :rawOutput "1000000#" .
56
+ :case3 :reportLine "111111 + 1 = 1000000" .
57
+ :case3 log:outputString "111111 + 1 = 1000000" .
58
+ :case4 :haltedAtStep 2 .
59
+ :case4 :hasStep <http://example/eyeling/turing/case4/step-0> .
60
+ :case4 :hasStep <http://example/eyeling/turing/case4/step-1> .
61
+ :case4 :hasStep <http://example/eyeling/turing/case4/step-2> .
62
+ :case4 :output "1" .
63
+ :case4 :rawOutput "1#" .
64
+ :case4 :reportLine "empty tape + 1 = 1" .
65
+ :case4 log:outputString "empty tape + 1 = 1" .
66
+ :case5 :haltedAtStep 8 .
67
+ :case5 :hasStep <http://example/eyeling/turing/case5/step-0> .
68
+ :case5 :hasStep <http://example/eyeling/turing/case5/step-1> .
69
+ :case5 :hasStep <http://example/eyeling/turing/case5/step-2> .
70
+ :case5 :hasStep <http://example/eyeling/turing/case5/step-3> .
71
+ :case5 :hasStep <http://example/eyeling/turing/case5/step-4> .
72
+ :case5 :hasStep <http://example/eyeling/turing/case5/step-5> .
73
+ :case5 :hasStep <http://example/eyeling/turing/case5/step-6> .
74
+ :case5 :hasStep <http://example/eyeling/turing/case5/step-7> .
75
+ :case5 :hasStep <http://example/eyeling/turing/case5/step-8> .
76
+ :case5 :output "100001" .
77
+ :case5 :rawOutput "100001#" .
78
+ :case5 :reportLine "100000 + 1 = 100001" .
79
+ :case5 log:outputString "100000 + 1 = 100001" .
80
+ <http://example/eyeling/turing/case1/step-0> :case :case1 .
81
+ <http://example/eyeling/turing/case1/step-0> :cell "1" .
82
+ <http://example/eyeling/turing/case1/step-0> :left "" .
83
+ <http://example/eyeling/turing/case1/step-0> :machine :add1 .
84
+ <http://example/eyeling/turing/case1/step-0> :right "01001" .
85
+ <http://example/eyeling/turing/case1/step-0> :state :scanRight .
86
+ <http://example/eyeling/turing/case1/step-0> :step 0 .
87
+ <http://example/eyeling/turing/case1/step-0> a :Configuration .
88
+ <http://example/eyeling/turing/case1/step-1> :case :case1 .
89
+ <http://example/eyeling/turing/case1/step-1> :cell "0" .
90
+ <http://example/eyeling/turing/case1/step-1> :left "1" .
91
+ <http://example/eyeling/turing/case1/step-1> :machine :add1 .
92
+ <http://example/eyeling/turing/case1/step-1> :right "1001" .
93
+ <http://example/eyeling/turing/case1/step-1> :state :scanRight .
94
+ <http://example/eyeling/turing/case1/step-1> :step 1 .
95
+ <http://example/eyeling/turing/case1/step-1> a :Configuration .
96
+ <http://example/eyeling/turing/case1/step-2> :case :case1 .
97
+ <http://example/eyeling/turing/case1/step-2> :cell "1" .
98
+ <http://example/eyeling/turing/case1/step-2> :left "10" .
99
+ <http://example/eyeling/turing/case1/step-2> :machine :add1 .
100
+ <http://example/eyeling/turing/case1/step-2> :right "001" .
101
+ <http://example/eyeling/turing/case1/step-2> :state :scanRight .
102
+ <http://example/eyeling/turing/case1/step-2> :step 2 .
103
+ <http://example/eyeling/turing/case1/step-2> a :Configuration .
104
+ <http://example/eyeling/turing/case1/step-3> :case :case1 .
105
+ <http://example/eyeling/turing/case1/step-3> :cell "0" .
106
+ <http://example/eyeling/turing/case1/step-3> :left "101" .
107
+ <http://example/eyeling/turing/case1/step-3> :machine :add1 .
108
+ <http://example/eyeling/turing/case1/step-3> :right "01" .
109
+ <http://example/eyeling/turing/case1/step-3> :state :scanRight .
110
+ <http://example/eyeling/turing/case1/step-3> :step 3 .
111
+ <http://example/eyeling/turing/case1/step-3> a :Configuration .
112
+ <http://example/eyeling/turing/case1/step-4> :case :case1 .
113
+ <http://example/eyeling/turing/case1/step-4> :cell "0" .
114
+ <http://example/eyeling/turing/case1/step-4> :left "1010" .
115
+ <http://example/eyeling/turing/case1/step-4> :machine :add1 .
116
+ <http://example/eyeling/turing/case1/step-4> :right "1" .
117
+ <http://example/eyeling/turing/case1/step-4> :state :scanRight .
118
+ <http://example/eyeling/turing/case1/step-4> :step 4 .
119
+ <http://example/eyeling/turing/case1/step-4> a :Configuration .
120
+ <http://example/eyeling/turing/case1/step-5> :case :case1 .
121
+ <http://example/eyeling/turing/case1/step-5> :cell "1" .
122
+ <http://example/eyeling/turing/case1/step-5> :left "10100" .
123
+ <http://example/eyeling/turing/case1/step-5> :machine :add1 .
124
+ <http://example/eyeling/turing/case1/step-5> :right "" .
125
+ <http://example/eyeling/turing/case1/step-5> :state :scanRight .
126
+ <http://example/eyeling/turing/case1/step-5> :step 5 .
127
+ <http://example/eyeling/turing/case1/step-5> a :Configuration .
128
+ <http://example/eyeling/turing/case1/step-6> :case :case1 .
129
+ <http://example/eyeling/turing/case1/step-6> :cell "#" .
130
+ <http://example/eyeling/turing/case1/step-6> :left "101001" .
131
+ <http://example/eyeling/turing/case1/step-6> :machine :add1 .
132
+ <http://example/eyeling/turing/case1/step-6> :right "" .
133
+ <http://example/eyeling/turing/case1/step-6> :state :scanRight .
134
+ <http://example/eyeling/turing/case1/step-6> :step 6 .
135
+ <http://example/eyeling/turing/case1/step-6> a :Configuration .
136
+ <http://example/eyeling/turing/case1/step-7> :case :case1 .
137
+ <http://example/eyeling/turing/case1/step-7> :cell "1" .
138
+ <http://example/eyeling/turing/case1/step-7> :left "10100" .
139
+ <http://example/eyeling/turing/case1/step-7> :machine :add1 .
140
+ <http://example/eyeling/turing/case1/step-7> :right "#" .
141
+ <http://example/eyeling/turing/case1/step-7> :state :carry .
142
+ <http://example/eyeling/turing/case1/step-7> :step 7 .
143
+ <http://example/eyeling/turing/case1/step-7> a :Configuration .
144
+ <http://example/eyeling/turing/case1/step-8> :case :case1 .
145
+ <http://example/eyeling/turing/case1/step-8> :cell "0" .
146
+ <http://example/eyeling/turing/case1/step-8> :left "1010" .
147
+ <http://example/eyeling/turing/case1/step-8> :machine :add1 .
148
+ <http://example/eyeling/turing/case1/step-8> :right "0#" .
149
+ <http://example/eyeling/turing/case1/step-8> :state :carry .
150
+ <http://example/eyeling/turing/case1/step-8> :step 8 .
151
+ <http://example/eyeling/turing/case1/step-8> a :Configuration .
152
+ <http://example/eyeling/turing/case1/step-9> :case :case1 .
153
+ <http://example/eyeling/turing/case1/step-9> :cell "1" .
154
+ <http://example/eyeling/turing/case1/step-9> :left "1010" .
155
+ <http://example/eyeling/turing/case1/step-9> :machine :add1 .
156
+ <http://example/eyeling/turing/case1/step-9> :right "0#" .
157
+ <http://example/eyeling/turing/case1/step-9> :state :halt .
158
+ <http://example/eyeling/turing/case1/step-9> :step 9 .
159
+ <http://example/eyeling/turing/case1/step-9> a :Configuration .
160
+ <http://example/eyeling/turing/case2/step-0> :case :case2 .
161
+ <http://example/eyeling/turing/case2/step-0> :cell "1" .
162
+ <http://example/eyeling/turing/case2/step-0> :left "" .
163
+ <http://example/eyeling/turing/case2/step-0> :machine :add1 .
164
+ <http://example/eyeling/turing/case2/step-0> :right "01111" .
165
+ <http://example/eyeling/turing/case2/step-0> :state :scanRight .
166
+ <http://example/eyeling/turing/case2/step-0> :step 0 .
167
+ <http://example/eyeling/turing/case2/step-0> a :Configuration .
168
+ <http://example/eyeling/turing/case2/step-1> :case :case2 .
169
+ <http://example/eyeling/turing/case2/step-1> :cell "0" .
170
+ <http://example/eyeling/turing/case2/step-1> :left "1" .
171
+ <http://example/eyeling/turing/case2/step-1> :machine :add1 .
172
+ <http://example/eyeling/turing/case2/step-1> :right "1111" .
173
+ <http://example/eyeling/turing/case2/step-1> :state :scanRight .
174
+ <http://example/eyeling/turing/case2/step-1> :step 1 .
175
+ <http://example/eyeling/turing/case2/step-1> a :Configuration .
176
+ <http://example/eyeling/turing/case2/step-10> :case :case2 .
177
+ <http://example/eyeling/turing/case2/step-10> :cell "1" .
178
+ <http://example/eyeling/turing/case2/step-10> :left "10" .
179
+ <http://example/eyeling/turing/case2/step-10> :machine :add1 .
180
+ <http://example/eyeling/turing/case2/step-10> :right "000#" .
181
+ <http://example/eyeling/turing/case2/step-10> :state :carry .
182
+ <http://example/eyeling/turing/case2/step-10> :step 10 .
183
+ <http://example/eyeling/turing/case2/step-10> a :Configuration .
184
+ <http://example/eyeling/turing/case2/step-11> :case :case2 .
185
+ <http://example/eyeling/turing/case2/step-11> :cell "0" .
186
+ <http://example/eyeling/turing/case2/step-11> :left "1" .
187
+ <http://example/eyeling/turing/case2/step-11> :machine :add1 .
188
+ <http://example/eyeling/turing/case2/step-11> :right "0000#" .
189
+ <http://example/eyeling/turing/case2/step-11> :state :carry .
190
+ <http://example/eyeling/turing/case2/step-11> :step 11 .
191
+ <http://example/eyeling/turing/case2/step-11> a :Configuration .
192
+ <http://example/eyeling/turing/case2/step-12> :case :case2 .
193
+ <http://example/eyeling/turing/case2/step-12> :cell "1" .
194
+ <http://example/eyeling/turing/case2/step-12> :left "1" .
195
+ <http://example/eyeling/turing/case2/step-12> :machine :add1 .
196
+ <http://example/eyeling/turing/case2/step-12> :right "0000#" .
197
+ <http://example/eyeling/turing/case2/step-12> :state :halt .
198
+ <http://example/eyeling/turing/case2/step-12> :step 12 .
199
+ <http://example/eyeling/turing/case2/step-12> a :Configuration .
200
+ <http://example/eyeling/turing/case2/step-2> :case :case2 .
201
+ <http://example/eyeling/turing/case2/step-2> :cell "1" .
202
+ <http://example/eyeling/turing/case2/step-2> :left "10" .
203
+ <http://example/eyeling/turing/case2/step-2> :machine :add1 .
204
+ <http://example/eyeling/turing/case2/step-2> :right "111" .
205
+ <http://example/eyeling/turing/case2/step-2> :state :scanRight .
206
+ <http://example/eyeling/turing/case2/step-2> :step 2 .
207
+ <http://example/eyeling/turing/case2/step-2> a :Configuration .
208
+ <http://example/eyeling/turing/case2/step-3> :case :case2 .
209
+ <http://example/eyeling/turing/case2/step-3> :cell "1" .
210
+ <http://example/eyeling/turing/case2/step-3> :left "101" .
211
+ <http://example/eyeling/turing/case2/step-3> :machine :add1 .
212
+ <http://example/eyeling/turing/case2/step-3> :right "11" .
213
+ <http://example/eyeling/turing/case2/step-3> :state :scanRight .
214
+ <http://example/eyeling/turing/case2/step-3> :step 3 .
215
+ <http://example/eyeling/turing/case2/step-3> a :Configuration .
216
+ <http://example/eyeling/turing/case2/step-4> :case :case2 .
217
+ <http://example/eyeling/turing/case2/step-4> :cell "1" .
218
+ <http://example/eyeling/turing/case2/step-4> :left "1011" .
219
+ <http://example/eyeling/turing/case2/step-4> :machine :add1 .
220
+ <http://example/eyeling/turing/case2/step-4> :right "1" .
221
+ <http://example/eyeling/turing/case2/step-4> :state :scanRight .
222
+ <http://example/eyeling/turing/case2/step-4> :step 4 .
223
+ <http://example/eyeling/turing/case2/step-4> a :Configuration .
224
+ <http://example/eyeling/turing/case2/step-5> :case :case2 .
225
+ <http://example/eyeling/turing/case2/step-5> :cell "1" .
226
+ <http://example/eyeling/turing/case2/step-5> :left "10111" .
227
+ <http://example/eyeling/turing/case2/step-5> :machine :add1 .
228
+ <http://example/eyeling/turing/case2/step-5> :right "" .
229
+ <http://example/eyeling/turing/case2/step-5> :state :scanRight .
230
+ <http://example/eyeling/turing/case2/step-5> :step 5 .
231
+ <http://example/eyeling/turing/case2/step-5> a :Configuration .
232
+ <http://example/eyeling/turing/case2/step-6> :case :case2 .
233
+ <http://example/eyeling/turing/case2/step-6> :cell "#" .
234
+ <http://example/eyeling/turing/case2/step-6> :left "101111" .
235
+ <http://example/eyeling/turing/case2/step-6> :machine :add1 .
236
+ <http://example/eyeling/turing/case2/step-6> :right "" .
237
+ <http://example/eyeling/turing/case2/step-6> :state :scanRight .
238
+ <http://example/eyeling/turing/case2/step-6> :step 6 .
239
+ <http://example/eyeling/turing/case2/step-6> a :Configuration .
240
+ <http://example/eyeling/turing/case2/step-7> :case :case2 .
241
+ <http://example/eyeling/turing/case2/step-7> :cell "1" .
242
+ <http://example/eyeling/turing/case2/step-7> :left "10111" .
243
+ <http://example/eyeling/turing/case2/step-7> :machine :add1 .
244
+ <http://example/eyeling/turing/case2/step-7> :right "#" .
245
+ <http://example/eyeling/turing/case2/step-7> :state :carry .
246
+ <http://example/eyeling/turing/case2/step-7> :step 7 .
247
+ <http://example/eyeling/turing/case2/step-7> a :Configuration .
248
+ <http://example/eyeling/turing/case2/step-8> :case :case2 .
249
+ <http://example/eyeling/turing/case2/step-8> :cell "1" .
250
+ <http://example/eyeling/turing/case2/step-8> :left "1011" .
251
+ <http://example/eyeling/turing/case2/step-8> :machine :add1 .
252
+ <http://example/eyeling/turing/case2/step-8> :right "0#" .
253
+ <http://example/eyeling/turing/case2/step-8> :state :carry .
254
+ <http://example/eyeling/turing/case2/step-8> :step 8 .
255
+ <http://example/eyeling/turing/case2/step-8> a :Configuration .
256
+ <http://example/eyeling/turing/case2/step-9> :case :case2 .
257
+ <http://example/eyeling/turing/case2/step-9> :cell "1" .
258
+ <http://example/eyeling/turing/case2/step-9> :left "101" .
259
+ <http://example/eyeling/turing/case2/step-9> :machine :add1 .
260
+ <http://example/eyeling/turing/case2/step-9> :right "00#" .
261
+ <http://example/eyeling/turing/case2/step-9> :state :carry .
262
+ <http://example/eyeling/turing/case2/step-9> :step 9 .
263
+ <http://example/eyeling/turing/case2/step-9> a :Configuration .
264
+ <http://example/eyeling/turing/case3/step-0> :case :case3 .
265
+ <http://example/eyeling/turing/case3/step-0> :cell "1" .
266
+ <http://example/eyeling/turing/case3/step-0> :left "" .
267
+ <http://example/eyeling/turing/case3/step-0> :machine :add1 .
268
+ <http://example/eyeling/turing/case3/step-0> :right "11111" .
269
+ <http://example/eyeling/turing/case3/step-0> :state :scanRight .
270
+ <http://example/eyeling/turing/case3/step-0> :step 0 .
271
+ <http://example/eyeling/turing/case3/step-0> a :Configuration .
272
+ <http://example/eyeling/turing/case3/step-1> :case :case3 .
273
+ <http://example/eyeling/turing/case3/step-1> :cell "1" .
274
+ <http://example/eyeling/turing/case3/step-1> :left "1" .
275
+ <http://example/eyeling/turing/case3/step-1> :machine :add1 .
276
+ <http://example/eyeling/turing/case3/step-1> :right "1111" .
277
+ <http://example/eyeling/turing/case3/step-1> :state :scanRight .
278
+ <http://example/eyeling/turing/case3/step-1> :step 1 .
279
+ <http://example/eyeling/turing/case3/step-1> a :Configuration .
280
+ <http://example/eyeling/turing/case3/step-10> :case :case3 .
281
+ <http://example/eyeling/turing/case3/step-10> :cell "1" .
282
+ <http://example/eyeling/turing/case3/step-10> :left "11" .
283
+ <http://example/eyeling/turing/case3/step-10> :machine :add1 .
284
+ <http://example/eyeling/turing/case3/step-10> :right "000#" .
285
+ <http://example/eyeling/turing/case3/step-10> :state :carry .
286
+ <http://example/eyeling/turing/case3/step-10> :step 10 .
287
+ <http://example/eyeling/turing/case3/step-10> a :Configuration .
288
+ <http://example/eyeling/turing/case3/step-11> :case :case3 .
289
+ <http://example/eyeling/turing/case3/step-11> :cell "1" .
290
+ <http://example/eyeling/turing/case3/step-11> :left "1" .
291
+ <http://example/eyeling/turing/case3/step-11> :machine :add1 .
292
+ <http://example/eyeling/turing/case3/step-11> :right "0000#" .
293
+ <http://example/eyeling/turing/case3/step-11> :state :carry .
294
+ <http://example/eyeling/turing/case3/step-11> :step 11 .
295
+ <http://example/eyeling/turing/case3/step-11> a :Configuration .
296
+ <http://example/eyeling/turing/case3/step-12> :case :case3 .
297
+ <http://example/eyeling/turing/case3/step-12> :cell "1" .
298
+ <http://example/eyeling/turing/case3/step-12> :left "" .
299
+ <http://example/eyeling/turing/case3/step-12> :machine :add1 .
300
+ <http://example/eyeling/turing/case3/step-12> :right "00000#" .
301
+ <http://example/eyeling/turing/case3/step-12> :state :carry .
302
+ <http://example/eyeling/turing/case3/step-12> :step 12 .
303
+ <http://example/eyeling/turing/case3/step-12> a :Configuration .
304
+ <http://example/eyeling/turing/case3/step-13> :case :case3 .
305
+ <http://example/eyeling/turing/case3/step-13> :cell "#" .
306
+ <http://example/eyeling/turing/case3/step-13> :left "" .
307
+ <http://example/eyeling/turing/case3/step-13> :machine :add1 .
308
+ <http://example/eyeling/turing/case3/step-13> :right "000000#" .
309
+ <http://example/eyeling/turing/case3/step-13> :state :carry .
310
+ <http://example/eyeling/turing/case3/step-13> :step 13 .
311
+ <http://example/eyeling/turing/case3/step-13> a :Configuration .
312
+ <http://example/eyeling/turing/case3/step-14> :case :case3 .
313
+ <http://example/eyeling/turing/case3/step-14> :cell "1" .
314
+ <http://example/eyeling/turing/case3/step-14> :left "" .
315
+ <http://example/eyeling/turing/case3/step-14> :machine :add1 .
316
+ <http://example/eyeling/turing/case3/step-14> :right "000000#" .
317
+ <http://example/eyeling/turing/case3/step-14> :state :halt .
318
+ <http://example/eyeling/turing/case3/step-14> :step 14 .
319
+ <http://example/eyeling/turing/case3/step-14> a :Configuration .
320
+ <http://example/eyeling/turing/case3/step-2> :case :case3 .
321
+ <http://example/eyeling/turing/case3/step-2> :cell "1" .
322
+ <http://example/eyeling/turing/case3/step-2> :left "11" .
323
+ <http://example/eyeling/turing/case3/step-2> :machine :add1 .
324
+ <http://example/eyeling/turing/case3/step-2> :right "111" .
325
+ <http://example/eyeling/turing/case3/step-2> :state :scanRight .
326
+ <http://example/eyeling/turing/case3/step-2> :step 2 .
327
+ <http://example/eyeling/turing/case3/step-2> a :Configuration .
328
+ <http://example/eyeling/turing/case3/step-3> :case :case3 .
329
+ <http://example/eyeling/turing/case3/step-3> :cell "1" .
330
+ <http://example/eyeling/turing/case3/step-3> :left "111" .
331
+ <http://example/eyeling/turing/case3/step-3> :machine :add1 .
332
+ <http://example/eyeling/turing/case3/step-3> :right "11" .
333
+ <http://example/eyeling/turing/case3/step-3> :state :scanRight .
334
+ <http://example/eyeling/turing/case3/step-3> :step 3 .
335
+ <http://example/eyeling/turing/case3/step-3> a :Configuration .
336
+ <http://example/eyeling/turing/case3/step-4> :case :case3 .
337
+ <http://example/eyeling/turing/case3/step-4> :cell "1" .
338
+ <http://example/eyeling/turing/case3/step-4> :left "1111" .
339
+ <http://example/eyeling/turing/case3/step-4> :machine :add1 .
340
+ <http://example/eyeling/turing/case3/step-4> :right "1" .
341
+ <http://example/eyeling/turing/case3/step-4> :state :scanRight .
342
+ <http://example/eyeling/turing/case3/step-4> :step 4 .
343
+ <http://example/eyeling/turing/case3/step-4> a :Configuration .
344
+ <http://example/eyeling/turing/case3/step-5> :case :case3 .
345
+ <http://example/eyeling/turing/case3/step-5> :cell "1" .
346
+ <http://example/eyeling/turing/case3/step-5> :left "11111" .
347
+ <http://example/eyeling/turing/case3/step-5> :machine :add1 .
348
+ <http://example/eyeling/turing/case3/step-5> :right "" .
349
+ <http://example/eyeling/turing/case3/step-5> :state :scanRight .
350
+ <http://example/eyeling/turing/case3/step-5> :step 5 .
351
+ <http://example/eyeling/turing/case3/step-5> a :Configuration .
352
+ <http://example/eyeling/turing/case3/step-6> :case :case3 .
353
+ <http://example/eyeling/turing/case3/step-6> :cell "#" .
354
+ <http://example/eyeling/turing/case3/step-6> :left "111111" .
355
+ <http://example/eyeling/turing/case3/step-6> :machine :add1 .
356
+ <http://example/eyeling/turing/case3/step-6> :right "" .
357
+ <http://example/eyeling/turing/case3/step-6> :state :scanRight .
358
+ <http://example/eyeling/turing/case3/step-6> :step 6 .
359
+ <http://example/eyeling/turing/case3/step-6> a :Configuration .
360
+ <http://example/eyeling/turing/case3/step-7> :case :case3 .
361
+ <http://example/eyeling/turing/case3/step-7> :cell "1" .
362
+ <http://example/eyeling/turing/case3/step-7> :left "11111" .
363
+ <http://example/eyeling/turing/case3/step-7> :machine :add1 .
364
+ <http://example/eyeling/turing/case3/step-7> :right "#" .
365
+ <http://example/eyeling/turing/case3/step-7> :state :carry .
366
+ <http://example/eyeling/turing/case3/step-7> :step 7 .
367
+ <http://example/eyeling/turing/case3/step-7> a :Configuration .
368
+ <http://example/eyeling/turing/case3/step-8> :case :case3 .
369
+ <http://example/eyeling/turing/case3/step-8> :cell "1" .
370
+ <http://example/eyeling/turing/case3/step-8> :left "1111" .
371
+ <http://example/eyeling/turing/case3/step-8> :machine :add1 .
372
+ <http://example/eyeling/turing/case3/step-8> :right "0#" .
373
+ <http://example/eyeling/turing/case3/step-8> :state :carry .
374
+ <http://example/eyeling/turing/case3/step-8> :step 8 .
375
+ <http://example/eyeling/turing/case3/step-8> a :Configuration .
376
+ <http://example/eyeling/turing/case3/step-9> :case :case3 .
377
+ <http://example/eyeling/turing/case3/step-9> :cell "1" .
378
+ <http://example/eyeling/turing/case3/step-9> :left "111" .
379
+ <http://example/eyeling/turing/case3/step-9> :machine :add1 .
380
+ <http://example/eyeling/turing/case3/step-9> :right "00#" .
381
+ <http://example/eyeling/turing/case3/step-9> :state :carry .
382
+ <http://example/eyeling/turing/case3/step-9> :step 9 .
383
+ <http://example/eyeling/turing/case3/step-9> a :Configuration .
384
+ <http://example/eyeling/turing/case4/step-0> :case :case4 .
385
+ <http://example/eyeling/turing/case4/step-0> :cell "#" .
386
+ <http://example/eyeling/turing/case4/step-0> :left "" .
387
+ <http://example/eyeling/turing/case4/step-0> :machine :add1 .
388
+ <http://example/eyeling/turing/case4/step-0> :right "" .
389
+ <http://example/eyeling/turing/case4/step-0> :state :scanRight .
390
+ <http://example/eyeling/turing/case4/step-0> :step 0 .
391
+ <http://example/eyeling/turing/case4/step-0> a :Configuration .
392
+ <http://example/eyeling/turing/case4/step-1> :case :case4 .
393
+ <http://example/eyeling/turing/case4/step-1> :cell "#" .
394
+ <http://example/eyeling/turing/case4/step-1> :left "" .
395
+ <http://example/eyeling/turing/case4/step-1> :machine :add1 .
396
+ <http://example/eyeling/turing/case4/step-1> :right "#" .
397
+ <http://example/eyeling/turing/case4/step-1> :state :carry .
398
+ <http://example/eyeling/turing/case4/step-1> :step 1 .
399
+ <http://example/eyeling/turing/case4/step-1> a :Configuration .
400
+ <http://example/eyeling/turing/case4/step-2> :case :case4 .
401
+ <http://example/eyeling/turing/case4/step-2> :cell "1" .
402
+ <http://example/eyeling/turing/case4/step-2> :left "" .
403
+ <http://example/eyeling/turing/case4/step-2> :machine :add1 .
404
+ <http://example/eyeling/turing/case4/step-2> :right "#" .
405
+ <http://example/eyeling/turing/case4/step-2> :state :halt .
406
+ <http://example/eyeling/turing/case4/step-2> :step 2 .
407
+ <http://example/eyeling/turing/case4/step-2> a :Configuration .
408
+ <http://example/eyeling/turing/case5/step-0> :case :case5 .
409
+ <http://example/eyeling/turing/case5/step-0> :cell "1" .
410
+ <http://example/eyeling/turing/case5/step-0> :left "" .
411
+ <http://example/eyeling/turing/case5/step-0> :machine :add1 .
412
+ <http://example/eyeling/turing/case5/step-0> :right "00000" .
413
+ <http://example/eyeling/turing/case5/step-0> :state :scanRight .
414
+ <http://example/eyeling/turing/case5/step-0> :step 0 .
415
+ <http://example/eyeling/turing/case5/step-0> a :Configuration .
416
+ <http://example/eyeling/turing/case5/step-1> :case :case5 .
417
+ <http://example/eyeling/turing/case5/step-1> :cell "0" .
418
+ <http://example/eyeling/turing/case5/step-1> :left "1" .
419
+ <http://example/eyeling/turing/case5/step-1> :machine :add1 .
420
+ <http://example/eyeling/turing/case5/step-1> :right "0000" .
421
+ <http://example/eyeling/turing/case5/step-1> :state :scanRight .
422
+ <http://example/eyeling/turing/case5/step-1> :step 1 .
423
+ <http://example/eyeling/turing/case5/step-1> a :Configuration .
424
+ <http://example/eyeling/turing/case5/step-2> :case :case5 .
425
+ <http://example/eyeling/turing/case5/step-2> :cell "0" .
426
+ <http://example/eyeling/turing/case5/step-2> :left "10" .
427
+ <http://example/eyeling/turing/case5/step-2> :machine :add1 .
428
+ <http://example/eyeling/turing/case5/step-2> :right "000" .
429
+ <http://example/eyeling/turing/case5/step-2> :state :scanRight .
430
+ <http://example/eyeling/turing/case5/step-2> :step 2 .
431
+ <http://example/eyeling/turing/case5/step-2> a :Configuration .
432
+ <http://example/eyeling/turing/case5/step-3> :case :case5 .
433
+ <http://example/eyeling/turing/case5/step-3> :cell "0" .
434
+ <http://example/eyeling/turing/case5/step-3> :left "100" .
435
+ <http://example/eyeling/turing/case5/step-3> :machine :add1 .
436
+ <http://example/eyeling/turing/case5/step-3> :right "00" .
437
+ <http://example/eyeling/turing/case5/step-3> :state :scanRight .
438
+ <http://example/eyeling/turing/case5/step-3> :step 3 .
439
+ <http://example/eyeling/turing/case5/step-3> a :Configuration .
440
+ <http://example/eyeling/turing/case5/step-4> :case :case5 .
441
+ <http://example/eyeling/turing/case5/step-4> :cell "0" .
442
+ <http://example/eyeling/turing/case5/step-4> :left "1000" .
443
+ <http://example/eyeling/turing/case5/step-4> :machine :add1 .
444
+ <http://example/eyeling/turing/case5/step-4> :right "0" .
445
+ <http://example/eyeling/turing/case5/step-4> :state :scanRight .
446
+ <http://example/eyeling/turing/case5/step-4> :step 4 .
447
+ <http://example/eyeling/turing/case5/step-4> a :Configuration .
448
+ <http://example/eyeling/turing/case5/step-5> :case :case5 .
449
+ <http://example/eyeling/turing/case5/step-5> :cell "0" .
450
+ <http://example/eyeling/turing/case5/step-5> :left "10000" .
451
+ <http://example/eyeling/turing/case5/step-5> :machine :add1 .
452
+ <http://example/eyeling/turing/case5/step-5> :right "" .
453
+ <http://example/eyeling/turing/case5/step-5> :state :scanRight .
454
+ <http://example/eyeling/turing/case5/step-5> :step 5 .
455
+ <http://example/eyeling/turing/case5/step-5> a :Configuration .
456
+ <http://example/eyeling/turing/case5/step-6> :case :case5 .
457
+ <http://example/eyeling/turing/case5/step-6> :cell "#" .
458
+ <http://example/eyeling/turing/case5/step-6> :left "100000" .
459
+ <http://example/eyeling/turing/case5/step-6> :machine :add1 .
460
+ <http://example/eyeling/turing/case5/step-6> :right "" .
461
+ <http://example/eyeling/turing/case5/step-6> :state :scanRight .
462
+ <http://example/eyeling/turing/case5/step-6> :step 6 .
463
+ <http://example/eyeling/turing/case5/step-6> a :Configuration .
464
+ <http://example/eyeling/turing/case5/step-7> :case :case5 .
465
+ <http://example/eyeling/turing/case5/step-7> :cell "0" .
466
+ <http://example/eyeling/turing/case5/step-7> :left "10000" .
467
+ <http://example/eyeling/turing/case5/step-7> :machine :add1 .
468
+ <http://example/eyeling/turing/case5/step-7> :right "#" .
469
+ <http://example/eyeling/turing/case5/step-7> :state :carry .
470
+ <http://example/eyeling/turing/case5/step-7> :step 7 .
471
+ <http://example/eyeling/turing/case5/step-7> a :Configuration .
472
+ <http://example/eyeling/turing/case5/step-8> :case :case5 .
473
+ <http://example/eyeling/turing/case5/step-8> :cell "1" .
474
+ <http://example/eyeling/turing/case5/step-8> :left "10000" .
475
+ <http://example/eyeling/turing/case5/step-8> :machine :add1 .
476
+ <http://example/eyeling/turing/case5/step-8> :right "#" .
477
+ <http://example/eyeling/turing/case5/step-8> :state :halt .
478
+ <http://example/eyeling/turing/case5/step-8> :step 8 .
479
+ <http://example/eyeling/turing/case5/step-8> a :Configuration .
480
+ <http://example/eyeling/turing/report/through/http%3A%2F%2Fexample%2Feyeling%2Fturing%2Fcase1> :lastCase :case1 .
481
+ <http://example/eyeling/turing/report/through/http%3A%2F%2Fexample%2Feyeling%2Fturing%2Fcase1> :report :report .
482
+ <http://example/eyeling/turing/report/through/http%3A%2F%2Fexample%2Feyeling%2Fturing%2Fcase1> :summary "## Turing Machine\nThe generic SRL interpreter runs the :add1 Turing machine from transition facts.\n101001 + 1 = 101010" .
483
+ <http://example/eyeling/turing/report/through/http%3A%2F%2Fexample%2Feyeling%2Fturing%2Fcase1> a :ReportState .
484
+ <http://example/eyeling/turing/report/through/http%3A%2F%2Fexample%2Feyeling%2Fturing%2Fcase2> :lastCase :case2 .
485
+ <http://example/eyeling/turing/report/through/http%3A%2F%2Fexample%2Feyeling%2Fturing%2Fcase2> :report :report .
486
+ <http://example/eyeling/turing/report/through/http%3A%2F%2Fexample%2Feyeling%2Fturing%2Fcase2> :summary "## Turing Machine\nThe generic SRL interpreter runs the :add1 Turing machine from transition facts.\n101001 + 1 = 101010\n101111 + 1 = 110000" .
487
+ <http://example/eyeling/turing/report/through/http%3A%2F%2Fexample%2Feyeling%2Fturing%2Fcase2> a :ReportState .
488
+ <http://example/eyeling/turing/report/through/http%3A%2F%2Fexample%2Feyeling%2Fturing%2Fcase3> :lastCase :case3 .
489
+ <http://example/eyeling/turing/report/through/http%3A%2F%2Fexample%2Feyeling%2Fturing%2Fcase3> :report :report .
490
+ <http://example/eyeling/turing/report/through/http%3A%2F%2Fexample%2Feyeling%2Fturing%2Fcase3> :summary "## Turing Machine\nThe generic SRL interpreter runs the :add1 Turing machine from transition facts.\n101001 + 1 = 101010\n101111 + 1 = 110000\n111111 + 1 = 1000000" .
491
+ <http://example/eyeling/turing/report/through/http%3A%2F%2Fexample%2Feyeling%2Fturing%2Fcase3> a :ReportState .
492
+ <http://example/eyeling/turing/report/through/http%3A%2F%2Fexample%2Feyeling%2Fturing%2Fcase4> :lastCase :case4 .
493
+ <http://example/eyeling/turing/report/through/http%3A%2F%2Fexample%2Feyeling%2Fturing%2Fcase4> :report :report .
494
+ <http://example/eyeling/turing/report/through/http%3A%2F%2Fexample%2Feyeling%2Fturing%2Fcase4> :summary "## Turing Machine\nThe generic SRL interpreter runs the :add1 Turing machine from transition facts.\n101001 + 1 = 101010\n101111 + 1 = 110000\n111111 + 1 = 1000000\nempty tape + 1 = 1" .
495
+ <http://example/eyeling/turing/report/through/http%3A%2F%2Fexample%2Feyeling%2Fturing%2Fcase4> a :ReportState .
496
+ <http://example/eyeling/turing/report/through/http%3A%2F%2Fexample%2Feyeling%2Fturing%2Fcase5> :lastCase :case5 .
497
+ <http://example/eyeling/turing/report/through/http%3A%2F%2Fexample%2Feyeling%2Fturing%2Fcase5> :report :report .
498
+ <http://example/eyeling/turing/report/through/http%3A%2F%2Fexample%2Feyeling%2Fturing%2Fcase5> :summary "## Turing Machine\nThe generic SRL interpreter runs the :add1 Turing machine from transition facts.\n101001 + 1 = 101010\n101111 + 1 = 110000\n111111 + 1 = 1000000\nempty tape + 1 = 1\n100000 + 1 = 100001" .
499
+ <http://example/eyeling/turing/report/through/http%3A%2F%2Fexample%2Feyeling%2Fturing%2Fcase5> a :FinalReportState .
500
+ <http://example/eyeling/turing/report/through/http%3A%2F%2Fexample%2Feyeling%2Fturing%2Fcase5> a :ReportState .
@@ -0,0 +1,306 @@
1
+ # =================
2
+ # Turing machine
3
+ # =================
4
+ # SRL translation of eyeling/examples/turing.n3.
5
+ #
6
+ # The original N3 example defines a small Turing machine interpreter using
7
+ # list:firstRest, list:append, and recursive rules. This SRL version keeps the
8
+ # same idea as generic data-driven rules: a machine is described by transition
9
+ # facts, and the interpreter derives configurations until it reaches :halt.
10
+ #
11
+ # Source: https://raw.githubusercontent.com/eyereasoner/eyeling/refs/heads/main/examples/turing.n3
12
+
13
+ PREFIX log: <http://www.w3.org/2000/10/swap/log#>
14
+ PREFIX : <http://example/eyeling/turing/>
15
+
16
+ DATA {
17
+ :add1 a :TuringMachine ;
18
+ :start :scanRight ;
19
+ :transition :q0_0, :q0_1, :q0_blank, :q1_0, :q1_1, :q1_blank .
20
+
21
+ # Move to the right until the first blank, then carry one bit to the left.
22
+ :q0_0 :from :scanRight ; :read "0" ; :write "0" ; :move :right ; :to :scanRight .
23
+ :q0_1 :from :scanRight ; :read "1" ; :write "1" ; :move :right ; :to :scanRight .
24
+ :q0_blank :from :scanRight ; :read "#" ; :write "#" ; :move :left ; :to :carry .
25
+
26
+ # Carry one through trailing ones. A zero, or the leading blank, stops.
27
+ :q1_0 :from :carry ; :read "0" ; :write "1" ; :move :stop ; :to :halt .
28
+ :q1_1 :from :carry ; :read "1" ; :write "0" ; :move :left ; :to :carry .
29
+ :q1_blank :from :carry ; :read "#" ; :write "1" ; :move :stop ; :to :halt .
30
+
31
+ :case1 a :Run ; :machine :add1 ; :input "101001" ; :label "101001 + 1" ; :nextCase :case2 .
32
+ :case2 a :Run ; :machine :add1 ; :input "101111" ; :label "101111 + 1" ; :nextCase :case3 .
33
+ :case3 a :Run ; :machine :add1 ; :input "111111" ; :label "111111 + 1" ; :nextCase :case4 .
34
+ :case4 a :Run ; :machine :add1 ; :input "" ; :label "empty tape + 1" ; :nextCase :case5 .
35
+ :case5 a :Run ; :machine :add1 ; :input "100000" ; :label "100000 + 1" .
36
+
37
+ :report a :TuringReport ;
38
+ :machine :add1 ;
39
+ :firstCase :case1 ;
40
+ :title "## Turing Machine" ;
41
+ :intro "The generic SRL interpreter runs the :add1 Turing machine from transition facts." .
42
+ }
43
+
44
+ # Start a run with the first input symbol under the head.
45
+ RULE {
46
+ ?cfg a :Configuration ;
47
+ :case ?case ;
48
+ :machine ?machine ;
49
+ :step 0 ;
50
+ :state ?state ;
51
+ :left "" ;
52
+ :cell ?cell ;
53
+ :right ?right .
54
+ ?case :hasStep ?cfg .
55
+ }
56
+ WHERE {
57
+ ?case a :Run ; :machine ?machine ; :input ?input .
58
+ ?machine :start ?state .
59
+ SET(?len := STRLEN(?input))
60
+ FILTER(?len > 0)
61
+ SET(?cfg := IRI(CONCAT(STR(?case), "/step-0")))
62
+ SET(?cell := SUBSTR(?input, 1, 1))
63
+ SET(?right := SUBSTR(?input, 2))
64
+ }
65
+
66
+ # Empty input starts on a blank cell.
67
+ RULE {
68
+ ?cfg a :Configuration ;
69
+ :case ?case ;
70
+ :machine ?machine ;
71
+ :step 0 ;
72
+ :state ?state ;
73
+ :left "" ;
74
+ :cell "#" ;
75
+ :right "" .
76
+ ?case :hasStep ?cfg .
77
+ }
78
+ WHERE {
79
+ ?case a :Run ; :machine ?machine ; :input "" .
80
+ ?machine :start ?state .
81
+ SET(?cfg := IRI(CONCAT(STR(?case), "/step-0")))
82
+ }
83
+
84
+ # Move right: append the written cell to the left side, then read the first
85
+ # symbol from the right side, or a blank if the right side is empty.
86
+ RULE {
87
+ ?nextCfg a :Configuration ;
88
+ :case ?case ;
89
+ :machine ?machine ;
90
+ :step ?nextStep ;
91
+ :state ?nextState ;
92
+ :left ?newLeft ;
93
+ :cell ?newCell ;
94
+ :right ?newRight .
95
+ ?case :hasStep ?nextCfg .
96
+ }
97
+ WHERE {
98
+ ?cfg a :Configuration ;
99
+ :case ?case ;
100
+ :machine ?machine ;
101
+ :step ?step ;
102
+ :state ?state ;
103
+ :left ?left ;
104
+ :cell ?cell ;
105
+ :right ?right .
106
+ ?machine :transition ?transition .
107
+ ?transition :from ?state ; :read ?read ; :write ?write ; :move :right ; :to ?nextState .
108
+ FILTER(STR(?cell) = STR(?read))
109
+ SET(?nextStep := ?step + 1)
110
+ SET(?nextCfg := IRI(CONCAT(STR(?case), "/step-", STR(?nextStep))))
111
+ SET(?rightLen := STRLEN(?right))
112
+ SET(?newLeft := CONCAT(?left, ?write))
113
+ SET(?newCell := IF(?rightLen = 0, "#", SUBSTR(?right, 1, 1)))
114
+ SET(?newRight := IF(?rightLen = 0, "", SUBSTR(?right, 2)))
115
+ }
116
+
117
+ # Move left when there is a cell to the left of the head.
118
+ RULE {
119
+ ?nextCfg a :Configuration ;
120
+ :case ?case ;
121
+ :machine ?machine ;
122
+ :step ?nextStep ;
123
+ :state ?nextState ;
124
+ :left ?newLeft ;
125
+ :cell ?newCell ;
126
+ :right ?newRight .
127
+ ?case :hasStep ?nextCfg .
128
+ }
129
+ WHERE {
130
+ ?cfg a :Configuration ;
131
+ :case ?case ;
132
+ :machine ?machine ;
133
+ :step ?step ;
134
+ :state ?state ;
135
+ :left ?left ;
136
+ :cell ?cell ;
137
+ :right ?right .
138
+ ?machine :transition ?transition .
139
+ ?transition :from ?state ; :read ?read ; :write ?write ; :move :left ; :to ?nextState .
140
+ FILTER(STR(?cell) = STR(?read))
141
+ SET(?leftLen := STRLEN(?left))
142
+ FILTER(?leftLen > 0)
143
+ SET(?nextStep := ?step + 1)
144
+ SET(?nextCfg := IRI(CONCAT(STR(?case), "/step-", STR(?nextStep))))
145
+ SET(?newLeftLen := ?leftLen - 1)
146
+ SET(?newLeft := SUBSTR(?left, 1, ?newLeftLen))
147
+ SET(?newCell := SUBSTR(?left, ?leftLen, 1))
148
+ SET(?newRight := CONCAT(?write, ?right))
149
+ }
150
+
151
+ # Move left from the left edge: the new cell is blank.
152
+ RULE {
153
+ ?nextCfg a :Configuration ;
154
+ :case ?case ;
155
+ :machine ?machine ;
156
+ :step ?nextStep ;
157
+ :state ?nextState ;
158
+ :left "" ;
159
+ :cell "#" ;
160
+ :right ?newRight .
161
+ ?case :hasStep ?nextCfg .
162
+ }
163
+ WHERE {
164
+ ?cfg a :Configuration ;
165
+ :case ?case ;
166
+ :machine ?machine ;
167
+ :step ?step ;
168
+ :state ?state ;
169
+ :left ?left ;
170
+ :cell ?cell ;
171
+ :right ?right .
172
+ FILTER(STRLEN(?left) = 0)
173
+ ?machine :transition ?transition .
174
+ ?transition :from ?state ; :read ?read ; :write ?write ; :move :left ; :to ?nextState .
175
+ FILTER(STR(?cell) = STR(?read))
176
+ SET(?nextStep := ?step + 1)
177
+ SET(?nextCfg := IRI(CONCAT(STR(?case), "/step-", STR(?nextStep))))
178
+ SET(?newRight := CONCAT(?write, ?right))
179
+ }
180
+
181
+ # Stop: write the current cell and enter :halt without moving the head.
182
+ RULE {
183
+ ?nextCfg a :Configuration ;
184
+ :case ?case ;
185
+ :machine ?machine ;
186
+ :step ?nextStep ;
187
+ :state ?nextState ;
188
+ :left ?left ;
189
+ :cell ?write ;
190
+ :right ?right .
191
+ ?case :hasStep ?nextCfg .
192
+ }
193
+ WHERE {
194
+ ?cfg a :Configuration ;
195
+ :case ?case ;
196
+ :machine ?machine ;
197
+ :step ?step ;
198
+ :state ?state ;
199
+ :left ?left ;
200
+ :cell ?cell ;
201
+ :right ?right .
202
+ ?machine :transition ?transition .
203
+ ?transition :from ?state ; :read ?read ; :write ?write ; :move :stop ; :to ?nextState .
204
+ FILTER(STR(?cell) = STR(?read))
205
+ SET(?nextStep := ?step + 1)
206
+ SET(?nextCfg := IRI(CONCAT(STR(?case), "/step-", STR(?nextStep))))
207
+ }
208
+
209
+ # Compose the raw tape from the halting configuration.
210
+ RULE {
211
+ ?case :rawOutput ?raw ;
212
+ :haltedAtStep ?step .
213
+ }
214
+ WHERE {
215
+ ?cfg a :Configuration ;
216
+ :case ?case ;
217
+ :step ?step ;
218
+ :state :halt ;
219
+ :left ?left ;
220
+ :cell ?cell ;
221
+ :right ?right .
222
+ SET(?raw := CONCAT(?left, ?cell, ?right))
223
+ }
224
+
225
+ # The original list-based N3 machine leaves a trailing blank on these tapes.
226
+ # For the user-facing binary result, trim that final blank symbol.
227
+ RULE { ?case :output ?output }
228
+ WHERE {
229
+ ?case :rawOutput ?raw .
230
+ FILTER STRENDS(?raw, "#")
231
+ SET(?len := STRLEN(?raw) - 1)
232
+ SET(?output := SUBSTR(?raw, 1, ?len))
233
+ }
234
+
235
+ RULE { ?case :output ?raw }
236
+ WHERE {
237
+ ?case :rawOutput ?raw .
238
+ FILTER(!STRENDS(?raw, "#"))
239
+ }
240
+
241
+ # Derive a report line for each run. Adding a new case only requires adding
242
+ # another :Run fact and linking it into the :nextCase chain.
243
+ RULE {
244
+ ?case :reportLine ?line .
245
+ ?case log:outputString ?line .
246
+ }
247
+ WHERE {
248
+ ?case a :Run ; :label ?label ; :output ?output .
249
+ SET(?line := CONCAT(?label, " = ", ?output))
250
+ }
251
+
252
+ # Accumulate the report text from the data-driven case chain.
253
+ RULE {
254
+ ?state a :ReportState ;
255
+ :report ?report ;
256
+ :lastCase ?case ;
257
+ :summary ?summary .
258
+ }
259
+ WHERE {
260
+ ?report a :TuringReport ;
261
+ :title ?title ;
262
+ :intro ?intro ;
263
+ :firstCase ?case .
264
+ ?case :reportLine ?line .
265
+ SET(?state := IRI(CONCAT(STR(?report), "/through/", ENCODE_FOR_URI(STR(?case)))))
266
+ SET(?summary := CONCAT(?title, "\n", ?intro, "\n", ?line))
267
+ }
268
+
269
+ RULE {
270
+ ?nextState a :ReportState ;
271
+ :report ?report ;
272
+ :lastCase ?nextCase ;
273
+ :summary ?nextSummary .
274
+ }
275
+ WHERE {
276
+ ?state a :ReportState ;
277
+ :report ?report ;
278
+ :lastCase ?case ;
279
+ :summary ?summary .
280
+ ?case :nextCase ?nextCase .
281
+ ?nextCase :reportLine ?line .
282
+ SET(?nextState := IRI(CONCAT(STR(?report), "/through/", ENCODE_FOR_URI(STR(?nextCase)))))
283
+ SET(?nextSummary := CONCAT(?summary, "\n", ?line))
284
+ }
285
+
286
+ # Mark the accumulated report state that ends at the last case. This rule is
287
+ # intentionally SET-free so the stratified negation does not create a run-once
288
+ # rule in the recursive report-building component.
289
+ RULE {
290
+ ?state a :FinalReportState .
291
+ }
292
+ WHERE {
293
+ ?state a :ReportState ; :lastCase ?case .
294
+ NOT { ?case :nextCase ?later . }
295
+ }
296
+
297
+ RULE {
298
+ :answer a :TuringRun ;
299
+ :machine ?machine ;
300
+ :summary ?summary ;
301
+ log:outputString ?summary .
302
+ }
303
+ WHERE {
304
+ ?report a :TuringReport ; :machine ?machine .
305
+ ?state a :FinalReportState ; :report ?report ; :summary ?summary .
306
+ }
package/eyeleng.js CHANGED
@@ -40,7 +40,7 @@
40
40
  const VERSION = readPackageVersion();
41
41
 
42
42
  function help() {
43
- return `eyeleng ${VERSION}\n\nA dependency-free JavaScript implementation experiment for the SHACL 1.2 Rules draft, including SRL and RDF Rules syntax front-ends.\n\nUsage:\n eyeleng [options] [file ...]\n\nOptions:\n --all Print the full closure, including input facts\n --json Print JSON instead of compact triples/bindings\n --trace Print derivation trace to stderr, or include it in JSON\n --stats Print iteration and triple counts to stderr\n --check Parse and analyze only; do not run rules\n --strict Treat static warnings as errors\n --deps Print rule dependency edges during --check\n --query TEXT Run a raw SRL body pattern over the closure\n --query-file FILE Read a raw SRL body pattern from a file\n --max-iterations N Stop after N fixpoint iterations within a recursive layer\n --no-imports Parse IMPORTS/owl:imports but do not load imported rule sets\n --syntax MODE Use srl, rdf, or auto syntax detection (default auto)\n --ruleset TERM In RDF syntax, run only the selected srl:RuleSet\n --version Print version\n -h, --help Print this help\n\nWith no file arguments, eyeleng reads from stdin.\n`;
43
+ return `eyeleng ${VERSION}\n\nA dependency-free JavaScript implementation experiment for the SHACL 1.2 Rules draft, including SRL and RDF Rules syntax front-ends.\n\nUsage:\n eyeleng [options] [file ...]\n\nOptions:\n --all Print the full closure, including input facts\n --json Print JSON instead of compact triples/bindings\n --trace Print derivation trace to stderr, or include it in JSON\n --stats Print iteration and triple counts to stderr\n --check Parse and analyze only; do not run rules\n --strict Treat static warnings as errors\n --deps Print rule dependency edges during --check\n --query TEXT Run a raw SRL body pattern over the closure\n --query-file FILE Read a raw SRL body pattern from a file\n --max-iterations N Stop after N fixpoint iterations within a recursive layer\n --no-imports Parse IMPORTS/owl:imports but do not load imported rule sets\n --rdf-messages Parse input as an RDF Message Log\n --stream-messages Replay RDF Message Log envelopes\n --include-message-facts Include payload facts while parsing RDF Message Logs\n --syntax MODE Use srl, rdf, or auto syntax detection (default auto)\n --ruleset TERM In RDF syntax, run only the selected srl:RuleSet\n --version Print version\n -h, --help Print this help\n\nWith no file arguments, eyeleng reads from stdin.\n`;
44
44
  }
45
45
 
46
46
  function parseArgs(argv) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eyeleng",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "description": "The EYE Logic Engine: a JavaScript implementation of SHACL Rules, including SRL and RDF Rules syntax front-ends.",
5
5
  "keywords": [
6
6
  "SRL",
package/src/cli.js CHANGED
@@ -34,7 +34,7 @@ function readPackageVersion() {
34
34
  const VERSION = readPackageVersion();
35
35
 
36
36
  function help() {
37
- return `eyeleng ${VERSION}\n\nA dependency-free JavaScript implementation experiment for the SHACL 1.2 Rules draft, including SRL and RDF Rules syntax front-ends.\n\nUsage:\n eyeleng [options] [file ...]\n\nOptions:\n --all Print the full closure, including input facts\n --json Print JSON instead of compact triples/bindings\n --trace Print derivation trace to stderr, or include it in JSON\n --stats Print iteration and triple counts to stderr\n --check Parse and analyze only; do not run rules\n --strict Treat static warnings as errors\n --deps Print rule dependency edges during --check\n --query TEXT Run a raw SRL body pattern over the closure\n --query-file FILE Read a raw SRL body pattern from a file\n --max-iterations N Stop after N fixpoint iterations within a recursive layer\n --no-imports Parse IMPORTS/owl:imports but do not load imported rule sets\n --syntax MODE Use srl, rdf, or auto syntax detection (default auto)\n --ruleset TERM In RDF syntax, run only the selected srl:RuleSet\n --version Print version\n -h, --help Print this help\n\nWith no file arguments, eyeleng reads from stdin.\n`;
37
+ return `eyeleng ${VERSION}\n\nA dependency-free JavaScript implementation experiment for the SHACL 1.2 Rules draft, including SRL and RDF Rules syntax front-ends.\n\nUsage:\n eyeleng [options] [file ...]\n\nOptions:\n --all Print the full closure, including input facts\n --json Print JSON instead of compact triples/bindings\n --trace Print derivation trace to stderr, or include it in JSON\n --stats Print iteration and triple counts to stderr\n --check Parse and analyze only; do not run rules\n --strict Treat static warnings as errors\n --deps Print rule dependency edges during --check\n --query TEXT Run a raw SRL body pattern over the closure\n --query-file FILE Read a raw SRL body pattern from a file\n --max-iterations N Stop after N fixpoint iterations within a recursive layer\n --no-imports Parse IMPORTS/owl:imports but do not load imported rule sets\n --rdf-messages Parse input as an RDF Message Log\n --stream-messages Replay RDF Message Log envelopes\n --include-message-facts Include payload facts while parsing RDF Message Logs\n --syntax MODE Use srl, rdf, or auto syntax detection (default auto)\n --ruleset TERM In RDF syntax, run only the selected srl:RuleSet\n --version Print version\n -h, --help Print this help\n\nWith no file arguments, eyeleng reads from stdin.\n`;
38
38
  }
39
39
 
40
40
  function parseArgs(argv) {
@@ -0,0 +1,41 @@
1
+ 'use strict';
2
+
3
+ const assert = require('node:assert/strict');
4
+ const fs = require('node:fs');
5
+ const path = require('node:path');
6
+ const { test, main } = require('./harness.js').createHarness('CLI');
7
+ const { help, parseArgs } = require('../src/cli.js');
8
+
9
+ function longOptions(text) {
10
+ return Array.from(text.matchAll(/(^|\s)(--[a-z][a-z0-9-]*)\b/gm), (match) => match[2])
11
+ .filter((option, index, options) => options.indexOf(option) === index)
12
+ .sort();
13
+ }
14
+
15
+ function readmeCliOptions() {
16
+ const readme = fs.readFileSync(path.join(__dirname, '..', 'README.md'), 'utf8');
17
+ const match = readme.match(/Important options:\n\n```text\n([\s\S]*?)\n```/);
18
+ assert.ok(match, 'README.md should contain the CLI Important options text block');
19
+ return match[1];
20
+ }
21
+
22
+ test('CLI help documents RDF Message Log flags', () => {
23
+ const text = help();
24
+ assert.match(text, /--rdf-messages\s+Parse input as an RDF Message Log/);
25
+ assert.match(text, /--stream-messages\s+Replay RDF Message Log envelopes/);
26
+ assert.match(text, /--include-message-facts\s+Include payload facts while parsing RDF Message Logs/);
27
+ });
28
+
29
+ test('README CLI options stay in sync with --help', () => {
30
+ const helpOptions = longOptions(help()).filter((option) => option !== '--help');
31
+ const readmeOptions = longOptions(readmeCliOptions()).filter((option) => option !== '--help');
32
+ assert.deepEqual(readmeOptions, helpOptions);
33
+ });
34
+
35
+ test('RDF Message Log flags are accepted by parseArgs', () => {
36
+ assert.equal(parseArgs(['--rdf-messages']).options.rdfMessages, true);
37
+ assert.equal(parseArgs(['--stream-messages']).options.rdfMessages, true);
38
+ assert.equal(parseArgs(['--include-message-facts']).options.includeMessageFacts, true);
39
+ });
40
+
41
+ main();
package/test/run.js CHANGED
@@ -13,6 +13,7 @@ const summaryFile = path.join(os.tmpdir(), `eyeleng-test-summary-${process.pid}.
13
13
 
14
14
  const preferred = [
15
15
  'api.test.js',
16
+ 'cli.test.js',
16
17
  'builtins.test.js',
17
18
  'browser-bundle.test.js',
18
19
  'examples.test.js',