eyeling 1.16.2 → 1.16.4

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.
Files changed (51) hide show
  1. package/HANDBOOK.md +4 -0
  2. package/README.md +0 -1
  3. package/examples/ershov-mixed-computation.n3 +106 -0
  4. package/examples/output/ershov-mixed-computation.n3 +15 -0
  5. package/eyeling.js +510 -263
  6. package/lib/cli.js +22 -12
  7. package/lib/engine.js +488 -251
  8. package/package.json +2 -3
  9. package/arctifacts/README.md +0 -59
  10. package/arctifacts/ackermann.html +0 -678
  11. package/arctifacts/auroracare.html +0 -1297
  12. package/arctifacts/bike-trip.html +0 -752
  13. package/arctifacts/binomial-theorem.html +0 -631
  14. package/arctifacts/bmi.html +0 -511
  15. package/arctifacts/building-performance.html +0 -750
  16. package/arctifacts/clinical-care.html +0 -726
  17. package/arctifacts/collatz.html +0 -403
  18. package/arctifacts/complex.html +0 -321
  19. package/arctifacts/control-system.html +0 -482
  20. package/arctifacts/delfour.html +0 -849
  21. package/arctifacts/earthquake-epicenter.html +0 -982
  22. package/arctifacts/eco-route.html +0 -662
  23. package/arctifacts/euclid-infinitude.html +0 -564
  24. package/arctifacts/euler-identity.html +0 -667
  25. package/arctifacts/exoplanet-transit.html +0 -1000
  26. package/arctifacts/faltings-theorem.html +0 -1046
  27. package/arctifacts/fibonacci.html +0 -299
  28. package/arctifacts/fundamental-theorem-arithmetic.html +0 -398
  29. package/arctifacts/godel-numbering.html +0 -743
  30. package/arctifacts/gps-bike.html +0 -759
  31. package/arctifacts/gps-clinical-bench.html +0 -792
  32. package/arctifacts/graph-french.html +0 -449
  33. package/arctifacts/grass-molecular.html +0 -592
  34. package/arctifacts/group-theory.html +0 -740
  35. package/arctifacts/health-info.html +0 -833
  36. package/arctifacts/kaprekar-constant.html +0 -576
  37. package/arctifacts/lee.html +0 -805
  38. package/arctifacts/linked-lists.html +0 -502
  39. package/arctifacts/lldm.html +0 -612
  40. package/arctifacts/matrix-multiplication.html +0 -502
  41. package/arctifacts/matrix.html +0 -651
  42. package/arctifacts/newton-raphson.html +0 -944
  43. package/arctifacts/peano-factorial.html +0 -456
  44. package/arctifacts/pi.html +0 -363
  45. package/arctifacts/polynomial.html +0 -646
  46. package/arctifacts/prime.html +0 -366
  47. package/arctifacts/pythagorean-theorem.html +0 -468
  48. package/arctifacts/rest-path.html +0 -469
  49. package/arctifacts/roots-of-unity.html +0 -363
  50. package/arctifacts/turing.html +0 -409
  51. package/arctifacts/wind-turbines.html +0 -726
