eyeling 1.33.5 → 1.33.7

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 (34) hide show
  1. package/README.md +50 -106
  2. package/docs/eyelang-guide.md +550 -0
  3. package/docs/eyelang-language-reference.md +11 -9
  4. package/examples/eyelang/annotation.pl +9 -9
  5. package/examples/eyelang/context-association.pl +3 -3
  6. package/examples/eyelang/delfour.pl +7 -7
  7. package/examples/eyelang/dijkstra-risk-path.pl +2 -2
  8. package/examples/eyelang/dijkstra.pl +2 -2
  9. package/examples/eyelang/family-cousins.pl +1 -1
  10. package/examples/eyelang/gps.pl +4 -4
  11. package/examples/eyelang/odrl-dpv-healthcare-risk-ranked.pl +2 -2
  12. package/examples/eyelang/odrl-dpv-risk-ranked.pl +2 -2
  13. package/examples/eyelang/proof/annotation.pl +12 -12
  14. package/examples/eyelang/resilient-city-orchestration.pl +5 -5
  15. package/lib/eyelang/builtins/context.js +42 -0
  16. package/lib/eyelang/builtins/registry.js +2 -2
  17. package/package.json +1 -1
  18. package/test/eyelang/conformance/README.md +1 -1
  19. package/test/eyelang/conformance/cases/extension/006_holds_parts.pl +4 -0
  20. package/test/eyelang/conformance/cases/extension/026_nested_holds_parts.pl +4 -0
  21. package/test/eyelang/conformance/cases/extension/027_formula_member.query +1 -0
  22. package/test/eyelang/conformance/cases/extension/027_holds_member.pl +3 -0
  23. package/test/eyelang/conformance/expected/extension/006_holds_parts.out +3 -0
  24. package/test/eyelang/conformance/expected/extension/026_nested_holds_parts.out +3 -0
  25. package/test/eyelang/conformance/expected/extension/027_holds_member.out +2 -0
  26. package/test/eyelang/run-regression.mjs +2 -2
  27. package/test/packlist.test.js +1 -0
  28. package/examples/eyelang/INTEGRATION.md +0 -20
  29. package/examples/eyelang/README.md +0 -553
  30. package/lib/eyelang/builtins/formula.js +0 -26
  31. package/test/eyelang/conformance/cases/extension/006_formula_terms.pl +0 -4
  32. package/test/eyelang/conformance/cases/extension/026_nested_formula_terms.pl +0 -4
  33. package/test/eyelang/conformance/expected/extension/006_formula_terms.out +0 -2
  34. package/test/eyelang/conformance/expected/extension/026_nested_formula_terms.out +0 -3
