eyeling 1.33.1 → 1.33.3
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 +8 -0
- package/bin/eyeling.cjs +1 -1
- package/dist/browser/eyeling.browser.js +1 -1
- package/examples/eyelang/INTEGRATION.md +7 -0
- package/examples/eyelang/README.md +15 -76
- package/examples/eyelang/SPEC.md +1 -2
- package/examples/eyelang/output/vulnerability-impact.pl +20 -0
- package/examples/eyelang/vulnerability-impact.pl +70 -0
- package/examples/output/vulnerability-impact.n3 +22 -0
- package/examples/vulnerability-impact.n3 +80 -0
- package/eyelang.d.ts +0 -12
- package/eyeling.js +1 -1
- package/index.d.ts +0 -4
- package/index.js +2 -6
- package/lib/cli.js +1 -1
- package/lib/eyelang/bin.js +1 -1
- package/lib/eyelang/builtins/{aggregation.mjs → aggregation.js} +1 -1
- package/lib/eyelang/builtins/{alphametic.mjs → alphametic.js} +1 -1
- package/lib/eyelang/builtins/{arithmetic.mjs → arithmetic.js} +1 -1
- package/lib/eyelang/builtins/{core.mjs → core.js} +1 -1
- package/lib/eyelang/builtins/{formula.mjs → formula.js} +1 -1
- package/lib/eyelang/builtins/{lists.mjs → lists.js} +1 -1
- package/lib/eyelang/builtins/{matrix.mjs → matrix.js} +1 -1
- package/lib/eyelang/builtins/{number-theory.mjs → number-theory.js} +1 -1
- package/lib/eyelang/builtins/{portfolio.mjs → portfolio.js} +1 -1
- package/lib/eyelang/builtins/{registry.mjs → registry.js} +14 -15
- package/lib/eyelang/builtins/{search.mjs → search.js} +5 -5
- package/lib/eyelang/builtins/{strings.mjs → strings.js} +1 -1
- package/lib/eyelang/builtins/{sudoku.mjs → sudoku.js} +1 -1
- package/lib/eyelang/{cli.mjs → cli.js} +6 -18
- package/lib/eyelang/{explain.mjs → explain.js} +4 -4
- package/lib/eyelang/{hash.mjs → hash.js} +2 -2
- package/lib/eyelang/{index.mjs → index.js} +11 -12
- package/lib/eyelang/package.json +3 -0
- package/lib/eyelang/{parser.mjs → parser.js} +1 -1
- package/lib/eyelang/{program.mjs → program.js} +2 -9
- package/lib/eyelang/{solver.mjs → solver.js} +4 -4
- package/package.json +3 -3
- package/test/eyelang/run-conformance.mjs +1 -1
- package/test/eyelang/run-examples.mjs +2 -3
- package/test/eyelang/run-regression.mjs +4 -65
- package/test/eyelang/test-style.mjs +10 -7
- package/test/eyelang.test.js +1 -1
- package/test/run.js +186 -37
- package/examples/eyelang/annotation-rdf12.ttl +0 -12
- package/examples/eyelang/directional-language.ttl +0 -9
- package/examples/eyelang/eyeling-ackermann.n3 +0 -41
- package/examples/eyelang/eyeling-age-threshold.n3 +0 -12
- package/examples/eyelang/eyeling-alignment-demo.n3 +0 -11
- package/examples/eyelang/eyeling-allen-interval-calculus-small.n3 +0 -13
- package/examples/eyelang/eyeling-backward-recursion.n3 +0 -11
- package/examples/eyelang/eyeling-backward.n3 +0 -10
- package/examples/eyelang/eyeling-basic-monadic-small.n3 +0 -11
- package/examples/eyelang/eyeling-bmi.n3 +0 -10
- package/examples/eyelang/eyeling-cat-koko.n3 +0 -15
- package/examples/eyelang/eyeling-collatz-small.n3 +0 -11
- package/examples/eyelang/eyeling-collection.n3 +0 -11
- package/examples/eyelang/eyeling-complex-arithmetic.n3 +0 -10
- package/examples/eyelang/eyeling-context-association.n3 +0 -11
- package/examples/eyelang/eyeling-control-system-small.n3 +0 -11
- package/examples/eyelang/eyeling-crypto-builtins-extra.n3 +0 -10
- package/examples/eyelang/eyeling-crypto-builtins.n3 +0 -8
- package/examples/eyelang/eyeling-deep-taxonomy-10.n3 +0 -18
- package/examples/eyelang/eyeling-derived-backward-rule-flat.n3 +0 -10
- package/examples/eyelang/eyeling-derived-rule-flat.n3 +0 -9
- package/examples/eyelang/eyeling-digital-product-passport-small.n3 +0 -11
- package/examples/eyelang/eyeling-dijkstra-tiny.n3 +0 -14
- package/examples/eyelang/eyeling-dog-license.n3 +0 -13
- package/examples/eyelang/eyeling-drone-corridor-planner-small.n3 +0 -13
- package/examples/eyelang/eyeling-equals.n3 +0 -8
- package/examples/eyelang/eyeling-equivalence-classes.n3 +0 -11
- package/examples/eyelang/eyeling-euler-identity.n3 +0 -9
- package/examples/eyelang/eyeling-existential-rule.n3 +0 -9
- package/examples/eyelang/eyeling-expression-eval.n3 +0 -11
- package/examples/eyelang/eyeling-family-cousins-extended.n3 +0 -12
- package/examples/eyelang/eyeling-fastpow.n3 +0 -10
- package/examples/eyelang/eyeling-fibonacci.n3 +0 -44
- package/examples/eyelang/eyeling-french-cities-reachability.n3 +0 -22
- package/examples/eyelang/eyeling-goldbach-small.n3 +0 -22
- package/examples/eyelang/eyeling-good-cobbler.n3 +0 -9
- package/examples/eyelang/eyeling-list-builtins.n3 +0 -10
- package/examples/eyelang/eyeling-list-collection-extra.n3 +0 -9
- package/examples/eyelang/eyeling-math-builtins.n3 +0 -9
- package/examples/eyelang/eyeling-string-builtins-extra.n3 +0 -9
- package/examples/eyelang/eyeling-string-builtins.n3 +0 -10
- package/examples/eyelang/eyeling-time-builtins.n3 +0 -11
- package/examples/eyelang/eyeling-time-components-extra.n3 +0 -10
- package/examples/eyelang/eyeling-witch.n3 +0 -10
- package/examples/eyelang/family-cousins.n3 +0 -17
- package/examples/eyelang/n3-builtins.n3 +0 -28
- package/examples/eyelang/output/annotation-rdf12.ttl +0 -1
- package/examples/eyelang/output/directional-language.ttl +0 -1
- package/examples/eyelang/output/eyeling-ackermann.n3 +0 -12
- package/examples/eyelang/output/eyeling-age-threshold.n3 +0 -4
- package/examples/eyelang/output/eyeling-alignment-demo.n3 +0 -1
- package/examples/eyelang/output/eyeling-allen-interval-calculus-small.n3 +0 -3
- package/examples/eyelang/output/eyeling-backward-recursion.n3 +0 -9
- package/examples/eyelang/output/eyeling-backward.n3 +0 -1
- package/examples/eyelang/output/eyeling-basic-monadic-small.n3 +0 -8
- package/examples/eyelang/output/eyeling-bmi.n3 +0 -2
- package/examples/eyelang/output/eyeling-cat-koko.n3 +0 -3
- package/examples/eyelang/output/eyeling-collatz-small.n3 +0 -3
- package/examples/eyelang/output/eyeling-collection.n3 +0 -1
- package/examples/eyelang/output/eyeling-complex-arithmetic.n3 +0 -5
- package/examples/eyelang/output/eyeling-context-association.n3 +0 -4
- package/examples/eyelang/output/eyeling-control-system-small.n3 +0 -4
- package/examples/eyelang/output/eyeling-crypto-builtins-extra.n3 +0 -3
- package/examples/eyelang/output/eyeling-crypto-builtins.n3 +0 -2
- package/examples/eyelang/output/eyeling-deep-taxonomy-10.n3 +0 -32
- package/examples/eyelang/output/eyeling-derived-backward-rule-flat.n3 +0 -4
- package/examples/eyelang/output/eyeling-derived-rule-flat.n3 +0 -2
- package/examples/eyelang/output/eyeling-digital-product-passport-small.n3 +0 -3
- package/examples/eyelang/output/eyeling-dijkstra-tiny.n3 +0 -9
- package/examples/eyelang/output/eyeling-dog-license.n3 +0 -1
- package/examples/eyelang/output/eyeling-drone-corridor-planner-small.n3 +0 -5
- package/examples/eyelang/output/eyeling-equals.n3 +0 -1
- package/examples/eyelang/output/eyeling-equivalence-classes.n3 +0 -2
- package/examples/eyelang/output/eyeling-euler-identity.n3 +0 -3
- package/examples/eyelang/output/eyeling-existential-rule.n3 +0 -4
- package/examples/eyelang/output/eyeling-expression-eval.n3 +0 -3
- package/examples/eyelang/output/eyeling-family-cousins-extended.n3 +0 -6
- package/examples/eyelang/output/eyeling-fastpow.n3 +0 -4
- package/examples/eyelang/output/eyeling-fibonacci.n3 +0 -6
- package/examples/eyelang/output/eyeling-french-cities-reachability.n3 +0 -25
- package/examples/eyelang/output/eyeling-goldbach-small.n3 +0 -2
- package/examples/eyelang/output/eyeling-good-cobbler.n3 +0 -2
- package/examples/eyelang/output/eyeling-list-builtins.n3 +0 -6
- package/examples/eyelang/output/eyeling-list-collection-extra.n3 +0 -5
- package/examples/eyelang/output/eyeling-math-builtins.n3 +0 -5
- package/examples/eyelang/output/eyeling-string-builtins-extra.n3 +0 -3
- package/examples/eyelang/output/eyeling-string-builtins.n3 +0 -4
- package/examples/eyelang/output/eyeling-time-builtins.n3 +0 -4
- package/examples/eyelang/output/eyeling-time-components-extra.n3 +0 -5
- package/examples/eyelang/output/eyeling-witch.n3 +0 -2
- package/examples/eyelang/output/family-cousins.n3 +0 -8
- package/examples/eyelang/output/n3-builtins.n3 +0 -6
- package/examples/eyelang/output/socrates.n3 +0 -1
- package/examples/eyelang/output/triple-term.n3 +0 -2
- package/examples/eyelang/socrates.n3 +0 -11
- package/examples/eyelang/triple-term.n3 +0 -9
- package/lib/eyelang/builtins/n3.mjs +0 -483
- package/lib/eyelang/rdf.mjs +0 -747
- /package/lib/eyelang/builtins/{control.mjs → control.js} +0 -0
- /package/lib/eyelang/{term.mjs → term.js} +0 -0
package/README.md
CHANGED
|
@@ -631,6 +631,13 @@ Use the CLI option when running `.pl` programs:
|
|
|
631
631
|
eyeling --engine eyelang examples/eyelang/ancestor.pl
|
|
632
632
|
```
|
|
633
633
|
|
|
634
|
+
A paired example shows the same vulnerability-impact scenario in both engines:
|
|
635
|
+
|
|
636
|
+
```bash
|
|
637
|
+
eyeling examples/vulnerability-impact.n3
|
|
638
|
+
eyeling --engine eyelang examples/eyelang/vulnerability-impact.pl
|
|
639
|
+
```
|
|
640
|
+
|
|
634
641
|
Use the CommonJS convenience API when the rest of your application already imports `eyeling`:
|
|
635
642
|
|
|
636
643
|
```js
|
|
@@ -1171,6 +1178,7 @@ The repository contains more than two hundred N3 examples under `examples/`, plu
|
|
|
1171
1178
|
| `examples/age.n3` | Literal propagation. |
|
|
1172
1179
|
| `examples/family-cousins.n3` | Multi-hop relational inference. |
|
|
1173
1180
|
| `examples/dijkstra.n3` | Graph/path reasoning. |
|
|
1181
|
+
| `examples/vulnerability-impact.n3` and `examples/eyelang/vulnerability-impact.pl` | Paired N3 and eyelang dependency-risk example. |
|
|
1174
1182
|
| `examples/list-map.n3` | List processing. |
|
|
1175
1183
|
| `examples/string-builtins-tests.n3` | String built-ins. |
|
|
1176
1184
|
| `examples/math-builtins-tests.n3` | Numeric built-ins. |
|
package/bin/eyeling.cjs
CHANGED
|
@@ -37,7 +37,7 @@ function normalizeEngineName(value) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
async function runEyelangCli(argv) {
|
|
40
|
-
const cliUrl = pathToFileURL(path.join(__dirname, '..', 'lib', 'eyelang', 'cli.
|
|
40
|
+
const cliUrl = pathToFileURL(path.join(__dirname, '..', 'lib', 'eyelang', 'cli.js')).href;
|
|
41
41
|
const cli = await import(cliUrl);
|
|
42
42
|
await cli.main(argv);
|
|
43
43
|
}
|
|
@@ -6483,7 +6483,7 @@ async function main() {
|
|
|
6483
6483
|
`Options:\n` +
|
|
6484
6484
|
` -a, --ast Print parsed AST as JSON and exit.\n` +
|
|
6485
6485
|
` --builtin <module.js> Load a custom builtin module (repeatable).\n` +
|
|
6486
|
-
` --engine <n3|eyelang>
|
|
6486
|
+
` --engine <n3|eyelang> Select the N3 engine (default) or eyelang engine.\n` +
|
|
6487
6487
|
` -d, --deterministic-skolem Make log:skolem stable across reasoning runs.\n` +
|
|
6488
6488
|
` -e, --enforce-https Rewrite http:// IRIs to https:// for log dereferencing builtins.\n` +
|
|
6489
6489
|
` -h, --help Show this help and exit.\n` +
|
|
@@ -6,6 +6,13 @@ This directory contains eyelang examples that can be exercised through Eyeling's
|
|
|
6
6
|
eyeling --engine eyelang examples/eyelang/ancestor.pl
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
+
For a paired example, compare the N3 and eyelang versions of the same dependency-risk scenario:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
eyeling examples/vulnerability-impact.n3
|
|
13
|
+
eyeling --engine eyelang examples/eyelang/vulnerability-impact.pl
|
|
14
|
+
```
|
|
15
|
+
|
|
9
16
|
The eyelang conformance corpus is kept under `test/eyelang/` and can be run with:
|
|
10
17
|
|
|
11
18
|
```bash
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# eyelang
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/eyelang)
|
|
4
|
+
[](https://doi.org/10.5281/zenodo.20342331)
|
|
5
|
+
|
|
3
6
|
eyelang is a small rule engine for Prolog-style Horn clauses over ordinary terms, lists, arithmetic, strings, and finite search. The command-line executable is `eyelang`.
|
|
4
7
|
|
|
5
8
|
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.
|
|
@@ -17,13 +20,12 @@ For the normative language definition, including lexical syntax, terms, clauses,
|
|
|
17
20
|
4. [Writing programs](#writing-programs)
|
|
18
21
|
5. [Aggregation helpers](#aggregation-helpers)
|
|
19
22
|
6. [Formula data](#formula-data)
|
|
20
|
-
7. [
|
|
21
|
-
8. [
|
|
22
|
-
9. [
|
|
23
|
-
10. [
|
|
24
|
-
11. [
|
|
25
|
-
12. [
|
|
26
|
-
13. [Implementation limits](#implementation-limits)
|
|
23
|
+
7. [Example catalog](#example-catalog)
|
|
24
|
+
8. [Golden outputs, tests, and conformance](#golden-outputs-tests-and-conformance)
|
|
25
|
+
9. [Development and release](#development-and-release)
|
|
26
|
+
10. [Relationship to Eyeling](#relationship-to-eyeling)
|
|
27
|
+
11. [Performance notes](#performance-notes)
|
|
28
|
+
12. [Implementation limits](#implementation-limits)
|
|
27
29
|
|
|
28
30
|
## Quick start
|
|
29
31
|
|
|
@@ -313,69 +315,9 @@ formula_binary((name(alice, "Alice"), knows(alice, bob)), S, P, O).
|
|
|
313
315
|
This can yield `S = alice`, `P = name`, `O = "Alice"` and `S = alice`, `P = knows`, `O = bob`. The utility is useful for quoted formula data, but it does not make those formula members true in the ambient program.
|
|
314
316
|
|
|
315
317
|
|
|
316
|
-
## RDF 1.2 and Notation3 compatibility
|
|
317
|
-
|
|
318
|
-
The core eyelang syntax remains Prolog-like, but `src/rdf.js` adds a compatibility layer for RDF 1.2 Turtle/N-Triples style data and a practical Notation3 rule subset. Use it from the CLI with `--rdf`, `--rdf12`, `--n3`, or `--input-format FORMAT`; file inputs ending in `.ttl`, `.nt`, or `.n3` are recognized when the CLI uses its default `auto` format.
|
|
319
|
-
|
|
320
|
-
```sh
|
|
321
|
-
bin/eyelang --rdf data.ttl rules.n3
|
|
322
|
-
printf '@prefix : <http://example.com/> .
|
|
323
|
-
{ ?x :parent ?y . } => { ?x :related ?y . } .
|
|
324
|
-
:alice :parent :bob .
|
|
325
|
-
' | bin/eyelang --n3 -
|
|
326
|
-
```
|
|
327
|
-
|
|
328
|
-
RDF triples are lowered to ordinary `rdf/3` goals:
|
|
329
|
-
|
|
330
|
-
```prolog
|
|
331
|
-
rdf(Subject, Predicate, Object).
|
|
332
|
-
```
|
|
333
|
-
|
|
334
|
-
RDF terms are explicit eyelang compound terms:
|
|
335
|
-
|
|
336
|
-
```prolog
|
|
337
|
-
iri("http://example.com/alice")
|
|
338
|
-
bnode("b0")
|
|
339
|
-
literal("Alice", iri("http://www.w3.org/2001/XMLSchema#string"), "", "")
|
|
340
|
-
triple(Subject, Predicate, Object)
|
|
341
|
-
```
|
|
342
|
-
|
|
343
|
-
The layer supports `PREFIX`/`@prefix`, `BASE`/`@base`, `VERSION`/`@version`, IRIs, prefixed names, blank nodes, strings, numeric and boolean literals, language-tagged and RDF 1.2 directional language-tagged strings, RDF collections, blank-node property lists, RDF 1.2 triple terms `<<( ... )>>`, reified triple sugar `<< ... >>`, annotation blocks `{| ... |}`, N3 rules of the form `{ antecedent } => { consequent } .`, reverse rules of the form `{ consequent } <= { antecedent } .`, and N3 equality `=` as `owl:sameAs`. Reified triples and annotations are expanded through `rdf:reifies`, so this Turtle fragment:
|
|
344
|
-
|
|
345
|
-
```turtle
|
|
346
|
-
VERSION "1.2"
|
|
347
|
-
PREFIX : <http://example.com/>
|
|
348
|
-
:alice :name "Alice" ~ :t {| :statedBy :bob |} .
|
|
349
|
-
```
|
|
350
|
-
|
|
351
|
-
is made available as eyelang facts like:
|
|
352
|
-
|
|
353
|
-
```prolog
|
|
354
|
-
rdf(iri("http://example.com/alice"), iri("http://example.com/name"), literal("Alice", iri("http://www.w3.org/2001/XMLSchema#string"), "", "")).
|
|
355
|
-
rdf(iri("http://example.com/t"), iri("http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies"), triple(iri("http://example.com/alice"), iri("http://example.com/name"), literal("Alice", iri("http://www.w3.org/2001/XMLSchema#string"), "", ""))).
|
|
356
|
-
rdf(iri("http://example.com/t"), iri("http://example.com/statedBy"), iri("http://example.com/bob")).
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
From JavaScript, use `parseRdfClauses(source, options)` when you want clause objects, or `rdfToEyelang(source, options)` when you want the lowered eyelang source text.
|
|
360
|
-
|
|
361
|
-
N3 body triples whose predicates are in the common SWAP namespaces are lowered to eyelang built-ins instead of `rdf/3` goals. The practical bridge covers math comparisons and arithmetic such as `math:sum`, `math:difference`, `math:product`, `math:quotient`, `math:rounded`, and trigonometric functions, with exact BigInt-backed integer paths for large N3 arithmetic examples; string predicates such as `string:contains`, `string:startsWith`, `string:concatenation`, `string:length`, `string:replace`, and `string:scrape`; list predicates such as `list:member`, `list:append`, `list:first`, `list:rest`, `list:length`, `list:reverse`, and `list:sort`; `crypto:sha`, `crypto:md5`, `crypto:sha256`, `crypto:sha512`; simple `time:*` component extraction; and selected `log:*` helpers such as `log:equalTo`, `log:notEqualTo`, `log:uri`, `log:dtlit`, and `log:rawType`. This follows the builtin families used by eyeling while keeping eyelang's execution model small.
|
|
362
|
-
|
|
363
|
-
RDF/N3 examples now live directly in [`examples/`](examples/), with golden outputs in [`examples/output/`](examples/output/), matching the existing example layout. They include eyeling-inspired `socrates.n3`, `family-cousins.n3`, and `annotation-rdf12.ttl` examples; focused RDF 1.2 triple-term and directional-language examples; `n3-builtins.n3`; and a larger `eyeling-*.n3` set adapted from the eyeling example directory. The added eyeling-style examples cover backward rules, recursive `<=`, equality, collection/list handling, Ackermann-style hyperoperations, Fibonacci numbers, dog-license, witch, Cat Koko, family/cousin, alignment, BMI, and SWAP math/string/list/crypto/time builtins. Run them with auto format detection or force the reader explicitly:
|
|
364
|
-
|
|
365
|
-
```sh
|
|
366
|
-
bin/eyelang examples/socrates.n3
|
|
367
|
-
bin/eyelang --rdf12 examples/annotation-rdf12.ttl
|
|
368
|
-
bin/eyelang --n3 examples/n3-builtins.n3
|
|
369
|
-
bin/eyelang --n3 examples/eyeling-backward-recursion.n3
|
|
370
|
-
bin/eyelang --n3 examples/eyeling-ackermann.n3
|
|
371
|
-
bin/eyelang --n3 examples/eyeling-fibonacci.n3
|
|
372
|
-
```
|
|
373
|
-
|
|
374
|
-
This is a compatibility layer, not a validating W3C conformance parser. It intentionally covers the graph-oriented syntax, common RDF 1.2 constructs, and the N3 Horn-rule/builtin patterns that map cleanly to eyelang; it does not implement RDF/XML, full TriG datasets, SPARQL, scoped N3 formula built-ins such as full `log:semantics`, or every Notation3 construct.
|
|
375
|
-
|
|
376
318
|
## Example catalog
|
|
377
319
|
|
|
378
|
-
The repository includes examples for recursion, graph reachability, finite search, arithmetic, list processing, optimization, policies, puzzles,
|
|
320
|
+
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.
|
|
379
321
|
|
|
380
322
|
| Input | Short description | Output |
|
|
381
323
|
| --- | --- | --- |
|
|
@@ -388,7 +330,6 @@ The repository includes examples for recursion, graph reachability, finite searc
|
|
|
388
330
|
| [`ancestor.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/ancestor.pl) | Derives ancestors from parent facts. | [`output/ancestor.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/output/ancestor.pl) |
|
|
389
331
|
| [`animal.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/animal.pl) | Classifies animals from traits. | [`output/animal.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/output/animal.pl) |
|
|
390
332
|
| [`annotation.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/annotation.pl) | Derives facts from quoted annotation data. | [`output/annotation.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/output/annotation.pl) |
|
|
391
|
-
| [`annotation-rdf12.ttl`](https://github.com/eyereasoner/eyelang/blob/main/examples/annotation-rdf12.ttl) | Demonstrates RDF 1.2 annotation syntax lowered through `rdf:reifies`. | [`output/annotation-rdf12.ttl`](https://github.com/eyereasoner/eyelang/blob/main/examples/output/annotation-rdf12.ttl) |
|
|
392
333
|
| [`auroracare.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/auroracare.pl) | Evaluates purpose-based medical data access scenarios. | [`output/auroracare.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/output/auroracare.pl) |
|
|
393
334
|
| [`backward.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/backward.pl) | Shows a backward-rule pattern as a goal-directed numeric rule. | [`output/backward.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/output/backward.pl) |
|
|
394
335
|
| [`basic-monadic.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/basic-monadic.pl) | Runs a monadic benchmark over generated inputs. | [`output/basic-monadic.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/output/basic-monadic.pl) |
|
|
@@ -512,21 +453,19 @@ The repository includes examples for recursion, graph reachability, finite searc
|
|
|
512
453
|
| [`traveling-salesman.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/traveling-salesman.pl) | Finds an optimal traveling-salesman tour. | [`output/traveling-salesman.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/output/traveling-salesman.pl) |
|
|
513
454
|
| [`turing.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/turing.pl) | Simulates a binary-increment Turing machine. | [`output/turing.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/output/turing.pl) |
|
|
514
455
|
| [`vector-similarity.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/vector-similarity.pl) | Computes dot product, norm, and cosine similarity. | [`output/vector-similarity.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/output/vector-similarity.pl) |
|
|
515
|
-
| [`
|
|
456
|
+
| [`vulnerability-impact.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/vulnerability-impact.pl) | Analyzes vulnerable transitive dependencies and urgent patch impact. | [`output/vulnerability-impact.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/output/vulnerability-impact.pl) |
|
|
457
|
+
| [`witch.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/witch.pl) | Derives the classic “burn the witch” rule chain. | [`output/witch.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/output/witch.pl) |
|
|
516
458
|
| [`wolf-goat-cabbage.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/wolf-goat-cabbage.pl) | Solves the wolf-goat-cabbage river crossing. | [`output/wolf-goat-cabbage.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/output/wolf-goat-cabbage.pl) |
|
|
517
459
|
| [`zebra.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/zebra.pl) | Solves the zebra logic puzzle. | [`output/zebra.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/output/zebra.pl) |
|
|
518
460
|
|
|
519
461
|
|
|
520
|
-
| [`directional-language.ttl`](https://github.com/eyereasoner/eyelang/blob/main/examples/directional-language.ttl) | Demonstrates RDF 1.2 directional language-tagged strings. | [`output/directional-language.ttl`](https://github.com/eyereasoner/eyelang/blob/main/examples/output/directional-language.ttl) |
|
|
521
|
-
| [`n3-builtins.n3`](https://github.com/eyereasoner/eyelang/blob/main/examples/n3-builtins.n3) | Uses N3 `<=` plus `math:`, `string:`, and `list:` builtins. | [`output/n3-builtins.n3`](https://github.com/eyereasoner/eyelang/blob/main/examples/output/n3-builtins.n3) |
|
|
522
|
-
| [`triple-term.n3`](https://github.com/eyereasoner/eyelang/blob/main/examples/triple-term.n3) | Demonstrates RDF 1.2 triple terms in N3 data and rules. | [`output/triple-term.n3`](https://github.com/eyereasoner/eyelang/blob/main/examples/output/triple-term.n3) |
|
|
523
462
|
|
|
524
463
|
## Golden outputs, tests, and conformance
|
|
525
464
|
|
|
526
|
-
Golden answer outputs live in [`examples/output`](examples/output). `npm run test:examples` covers every top-level runnable
|
|
465
|
+
Golden answer outputs live in [`examples/output`](examples/output). `npm run test:examples` covers every top-level runnable `.pl` example. A curated proof-output suite for `.pl` examples lives in [`examples/proof`](examples/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:
|
|
527
466
|
|
|
528
467
|
```sh
|
|
529
|
-
for f in examples/*.pl
|
|
468
|
+
for f in examples/*.pl; do
|
|
530
469
|
[ -e "$f" ] || continue
|
|
531
470
|
b=$(basename "$f")
|
|
532
471
|
EYELANG_LOCAL_TIME=2026-05-30 bin/eyelang "$f" > "examples/output/$b"
|
|
@@ -625,4 +564,4 @@ For large programs, keep helper predicates selective, bind arguments early, and
|
|
|
625
564
|
|
|
626
565
|
## Implementation limits
|
|
627
566
|
|
|
628
|
-
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.
|
|
567
|
+
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.
|
package/examples/eyelang/SPEC.md
CHANGED
|
@@ -470,7 +470,7 @@ An extension built-in SHOULD obey the same surface-language discipline as standa
|
|
|
470
470
|
- it SHOULD document its intended modes, especially which arguments must be ground before it runs deterministically;
|
|
471
471
|
- it MUST NOT change the meaning of ordinary facts, rules, unification, or standard built-ins.
|
|
472
472
|
|
|
473
|
-
For example, an implementation may include extension modules for Sudoku solving, portfolio selection, number-theory algorithms, graph search, matrix operations, alphametic puzzles
|
|
473
|
+
For example, an implementation may include extension modules for Sudoku solving, portfolio selection, number-theory algorithms, graph search, matrix operations, or alphametic puzzles. Those modules may be valuable and may make example programs much faster, but their predicate names, arities, algorithms, and modes are implementation-defined unless they are separately standardized.
|
|
474
474
|
|
|
475
475
|
An implementation that provides explanation output SHOULD make extension built-ins explainable at least as opaque successful or failed built-in calls, so that proof traces do not incorrectly report "no clauses" for a host-provided relation.
|
|
476
476
|
|
|
@@ -681,4 +681,3 @@ URL input uses host networking support when available. Hosts SHOULD treat downlo
|
|
|
681
681
|
|
|
682
682
|
Programs SHOULD be written with finite search in mind. Broad default materialization can be expensive for helper predicates; use `materialize/2` declarations and concise output predicates when needed.
|
|
683
683
|
|
|
684
|
-
Compatibility readers for external syntaxes such as RDF 1.2 Turtle, N-Triples, or Notation3 SHOULD be treated as front-end translations into eyelang clauses. Such readers may support N3 implication syntaxes such as `=>` and `<=`, empty `true` rule bodies, N3 equality as `owl:sameAs`, and common N3/SWAP built-in namespaces mapped to host extension built-ins, including exact integer arithmetic where the host provides it. Unless a host explicitly claims a separate RDF or N3 conformance profile, such readers are not part of core eyelang conformance and may accept only the subset that maps cleanly to finite Horn-clause reasoning.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
uses(webapp, api).
|
|
2
|
+
uses(worker, queue).
|
|
3
|
+
uses(frontend, ui).
|
|
4
|
+
uses(webapp, auth).
|
|
5
|
+
uses(worker, openssl).
|
|
6
|
+
uses(frontend, css).
|
|
7
|
+
uses(webapp, openssl).
|
|
8
|
+
impacted_by(webapp, api).
|
|
9
|
+
impacted_by(worker, queue).
|
|
10
|
+
impacted_by(frontend, ui).
|
|
11
|
+
impacted_by(webapp, auth).
|
|
12
|
+
impacted_by(worker, openssl).
|
|
13
|
+
impacted_by(frontend, css).
|
|
14
|
+
impacted_by(webapp, openssl).
|
|
15
|
+
risk(worker, high).
|
|
16
|
+
risk(webapp, high).
|
|
17
|
+
mitigate(worker, cve_2026_0001).
|
|
18
|
+
mitigate(webapp, cve_2026_0001).
|
|
19
|
+
urgent_patch(webapp, openssl_3_0_14).
|
|
20
|
+
urgent_patch(worker, openssl_3_0_14).
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
% Vulnerability impact analysis over a transitive dependency graph.
|
|
2
|
+
%
|
|
3
|
+
% This mirrors examples/vulnerability-impact.n3 using eyelang rules.
|
|
4
|
+
|
|
5
|
+
% Output declarations: materialize/2 selects the relations written to this example's golden output.
|
|
6
|
+
materialize(uses, 2).
|
|
7
|
+
materialize(impacted_by, 2).
|
|
8
|
+
materialize(risk, 2).
|
|
9
|
+
materialize(mitigate, 2).
|
|
10
|
+
materialize(urgent_patch, 2).
|
|
11
|
+
|
|
12
|
+
% Program structure: facts set up the scenario, and rules derive the materialized conclusions.
|
|
13
|
+
service(webapp).
|
|
14
|
+
service(worker).
|
|
15
|
+
service(frontend).
|
|
16
|
+
|
|
17
|
+
critical(webapp).
|
|
18
|
+
critical(worker).
|
|
19
|
+
|
|
20
|
+
depends_on(webapp, api).
|
|
21
|
+
depends_on(worker, queue).
|
|
22
|
+
depends_on(frontend, ui).
|
|
23
|
+
depends_on(api, auth).
|
|
24
|
+
depends_on(auth, openssl).
|
|
25
|
+
depends_on(queue, openssl).
|
|
26
|
+
depends_on(ui, css).
|
|
27
|
+
|
|
28
|
+
vulnerability(openssl, cve_2026_0001).
|
|
29
|
+
cvss(cve_2026_0001, 9.8).
|
|
30
|
+
fixed_by(cve_2026_0001, openssl_3_0_14).
|
|
31
|
+
|
|
32
|
+
vulnerability(css, cve_2026_0002).
|
|
33
|
+
cvss(cve_2026_0002, 5.4).
|
|
34
|
+
fixed_by(cve_2026_0002, css_2_1_1).
|
|
35
|
+
|
|
36
|
+
% Derivation rules: each rule below contributes one logical step toward the displayed results.
|
|
37
|
+
uses(Service, Dependency) :-
|
|
38
|
+
service(Service),
|
|
39
|
+
depends_on(Service, Dependency).
|
|
40
|
+
|
|
41
|
+
uses(Service, Dependency) :-
|
|
42
|
+
service(Service),
|
|
43
|
+
depends_on(Service, Intermediate),
|
|
44
|
+
depends_on(Intermediate, Dependency).
|
|
45
|
+
|
|
46
|
+
uses(Service, Dependency) :-
|
|
47
|
+
service(Service),
|
|
48
|
+
depends_on(Service, Intermediate),
|
|
49
|
+
depends_on(Intermediate, Next),
|
|
50
|
+
depends_on(Next, Dependency).
|
|
51
|
+
|
|
52
|
+
impacted_by(Service, Dependency) :-
|
|
53
|
+
uses(Service, Dependency).
|
|
54
|
+
|
|
55
|
+
exposed_to(Service, Vulnerability) :-
|
|
56
|
+
uses(Service, Package),
|
|
57
|
+
vulnerability(Package, Vulnerability),
|
|
58
|
+
cvss(Vulnerability, Score),
|
|
59
|
+
gt(Score, 7.0).
|
|
60
|
+
|
|
61
|
+
risk(Service, high) :-
|
|
62
|
+
exposed_to(Service, _Vulnerability).
|
|
63
|
+
|
|
64
|
+
mitigate(Service, Vulnerability) :-
|
|
65
|
+
exposed_to(Service, Vulnerability).
|
|
66
|
+
|
|
67
|
+
urgent_patch(Service, Patch) :-
|
|
68
|
+
critical(Service),
|
|
69
|
+
exposed_to(Service, Vulnerability),
|
|
70
|
+
fixed_by(Vulnerability, Patch).
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
@prefix : <https://example.org/vulnerability-impact#> .
|
|
2
|
+
|
|
3
|
+
:webapp :uses :api .
|
|
4
|
+
:worker :uses :queue .
|
|
5
|
+
:frontend :uses :ui .
|
|
6
|
+
:webapp :uses :auth .
|
|
7
|
+
:worker :uses :openssl .
|
|
8
|
+
:frontend :uses :css .
|
|
9
|
+
:webapp :uses :openssl .
|
|
10
|
+
:worker :risk :high .
|
|
11
|
+
:worker :mitigate :CVE_2026_0001 .
|
|
12
|
+
:webapp :risk :high .
|
|
13
|
+
:webapp :mitigate :CVE_2026_0001 .
|
|
14
|
+
:webapp :urgentPatch :openssl_3_0_14 .
|
|
15
|
+
:worker :urgentPatch :openssl_3_0_14 .
|
|
16
|
+
:webapp :impactedBy :api .
|
|
17
|
+
:worker :impactedBy :queue .
|
|
18
|
+
:frontend :impactedBy :ui .
|
|
19
|
+
:webapp :impactedBy :auth .
|
|
20
|
+
:worker :impactedBy :openssl .
|
|
21
|
+
:frontend :impactedBy :css .
|
|
22
|
+
:webapp :impactedBy :openssl .
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# ===========================================================
|
|
2
|
+
# Vulnerability impact analysis over a transitive dependency graph
|
|
3
|
+
# ===========================================================
|
|
4
|
+
|
|
5
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
6
|
+
@prefix : <https://example.org/vulnerability-impact#>.
|
|
7
|
+
|
|
8
|
+
# Services.
|
|
9
|
+
:webapp a :Service; :critical true; :dependsOn :api.
|
|
10
|
+
:worker a :Service; :critical true; :dependsOn :queue.
|
|
11
|
+
:frontend a :Service; :dependsOn :ui.
|
|
12
|
+
|
|
13
|
+
# Component dependencies.
|
|
14
|
+
:api :dependsOn :auth.
|
|
15
|
+
:auth :dependsOn :openssl.
|
|
16
|
+
:queue :dependsOn :openssl.
|
|
17
|
+
:ui :dependsOn :css.
|
|
18
|
+
|
|
19
|
+
# Vulnerability data.
|
|
20
|
+
:openssl :vulnerability :CVE_2026_0001.
|
|
21
|
+
:CVE_2026_0001 :cvss 9.8; :fixedBy :openssl_3_0_14.
|
|
22
|
+
|
|
23
|
+
:css :vulnerability :CVE_2026_0002.
|
|
24
|
+
:CVE_2026_0002 :cvss 5.4; :fixedBy :css_2_1_1.
|
|
25
|
+
|
|
26
|
+
# A service uses its direct dependencies and the components they pull in.
|
|
27
|
+
{
|
|
28
|
+
?S a :Service.
|
|
29
|
+
?S :dependsOn ?D.
|
|
30
|
+
} => {
|
|
31
|
+
?S :uses ?D.
|
|
32
|
+
}.
|
|
33
|
+
|
|
34
|
+
{
|
|
35
|
+
?S a :Service.
|
|
36
|
+
?S :dependsOn ?M.
|
|
37
|
+
?M :dependsOn ?D.
|
|
38
|
+
} => {
|
|
39
|
+
?S :uses ?D.
|
|
40
|
+
}.
|
|
41
|
+
|
|
42
|
+
{
|
|
43
|
+
?S a :Service.
|
|
44
|
+
?S :dependsOn ?M.
|
|
45
|
+
?M :dependsOn ?N.
|
|
46
|
+
?N :dependsOn ?D.
|
|
47
|
+
} => {
|
|
48
|
+
?S :uses ?D.
|
|
49
|
+
}.
|
|
50
|
+
|
|
51
|
+
# Materialize the dependency closure for impact review.
|
|
52
|
+
{
|
|
53
|
+
?S :uses ?D.
|
|
54
|
+
} => {
|
|
55
|
+
?S :impactedBy ?D.
|
|
56
|
+
}.
|
|
57
|
+
|
|
58
|
+
# A service is high risk when any reachable component has a severe vulnerability.
|
|
59
|
+
{
|
|
60
|
+
?S :uses ?Pkg.
|
|
61
|
+
?Pkg :vulnerability ?V.
|
|
62
|
+
?V :cvss ?Score.
|
|
63
|
+
?Score math:greaterThan 7.0.
|
|
64
|
+
} => {
|
|
65
|
+
?S :risk :high.
|
|
66
|
+
?S :mitigate ?V.
|
|
67
|
+
}.
|
|
68
|
+
|
|
69
|
+
# Critical services with a severe reachable vulnerability get the available patch first.
|
|
70
|
+
{
|
|
71
|
+
?S a :Service.
|
|
72
|
+
?S :critical true.
|
|
73
|
+
?S :uses ?Pkg.
|
|
74
|
+
?Pkg :vulnerability ?V.
|
|
75
|
+
?V :cvss ?Score.
|
|
76
|
+
?Score math:greaterThan 7.0.
|
|
77
|
+
?V :fixedBy ?Patch.
|
|
78
|
+
} => {
|
|
79
|
+
?S :urgentPatch ?Patch.
|
|
80
|
+
}.
|
package/eyelang.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ export interface EyelangRunOptions {
|
|
|
6
6
|
proof?: boolean;
|
|
7
7
|
why?: boolean;
|
|
8
8
|
explain?: boolean;
|
|
9
|
-
inputFormat?: 'auto' | 'eyelang' | 'rdf' | 'rdf12' | 'turtle' | 'ttl' | 'nt' | 'n3' | string;
|
|
10
9
|
[key: string]: unknown;
|
|
11
10
|
}
|
|
12
11
|
|
|
@@ -32,14 +31,6 @@ export class Program {
|
|
|
32
31
|
export function makeProgram(clauses?: unknown[], options?: EyelangRunOptions): Program;
|
|
33
32
|
export function parseClauses(source: string, options?: EyelangRunOptions): unknown[];
|
|
34
33
|
export function parseProgramText(source: string, options?: EyelangRunOptions): unknown[];
|
|
35
|
-
export function parseRdfClauses(source: string, options?: EyelangRunOptions): unknown[];
|
|
36
|
-
export function rdfToEyelang(source: string, options?: EyelangRunOptions): string;
|
|
37
|
-
export function clausesToEyelang(clauses: unknown[]): string;
|
|
38
|
-
export function rdfIri(value: string): unknown;
|
|
39
|
-
export function rdfBlank(value: string): unknown;
|
|
40
|
-
export function rdfLiteral(value: string, datatype?: string, language?: string): unknown;
|
|
41
|
-
export function rdfTripleTerm(subject: unknown, predicate: unknown, object: unknown): unknown;
|
|
42
|
-
export function rdfGoal(subject: unknown, predicate: unknown, object: unknown): unknown;
|
|
43
34
|
|
|
44
35
|
export class Env {
|
|
45
36
|
constructor(parent?: Env | null);
|
|
@@ -79,9 +70,6 @@ declare const eyelang: {
|
|
|
79
70
|
makeProgram: typeof makeProgram;
|
|
80
71
|
parseClauses: typeof parseClauses;
|
|
81
72
|
parseProgramText: typeof parseProgramText;
|
|
82
|
-
parseRdfClauses: typeof parseRdfClauses;
|
|
83
|
-
rdfToEyelang: typeof rdfToEyelang;
|
|
84
|
-
clausesToEyelang: typeof clausesToEyelang;
|
|
85
73
|
Solver: typeof Solver;
|
|
86
74
|
Env: typeof Env;
|
|
87
75
|
BuiltinRegistry: typeof BuiltinRegistry;
|
package/eyeling.js
CHANGED
|
@@ -6483,7 +6483,7 @@ async function main() {
|
|
|
6483
6483
|
`Options:\n` +
|
|
6484
6484
|
` -a, --ast Print parsed AST as JSON and exit.\n` +
|
|
6485
6485
|
` --builtin <module.js> Load a custom builtin module (repeatable).\n` +
|
|
6486
|
-
` --engine <n3|eyelang>
|
|
6486
|
+
` --engine <n3|eyelang> Select the N3 engine (default) or eyelang engine.\n` +
|
|
6487
6487
|
` -d, --deterministic-skolem Make log:skolem stable across reasoning runs.\n` +
|
|
6488
6488
|
` -e, --enforce-https Rewrite http:// IRIs to https:// for log dereferencing builtins.\n` +
|
|
6489
6489
|
` -h, --help Show this help and exit.\n` +
|
package/index.d.ts
CHANGED
|
@@ -98,10 +98,6 @@ export interface EyelangRunOptions {
|
|
|
98
98
|
why?: boolean;
|
|
99
99
|
explain?: boolean;
|
|
100
100
|
stats?: boolean;
|
|
101
|
-
rdf?: boolean;
|
|
102
|
-
rdf12?: boolean;
|
|
103
|
-
n3?: boolean;
|
|
104
|
-
inputFormat?: 'auto' | 'eyelang' | 'rdf' | 'rdf12' | 'turtle' | 'ttl' | 'nt' | 'n3' | string;
|
|
105
101
|
args?: string[];
|
|
106
102
|
maxBuffer?: number;
|
|
107
103
|
[key: string]: unknown;
|
package/index.js
CHANGED
|
@@ -27,8 +27,7 @@ function normalizeEyelangSourceForTempFile(source) {
|
|
|
27
27
|
typeof source.eyelang === 'string' ? source.eyelang
|
|
28
28
|
: typeof source.prolog === 'string' ? source.prolog
|
|
29
29
|
: typeof source.text === 'string' ? source.text
|
|
30
|
-
:
|
|
31
|
-
: null;
|
|
30
|
+
: null;
|
|
32
31
|
if (text !== null) return text;
|
|
33
32
|
}
|
|
34
33
|
throw new TypeError('reason({ engine: "eyelang" }, input): each source must be a string or an object with an eyelang/prolog/text field');
|
|
@@ -49,9 +48,6 @@ function reasonEyelangSync(opt = {}, input = '') {
|
|
|
49
48
|
|
|
50
49
|
if (opt.proof || opt.why || opt.explain) args.push('--proof');
|
|
51
50
|
if (opt.stats) args.push('--stats');
|
|
52
|
-
if (opt.rdf || opt.rdf12) args.push('--rdf');
|
|
53
|
-
if (opt.n3) args.push('--n3');
|
|
54
|
-
if (typeof opt.inputFormat === 'string' && opt.inputFormat) args.push('--input-format', opt.inputFormat);
|
|
55
51
|
if (Array.isArray(opt.args)) args.push(...opt.args);
|
|
56
52
|
|
|
57
53
|
const maxBuffer = Number.isFinite(opt.maxBuffer) ? opt.maxBuffer : 50 * 1024 * 1024;
|
|
@@ -85,7 +81,7 @@ function reasonEyelangSync(opt = {}, input = '') {
|
|
|
85
81
|
}
|
|
86
82
|
|
|
87
83
|
async function loadEyelangModule() {
|
|
88
|
-
return import(pathToFileURL(path.join(__dirname, 'lib', 'eyelang', 'index.
|
|
84
|
+
return import(pathToFileURL(path.join(__dirname, 'lib', 'eyelang', 'index.js')).href);
|
|
89
85
|
}
|
|
90
86
|
|
|
91
87
|
async function runEyelang(input = '', opt = {}) {
|
package/lib/cli.js
CHANGED
|
@@ -805,7 +805,7 @@ async function main() {
|
|
|
805
805
|
`Options:\n` +
|
|
806
806
|
` -a, --ast Print parsed AST as JSON and exit.\n` +
|
|
807
807
|
` --builtin <module.js> Load a custom builtin module (repeatable).\n` +
|
|
808
|
-
` --engine <n3|eyelang>
|
|
808
|
+
` --engine <n3|eyelang> Select the N3 engine (default) or eyelang engine.\n` +
|
|
809
809
|
` -d, --deterministic-skolem Make log:skolem stable across reasoning runs.\n` +
|
|
810
810
|
` -e, --enforce-https Rewrite http:// IRIs to https:// for log dereferencing builtins.\n` +
|
|
811
811
|
` -h, --help Show this help and exit.\n` +
|
package/lib/eyelang/bin.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
import('./cli.
|
|
4
|
+
import('./cli.js').then(({ main }) => main(process.argv.slice(2))).catch((error) => {
|
|
5
5
|
console.error(`eyelang: ${error && error.message ? error.message : String(error)}`);
|
|
6
6
|
process.exit(1);
|
|
7
7
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Aggregation builtins that run a inner goal and collect, count, sum, or select the best answers.
|
|
2
2
|
// Each handler clones the solver so the inner goal can enumerate independently of the outer goal.
|
|
3
|
-
import { compareTerms, copyResolved, isDecimalInteger, lexicalValue, listFromItems, numberTerm, numberTextFromDouble, parseFiniteNumber, unify } from '../term.
|
|
3
|
+
import { compareTerms, copyResolved, isDecimalInteger, lexicalValue, listFromItems, numberTerm, numberTextFromDouble, parseFiniteNumber, unify } from '../term.js';
|
|
4
4
|
|
|
5
5
|
export const aggregationBuiltins = {
|
|
6
6
|
register(registry) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// It evaluates column constraints right-to-left, so examples such as
|
|
3
3
|
// SEND+MORE=MONEY and DONALD+GERALD=ROBERT do not need to express digit search
|
|
4
4
|
// with many relational select/3 and arithmetic goals.
|
|
5
|
-
import { atom, deref, listFromItems, numberTerm, properListItems, unify } from '../term.
|
|
5
|
+
import { atom, deref, listFromItems, numberTerm, properListItems, unify } from '../term.js';
|
|
6
6
|
|
|
7
7
|
export const alphameticBuiltins = {
|
|
8
8
|
register(registry) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Numeric builtins for integer-preserving arithmetic, floating point functions, comparisons, and ranges.
|
|
2
2
|
// The code keeps BigInt paths where possible so large eyelang integers remain exact.
|
|
3
|
-
import { compareIntegerText, deref, isDecimalInteger, lexicalValue, numberTerm, numberTextFromDouble, parseFiniteNumber, unify } from '../term.
|
|
3
|
+
import { compareIntegerText, deref, isDecimalInteger, lexicalValue, numberTerm, numberTextFromDouble, parseFiniteNumber, unify } from '../term.js';
|
|
4
4
|
|
|
5
5
|
const unaryNames = ['neg', 'abs', 'sin', 'cos', 'asin', 'acos', 'rounded', 'log'];
|
|
6
6
|
const binaryNames = ['add', 'sub', 'mul', 'div', 'mod', 'max', 'min', 'pow'];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Core relational builtins that do not naturally belong to arithmetic, strings, lists, or aggregation.
|
|
2
2
|
// They are deterministic filters/projections and should avoid enumerating additional answers.
|
|
3
|
-
import { stringTerm, lexicalValue, unify } from '../term.
|
|
3
|
+
import { stringTerm, lexicalValue, unify } from '../term.js';
|
|
4
4
|
|
|
5
5
|
function* ok(env) { yield env; }
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Formula builtins that treat conjunctions as first-class data terms.
|
|
2
2
|
// These are used by examples that construct or inspect rule bodies programmatically.
|
|
3
|
-
import { atom, deref, isConjunction, unify } from '../term.
|
|
3
|
+
import { atom, deref, isConjunction, unify } from '../term.js';
|
|
4
4
|
|
|
5
5
|
export const formulaBuiltins = {
|
|
6
6
|
register(registry) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// List builtins for proper lists, selection, membership, sorting, and indexing.
|
|
2
2
|
// Several predicates support both checking and generation, so the argument modes are handled explicitly.
|
|
3
|
-
import { compareTerms, copyResolved, deref, isCons, lexicalValue, listFromItems, numberTerm, properListItems, unify } from '../term.
|
|
3
|
+
import { compareTerms, copyResolved, deref, isCons, lexicalValue, listFromItems, numberTerm, properListItems, unify } from '../term.js';
|
|
4
4
|
|
|
5
5
|
export const listBuiltins = {
|
|
6
6
|
register(registry) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Small dense-matrix arithmetic builtins.
|
|
2
2
|
// These are reusable numeric kernels for ground matrices; when arguments are not
|
|
3
3
|
// ground proper numeric lists, user-defined matrix predicates remain available.
|
|
4
|
-
import { deref, isDecimalInteger, listFromItems, numberTerm, numberTextFromDouble, parseFiniteNumber, properListItems, unify } from '../term.
|
|
4
|
+
import { deref, isDecimalInteger, listFromItems, numberTerm, numberTextFromDouble, parseFiniteNumber, properListItems, unify } from '../term.js';
|
|
5
5
|
|
|
6
6
|
export const matrixBuiltins = {
|
|
7
7
|
register(registry) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// arithmetic algorithms with many small recursive rule calls.
|
|
3
3
|
// The predicates are intentionally general: extended GCD, Collatz trajectories,
|
|
4
4
|
// Kaprekar iteration counts, and Goldbach pair generation.
|
|
5
|
-
import { deref, listFromItems, numberTerm, unify } from '../term.
|
|
5
|
+
import { deref, listFromItems, numberTerm, unify } from '../term.js';
|
|
6
6
|
|
|
7
7
|
export const numberTheoryBuiltins = {
|
|
8
8
|
register(registry) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Reusable bounded-subset optimizer for finite knapsack-style examples.
|
|
2
2
|
// Items are p(Name, Value, Cost, Risk) terms; the builtin enumerates every
|
|
3
3
|
// subset whose total cost/risk stays within the supplied caps.
|
|
4
|
-
import { deref, listFromItems, numberTerm, properListItems, unify } from '../term.
|
|
4
|
+
import { deref, listFromItems, numberTerm, properListItems, unify } from '../term.js';
|
|
5
5
|
|
|
6
6
|
export const portfolioBuiltins = {
|
|
7
7
|
register(registry) {
|