@@ -1,409 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1" />
6
- <title>Turing Machine (Binary +1)</title>
7
- <style>
8
- :root {
9
- --bg: #ffffff;
10
- --ink: #111827;
11
- --muted: #6b7280;
12
- --panel: #f8fafc;
13
- --border: #e5e7eb;
14
- --accent: #0ea5e9;
15
- --good: #16a34a;
16
- --cyan: #06b6d4;
17
- --indigo: #6366f1;
18
- --warn: #dc2626;
19
- --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
20
- --ui:
21
- system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', 'Apple Color Emoji',
22
- 'Segoe UI Emoji';
23
- }
24
- html,
25
- body {
26
- height: 100%;
27
- }
28
- body {
29
- margin: 0;
30
- background: var(--bg);
31
- color: var(--ink);
32
- font: 15px/1.55 var(--ui);
33
- }
34
- .wrap {
35
- max-width: 980px;
36
- margin: 28px auto;
37
- padding: 0 14px;
38
- }
39
- header {
40
- display: flex;
41
- align-items: center;
42
- justify-content: space-between;
43
- margin-bottom: 14px;
44
- }
45
- h1 {
46
- font-size: 20px;
47
- margin: 0;
48
- letter-spacing: 0.2px;
49
- }
50
- .pill {
51
- display: inline-flex;
52
- align-items: center;
53
- gap: 8px;
54
- padding: 6px 10px;
55
- border: 1px solid var(--border);
56
- border-radius: 999px;
57
- color: var(--muted);
58
- background: #fff;
59
- }
60
- .card {
61
- width: 100%;
62
- background: var(--panel);
63
- border: 1px solid var(--border);
64
- border-radius: 14px;
65
- overflow: hidden;
66
- margin-bottom: 14px;
67
- }
68
- .head {
69
- display: flex;
70
- align-items: center;
71
- justify-content: space-between;
72
- padding: 10px 12px;
73
- border-bottom: 1px solid var(--border);
74
- }
75
- .head h2 {
76
- font-size: 13px;
77
- text-transform: uppercase;
78
- letter-spacing: 0.08em;
79
- color: var(--muted);
80
- margin: 0;
81
- }
82
- .body {
83
- padding: 12px;
84
- }
85
- pre {
86
- white-space: pre-wrap;
87
- background: #fff;
88
- border: 1px solid var(--border);
89
- border-radius: 10px;
90
- padding: 12px;
91
- overflow: auto;
92
- font-family: var(--mono);
93
- font-size: 13px;
94
- margin: 0;
95
- }
96
- button {
97
- all: unset;
98
- background: #fff;
99
- border: 1px solid var(--border);
100
- padding: 9px 13px;
101
- border-radius: 10px;
102
- cursor: pointer;
103
- }
104
- button:hover {
105
- border-color: #cbd5e1;
106
- }
107
- .btns {
108
- display: flex;
109
- gap: 8px;
110
- flex-wrap: wrap;
111
- }
112
- .muted {
113
- color: var(--muted);
114
- }
115
-
116
- /* ARC boxes with thick colored left borders */
117
- .arcbox {
118
- background: #fff;
119
- border: 1px solid var(--border);
120
- border-radius: 12px;
121
- padding: 10px;
122
- margin: 10px 0;
123
- }
124
- .arcbox.answer {
125
- border-left: 10px solid var(--good);
126
- }
127
- .arcbox.reason {
128
- border-left: 10px solid var(--cyan);
129
- }
130
- .arcbox.check {
131
- border-left: 10px solid var(--indigo);
132
- }
133
- .arclabel {
134
- font-size: 11px;
135
- text-transform: uppercase;
136
- letter-spacing: 0.08em;
137
- color: var(--muted);
138
- margin-bottom: 6px;
139
- }
140
- </style>
141
- </head>
142
- <body>
143
- <div class="wrap">
144
- <header>
145
- <h1>Turing Machine (Binary incrementer)</h1>
146
- <div class="pill" id="status">Ready</div>
147
- </header>
148
-
149
- <div class="card">
150
- <div class="body">
151
- <p>
152
- <strong>What this is?</strong> A self‑contained, browser‑only demo of a one‑tape deterministic Turing
153
- Machine that computes <em>n → n+1</em> on unsigned binary. The ARC section reports
154
- <em>Answer • Reason • Check</em>.
155
- </p>
156
- </div>
157
- </div>
158
-
159
- <!-- Vertical layout: cards stacked in a single column -->
160
- <div class="card">
161
- <div class="head"><h2>Machine (fixed program)</h2></div>
162
- <div class="body">
163
- <pre class="muted" id="progBox">
164
- States: S0, S1, HALT Symbols: 0, 1, _ Moves: L, R, N
165
-
166
- S0: scan right to the first blank, then step left and switch to S1
167
- (S0, 0) -> (0, R, S0)
168
- (S0, 1) -> (1, R, S0)
169
- (S0, _) -> (_, L, S1)
170
-
171
- S1: add 1 with carry (to the left)
172
- (S1, 0) -> (1, N, HALT) ; found 0 → write 1 and halt
173
- (S1, 1) -> (0, L, S1) ; carry: flip 1→0 and keep going left
174
- (S1, _) -> (1, N, HALT) ; overflow (all 1s) → write leading 1 and halt</pre
175
- >
176
- <div class="btns" style="margin-top: 10px">
177
- <button onclick="run()">▶ Run</button>
178
- <button onclick="copyARC()">Copy ARC</button>
179
- <button onclick="downloadTxt()">⬇ Export .txt</button>
180
- </div>
181
- </div>
182
- </div>
183
-
184
- <div class="card">
185
- <div class="head"><h2>Samples</h2></div>
186
- <div class="body">
187
- <pre id="samplesBox" class="muted">
188
- A1: 101001 → 101010
189
- A2: 101111 → 110000
190
- A3: 111111 → 1000000
191
- A4: [] → [1]</pre
192
- >
193
- </div>
194
- </div>
195
-
196
- <div class="card">
197
- <div class="head">
198
- <h2>ARC Output</h2>
199
- <div class="muted">Cards with left borders</div>
200
- </div>
201
- <div class="body">
202
- <div class="arcbox answer">
203
- <div class="arclabel">Answer</div>
204
- <pre id="ans">(no run yet)</pre>
205
- </div>
206
- <div class="arcbox reason">
207
- <div class="arclabel">Reason why</div>
208
- <pre id="why">(no run yet)</pre>
209
- </div>
210
- <div class="arcbox check">
211
- <div class="arclabel">Check (harness)</div>
212
- <pre id="chk">(no run yet)</pre>
213
- </div>
214
- </div>
215
- </div>
216
- </div>
217
-
218
- <script>
219
- // ====== Turing Machine runtime ======
220
- const BLANK = '_';
221
- const PROGRAM = new Map([
222
- // S0: march right to the first blank, then step left and switch to S1
223
- [['S0', '0'].toString(), ['0', 'R', 'S0']],
224
- [['S0', '1'].toString(), ['1', 'R', 'S0']],
225
- [['S0', BLANK].toString(), [BLANK, 'L', 'S1']],
226
- // S1: add 1 with carry (to the left)
227
- [['S1', '0'].toString(), ['1', 'N', 'HALT']],
228
- [['S1', '1'].toString(), ['0', 'L', 'S1']],
229
- [['S1', BLANK].toString(), ['1', 'N', 'HALT']],
230
- ]);
231
-
232
- function tm_run(tapeArray, startState = 'S0', haltStates = new Set(['HALT']), maxSteps = 10000) {
233
- // sparse tape as Map(index -> symbol)
234
- const tape = new Map();
235
- for (let i = 0; i < tapeArray.length; i++) tape.set(i, tapeArray[i]);
236
- let head = 0,
237
- state = startState,
238
- steps = 0;
239
- while (!haltStates.has(state) && steps < maxSteps) {
240
- const sym = tape.has(head) ? tape.get(head) : BLANK;
241
- const key = [state, sym].toString();
242
- if (!PROGRAM.has(key)) break; // implicit halt if no rule
243
- const [write, move, next] = PROGRAM.get(key);
244
- tape.set(head, write);
245
- if (move === 'L') head--;
246
- else if (move === 'R') head++;
247
- // 'N' -> no move
248
- state = next;
249
- steps++;
250
- }
251
- // compact tape back to array and trim outer blanks
252
- if (tape.size === 0) return [];
253
- let lo = Math.min(...tape.keys()),
254
- hi = Math.max(...tape.keys());
255
- const out = [];
256
- for (let i = lo; i <= hi; i++) out.push(tape.get(i) ?? BLANK);
257
- while (out.length && out[0] === BLANK) out.shift();
258
- while (out.length && out[out.length - 1] === BLANK) out.pop();
259
- return out;
260
- }
261
- function increment(bits) {
262
- const inTape = bits.map((b) => String(b));
263
- const out = tm_run(inTape);
264
- return out.map((c) => Number(c));
265
- }
266
-
267
- // ====== Helpers ======
268
- function bits_to_int(bits) {
269
- return bits.reduce((x, b) => (x << 1) | (b & 1), 0);
270
- }
271
- function int_to_bits(x) {
272
- if (x <= 0) return [];
273
- const out = [];
274
- while (x) {
275
- out.push(x & 1);
276
- x >>= 1;
277
- }
278
- return out.reverse();
279
- }
280
- function normalize(bits) {
281
- let i = 0;
282
- while (i < bits.length && bits[i] === 0) i++;
283
- return bits.slice(i);
284
- }
285
- function setText(id, s) {
286
- const el = document.getElementById(id);
287
- if (el) el.textContent = s;
288
- }
289
- function status(msg, warn = false) {
290
- const el = document.getElementById('status');
291
- if (!el) return;
292
- el.textContent = msg;
293
- el.classList.toggle('warn', !!warn);
294
- }
295
-
296
- // ====== ARC runners ======
297
- function run() {
298
- // Answer
299
- let A = 'Answer\n======\n';
300
- const samples = {
301
- A1: [1, 0, 1, 0, 0, 1],
302
- A2: [1, 0, 1, 1, 1, 1],
303
- A3: [1, 1, 1, 1, 1, 1],
304
- A4: [],
305
- };
306
- for (const k of Object.keys(samples)) {
307
- const tape = samples[k];
308
- const out = increment(tape);
309
- A += `${k}: ${JSON.stringify(tape)} -> ${JSON.stringify(out)}\n`;
310
- }
311
- setText('ans', A);
312
-
313
- // Reason
314
- let R = 'Reason why\n==========\n';
315
- R += 'One-tape machine over symbols {0,1,_}.\n';
316
- R += 'Two phases:\n';
317
- R += ' • S0 scans right to the first blank to find the number’s end, then moves left.\n';
318
- R += ' • S1 performs +1 with carry: 1→0 and move left; if it sees 0, write 1 and halt;\n';
319
- R += ' if it runs off the left end (blank), write a leading 1 and halt.\n';
320
- R += 'Examples: 101001 → 101010; 111111 → 1000000; [] (zero) → [1].';
321
- setText('why', R);
322
-
323
- // Check
324
- let C = 'Check (harness)\n===============\n';
325
- // A) Correctness vs integers 0..4095
326
- let ok = true;
327
- for (let n = 0; n < 4096; n++) {
328
- const bits = int_to_bits(n);
329
- const inc_bits = increment(bits);
330
- const want = int_to_bits(n + 1);
331
- if (JSON.stringify(normalize(inc_bits)) !== JSON.stringify(normalize(want))) {
332
- ok = false;
333
- break;
334
- }
335
- }
336
- C += `Matches n→n+1 for 0..4095? ${ok}\n`;
337
- // B) Structural properties
338
- function well_formed(bs) {
339
- return bs.every((b) => b === 0 || b === 1);
340
- }
341
- let ok_len = true,
342
- ok_wf = true;
343
- const tests = [[], [0], [1], [1, 0], [1, 1], [1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 0, 1], [1, 0, 1, 1, 1, 1]];
344
- for (const bits of tests) {
345
- const out = increment(bits);
346
- if (!(out.length === bits.length || out.length === bits.length + 1)) ok_len = false;
347
- if (!well_formed(out)) ok_wf = false;
348
- }
349
- C += `Output length ∈ {len, len+1} on samples? ${ok_len}\n`;
350
- C += `Output symbols only 0/1? ${ok_wf}\n`;
351
- // C) Monotone
352
- let ok_mono = true;
353
- for (let n = 0; n < 200; n++) {
354
- const nxt = bits_to_int(increment(int_to_bits(n)));
355
- if (nxt !== n + 1) {
356
- ok_mono = false;
357
- break;
358
- }
359
- }
360
- C += `Monotone w.r.t. integer value (first 200)? ${ok_mono}\n`;
361
- // D) All-ones
362
- let ok_ones = true;
363
- for (let k = 1; k <= 15; k++) {
364
- const inp = Array(k).fill(1);
365
- const out = increment(inp);
366
- const want = [1].concat(Array(k).fill(0));
367
- if (JSON.stringify(out) !== JSON.stringify(want)) {
368
- ok_ones = false;
369
- break;
370
- }
371
- }
372
- C += `All-ones case yields 1 followed by k zeros? ${ok_ones}\n`;
373
- const ok_all = ok && ok_len && ok_wf && ok_mono && ok_ones;
374
- C += `\nAll checks passed? ${ok_all}`;
375
- setText('chk', C);
376
-
377
- status('Done');
378
- }
379
-
380
- function copyARC() {
381
- const txt = [
382
- document.getElementById('ans').textContent,
383
- document.getElementById('why').textContent,
384
- document.getElementById('chk').textContent,
385
- ].join('\n\n');
386
- navigator.clipboard?.writeText(txt).catch(() => {});
387
- }
388
- function downloadTxt() {
389
- const blob = new Blob(
390
- [
391
- document.getElementById('ans').textContent,
392
- '\n\n',
393
- document.getElementById('why').textContent,
394
- '\n\n',
395
- document.getElementById('chk').textContent,
396
- ],
397
- { type: 'text/plain' },
398
- );
399
- const a = document.createElement('a');
400
- a.href = URL.createObjectURL(blob);
401
- a.download = 'turing_output.txt';
402
- a.click();
403
- }
404
-
405
- // auto-run
406
- window.addEventListener('DOMContentLoaded', run);
407
- </script>
408
- </body>
409
- </html>