@@ -0,0 +1,550 @@
1
+ # eyelang Guide
2
+
3
+ This guide introduces eyelang, the small Prolog-style Horn-clause engine bundled with Eyeling. eyelang works over ordinary terms, lists, arithmetic, strings, and finite search. Run it through the main Eyeling CLI with `eyeling --engine eyelang`, or use `node lib/eyelang/bin.js` when working directly from a source checkout.
4
+
5
+ Programs write relations directly, for example `ancestor(pat, emma)` or `status(case1, accepted)`. eyelang output is ordinary eyelang syntax: by default, the CLI materializes selected answer facts and prints those facts only. Pass `--proof` (or `-p`) when you also want each answer followed by a `why/2` explanation fact that records the proof. Programs may add `materialize(Name, Arity).` declarations to focus output on selected predicates.
6
+
7
+
8
+ Try it in the [Eyeling browser playground](https://eyereasoner.github.io/eyeling/playground). The playground includes run options equivalent to CLI `--stats` and `--proof` when the eyelang engine is selected.
9
+
10
+ For the normative language definition, including lexical syntax, terms, clauses, goals, built-ins, `memoize/2`, `materialize/2`, and conformance boundaries, read the [eyelang language reference](eyelang-language-reference.md).
11
+
12
+ ## Contents
13
+
14
+ 1. [Quick start](#quick-start)
15
+ 2. [Running eyelang](#running-eyelang)
16
+ 3. [Default output](#default-output)
17
+ 4. [Writing programs](#writing-programs)
18
+ 5. [Aggregation helpers](#aggregation-helpers)
19
+ 6. [Context data](#context-data)
20
+ 7. [Example catalog](#example-catalog)
21
+ 8. [Golden outputs, tests, and conformance](#golden-outputs-tests-and-conformance)
22
+ 9. [Development and release](#development-and-release)
23
+ 10. [Relationship to Eyeling](#relationship-to-eyeling)
24
+ 11. [Performance notes](#performance-notes)
25
+ 12. [Implementation limits](#implementation-limits)
26
+
27
+ ## Quick start
28
+
29
+ Install dependencies, then run the eyelang engine through the main CLI:
30
+
31
+ ```sh
32
+ npm install
33
+ ```
34
+
35
+ There is no build step for the source-checkout CLI path. Run examples, multiple inputs, stdin, or a URL:
36
+
37
+ ```sh
38
+ eyeling --engine eyelang --version
39
+ eyeling --engine eyelang examples/eyelang/ancestor.pl
40
+ eyeling --engine eyelang facts.pl rules.pl
41
+ printf 'works(stdin, true) :- eq(ok, ok).\n' | eyeling --engine eyelang -
42
+ eyeling --engine eyelang https://raw.githubusercontent.com/eyereasoner/eyeling/refs/heads/main/examples/eyelang/ancestor.pl
43
+ ```
44
+
45
+ The CLI runs directly on Node.js 18 or newer. From a source checkout, `node lib/eyelang/bin.js` exposes the same eyelang-specific options without going through the `--engine` router.
46
+
47
+ Serve the playground locally:
48
+
49
+ ```sh
50
+ python3 -m http.server 8000
51
+ # then open http://localhost:8000/playground.html
52
+ ```
53
+
54
+ ## Running eyelang
55
+
56
+ Show the package version:
57
+
58
+ ```sh
59
+ eyeling --engine eyelang --version
60
+ eyeling --engine eyelang -v
61
+ ```
62
+
63
+ Run a program and let eyelang print derived binary facts:
64
+
65
+ ```sh
66
+ eyeling --engine eyelang examples/eyelang/ancestor.pl
67
+ ```
68
+
69
+ Enable proof explanations when you want machine-readable provenance:
70
+
71
+ ```sh
72
+ eyeling --engine eyelang --proof examples/eyelang/ancestor.pl
73
+ eyeling --engine eyelang -p examples/eyelang/ancestor.pl
74
+ ```
75
+
76
+ eyelang-readable explanations are opt-in proof output. Each `why/2` fact contains a nested abstract proof term, and a blank line separates consecutive explanations. Using eyelang syntax for explanations keeps them in the same language as the answers themselves: they are readable by humans, parseable by eyelang, easy to test, and can be transformed or explained further like any other eyelang data. For example:
77
+
78
+ ```prolog
79
+ type(socrates, mortal).
80
+ why(
81
+ type(socrates, mortal),
82
+ proof(
83
+ goal(type(socrates, mortal)),
84
+ by(rule("socrates.pl", clause(4))),
85
+ bindings([binding("X", socrates)]),
86
+ uses([
87
+ proof(
88
+ goal(type(socrates, man)),
89
+ by(fact("socrates.pl", clause(3)))
90
+ )
91
+ ])
92
+ )
93
+ ).
94
+
95
+ ```
96
+
97
+ The explanation output can itself be read as eyelang input; for example, another program can materialize `why/2` facts such as `why(type(socrates, mortal), Proof)`. `--proof` adds only these explanation facts; it does not change the answers found by the solver.
98
+
99
+ ### Explanation cookbook
100
+
101
+ eyelang answers can carry their own provenance when proof output is enabled.
102
+
103
+ Explain one derived fact:
104
+
105
+ ```sh
106
+ eyeling --engine eyelang --proof examples/eyelang/socrates.pl
107
+ ```
108
+
109
+ The output contains the answer and a `why/2` fact. The proof term shows the source rule that produced the answer and the source fact used below it. Source references use `rule("file.pl", clause(N))` and `fact("file.pl", clause(N))`, where `N` is the 1-based clause number in that file.
110
+
111
+ Inspect variable bindings with a small policy program:
112
+
113
+ ```prolog
114
+ score(case1, 95).
115
+ threshold(90).
116
+
117
+ status(Case, accepted) :-
118
+ score(Case, Score),
119
+ threshold(T),
120
+ ge(Score, T).
121
+ ```
122
+
123
+ ```sh
124
+ eyeling --engine eyelang --proof policy.pl
125
+ ```
126
+
127
+ The explanation contains the instantiated answer and the variables that made the rule succeed:
128
+
129
+ ```prolog
130
+ status(case1, accepted).
131
+ why(
132
+ status(case1, accepted),
133
+ proof(
134
+ goal(status(case1, accepted)),
135
+ by(rule("policy.pl", clause(3))),
136
+ bindings([binding("Case", case1), binding("Score", 95), binding("T", 90)]),
137
+ uses([...])
138
+ )
139
+ ).
140
+ ```
141
+
142
+ Use the `uses([...])` list to follow the proof tree. In the policy example it contains one subproof for `score(case1, 95)`, one for `threshold(90)`, and one for the built-in comparison `ge(95, 90)`. Built-ins are shown as `builtin(Name, Arity)` because they do not come from source clauses.
143
+
144
+ Reuse explanations as data:
145
+
146
+ ```sh
147
+ eyeling --engine eyelang --proof examples/eyelang/socrates.pl > socrates.why.pl
148
+ ```
149
+
150
+ The resulting file is ordinary eyelang syntax containing both answers and `why/2` proof facts.
151
+
152
+ Compose multiple files, stdin, and URLs:
153
+
154
+ ```sh
155
+ eyeling --engine eyelang facts.pl rules.pl
156
+ printf 'works(stdin, true) :- eq(ok, ok).\n' | eyeling --engine eyelang -
157
+ eyeling --engine eyelang https://example.test/program.pl
158
+ ```
159
+
160
+ ## Default output
161
+
162
+ eyelang programs write relation predicates directly:
163
+
164
+ ```prolog
165
+ parent(pat, jan).
166
+ parent(jan, emma).
167
+
168
+ ancestor(X, Y) :- parent(X, Y).
169
+ ancestor(X, Z) :- parent(X, Y), ancestor(Y, Z).
170
+ ```
171
+
172
+ By default, eyelang asks for new ground consequences of selected output predicates, suppresses duplicates, excludes source facts, sorts the result, and prints Prolog facts:
173
+
174
+ ```prolog
175
+ ancestor(jan, emma).
176
+ ancestor(pat, emma).
177
+ ancestor(pat, jan).
178
+ ```
179
+
180
+ This default is intentionally output-oriented. It is not a complete bottom-up saturation engine. Built-ins and proof search remain goal-directed; use `materialize/2` declarations and small output predicates when you want a specific relation, arity, or non-binary answer.
181
+
182
+ ### Focusing default output
183
+
184
+ Large examples often have internal helper predicates. Add `materialize(Name, Arity).` declarations to restrict default output to selected predicates:
185
+
186
+ ```prolog
187
+ materialize(answer, 2).
188
+
189
+ seed(case1).
190
+ helper(Case, score(95)) :- seed(Case).
191
+ answer(Case, accepted) :- helper(Case, score(95)).
192
+ ```
193
+
194
+ The default output is then:
195
+
196
+ ```prolog
197
+ answer(case1, accepted).
198
+ ```
199
+
200
+ `materialize/2` is a declaration, not a logical rule to prove. It affects which predicates the CLI prints, not the meaning of the rules themselves.
201
+
202
+ ## Writing programs
203
+
204
+ A good eyelang program normally has three layers:
205
+
206
+ 1. source facts;
207
+ 2. helper predicates for calculation or search;
208
+ 3. concise relation-style outputs, usually binary predicates such as `status(Case, Value)`, `reason(Case, Text)`, `ancestor(Person, Ancestor)`, or `cost(Path, Amount)`.
209
+
210
+ Example:
211
+
212
+ ```prolog
213
+ score(case1, 95).
214
+ threshold(90).
215
+
216
+ accepted(Case) :-
217
+ score(Case, Score),
218
+ threshold(Threshold),
219
+ ge(Score, Threshold).
220
+
221
+ status(Case, accepted) :- accepted(Case).
222
+ reason(Case, "score exceeds threshold") :- accepted(Case).
223
+ ```
224
+
225
+ When `status/2` and `reason/2` are derived, they appear in default output. If the program has many helper binary predicates, declare the intended output predicates:
226
+
227
+ ```prolog
228
+ materialize(status, 2).
229
+ materialize(reason, 2).
230
+ ```
231
+
232
+ ### Naming
233
+
234
+ Predicate names and atom constants use the same lexical form. Namespace-like names should be plain names such as `type`, `person_name`, or `odrl_permission`; colon names are not part of the language.
235
+
236
+ ### Embedding remains general
237
+
238
+ The CLI is output-oriented and uses `materialize/2` to decide what to print. Embedders can still use the JavaScript API and `Solver` directly for arbitrary goals and arities.
239
+
240
+ Add `-s` or `--stats` when you want lightweight solver counters on stderr without changing stdout:
241
+
242
+ ```sh
243
+ eyeling --engine eyelang -s examples/eyelang/n-queens.pl
244
+ ```
245
+
246
+ The playground has matching `--stats` and `--proof` checkboxes, so browser runs can show the same counters or explanations like the CLI.
247
+
248
+
249
+ ### Builtins
250
+
251
+ eyelang builtins are registered by name and arity in small modules under [`lib/eyelang/builtins`](../lib/eyelang/builtins). This keeps the runtime portable to Node.js and the browser while giving each builtin family a clear boundary. Builtins are enabled by normal predicate calls.
252
+
253
+ The core builtin families cover unification, arithmetic, comparison, dates, strings, lists, aggregation, context terms, and search control. Additional reusable finite-search helpers are available only where bundled examples need them to avoid large amounts of repetitive generate-and-test code. These helpers are deliberately general relations rather than shortcuts tied to a particular example name. For example:
254
+
255
+ ```prolog
256
+ answer(Queens) :-
257
+ n_queens(8, Queens).
258
+
259
+ best(Cycle, Cost) :-
260
+ cities(Cities),
261
+ weighted_hamiltonian_cycle(edge, Cities, Cycle, Cost).
262
+ ```
263
+
264
+ The reusable search and numeric helpers include `n_queens/2`, Hamiltonian path/cycle helpers, `cnf_model/3`, Quine-McCluskey helpers, bounded subset/path helpers, number-theory helpers such as `extended_gcd/5`, matrix helpers such as `matrix_multiply/2`, and `alphametic_sum/5`. These helpers are extension builtins of this implementation; [the eyelang language reference](eyelang-language-reference.md) defines the portable core and standard builtin profile.
265
+
266
+ To add a builtin, create or extend a module with `register(registry)` and call `registry.add(name, arity, handler, options)`. The default registry is assembled in [`lib/eyelang/builtins/registry.js`](../lib/eyelang/builtins/registry.js). Builtins that are only safe for specific argument modes should provide a `ready` predicate and `fallbackWhenNotReady: true`, so user-defined clauses remain visible until the builtin is applicable.
267
+
268
+
269
+ ## Aggregation helpers
270
+
271
+ eyelang includes goal-directed aggregation helpers for finite searches:
272
+
273
+ ```prolog
274
+ countall(Goal, Count).
275
+ sumall(Value, Goal, Sum).
276
+ aggregate_min(Key, Template, Goal, BestKey, BestTemplate).
277
+ aggregate_max(Key, Template, Goal, BestKey, BestTemplate).
278
+ ```
279
+
280
+ Use `countall/2` for solution counts, `sumall/3` for numeric totals, and `aggregate_min/5` or `aggregate_max/5` when a search should keep only the best candidate instead of collecting and sorting every answer. The `Key` can be a number, atom constant, string, compound term, or list; normal term ordering is used, so compound keys such as `[Cost, Path]` are useful for deterministic tie-breaking.
281
+
282
+ Example:
283
+
284
+ ```prolog
285
+ best_cycle(Cycle, Cost) :-
286
+ cities(Cities),
287
+ aggregate_min([Cost, Cycle], Cycle, candidate_cycle(Cities, Cycle, Cost), [Cost, Cycle], Cycle).
288
+ ```
289
+
290
+ ## Context data
291
+
292
+ Comma terms can be data as well as conjunctions. eyelang provides two context utilities:
293
+
294
+ ```prolog
295
+ holds((name(alice, "Alice"), knows(alice, bob)), name(S, O)).
296
+ holds((ready, name(alice, "Alice"), route(alice, bob, 7)), Name, Args).
297
+ ```
298
+
299
+ Use `holds/2` when you want to match the member term directly, for example `name(S, O)`, `route(A, B, Cost)`, or `edge(A, arc(B, Cost))`. Use `holds/3` when you need the predicate name and argument list as data: it exposes any-arity member as atom constant `Name` plus a proper list `Args`, so zero-, binary-, and ternary members appear as `ready/0`, `name/2`, and `route/3` shapes without a special binary predicate. These utilities are useful for quoted context data, but they do not make those context members true in the ambient program.
300
+
301
+
302
+ ## Example catalog
303
+
304
+ The repository includes examples for recursion, graph reachability, finite search, arithmetic, list processing, optimization, policies, puzzles, and applied scientific calculations. Bundled examples use relation-style output.
305
+
306
+ | Input | Short description | Output |
307
+ | --- | --- | --- |
308
+ | [`access-control-policy.pl`](../examples/eyelang/access-control-policy.pl) | Evaluates role and condition based access decisions. | [`output/access-control-policy.pl`](../examples/eyelang/output/access-control-policy.pl) |
309
+ | [`ackermann.pl`](../examples/eyelang/ackermann.pl) | Computes Ackermann-style hyperoperation values. | [`output/ackermann.pl`](../examples/eyelang/output/ackermann.pl) |
310
+ | [`age.pl`](../examples/eyelang/age.pl) | Checks whether people meet age thresholds. | [`output/age.pl`](../examples/eyelang/output/age.pl) |
311
+ | [`aliases-and-namespaces.pl`](../examples/eyelang/aliases-and-namespaces.pl) | Shows ordinary predicate names for vocabulary aliases. | [`output/aliases-and-namespaces.pl`](../examples/eyelang/output/aliases-and-namespaces.pl) |
312
+ | [`alignment-demo.pl`](../examples/eyelang/alignment-demo.pl) | Rolls dataset concepts up through a small alignment taxonomy. | [`output/alignment-demo.pl`](../examples/eyelang/output/alignment-demo.pl) |
313
+ | [`allen-interval-calculus.pl`](../examples/eyelang/allen-interval-calculus.pl) | Classifies interval relations with integer time offsets. | [`output/allen-interval-calculus.pl`](../examples/eyelang/output/allen-interval-calculus.pl) |
314
+ | [`ancestor.pl`](../examples/eyelang/ancestor.pl) | Derives ancestors from parent facts. | [`output/ancestor.pl`](../examples/eyelang/output/ancestor.pl) |
315
+ | [`animal.pl`](../examples/eyelang/animal.pl) | Classifies animals from traits. | [`output/animal.pl`](../examples/eyelang/output/animal.pl) |
316
+ | [`annotation.pl`](../examples/eyelang/annotation.pl) | Derives facts from quoted annotation data. | [`output/annotation.pl`](../examples/eyelang/output/annotation.pl) |
317
+ | [`auroracare.pl`](../examples/eyelang/auroracare.pl) | Evaluates purpose-based medical data access scenarios. | [`output/auroracare.pl`](../examples/eyelang/output/auroracare.pl) |
318
+ | [`backward.pl`](../examples/eyelang/backward.pl) | Shows a backward-rule pattern as a goal-directed numeric rule. | [`output/backward.pl`](../examples/eyelang/output/backward.pl) |
319
+ | [`basic-monadic.pl`](../examples/eyelang/basic-monadic.pl) | Runs a monadic benchmark over generated inputs. | [`output/basic-monadic.pl`](../examples/eyelang/output/basic-monadic.pl) |
320
+ | [`bayes-diagnosis.pl`](../examples/eyelang/bayes-diagnosis.pl) | Computes scaled Bayesian diagnosis posteriors. | [`output/bayes-diagnosis.pl`](../examples/eyelang/output/bayes-diagnosis.pl) |
321
+ | [`bayes-therapy.pl`](../examples/eyelang/bayes-therapy.pl) | Ranks therapies using Bayesian disease likelihoods. | [`output/bayes-therapy.pl`](../examples/eyelang/output/bayes-therapy.pl) |
322
+ | [`beam-deflection.pl`](../examples/eyelang/beam-deflection.pl) | Computes cantilever beam deflection. | [`output/beam-deflection.pl`](../examples/eyelang/output/beam-deflection.pl) |
323
+ | [`blocks-world-planning.pl`](../examples/eyelang/blocks-world-planning.pl) | Searches a finite blocks-world plan. | [`output/blocks-world-planning.pl`](../examples/eyelang/output/blocks-world-planning.pl) |
324
+ | [`bmi.pl`](../examples/eyelang/bmi.pl) | Normalizes BMI inputs and classifies weight. | [`output/bmi.pl`](../examples/eyelang/output/bmi.pl) |
325
+ | [`braking-safety-worlds.pl`](../examples/eyelang/braking-safety-worlds.pl) | Classifies braking safety under alternative worlds. | [`output/braking-safety-worlds.pl`](../examples/eyelang/output/braking-safety-worlds.pl) |
326
+ | [`buck-converter-design.pl`](../examples/eyelang/buck-converter-design.pl) | Checks buck-converter ripple design. | [`output/buck-converter-design.pl`](../examples/eyelang/output/buck-converter-design.pl) |
327
+ | [`cache-performance.pl`](../examples/eyelang/cache-performance.pl) | Summarizes cache latency performance. | [`output/cache-performance.pl`](../examples/eyelang/output/cache-performance.pl) |
328
+ | [`canary-release.pl`](../examples/eyelang/canary-release.pl) | Decides canary rollout or rollback. | [`output/canary-release.pl`](../examples/eyelang/output/canary-release.pl) |
329
+ | [`cat-koko.pl`](../examples/eyelang/cat-koko.pl) | Demonstrates named existential witnesses from a Cat Koko rule pattern. | [`output/cat-koko.pl`](../examples/eyelang/output/cat-koko.pl) |
330
+ | [`clinical-trial-screening.pl`](../examples/eyelang/clinical-trial-screening.pl) | Screens candidates for a trial. | [`output/clinical-trial-screening.pl`](../examples/eyelang/output/clinical-trial-screening.pl) |
331
+ | [`collatz-1000.pl`](../examples/eyelang/collatz-1000.pl) | Computes shared Collatz trajectories. | [`output/collatz-1000.pl`](../examples/eyelang/output/collatz-1000.pl) |
332
+ | [`combinatorics-findall-sort.pl`](../examples/eyelang/combinatorics-findall-sort.pl) | Collects and sorts finite combinations. | [`output/combinatorics-findall-sort.pl`](../examples/eyelang/output/combinatorics-findall-sort.pl) |
333
+ | [`competitive-enzyme-kinetics.pl`](../examples/eyelang/competitive-enzyme-kinetics.pl) | Computes inhibited enzyme reaction rates. | [`output/competitive-enzyme-kinetics.pl`](../examples/eyelang/output/competitive-enzyme-kinetics.pl) |
334
+ | [`complex-matrix-stability.pl`](../examples/eyelang/complex-matrix-stability.pl) | Checks stability of a 2x2 system. | [`output/complex-matrix-stability.pl`](../examples/eyelang/output/complex-matrix-stability.pl) |
335
+ | [`complex.pl`](../examples/eyelang/complex.pl) | Performs arithmetic on complex pairs. | [`output/complex.pl`](../examples/eyelang/output/complex.pl) |
336
+ | [`composition-of-injective-functions-is-injective.pl`](../examples/eyelang/composition-of-injective-functions-is-injective.pl) | Encodes composition and injectivity of finite functions. | [`output/composition-of-injective-functions-is-injective.pl`](../examples/eyelang/output/composition-of-injective-functions-is-injective.pl) |
337
+ | [`context-association.pl`](../examples/eyelang/context-association.pl) | Associates named contexts with their contents. | [`output/context-association.pl`](../examples/eyelang/output/context-association.pl) |
338
+ | [`control-system.pl`](../examples/eyelang/control-system.pl) | Evaluates control-system measurements and targets. | [`output/control-system.pl`](../examples/eyelang/output/control-system.pl) |
339
+ | [`cryptarithmetic-send-more-money.pl`](../examples/eyelang/cryptarithmetic-send-more-money.pl) | Solves SEND+MORE and related puzzles. | [`output/cryptarithmetic-send-more-money.pl`](../examples/eyelang/output/cryptarithmetic-send-more-money.pl) |
340
+ | [`cyclic-path.pl`](../examples/eyelang/cyclic-path.pl) | Computes paths in a cyclic graph. | [`output/cyclic-path.pl`](../examples/eyelang/output/cyclic-path.pl) |
341
+ | [`d3-group.pl`](../examples/eyelang/d3-group.pl) | Enumerates subgroups of the D3 group. | [`output/d3-group.pl`](../examples/eyelang/output/d3-group.pl) |
342
+ | [`dairy-energy-balance.pl`](../examples/eyelang/dairy-energy-balance.pl) | Classifies dairy cow energy balance. | [`output/dairy-energy-balance.pl`](../examples/eyelang/output/dairy-energy-balance.pl) |
343
+ | [`data-negotiation.pl`](../examples/eyelang/data-negotiation.pl) | Chooses an accepted data-negotiation offer. | [`output/data-negotiation.pl`](../examples/eyelang/output/data-negotiation.pl) |
344
+ | [`deep-taxonomy-10.pl`](../examples/eyelang/deep-taxonomy-10.pl) | Stress-tests recursive taxonomy depth 10. | [`output/deep-taxonomy-10.pl`](../examples/eyelang/output/deep-taxonomy-10.pl) |
345
+ | [`deep-taxonomy-100.pl`](../examples/eyelang/deep-taxonomy-100.pl) | Stress-tests recursive taxonomy depth 100. | [`output/deep-taxonomy-100.pl`](../examples/eyelang/output/deep-taxonomy-100.pl) |
346
+ | [`deep-taxonomy-1000.pl`](../examples/eyelang/deep-taxonomy-1000.pl) | Stress-tests recursive taxonomy depth 1000. | [`output/deep-taxonomy-1000.pl`](../examples/eyelang/output/deep-taxonomy-1000.pl) |
347
+ | [`deep-taxonomy-10000.pl`](../examples/eyelang/deep-taxonomy-10000.pl) | Stress-tests recursive taxonomy depth 10000. | [`output/deep-taxonomy-10000.pl`](../examples/eyelang/output/deep-taxonomy-10000.pl) |
348
+ | [`deep-taxonomy-100000.pl`](../examples/eyelang/deep-taxonomy-100000.pl) | Stress-tests recursive taxonomy depth 100000. | [`output/deep-taxonomy-100000.pl`](../examples/eyelang/output/deep-taxonomy-100000.pl) |
349
+ | [`delfour.pl`](../examples/eyelang/delfour.pl) | Derives shopping and authorization recommendations. | [`output/delfour.pl`](../examples/eyelang/output/delfour.pl) |
350
+ | [`dense-hamiltonian-cycle.pl`](../examples/eyelang/dense-hamiltonian-cycle.pl) | Searches a dense Hamiltonian cycle with aggregate minimization. | [`output/dense-hamiltonian-cycle.pl`](../examples/eyelang/output/dense-hamiltonian-cycle.pl) |
351
+ | [`deontic-logic.pl`](../examples/eyelang/deontic-logic.pl) | Reports obligations, prohibitions, and violations. | [`output/deontic-logic.pl`](../examples/eyelang/output/deontic-logic.pl) |
352
+ | [`derived-backward-rule.pl`](../examples/eyelang/derived-backward-rule.pl) | Derives an inverse-property backward rule from rule data. | [`output/derived-backward-rule.pl`](../examples/eyelang/output/derived-backward-rule.pl) |
353
+ | [`derived-rule.pl`](../examples/eyelang/derived-rule.pl) | Derives conclusions from rule data. | [`output/derived-rule.pl`](../examples/eyelang/output/derived-rule.pl) |
354
+ | [`diamond-property.pl`](../examples/eyelang/diamond-property.pl) | Checks the diamond property of a relation. | [`output/diamond-property.pl`](../examples/eyelang/output/diamond-property.pl) |
355
+ | [`dijkstra-findall-sort.pl`](../examples/eyelang/dijkstra-findall-sort.pl) | Finds shortest paths using collected candidates. | [`output/dijkstra-findall-sort.pl`](../examples/eyelang/output/dijkstra-findall-sort.pl) |
356
+ | [`dijkstra-risk-path.pl`](../examples/eyelang/dijkstra-risk-path.pl) | Ranks routes by cost and trust. | [`output/dijkstra-risk-path.pl`](../examples/eyelang/output/dijkstra-risk-path.pl) |
357
+ | [`dijkstra.pl`](../examples/eyelang/dijkstra.pl) | Enumerates weighted simple paths. | [`output/dijkstra.pl`](../examples/eyelang/output/dijkstra.pl) |
358
+ | [`dining-philosophers.pl`](../examples/eyelang/dining-philosophers.pl) | Simulates Chandy-Misra fork exchanges. | [`output/dining-philosophers.pl`](../examples/eyelang/output/dining-philosophers.pl) |
359
+ | [`dog.pl`](../examples/eyelang/dog.pl) | Counts dogs and derives when a license is required. | [`output/dog.pl`](../examples/eyelang/output/dog.pl) |
360
+ | [`drone-corridor-planner.pl`](../examples/eyelang/drone-corridor-planner.pl) | Plans bounded drone corridor routes. | [`output/drone-corridor-planner.pl`](../examples/eyelang/output/drone-corridor-planner.pl) |
361
+ | [`easter-computus.pl`](../examples/eyelang/easter-computus.pl) | Computes Gregorian Easter dates. | [`output/easter-computus.pl`](../examples/eyelang/output/easter-computus.pl) |
362
+ | [`electrical-rc-filter.pl`](../examples/eyelang/electrical-rc-filter.pl) | Sizes an RC low-pass filter. | [`output/electrical-rc-filter.pl`](../examples/eyelang/output/electrical-rc-filter.pl) |
363
+ | [`epidemic-policy.pl`](../examples/eyelang/epidemic-policy.pl) | Chooses policies from risk and social cost. | [`output/epidemic-policy.pl`](../examples/eyelang/output/epidemic-policy.pl) |
364
+ | [`equivalence-classes-overlap-implies-same-class.pl`](../examples/eyelang/equivalence-classes-overlap-implies-same-class.pl) | Packages the shared-member proof pattern for equivalence classes. | [`output/equivalence-classes-overlap-implies-same-class.pl`](../examples/eyelang/output/equivalence-classes-overlap-implies-same-class.pl) |
365
+ | [`eulerian-path.pl`](../examples/eyelang/eulerian-path.pl) | Finds an Eulerian path using each edge once. | [`output/eulerian-path.pl`](../examples/eyelang/output/eulerian-path.pl) |
366
+ | [`ev-range-worlds.pl`](../examples/eyelang/ev-range-worlds.pl) | Estimates electric-vehicle trip feasibility. | [`output/ev-range-worlds.pl`](../examples/eyelang/output/ev-range-worlds.pl) |
367
+ | [`existential-rule.pl`](../examples/eyelang/existential-rule.pl) | Represents existential witnesses with explicit Skolem-style terms. | [`output/existential-rule.pl`](../examples/eyelang/output/existential-rule.pl) |
368
+ | [`exoplanet-validation-worlds.pl`](../examples/eyelang/exoplanet-validation-worlds.pl) | Validates exoplanet candidates across worlds. | [`output/exoplanet-validation-worlds.pl`](../examples/eyelang/output/exoplanet-validation-worlds.pl) |
369
+ | [`expression-eval.pl`](../examples/eyelang/expression-eval.pl) | Evaluates a small arithmetic expression tree. | [`output/expression-eval.pl`](../examples/eyelang/output/expression-eval.pl) |
370
+ | [`family-cousins.pl`](../examples/eyelang/family-cousins.pl) | Derives cousin and family labels. | [`output/family-cousins.pl`](../examples/eyelang/output/family-cousins.pl) |
371
+ | [`fastpow.pl`](../examples/eyelang/fastpow.pl) | Computes powers by repeated squaring. | [`output/fastpow.pl`](../examples/eyelang/output/fastpow.pl) |
372
+ | [`fft8-numeric.pl`](../examples/eyelang/fft8-numeric.pl) | Runs an 8-point FFT over complex pairs. | [`output/fft8-numeric.pl`](../examples/eyelang/output/fft8-numeric.pl) |
373
+ | [`fibonacci.pl`](../examples/eyelang/fibonacci.pl) | Computes large Fibonacci numbers by fast doubling. | [`output/fibonacci.pl`](../examples/eyelang/output/fibonacci.pl) |
374
+ | [`field-nitrogen-balance.pl`](../examples/eyelang/field-nitrogen-balance.pl) | Classifies field nitrogen balance. | [`output/field-nitrogen-balance.pl`](../examples/eyelang/output/field-nitrogen-balance.pl) |
375
+ | [`floating-point.pl`](../examples/eyelang/floating-point.pl) | Exercises floating-point arithmetic and comparisons. | [`output/floating-point.pl`](../examples/eyelang/output/floating-point.pl) |
376
+ | [`flandor.pl`](../examples/eyelang/flandor.pl) | Derives a Flanders macro-insight authorization and retooling package. | [`output/flandor.pl`](../examples/eyelang/output/flandor.pl) |
377
+ | [`four-color-map.pl`](../examples/eyelang/four-color-map.pl) | Checks a four-colour map assignment. | [`output/four-color-map.pl`](../examples/eyelang/output/four-color-map.pl) |
378
+ | [`fundamental-theorem-arithmetic.pl`](../examples/eyelang/fundamental-theorem-arithmetic.pl) | Factors integers and reconstructs products. | [`output/fundamental-theorem-arithmetic.pl`](../examples/eyelang/output/fundamental-theorem-arithmetic.pl) |
379
+ | [`gcd-bezout-identity.pl`](../examples/eyelang/gcd-bezout-identity.pl) | Computes gcd and Bézout coefficients. | [`output/gcd-bezout-identity.pl`](../examples/eyelang/output/gcd-bezout-identity.pl) |
380
+ | [`gd-step-certified.pl`](../examples/eyelang/gd-step-certified.pl) | Certifies a gradient-descent step. | [`output/gd-step-certified.pl`](../examples/eyelang/output/gd-step-certified.pl) |
381
+ | [`gdpr-compliance.pl`](../examples/eyelang/gdpr-compliance.pl) | Checks GDPR-style processing compliance. | [`output/gdpr-compliance.pl`](../examples/eyelang/output/gdpr-compliance.pl) |
382
+ | [`goldbach-1000.pl`](../examples/eyelang/goldbach-1000.pl) | Finds Goldbach prime pairs up to 1000. | [`output/goldbach-1000.pl`](../examples/eyelang/output/goldbach-1000.pl) |
383
+ | [`good-cobbler.pl`](../examples/eyelang/good-cobbler.pl) | Demonstrates term-level structure with a good-cobbler statement. | [`output/good-cobbler.pl`](../examples/eyelang/output/good-cobbler.pl) |
384
+ | [`gps.pl`](../examples/eyelang/gps.pl) | Finds and verifies route paths. | [`output/gps.pl`](../examples/eyelang/output/gps.pl) |
385
+ | [`graph-reachability.pl`](../examples/eyelang/graph-reachability.pl) | Derives reachable nodes in a graph. | [`output/graph-reachability.pl`](../examples/eyelang/output/graph-reachability.pl) |
386
+ | [`gray-code-counter.pl`](../examples/eyelang/gray-code-counter.pl) | Generates Gray-code counter states. | [`output/gray-code-counter.pl`](../examples/eyelang/output/gray-code-counter.pl) |
387
+ | [`greatest-lower-bound-uniqueness.pl`](../examples/eyelang/greatest-lower-bound-uniqueness.pl) | Shows uniqueness of greatest lower bounds in a finite order instance. | [`output/greatest-lower-bound-uniqueness.pl`](../examples/eyelang/output/greatest-lower-bound-uniqueness.pl) |
388
+ | [`group-inverse-uniqueness.pl`](../examples/eyelang/group-inverse-uniqueness.pl) | Shows uniqueness of inverses in a finite group instance. | [`output/group-inverse-uniqueness.pl`](../examples/eyelang/output/group-inverse-uniqueness.pl) |
389
+ | [`hamiltonian-cycle.pl`](../examples/eyelang/hamiltonian-cycle.pl) | Finds a Hamiltonian cycle. | [`output/hamiltonian-cycle.pl`](../examples/eyelang/output/hamiltonian-cycle.pl) |
390
+ | [`hamiltonian-path.pl`](../examples/eyelang/hamiltonian-path.pl) | Finds a Hamiltonian path. | [`output/hamiltonian-path.pl`](../examples/eyelang/output/hamiltonian-path.pl) |
391
+ | [`hamming-code.pl`](../examples/eyelang/hamming-code.pl) | Corrects a single-bit Hamming word. | [`output/hamming-code.pl`](../examples/eyelang/output/hamming-code.pl) |
392
+ | [`hanoi.pl`](../examples/eyelang/hanoi.pl) | Derives the Towers of Hanoi moves. | [`output/hanoi.pl`](../examples/eyelang/output/hanoi.pl) |
393
+ | [`heat-loss.pl`](../examples/eyelang/heat-loss.pl) | Computes conductive heat loss. | [`output/heat-loss.pl`](../examples/eyelang/output/heat-loss.pl) |
394
+ | [`heron-theorem.pl`](../examples/eyelang/heron-theorem.pl) | Computes triangle area by Heron's theorem. | [`output/heron-theorem.pl`](../examples/eyelang/output/heron-theorem.pl) |
395
+ | [`ideal-gas-law.pl`](../examples/eyelang/ideal-gas-law.pl) | Applies the ideal gas law. | [`output/ideal-gas-law.pl`](../examples/eyelang/output/ideal-gas-law.pl) |
396
+ | [`illegitimate-reasoning.pl`](../examples/eyelang/illegitimate-reasoning.pl) | Detects suspect reasoning patterns. | [`output/illegitimate-reasoning.pl`](../examples/eyelang/output/illegitimate-reasoning.pl) |
397
+ | [`kaprekar.pl`](../examples/eyelang/kaprekar.pl) | Iterates toward Kaprekar's constant. | [`output/kaprekar.pl`](../examples/eyelang/output/kaprekar.pl) |
398
+ | [`law-of-cosines.pl`](../examples/eyelang/law-of-cosines.pl) | Computes a triangle side by cosine law. | [`output/law-of-cosines.pl`](../examples/eyelang/output/law-of-cosines.pl) |
399
+ | [`least-squares-regression.pl`](../examples/eyelang/least-squares-regression.pl) | Fits a least-squares regression line. | [`output/least-squares-regression.pl`](../examples/eyelang/output/least-squares-regression.pl) |
400
+ | [`list-collection.pl`](../examples/eyelang/list-collection.pl) | Demonstrates list and collection built-ins. | [`output/list-collection.pl`](../examples/eyelang/output/list-collection.pl) |
401
+ | [`lldm.pl`](../examples/eyelang/lldm.pl) | Calculates leg-length discrepancy measurements. | [`output/lldm.pl`](../examples/eyelang/output/lldm.pl) |
402
+ | [`manufacturing-quality-control.pl`](../examples/eyelang/manufacturing-quality-control.pl) | Evaluates process capability and quality. | [`output/manufacturing-quality-control.pl`](../examples/eyelang/output/manufacturing-quality-control.pl) |
403
+ | [`matrix.pl`](../examples/eyelang/matrix.pl) | Runs matrix operations over sample inputs. | [`output/matrix.pl`](../examples/eyelang/output/matrix.pl) |
404
+ | [`microgrid-dispatch.pl`](../examples/eyelang/microgrid-dispatch.pl) | Plans microgrid dispatch and reserve. | [`output/microgrid-dispatch.pl`](../examples/eyelang/output/microgrid-dispatch.pl) |
405
+ | [`monkey-bananas.pl`](../examples/eyelang/monkey-bananas.pl) | Solves the monkey-and-bananas puzzle. | [`output/monkey-bananas.pl`](../examples/eyelang/output/monkey-bananas.pl) |
406
+ | [`n-queens.pl`](../examples/eyelang/n-queens.pl) | Searches for N-queens placements. | [`output/n-queens.pl`](../examples/eyelang/output/n-queens.pl) |
407
+ | [`network-sla.pl`](../examples/eyelang/network-sla.pl) | Checks network path SLA compliance. | [`output/network-sla.pl`](../examples/eyelang/output/network-sla.pl) |
408
+ | [`newton-raphson.pl`](../examples/eyelang/newton-raphson.pl) | Finds roots by Newton-Raphson iteration. | [`output/newton-raphson.pl`](../examples/eyelang/output/newton-raphson.pl) |
409
+ | [`nixon-diamond.pl`](../examples/eyelang/nixon-diamond.pl) | Reports the classic Nixon-diamond conflict. | [`output/nixon-diamond.pl`](../examples/eyelang/output/nixon-diamond.pl) |
410
+ | [`odrl-dpv-healthcare-risk-ranked.pl`](../examples/eyelang/odrl-dpv-healthcare-risk-ranked.pl) | Ranks healthcare policy risks and mitigations. | [`output/odrl-dpv-healthcare-risk-ranked.pl`](../examples/eyelang/output/odrl-dpv-healthcare-risk-ranked.pl) |
411
+ | [`odrl-dpv-risk-ranked.pl`](../examples/eyelang/odrl-dpv-risk-ranked.pl) | Ranks data-policy risks and mitigations. | [`output/odrl-dpv-risk-ranked.pl`](../examples/eyelang/output/odrl-dpv-risk-ranked.pl) |
412
+ | [`orbital-transfer-design.pl`](../examples/eyelang/orbital-transfer-design.pl) | Designs a Hohmann orbital transfer. | [`output/orbital-transfer-design.pl`](../examples/eyelang/output/orbital-transfer-design.pl) |
413
+ | [`path-discovery.pl`](../examples/eyelang/path-discovery.pl) | Discovers bounded air-route paths. | [`output/path-discovery.pl`](../examples/eyelang/output/path-discovery.pl) |
414
+ | [`peano-arithmetic.pl`](../examples/eyelang/peano-arithmetic.pl) | Computes Peano addition, multiplication, and factorial. | [`output/peano-arithmetic.pl`](../examples/eyelang/output/peano-arithmetic.pl) |
415
+ | [`peasant.pl`](../examples/eyelang/peasant.pl) | Performs peasant multiplication and exponentiation. | [`output/peasant.pl`](../examples/eyelang/output/peasant.pl) |
416
+ | [`pendulum-period.pl`](../examples/eyelang/pendulum-period.pl) | Computes simple pendulum periods. | [`output/pendulum-period.pl`](../examples/eyelang/output/pendulum-period.pl) |
417
+ | [`polynomial.pl`](../examples/eyelang/polynomial.pl) | Finds complex integer polynomial roots. | [`output/polynomial.pl`](../examples/eyelang/output/polynomial.pl) |
418
+ | [`project-portfolio-optimization.pl`](../examples/eyelang/project-portfolio-optimization.pl) | Optimizes a constrained project portfolio with pruning and aggregate builtins. | [`output/project-portfolio-optimization.pl`](../examples/eyelang/output/project-portfolio-optimization.pl) |
419
+ | [`proof-contrapositive.pl`](../examples/eyelang/proof-contrapositive.pl) | Models proof by contrapositive. | [`output/proof-contrapositive.pl`](../examples/eyelang/output/proof-contrapositive.pl) |
420
+ | [`quadratic-formula.pl`](../examples/eyelang/quadratic-formula.pl) | Solves sample quadratic equations. | [`output/quadratic-formula.pl`](../examples/eyelang/output/quadratic-formula.pl) |
421
+ | [`quine-mccluskey.pl`](../examples/eyelang/quine-mccluskey.pl) | Minimizes Boolean terms with Quine-McCluskey. | [`output/quine-mccluskey.pl`](../examples/eyelang/output/quine-mccluskey.pl) |
422
+ | [`radioactive-decay.pl`](../examples/eyelang/radioactive-decay.pl) | Computes radioactive decay over time. | [`output/radioactive-decay.pl`](../examples/eyelang/output/radioactive-decay.pl) |
423
+ | [`resilient-city-orchestration.pl`](../examples/eyelang/resilient-city-orchestration.pl) | Orchestrates storm-response missions from signals, policy, routes, teams, and portfolio optimization. | [`output/resilient-city-orchestration.pl`](../examples/eyelang/output/resilient-city-orchestration.pl) |
424
+ | [`riemann-hypothesis.pl`](../examples/eyelang/riemann-hypothesis.pl) | Checks a finite catalogue of non-trivial zeta zeros against the Riemann-hypothesis condition. | [`output/riemann-hypothesis.pl`](../examples/eyelang/output/riemann-hypothesis.pl) |
425
+ | [`sat-dpll.pl`](../examples/eyelang/sat-dpll.pl) | Solves a finite SAT instance. | [`output/sat-dpll.pl`](../examples/eyelang/output/sat-dpll.pl) |
426
+ | [`security-incident-correlation.pl`](../examples/eyelang/security-incident-correlation.pl) | Correlates security incidents across signals. | [`output/security-incident-correlation.pl`](../examples/eyelang/output/security-incident-correlation.pl) |
427
+ | [`service-impact.pl`](../examples/eyelang/service-impact.pl) | Analyzes service impact over cyclic dependencies. | [`output/service-impact.pl`](../examples/eyelang/output/service-impact.pl) |
428
+ | [`sieve.pl`](../examples/eyelang/sieve.pl) | Enumerates primes with a sieve-style program. | [`output/sieve.pl`](../examples/eyelang/output/sieve.pl) |
429
+ | [`skolem-functions.pl`](../examples/eyelang/skolem-functions.pl) | Generates deterministic functional terms. | [`output/skolem-functions.pl`](../examples/eyelang/output/skolem-functions.pl) |
430
+ | [`socket-age.pl`](../examples/eyelang/socket-age.pl) | Shows socket-declared age reasoning inputs and plugs. | [`output/socket-age.pl`](../examples/eyelang/output/socket-age.pl) |
431
+ | [`socket-family.pl`](../examples/eyelang/socket-family.pl) | Shows socket-declared family-source inputs and ancestry rules. | [`output/socket-family.pl`](../examples/eyelang/output/socket-family.pl) |
432
+ | [`socrates.pl`](../examples/eyelang/socrates.pl) | Derives that Socrates is mortal. | [`output/socrates.pl`](../examples/eyelang/output/socrates.pl) |
433
+ | [`statistics-summary.pl`](../examples/eyelang/statistics-summary.pl) | Computes population statistics for a sample. | [`output/statistics-summary.pl`](../examples/eyelang/output/statistics-summary.pl) |
434
+ | [`superdense-coding.pl`](../examples/eyelang/superdense-coding.pl) | Models superdense-coding bit transmission. | [`output/superdense-coding.pl`](../examples/eyelang/output/superdense-coding.pl) |
435
+ | [`traveling-salesman.pl`](../examples/eyelang/traveling-salesman.pl) | Finds an optimal traveling-salesman tour. | [`output/traveling-salesman.pl`](../examples/eyelang/output/traveling-salesman.pl) |
436
+ | [`turing.pl`](../examples/eyelang/turing.pl) | Simulates a binary-increment Turing machine. | [`output/turing.pl`](../examples/eyelang/output/turing.pl) |
437
+ | [`vector-similarity.pl`](../examples/eyelang/vector-similarity.pl) | Computes dot product, norm, and cosine similarity. | [`output/vector-similarity.pl`](../examples/eyelang/output/vector-similarity.pl) |
438
+ | [`vulnerability-impact.pl`](../examples/eyelang/vulnerability-impact.pl) | Analyzes vulnerable transitive dependencies and urgent patch impact. | [`output/vulnerability-impact.pl`](../examples/eyelang/output/vulnerability-impact.pl) |
439
+ | [`witch.pl`](../examples/eyelang/witch.pl) | Derives the classic “burn the witch” rule chain. | [`output/witch.pl`](../examples/eyelang/output/witch.pl) |
440
+ | [`wolf-goat-cabbage.pl`](../examples/eyelang/wolf-goat-cabbage.pl) | Solves the wolf-goat-cabbage river crossing. | [`output/wolf-goat-cabbage.pl`](../examples/eyelang/output/wolf-goat-cabbage.pl) |
441
+ | [`zebra.pl`](../examples/eyelang/zebra.pl) | Solves the zebra logic puzzle. | [`output/zebra.pl`](../examples/eyelang/output/zebra.pl) |
442
+
443
+
444
+
445
+ ## Golden outputs, tests, and conformance
446
+
447
+ Golden answer outputs live in [`examples/eyelang/output`](../examples/eyelang/output). `npm run test:eyelang` covers the eyelang integration check, conformance cases, regression checks, runnable examples, and proof-output examples. A curated proof-output suite for `.pl` examples lives in [`examples/eyelang/proof`](../examples/eyelang/proof). Example tests pin `local_time/1` to `2026-05-30` so date-dependent examples stay deterministic. Regenerate them after an intentional output or explanation change:
448
+
449
+ ```sh
450
+ for f in examples/eyelang/*.pl; do
451
+ [ -e "$f" ] || continue
452
+ b=$(basename "$f")
453
+ EYELANG_LOCAL_TIME=2026-05-30 eyeling --engine eyelang "$f" > "examples/eyelang/output/$b"
454
+ done
455
+
456
+ for f in examples/eyelang/proof/*.pl; do
457
+ b=$(basename "$f")
458
+ EYELANG_LOCAL_TIME=2026-05-30 eyeling --engine eyelang --proof "examples/eyelang/$b" > "examples/eyelang/proof/$b"
459
+ done
460
+ ```
461
+
462
+ Run the full eyelang suite:
463
+
464
+ ```sh
465
+ npm run test:eyelang
466
+ ```
467
+
468
+ The eyelang corpus runner runs in this order: Conformance, Regression/API/White-box, Examples. Each section prints its own subtotal, followed by a suite-specific grand total. The suite checks the conformance cases derived from the language reference, supplemental regression/API/white-box checks, and every runnable example against its golden output.
469
+
470
+ Run only one internal suite when you are iterating:
471
+
472
+ ```sh
473
+ node test/eyelang/run-conformance.mjs
474
+ node test/eyelang/run-regression.mjs
475
+ node test/eyelang/run-examples.mjs
476
+ ```
477
+
478
+ The conformance suite lives in [`test/eyelang/conformance/`](../test/eyelang/conformance/) and is split into `core` and `extension` profiles matching the language reference. Each case is a small program with an exact expected stdout file, and some internal conformance cases also include a goal file for testing the embeddable solver, so other implementations can reuse the same cases. The regression suite lives in [`test/eyelang/run-regression.mjs`](../test/eyelang/run-regression.mjs) and covers CLI regressions, the public JavaScript API, and white-box invariants for parser, unification, and indexing behavior.
479
+
480
+ ## Development and release
481
+
482
+ Common commands:
483
+
484
+ ```sh
485
+ npm run test:eyelang # integration check plus eyelang corpus
486
+ npm run test:eyelang:corpus # conformance, regression/API/white-box, examples, and proof examples
487
+ node test/eyelang/run-conformance.mjs
488
+ node test/eyelang/run-regression.mjs
489
+ node test/eyelang/run-examples.mjs
490
+ eyeling --engine eyelang --help
491
+ ```
492
+
493
+ Useful profiling smoke test:
494
+
495
+ ```sh
496
+ eyeling --engine eyelang -s examples/eyelang/n-queens.pl > /dev/null
497
+ ```
498
+
499
+ For a release:
500
+
501
+ 1. update `VERSION`;
502
+ 2. update `README.md` and the language reference;
503
+ 3. regenerate golden outputs if behavior changed;
504
+ 4. run `npm run test:eyelang`;
505
+ 5. publish the repository with the browser playground assets if publishing the playground. The playground includes controls equivalent to CLI `--stats` and `--proof`.
506
+
507
+ ## Relationship to Eyeling
508
+
509
+ [Eyeling](https://github.com/eyereasoner/eyeling) and eyelang share the same goal of small, inspectable rule-based reasoning in JavaScript, but they make different language and implementation trade-offs.
510
+
511
+ Eyeling is the RDF/Notation3 member of the family. It reads N3-style triples, quoted formulas, forward rules written with `=>`, backward rules written with `<=`, RDF terms, RDF-JS data, and RDF-oriented streams. That makes it the better fit when data interchange with RDF/N3 tools is the main requirement.
512
+
513
+ eyelang is the compact Prolog-style member of the family. It uses ordinary predicate syntax such as `parent(alice, bob).` and `ancestor(X, Z) :- parent(X, Y), ancestor(Y, Z).` This keeps the core syntax close to the ISO-standardized Prolog tradition while deliberately staying much smaller than ISO Prolog. It is a good fit when the problem is naturally relational, goal-directed, finite, and does not need RDF graph interchange.
514
+
515
+ A useful rule of thumb:
516
+
517
+ | Use case | Prefer | Why |
518
+ | --- | --- | --- |
519
+ | RDF/N3 data, triples, prefixes, graph terms, RDF-JS, RDF message streams | Eyeling | The surface language and APIs are RDF/Notation3-native. |
520
+ | Compact relational rules over ordinary terms, lists, arithmetic, and finite search | eyelang | The syntax is shorter for non-RDF relation programs and output is ordinary facts. |
521
+ | Human-auditable derivations | Either | Both can emit proof explanations when requested. |
522
+ | Large generated Horn-clause workloads | eyelang | The engine specializes in predicate/arity indexing, scalar argument indexes, fast fact paths, and materialized output goals. |
523
+
524
+ For the deep taxonomy benchmark, eyelang is substantially faster in current local checks. On one sandbox run, `eyeling --engine eyelang examples/eyelang/deep-taxonomy-100000.pl > /dev/null` took about `1.60 sec`, while `eyeling` package version `1.28.7` on `examples/deep-taxonomy-100000.n3` took about `4.56 sec` without proof and about `5.04 sec` with proof. Treat those numbers as a smoke comparison rather than a formal benchmark: hardware, Node.js version, package version, and CLI startup all matter.
525
+
526
+ The projects are therefore complementary rather than replacements for each other: Eyeling optimizes for Semantic Web interoperability and N3 expressiveness; eyelang optimizes for a small standard-looking relational rule language and fast finite goal-directed execution.
527
+
528
+ ## Performance notes
529
+
530
+ Use `-s` or `--stats` for a quick sanity check while optimizing solver changes. It prints counters such as `solve_goals_calls`, `unify_calls`, `deterministic_rule_expansions`, `candidate_lists_selected`, `clause_candidates_considered`, `clauses_tried`, `max_depth`, and `max_solver_call_depth` to stderr, leaving normal output stable for golden-file tests. The `max_solver_call_depth` counter is especially useful for browser regressions, where the VM call stack can be tighter than a command-line run.
531
+
532
+ eyelang hashes predicate groups by name and arity, then indexes clauses by scalar argument values. It also builds two-argument composite indexes for scalar pairs and probes those composite indexes without per-lookup heap allocation. This helps both large generated programs with many predicates and selective queries such as:
533
+
534
+ ```prolog
535
+ edge(g1, a, X).
536
+ path(a, Y).
537
+ status(Case, accepted).
538
+ ```
539
+
540
+ Ground facts use a fast path that avoids freshening and copying a rule body. Recursive-predicate detection uses an explicit work stack, which keeps large predicate chains safer in the browser. Recursive examples use an active-call variant guard to prevent common cyclic closures from looping. Selected predicates can be memoized with:
541
+
542
+ ```prolog
543
+ memoize(path, 2).
544
+ ```
545
+
546
+ For large programs, keep helper predicates selective, bind arguments early, and declare focused output predicates with `materialize/2` when default output would otherwise solve broad helper goals.
547
+
548
+ ## Implementation limits
549
+
550
+ eyelang is intentionally smaller than ISO Prolog. It has no operators, cut, modules, dynamic database updates, DCGs, or complete ISO library. Negation is negation-as-failure through `not/1`. Search is goal-directed and expected to be finite for the selected output goals. Output explanations are non-normative proof printouts and do not change answer semantics.
@@ -39,7 +39,7 @@
39
39
  - [9.6 Strings and atom constants](#96-strings-and-atom-constants)
40
40
  - [9.7 Lists](#97-lists)
41
41
  - [9.8 Aggregation and ordering](#98-aggregation-and-ordering)
42
- - [9.9 Formula terms](#99-formula-terms)
42
+ - [9.9 Context terms](#99-context-terms)
43
43
  - [9.10 Search control](#910-search-control)
44
44
  - [10. Extension built-ins](#10-extension-built-ins)
45
45
  - [11. Declarations](#11-declarations)
@@ -67,7 +67,7 @@
67
67
 
68
68
  eyelang is a compact Prolog-like definite-clause language for rule-based programs over ordinary terms, lists, arithmetic, strings, and finite search. An eyelang program is a finite sequence of facts and Horn clauses. The underlying declarative semantics of the pure language is **Herbrand semantics**: constants, compound terms, and lists denote themselves, and predicates denote sets of ground atomic formulas over those terms. Evaluation is goal-directed: goals are solved by unification against facts, rules, and a fixed set of built-in predicates.
69
69
 
70
- eyelang is intentionally smaller than ISO Prolog. It supports enough Prolog syntax to express Horn-clause reasoning, list processing, arithmetic examples, finite search, and formula data, without operators, cut, modules, dynamic predicates, DCGs, or a complete ISO standard library.
70
+ eyelang is intentionally smaller than ISO Prolog. It supports enough Prolog syntax to express Horn-clause reasoning, list processing, arithmetic examples, finite search, and context data, without operators, cut, modules, dynamic predicates, DCGs, or a complete ISO standard library.
71
71
 
72
72
  ## 1. Terminology and normative language
73
73
 
@@ -96,7 +96,7 @@ eyelang is designed to be:
96
96
  - small enough to embed and audit;
97
97
  - deterministic in textual output order after duplicate suppression;
98
98
  - useful for relation-style `p(S, O)` output through ordinary predicate names;
99
- - practical for examples involving recursion, lists, arithmetic, strings, aggregation, finite search, and formula-valued data.
99
+ - practical for examples involving recursion, lists, arithmetic, strings, aggregation, finite search, and context-valued data.
100
100
 
101
101
  Non-goals include complete ISO Prolog compatibility, operator declarations, module systems, dynamic database updates, cut-based control, and full bottom-up closure semantics.
102
102
 
@@ -252,7 +252,7 @@ Parenthesized comma terms may be goals or data:
252
252
  (name(alice, "Alice"), knows(alice, bob))
253
253
  ```
254
254
 
255
- When a comma term appears as a goal, it is evaluated as conjunction. When it appears as data, it remains a term. `formula_binary/4` enumerates binary members inside such formula terms.
255
+ When a comma term appears as a goal, it is evaluated as conjunction. When it appears as data, it remains a term. `holds/2` enumerates member terms inside such contexts, and `holds/3` exposes each member as a predicate name plus an argument list for any arity.
256
256
 
257
257
  ## 6. Clauses and predicates
258
258
 
@@ -429,21 +429,23 @@ Comparisons interpret numeric-looking terms numerically. Other scalar terms are
429
429
  | `aggregate_max(Key, Template, Goal, BestKey, BestTemplate)` | Selects the solution of `Goal` with the largest resolved `Key`, returning that key and the corresponding resolved `Template`. Fails when `Goal` has no solutions. |
430
430
  | `sort(Input, Output)` | Sorts and deduplicates a proper list. |
431
431
 
432
- ### 9.9 Formula terms
432
+ ### 9.9 Context terms
433
433
 
434
- Formula terms are data representations of atomic formulas and comma conjunctions.
434
+ Context terms are data representations of atomic formulas and comma conjunctions.
435
435
 
436
436
  | Built-in | Meaning |
437
437
  |---|---|
438
- | `formula_binary(Formula, S, P, O)` | Enumerates binary formula members `P(S, O)`, exposing the functor as atom constant `P`. |
438
+ | `holds(Context, Term)` | Enumerates member terms inside a context term and unifies each member with `Term`. |
439
+ | `holds(Context, Name, Args)` | Enumerates context members of any arity, exposing each member as atom constant `Name` plus a proper argument list `Args`. |
439
440
 
440
441
  Example:
441
442
 
442
443
  ```prolog
443
- formula_binary((name(alice, "Alice"), knows(alice, bob)), S, P, O).
444
+ holds((name(alice, "Alice"), knows(alice, bob)), name(S, O)).
445
+ holds((ready, name(alice, "Alice"), route(alice, bob, 7)), Name, Args).
444
446
  ```
445
447
 
446
- This can yield `formula_binary((name(alice, "Alice"), knows(alice, bob)), alice, name, "Alice").` and `formula_binary((name(alice, "Alice"), knows(alice, bob)), alice, knows, bob).`
448
+ The first goal can yield `holds((name(alice, "Alice"), knows(alice, bob)), name(alice, "Alice")).` The second can yield `holds((ready, name(alice, "Alice"), route(alice, bob, 7)), ready, []).`, `holds((ready, name(alice, "Alice"), route(alice, bob, 7)), name, [alice, "Alice"]).`, and `holds((ready, name(alice, "Alice"), route(alice, bob, 7)), route, [alice, bob, 7]).`
447
449
 
448
450
  ### 9.10 Search control
449
451