eyelang 1.5.5 → 1.6.0
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 +101 -9
- package/SPEC.md +3 -1
- package/examples/annotation-rdf12.ttl +12 -0
- package/examples/directional-language.ttl +9 -0
- package/examples/eyeling-ackermann.n3 +41 -0
- package/examples/eyeling-age-threshold.n3 +12 -0
- package/examples/eyeling-alignment-demo.n3 +11 -0
- package/examples/eyeling-allen-interval-calculus-small.n3 +13 -0
- package/examples/eyeling-backward-recursion.n3 +11 -0
- package/examples/eyeling-backward.n3 +10 -0
- package/examples/eyeling-basic-monadic-small.n3 +11 -0
- package/examples/eyeling-bmi.n3 +10 -0
- package/examples/eyeling-cat-koko.n3 +15 -0
- package/examples/eyeling-collatz-small.n3 +11 -0
- package/examples/eyeling-collection.n3 +11 -0
- package/examples/eyeling-complex-arithmetic.n3 +10 -0
- package/examples/eyeling-context-association.n3 +11 -0
- package/examples/eyeling-control-system-small.n3 +11 -0
- package/examples/eyeling-crypto-builtins-extra.n3 +10 -0
- package/examples/eyeling-crypto-builtins.n3 +8 -0
- package/examples/eyeling-deep-taxonomy-10.n3 +18 -0
- package/examples/eyeling-derived-backward-rule-flat.n3 +10 -0
- package/examples/eyeling-derived-rule-flat.n3 +9 -0
- package/examples/eyeling-digital-product-passport-small.n3 +11 -0
- package/examples/eyeling-dijkstra-tiny.n3 +14 -0
- package/examples/eyeling-dog-license.n3 +13 -0
- package/examples/eyeling-drone-corridor-planner-small.n3 +13 -0
- package/examples/eyeling-equals.n3 +8 -0
- package/examples/eyeling-equivalence-classes.n3 +11 -0
- package/examples/eyeling-euler-identity.n3 +9 -0
- package/examples/eyeling-existential-rule.n3 +9 -0
- package/examples/eyeling-expression-eval.n3 +11 -0
- package/examples/eyeling-family-cousins-extended.n3 +12 -0
- package/examples/eyeling-fastpow.n3 +10 -0
- package/examples/eyeling-fibonacci.n3 +44 -0
- package/examples/eyeling-french-cities-reachability.n3 +22 -0
- package/examples/eyeling-goldbach-small.n3 +22 -0
- package/examples/eyeling-good-cobbler.n3 +9 -0
- package/examples/eyeling-list-builtins.n3 +10 -0
- package/examples/eyeling-list-collection-extra.n3 +9 -0
- package/examples/eyeling-math-builtins.n3 +9 -0
- package/examples/eyeling-string-builtins-extra.n3 +9 -0
- package/examples/eyeling-string-builtins.n3 +10 -0
- package/examples/eyeling-time-builtins.n3 +11 -0
- package/examples/eyeling-time-components-extra.n3 +10 -0
- package/examples/eyeling-witch.n3 +10 -0
- package/examples/family-cousins.n3 +17 -0
- package/examples/n3-builtins.n3 +28 -0
- package/examples/output/annotation-rdf12.ttl +1 -0
- package/examples/output/directional-language.ttl +1 -0
- package/examples/output/eyeling-ackermann.n3 +12 -0
- package/examples/output/eyeling-age-threshold.n3 +4 -0
- package/examples/output/eyeling-alignment-demo.n3 +1 -0
- package/examples/output/eyeling-allen-interval-calculus-small.n3 +3 -0
- package/examples/output/eyeling-backward-recursion.n3 +9 -0
- package/examples/output/eyeling-backward.n3 +1 -0
- package/examples/output/eyeling-basic-monadic-small.n3 +8 -0
- package/examples/output/eyeling-bmi.n3 +2 -0
- package/examples/output/eyeling-cat-koko.n3 +3 -0
- package/examples/output/eyeling-collatz-small.n3 +3 -0
- package/examples/output/eyeling-collection.n3 +1 -0
- package/examples/output/eyeling-complex-arithmetic.n3 +5 -0
- package/examples/output/eyeling-context-association.n3 +4 -0
- package/examples/output/eyeling-control-system-small.n3 +4 -0
- package/examples/output/eyeling-crypto-builtins-extra.n3 +3 -0
- package/examples/output/eyeling-crypto-builtins.n3 +2 -0
- package/examples/output/eyeling-deep-taxonomy-10.n3 +32 -0
- package/examples/output/eyeling-derived-backward-rule-flat.n3 +4 -0
- package/examples/output/eyeling-derived-rule-flat.n3 +2 -0
- package/examples/output/eyeling-digital-product-passport-small.n3 +3 -0
- package/examples/output/eyeling-dijkstra-tiny.n3 +9 -0
- package/examples/output/eyeling-dog-license.n3 +1 -0
- package/examples/output/eyeling-drone-corridor-planner-small.n3 +5 -0
- package/examples/output/eyeling-equals.n3 +1 -0
- package/examples/output/eyeling-equivalence-classes.n3 +2 -0
- package/examples/output/eyeling-euler-identity.n3 +3 -0
- package/examples/output/eyeling-existential-rule.n3 +4 -0
- package/examples/output/eyeling-expression-eval.n3 +3 -0
- package/examples/output/eyeling-family-cousins-extended.n3 +6 -0
- package/examples/output/eyeling-fastpow.n3 +4 -0
- package/examples/output/eyeling-fibonacci.n3 +6 -0
- package/examples/output/eyeling-french-cities-reachability.n3 +25 -0
- package/examples/output/eyeling-goldbach-small.n3 +2 -0
- package/examples/output/eyeling-good-cobbler.n3 +2 -0
- package/examples/output/eyeling-list-builtins.n3 +6 -0
- package/examples/output/eyeling-list-collection-extra.n3 +5 -0
- package/examples/output/eyeling-math-builtins.n3 +5 -0
- package/examples/output/eyeling-string-builtins-extra.n3 +3 -0
- package/examples/output/eyeling-string-builtins.n3 +4 -0
- package/examples/output/eyeling-time-builtins.n3 +4 -0
- package/examples/output/eyeling-time-components-extra.n3 +5 -0
- package/examples/output/eyeling-witch.n3 +2 -0
- package/examples/output/family-cousins.n3 +8 -0
- package/examples/output/n3-builtins.n3 +6 -0
- package/examples/output/resilient-city-orchestration.pl +67 -0
- package/examples/output/riemann-hypothesis.pl +12 -0
- package/examples/output/socrates.n3 +1 -0
- package/examples/output/triple-term.n3 +2 -0
- package/examples/resilient-city-orchestration.pl +303 -0
- package/examples/riemann-hypothesis.pl +110 -0
- package/examples/socrates.n3 +11 -0
- package/examples/triple-term.n3 +9 -0
- package/package.json +1 -1
- package/playground.html +2 -0
- package/src/builtins/n3.js +483 -0
- package/src/builtins/registry.js +2 -1
- package/src/cli.js +13 -1
- package/src/index.js +3 -2
- package/src/parser.js +37 -16
- package/src/program.js +14 -3
- package/src/rdf.js +747 -0
- package/test/run-examples.js +7 -1
- package/test/run-regression.js +60 -0
package/README.md
CHANGED
|
@@ -20,11 +20,13 @@ For the normative language definition, including lexical syntax, terms, clauses,
|
|
|
20
20
|
4. [Writing programs](#writing-programs)
|
|
21
21
|
5. [Aggregation helpers](#aggregation-helpers)
|
|
22
22
|
6. [Formula data](#formula-data)
|
|
23
|
-
7. [
|
|
24
|
-
8. [
|
|
25
|
-
9. [
|
|
26
|
-
10. [
|
|
27
|
-
11. [
|
|
23
|
+
7. [RDF 1.2 and Notation3 compatibility](#rdf-12-and-notation3-compatibility)
|
|
24
|
+
8. [Example catalog](#example-catalog)
|
|
25
|
+
9. [Golden outputs, tests, and conformance](#golden-outputs-tests-and-conformance)
|
|
26
|
+
10. [Development and release](#development-and-release)
|
|
27
|
+
11. [Relationship to Eyeling](#relationship-to-eyeling)
|
|
28
|
+
12. [Performance notes](#performance-notes)
|
|
29
|
+
13. [Implementation limits](#implementation-limits)
|
|
28
30
|
|
|
29
31
|
## Quick start
|
|
30
32
|
|
|
@@ -313,6 +315,67 @@ formula_binary((name(alice, "Alice"), knows(alice, bob)), S, P, O).
|
|
|
313
315
|
|
|
314
316
|
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.
|
|
315
317
|
|
|
318
|
+
|
|
319
|
+
## RDF 1.2 and Notation3 compatibility
|
|
320
|
+
|
|
321
|
+
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.
|
|
322
|
+
|
|
323
|
+
```sh
|
|
324
|
+
bin/eyelang --rdf data.ttl rules.n3
|
|
325
|
+
printf '@prefix : <http://example.com/> .
|
|
326
|
+
{ ?x :parent ?y . } => { ?x :related ?y . } .
|
|
327
|
+
:alice :parent :bob .
|
|
328
|
+
' | bin/eyelang --n3 -
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
RDF triples are lowered to ordinary `rdf/3` goals:
|
|
332
|
+
|
|
333
|
+
```prolog
|
|
334
|
+
rdf(Subject, Predicate, Object).
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
RDF terms are explicit eyelang compound terms:
|
|
338
|
+
|
|
339
|
+
```prolog
|
|
340
|
+
iri("http://example.com/alice")
|
|
341
|
+
bnode("b0")
|
|
342
|
+
literal("Alice", iri("http://www.w3.org/2001/XMLSchema#string"), "", "")
|
|
343
|
+
triple(Subject, Predicate, Object)
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
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:
|
|
347
|
+
|
|
348
|
+
```turtle
|
|
349
|
+
VERSION "1.2"
|
|
350
|
+
PREFIX : <http://example.com/>
|
|
351
|
+
:alice :name "Alice" ~ :t {| :statedBy :bob |} .
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
is made available as eyelang facts like:
|
|
355
|
+
|
|
356
|
+
```prolog
|
|
357
|
+
rdf(iri("http://example.com/alice"), iri("http://example.com/name"), literal("Alice", iri("http://www.w3.org/2001/XMLSchema#string"), "", "")).
|
|
358
|
+
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"), "", ""))).
|
|
359
|
+
rdf(iri("http://example.com/t"), iri("http://example.com/statedBy"), iri("http://example.com/bob")).
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
From JavaScript, use `parseRdfClauses(source, options)` when you want clause objects, or `rdfToEyelang(source, options)` when you want the lowered eyelang source text.
|
|
363
|
+
|
|
364
|
+
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.
|
|
365
|
+
|
|
366
|
+
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:
|
|
367
|
+
|
|
368
|
+
```sh
|
|
369
|
+
bin/eyelang examples/socrates.n3
|
|
370
|
+
bin/eyelang --rdf12 examples/annotation-rdf12.ttl
|
|
371
|
+
bin/eyelang --n3 examples/n3-builtins.n3
|
|
372
|
+
bin/eyelang --n3 examples/eyeling-backward-recursion.n3
|
|
373
|
+
bin/eyelang --n3 examples/eyeling-ackermann.n3
|
|
374
|
+
bin/eyelang --n3 examples/eyeling-fibonacci.n3
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
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.
|
|
378
|
+
|
|
316
379
|
## Example catalog
|
|
317
380
|
|
|
318
381
|
The repository includes examples for recursion, graph reachability, finite search, arithmetic, list processing, optimization, policies, puzzles, N3-inspired rule chains, and applied scientific calculations. Bundled examples use relation-style output.
|
|
@@ -328,6 +391,7 @@ The repository includes examples for recursion, graph reachability, finite searc
|
|
|
328
391
|
| [`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) |
|
|
329
392
|
| [`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) |
|
|
330
393
|
| [`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) |
|
|
394
|
+
| [`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) |
|
|
331
395
|
| [`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) |
|
|
332
396
|
| [`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) |
|
|
333
397
|
| [`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) |
|
|
@@ -435,6 +499,8 @@ The repository includes examples for recursion, graph reachability, finite searc
|
|
|
435
499
|
| [`quadratic-formula.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/quadratic-formula.pl) | Solves sample quadratic equations. | [`output/quadratic-formula.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/output/quadratic-formula.pl) |
|
|
436
500
|
| [`quine-mccluskey.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/quine-mccluskey.pl) | Minimizes Boolean terms with Quine-McCluskey. | [`output/quine-mccluskey.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/output/quine-mccluskey.pl) |
|
|
437
501
|
| [`radioactive-decay.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/radioactive-decay.pl) | Computes radioactive decay over time. | [`output/radioactive-decay.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/output/radioactive-decay.pl) |
|
|
502
|
+
| [`resilient-city-orchestration.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/resilient-city-orchestration.pl) | Orchestrates storm-response missions from signals, policy, routes, teams, and portfolio optimization. | [`output/resilient-city-orchestration.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/output/resilient-city-orchestration.pl) |
|
|
503
|
+
| [`riemann-hypothesis.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/riemann-hypothesis.pl) | Checks a finite catalogue of non-trivial zeta zeros against the Riemann-hypothesis condition. | [`output/riemann-hypothesis.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/output/riemann-hypothesis.pl) |
|
|
438
504
|
| [`sat-dpll.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/sat-dpll.pl) | Solves a finite SAT instance. | [`output/sat-dpll.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/output/sat-dpll.pl) |
|
|
439
505
|
| [`security-incident-correlation.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/security-incident-correlation.pl) | Correlates security incidents across signals. | [`output/security-incident-correlation.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/output/security-incident-correlation.pl) |
|
|
440
506
|
| [`service-impact.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/service-impact.pl) | Analyzes service impact over cyclic dependencies. | [`output/service-impact.pl`](https://github.com/eyereasoner/eyelang/blob/main/examples/output/service-impact.pl) |
|
|
@@ -454,12 +520,17 @@ The repository includes examples for recursion, graph reachability, finite searc
|
|
|
454
520
|
| [`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) |
|
|
455
521
|
|
|
456
522
|
|
|
523
|
+
| [`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) |
|
|
524
|
+
| [`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) |
|
|
525
|
+
| [`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) |
|
|
526
|
+
|
|
457
527
|
## Golden outputs, tests, and conformance
|
|
458
528
|
|
|
459
|
-
Golden answer outputs live in [`examples/output`](examples/output). A curated proof-output suite 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:
|
|
529
|
+
Golden answer outputs live in [`examples/output`](examples/output). `npm run test:examples` covers every top-level runnable example with extension `.pl`, `.n3`, `.ttl`, or `.nt`. 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:
|
|
460
530
|
|
|
461
531
|
```sh
|
|
462
|
-
for f in examples/*.pl; do
|
|
532
|
+
for f in examples/*.pl examples/*.n3 examples/*.ttl examples/*.nt; do
|
|
533
|
+
[ -e "$f" ] || continue
|
|
463
534
|
b=$(basename "$f")
|
|
464
535
|
EYELANG_LOCAL_TIME=2026-05-30 bin/eyelang "$f" > "examples/output/$b"
|
|
465
536
|
done
|
|
@@ -476,7 +547,7 @@ Run the full test suite:
|
|
|
476
547
|
npm test
|
|
477
548
|
```
|
|
478
549
|
|
|
479
|
-
The test suite 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 `SPEC.md`, supplemental regression/API/white-box checks, and every example against its
|
|
550
|
+
The test suite 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 `SPEC.md`, supplemental regression/API/white-box checks, and every runnable example against its golden output.
|
|
480
551
|
|
|
481
552
|
Run only one suite when you are iterating:
|
|
482
553
|
|
|
@@ -514,6 +585,27 @@ For a release:
|
|
|
514
585
|
4. run `npm test`;
|
|
515
586
|
5. publish the repository with `playground.html` and `playground-worker.mjs` if publishing the playground. The playground includes controls equivalent to CLI `--stats` and `--proof`.
|
|
516
587
|
|
|
588
|
+
## Relationship to Eyeling
|
|
589
|
+
|
|
590
|
+
[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.
|
|
591
|
+
|
|
592
|
+
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.
|
|
593
|
+
|
|
594
|
+
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.
|
|
595
|
+
|
|
596
|
+
A useful rule of thumb:
|
|
597
|
+
|
|
598
|
+
| Use case | Prefer | Why |
|
|
599
|
+
| --- | --- | --- |
|
|
600
|
+
| RDF/N3 data, triples, prefixes, graph terms, RDF-JS, RDF message streams | Eyeling | The surface language and APIs are RDF/Notation3-native. |
|
|
601
|
+
| 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. |
|
|
602
|
+
| Human-auditable derivations | Either | Both can emit proof explanations when requested. |
|
|
603
|
+
| Large generated Horn-clause workloads | eyelang | The engine specializes in predicate/arity indexing, scalar argument indexes, fast fact paths, and materialized output goals. |
|
|
604
|
+
|
|
605
|
+
For the deep taxonomy benchmark, eyelang is substantially faster in current local checks. On one sandbox run, `node bin/eyelang examples/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.
|
|
606
|
+
|
|
607
|
+
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.
|
|
608
|
+
|
|
517
609
|
## Performance notes
|
|
518
610
|
|
|
519
611
|
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.
|
|
@@ -536,4 +628,4 @@ For large programs, keep helper predicates selective, bind arguments early, and
|
|
|
536
628
|
|
|
537
629
|
## Implementation limits
|
|
538
630
|
|
|
539
|
-
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.
|
|
631
|
+
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. The RDF 1.2 / Notation3 reader is an implementation compatibility layer over `rdf/3`, not a normative RDF conformance profile.
|
package/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,
|
|
473
|
+
For example, an implementation may include extension modules for Sudoku solving, portfolio selection, number-theory algorithms, graph search, matrix operations, alphametic puzzles, or a non-normative RDF/Notation3 reader that lowers RDF triples to ordinary eyelang predicates such as `rdf/3` and lowers selected Notation3 built-in predicates to extension built-ins such as `n3_math_sum/2` or `n3_string_contains/2`. Those modules may be valuable and may make example programs much faster, but their predicate names, arities, algorithms, syntax accepted by non-eyelang readers, 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
|
|
|
@@ -680,3 +680,5 @@ status(a, open) :- open(a).
|
|
|
680
680
|
URL input uses host networking support when available. Hosts SHOULD treat downloaded programs as untrusted code because they can trigger expensive search.
|
|
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
|
+
|
|
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,12 @@
|
|
|
1
|
+
# Inspired by eyereasoner/eyeling examples/annotation.n3.
|
|
2
|
+
# Demonstrates RDF 1.2 annotation syntax lowered through rdf:reifies.
|
|
3
|
+
VERSION "1.2"
|
|
4
|
+
PREFIX : <http://example.org/annotation#>
|
|
5
|
+
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
|
|
6
|
+
|
|
7
|
+
:a :name "Alice" ~ :t {| :statedBy :bob ; :recorded "2021-07-07"^^xsd:date |} .
|
|
8
|
+
|
|
9
|
+
{ ?Statement rdf:reifies <<( ?Person :name ?Name )>> .
|
|
10
|
+
?Statement :statedBy ?Agent . }
|
|
11
|
+
=>
|
|
12
|
+
{ ?Person :nameStatementBy ?Agent . } .
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Adapted from eyeling/examples/ackermann.n3.
|
|
2
|
+
# Demonstrates <= rules over RDF lists and exact BigInt-capable math builtins.
|
|
3
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
4
|
+
@prefix : <https://eyereasoner.github.io/eyeling/examples/ackermann#>.
|
|
5
|
+
|
|
6
|
+
# ackermann(x, y) = hyper(x, y + 3, 2) - 3.
|
|
7
|
+
{ (?X ?Y) :ackermann ?A } <= {
|
|
8
|
+
(?Y 3) math:sum ?B.
|
|
9
|
+
(?X ?B 2) :ackermann ?C.
|
|
10
|
+
(?C 3) math:difference ?A.
|
|
11
|
+
}.
|
|
12
|
+
|
|
13
|
+
# Successor, addition, multiplication, and exponentiation levels.
|
|
14
|
+
{ (0 ?Y ?Z) :ackermann ?A } <= { (?Y 1) math:sum ?A }.
|
|
15
|
+
{ (1 ?Y ?Z) :ackermann ?A } <= { (?Y ?Z) math:sum ?A }.
|
|
16
|
+
{ (2 ?Y ?Z) :ackermann ?A } <= { (?Y ?Z) math:product ?A }.
|
|
17
|
+
{ (3 ?Y ?Z) :ackermann ?A } <= { (?Z ?Y) math:exponentiation ?A }.
|
|
18
|
+
|
|
19
|
+
# Tetration and higher hyperoperations.
|
|
20
|
+
{ (?X 0 ?Z) :ackermann 1 } <= { ?X math:greaterThan 3 }.
|
|
21
|
+
{ (?X ?Y ?Z) :ackermann ?A } <= {
|
|
22
|
+
?X math:greaterThan 3.
|
|
23
|
+
?Y math:notEqualTo 0.
|
|
24
|
+
(?Y 1) math:difference ?B.
|
|
25
|
+
(?X ?B ?Z) :ackermann ?C.
|
|
26
|
+
(?X 1) math:difference ?D.
|
|
27
|
+
(?D ?C ?Z) :ackermann ?A.
|
|
28
|
+
}.
|
|
29
|
+
|
|
30
|
+
{ (0 0) :ackermann ?A } => { :ackermann_0_0 :value ?A }.
|
|
31
|
+
{ (0 6) :ackermann ?A } => { :ackermann_0_6 :value ?A }.
|
|
32
|
+
{ (1 2) :ackermann ?A } => { :ackermann_1_2 :value ?A }.
|
|
33
|
+
{ (1 7) :ackermann ?A } => { :ackermann_1_7 :value ?A }.
|
|
34
|
+
{ (2 2) :ackermann ?A } => { :ackermann_2_2 :value ?A }.
|
|
35
|
+
{ (2 9) :ackermann ?A } => { :ackermann_2_9 :value ?A }.
|
|
36
|
+
{ (3 4) :ackermann ?A } => { :ackermann_3_4 :value ?A }.
|
|
37
|
+
{ (3 1000) :ackermann ?A } => { :ackermann_3_1000 :value ?A }.
|
|
38
|
+
{ (4 0) :ackermann ?A } => { :ackermann_4_0 :value ?A }.
|
|
39
|
+
{ (4 1) :ackermann ?A } => { :ackermann_4_1 :value ?A }.
|
|
40
|
+
{ (4 2) :ackermann ?A } => { :ackermann_4_2 :value ?A }.
|
|
41
|
+
{ (5 0) :ackermann ?A } => { :ackermann_5_0 :value ?A }.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Adapted from eyeling/examples/age.n3.
|
|
2
|
+
# Classifies people against age thresholds using N3 math builtins.
|
|
3
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
4
|
+
@prefix : <https://eyereasoner.github.io/eyeling/examples/age#>.
|
|
5
|
+
|
|
6
|
+
:alice :age 23.
|
|
7
|
+
:bob :age 17.
|
|
8
|
+
:carol :age 65.
|
|
9
|
+
|
|
10
|
+
{ ?P :age ?A. ?A math:notLessThan 18. } => { ?P :adult true. }.
|
|
11
|
+
{ ?P :age ?A. ?A math:notLessThan 65. } => { ?P :senior true. }.
|
|
12
|
+
{ ?P :adult true. ?P :senior true. } => { ?P :discount :seniorPass. }.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Adapted from eyeling/examples/alignment-demo.n3.
|
|
2
|
+
# Simple vocabulary alignment using owl:sameAs and an explicit transfer rule.
|
|
3
|
+
@prefix owl: <http://www.w3.org/2002/07/owl#>.
|
|
4
|
+
@prefix schema: <https://schema.org/>.
|
|
5
|
+
@prefix ex: <https://example.org/ns#>.
|
|
6
|
+
@prefix : <https://eyereasoner.github.io/ns#>.
|
|
7
|
+
|
|
8
|
+
ex:label = schema:name.
|
|
9
|
+
:alice ex:label "Alice".
|
|
10
|
+
|
|
11
|
+
{ ?p owl:sameAs ?q. ?s ?p ?o. } => { ?s ?q ?o. }.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Adapted from eyeling/examples/allen-interval-calculus.n3.
|
|
2
|
+
# Classifies a few interval relations with math comparisons.
|
|
3
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
4
|
+
@prefix : <https://eyereasoner.github.io/eyeling/examples/allen#>.
|
|
5
|
+
|
|
6
|
+
:a :start 1; :end 3.
|
|
7
|
+
:b :start 3; :end 5.
|
|
8
|
+
:c :start 4; :end 8.
|
|
9
|
+
:d :start 1; :end 8.
|
|
10
|
+
|
|
11
|
+
{ ?X :end ?XE. ?Y :start ?YS. ?XE math:equalTo ?YS. } => { (?X ?Y) :allen :meets. }.
|
|
12
|
+
{ ?X :start ?XS; :end ?XE. ?Y :start ?YS; :end ?YE. ?XS math:lessThan ?YS. ?XE math:greaterThan ?YS. ?XE math:lessThan ?YE. } => { (?X ?Y) :allen :overlaps. }.
|
|
13
|
+
{ ?X :start ?XS; :end ?XE. ?Y :start ?YS; :end ?YE. ?XS math:equalTo ?YS. ?XE math:lessThan ?YE. } => { (?X ?Y) :allen :starts. }.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Adapted from eyeling/examples/backward-recursion.n3.
|
|
2
|
+
# Demonstrates recursive <= rules.
|
|
3
|
+
@prefix : <urn:example#>.
|
|
4
|
+
|
|
5
|
+
:a :parent :b.
|
|
6
|
+
:b :parent :c.
|
|
7
|
+
:c :parent :d.
|
|
8
|
+
|
|
9
|
+
{ ?x :ancestor ?y } <= { ?x :parent ?y }.
|
|
10
|
+
{ ?x :ancestor ?z } <= { ?x :parent ?y. ?y :ancestor ?z }.
|
|
11
|
+
{ :a :ancestor ?who } => { :a :reaches ?who }.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Adapted from eyeling/examples/backward.n3.
|
|
2
|
+
# Backward rule example: <= acts like a :- rule over N3 triples.
|
|
3
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
4
|
+
@prefix : <https://eyereasoner.github.io/ns#>.
|
|
5
|
+
|
|
6
|
+
# something is more interesting if it is greater
|
|
7
|
+
{ ?X :moreInterestingThan ?Y. } <= { ?X math:greaterThan ?Y. }.
|
|
8
|
+
|
|
9
|
+
# derivation (forward)
|
|
10
|
+
{ 5 :moreInterestingThan 3. } => { 5 :isIndeedMoreInterestingThan 3. }.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Adapted from eyeling/examples/basic-monadic.n3.
|
|
2
|
+
# A tiny monadic propagation benchmark.
|
|
3
|
+
@prefix : <https://eyereasoner.github.io/eyeling/examples/basic-monadic#>.
|
|
4
|
+
|
|
5
|
+
:i0 a :N0.
|
|
6
|
+
:i1 a :N0.
|
|
7
|
+
:i2 a :N1.
|
|
8
|
+
|
|
9
|
+
{ ?X a :N0. } => { ?X a :N1. }.
|
|
10
|
+
{ ?X a :N1. } => { ?X a :N2. }.
|
|
11
|
+
{ ?X a :N2. } => { ?X :accepted true. }.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Adapted from eyeling/examples/bmi.n3.
|
|
2
|
+
# Computes BMI from mass and squared height using math builtins.
|
|
3
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
4
|
+
@prefix : <https://eyereasoner.github.io/ns#>.
|
|
5
|
+
|
|
6
|
+
:alice :massKg 72;
|
|
7
|
+
:heightM 1.8.
|
|
8
|
+
|
|
9
|
+
{ ?P :heightM ?H. (?H 2) math:exponentiation ?H2. } => { ?P :heightSquared ?H2. }.
|
|
10
|
+
{ ?P :massKg ?M. ?P :heightSquared ?H2. (?M ?H2) math:quotient ?BMI. } => { ?P :bmi ?BMI. }.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Adapted from eyeling/examples/cat-koko.n3.
|
|
2
|
+
# The original derives nested rules; this version keeps the animal split and log:notEqualTo test.
|
|
3
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
|
|
4
|
+
@prefix : <https://eyereasoner.github.io/ns#>.
|
|
5
|
+
|
|
6
|
+
:Koko a :Animal.
|
|
7
|
+
|
|
8
|
+
{ :Koko a :Animal. } => {
|
|
9
|
+
:catKoko a :Cat.
|
|
10
|
+
:britishKoko a :BritishShortHair.
|
|
11
|
+
}.
|
|
12
|
+
|
|
13
|
+
{ ?X a :Cat. ?Y a :BritishShortHair. ?X log:notEqualTo ?Y. } => {
|
|
14
|
+
:test :is true.
|
|
15
|
+
}.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Adapted from eyeling/examples/collatz-1000.n3.
|
|
2
|
+
# A small, bounded Collatz step demonstration.
|
|
3
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
4
|
+
@prefix : <https://eyereasoner.github.io/eyeling/examples/collatz#>.
|
|
5
|
+
|
|
6
|
+
:case6 :value 6.
|
|
7
|
+
:case7 :value 7.
|
|
8
|
+
|
|
9
|
+
{ ?C :value ?N. (?N 2) math:remainder 0. (?N 2) math:integerQuotient ?M. } => { ?C :next ?M. }.
|
|
10
|
+
{ ?C :value ?N. (?N 2) math:remainder 1. (?N 3) math:product ?T. (?T 1) math:sum ?M. } => { ?C :next ?M. }.
|
|
11
|
+
{ ?C :next ?N. ?N math:greaterThan 10. } => { ?C :jumpsAboveTen true. }.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Adapted from eyeling/examples/collection.n3.
|
|
2
|
+
# Shows N3/RDF collections in subject and object positions.
|
|
3
|
+
@prefix list: <http://www.w3.org/2000/10/swap/list#>.
|
|
4
|
+
@prefix : <https://eyereasoner.github.io/eyeling/examples/collection#>.
|
|
5
|
+
|
|
6
|
+
(1 _:b2 (2)) :p2 :q2.
|
|
7
|
+
_:b2 :p :q.
|
|
8
|
+
|
|
9
|
+
{ (1 _:b2 (2)) list:length ?Length. } => {
|
|
10
|
+
:collection :length ?Length.
|
|
11
|
+
}.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Adapted from eyeling/examples/complex.n3.
|
|
2
|
+
# Computes complex addition on pair-shaped RDF collections.
|
|
3
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
4
|
+
@prefix : <https://eyereasoner.github.io/eyeling/examples/complex#>.
|
|
5
|
+
|
|
6
|
+
:z1 :cartesian (3 4).
|
|
7
|
+
:z2 :cartesian (5 -2).
|
|
8
|
+
|
|
9
|
+
{ ?A :cartesian (?AR ?AI). ?B :cartesian (?BR ?BI). (?AR ?BR) math:sum ?RR. (?AI ?BI) math:sum ?RI. } => { (?A ?B) :sum (?RR ?RI). }.
|
|
10
|
+
{ (:z1 :z2) :sum ?Z. } => { :example :complexSum ?Z. }.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Adapted from eyeling/examples/context-association.n3.
|
|
2
|
+
# Associates named contexts with facts and derives their subjects.
|
|
3
|
+
@prefix : <https://eyereasoner.github.io/eyeling/examples/context-association#>.
|
|
4
|
+
|
|
5
|
+
:ctx1 :contains :fact1.
|
|
6
|
+
:ctx2 :contains :fact2.
|
|
7
|
+
:fact1 :subject :alice; :predicate :likes; :object :tea.
|
|
8
|
+
:fact2 :subject :bob; :predicate :likes; :object :coffee.
|
|
9
|
+
|
|
10
|
+
{ ?C :contains ?F. ?F :subject ?S. } => { ?C :mentions ?S. }.
|
|
11
|
+
{ ?C :mentions ?S. } => { ?S :mentionedIn ?C. }.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Adapted from eyeling/examples/control-system.n3.
|
|
2
|
+
# Flags control measurements outside a safe envelope.
|
|
3
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
4
|
+
@prefix : <https://eyereasoner.github.io/eyeling/examples/control-system#>.
|
|
5
|
+
|
|
6
|
+
:loop1 :target 100; :actual 103; :tolerance 5.
|
|
7
|
+
:loop2 :target 100; :actual 111; :tolerance 5.
|
|
8
|
+
|
|
9
|
+
{ ?L :target ?T; :actual ?A. (?A ?T) math:difference ?D. ?D math:absoluteValue ?Abs. } => { ?L :absoluteError ?Abs. }.
|
|
10
|
+
{ ?L :absoluteError ?E; :tolerance ?Tol. ?E math:notGreaterThan ?Tol. } => { ?L :status :ok. }.
|
|
11
|
+
{ ?L :absoluteError ?E; :tolerance ?Tol. ?E math:greaterThan ?Tol. } => { ?L :status :alarm. }.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Adapted from eyeling/examples/crypto-builtins-tests.n3.
|
|
2
|
+
# Extra digest checks beyond the compact builtins demo.
|
|
3
|
+
@prefix crypto: <http://www.w3.org/2000/10/swap/crypto#>.
|
|
4
|
+
@prefix string: <http://www.w3.org/2000/10/swap/string#>.
|
|
5
|
+
@prefix : <https://eyereasoner.github.io/eyeling/examples/crypto-extra#>.
|
|
6
|
+
|
|
7
|
+
:payload :text "eyelang".
|
|
8
|
+
|
|
9
|
+
{ :payload :text ?T. ?T crypto:sha256 ?H. ?H string:length ?L. } => { :payload :sha256Length ?L; :sha256 ?H. }.
|
|
10
|
+
{ :payload :sha256Length 64. } => { :payload :hashLooksComplete true. }.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Inspired by eyeling/examples/crypto-builtins-tests.n3.
|
|
2
|
+
@prefix crypto: <http://www.w3.org/2000/10/swap/crypto#>.
|
|
3
|
+
@prefix : <https://eyereasoner.github.io/ns#>.
|
|
4
|
+
|
|
5
|
+
:payload :text "eyelang".
|
|
6
|
+
|
|
7
|
+
{ :payload :text ?Text. ?Text crypto:sha256 ?Digest. } => { :payload :sha256 ?Digest. }.
|
|
8
|
+
{ :payload :text ?Text. ?Text crypto:md5 ?Digest. } => { :payload :md5 ?Digest. }.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Adapted from eyeling/examples/deep-taxonomy-10.n3.
|
|
2
|
+
# Depth-10 classification chain.
|
|
3
|
+
@prefix : <https://eyereasoner.github.io/eyeling/examples/deep-taxonomy-10#>.
|
|
4
|
+
|
|
5
|
+
:ind a :N0.
|
|
6
|
+
|
|
7
|
+
{ ?X a :N0. } => { ?X a :N1, :I1, :J1. }.
|
|
8
|
+
{ ?X a :N1. } => { ?X a :N2, :I2, :J2. }.
|
|
9
|
+
{ ?X a :N2. } => { ?X a :N3, :I3, :J3. }.
|
|
10
|
+
{ ?X a :N3. } => { ?X a :N4, :I4, :J4. }.
|
|
11
|
+
{ ?X a :N4. } => { ?X a :N5, :I5, :J5. }.
|
|
12
|
+
{ ?X a :N5. } => { ?X a :N6, :I6, :J6. }.
|
|
13
|
+
{ ?X a :N6. } => { ?X a :N7, :I7, :J7. }.
|
|
14
|
+
{ ?X a :N7. } => { ?X a :N8, :I8, :J8. }.
|
|
15
|
+
{ ?X a :N8. } => { ?X a :N9, :I9, :J9. }.
|
|
16
|
+
{ ?X a :N9. } => { ?X a :N10, :I10, :J10. }.
|
|
17
|
+
{ ?X a :N10. } => { ?X a :A2. }.
|
|
18
|
+
{ :ind a :A2. } => { :test :is true. }.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Adapted from eyeling/examples/derived-backward-rule.n3.
|
|
2
|
+
# Demonstrates an inverse-property rule without nested-rule materialization.
|
|
3
|
+
@prefix : <https://eyereasoner.github.io/eyeling/examples/derived-backward-rule#>.
|
|
4
|
+
|
|
5
|
+
:parentOf :invOf :childOf.
|
|
6
|
+
:alice :parentOf :bob.
|
|
7
|
+
:claire :parentOf :diana.
|
|
8
|
+
|
|
9
|
+
{ ?P :invOf ?Q. ?Y ?P ?X. } => { ?X ?Q ?Y. }.
|
|
10
|
+
{ ?X :childOf ?Y. } => { ?X :hasParent ?Y. }.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Adapted from eyeling/examples/derived-rule.n3.
|
|
2
|
+
# eyelang's N3 layer does not materialize nested rules yet, so this is a flat equivalent.
|
|
3
|
+
@prefix : <https://eyereasoner.github.io/eyeling/examples/derived-rule#>.
|
|
4
|
+
|
|
5
|
+
:Minka a :Cat.
|
|
6
|
+
:Charly a :Dog.
|
|
7
|
+
|
|
8
|
+
{ ?X a :Cat. ?Y a :Dog. } => { :test :is true. }.
|
|
9
|
+
{ ?X a :Cat. ?Y a :Dog. } => { ?X :compatibleWith ?Y. }.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Adapted from eyeling/examples/digital-product-passport.n3.
|
|
2
|
+
# Simple product passport conformance rules.
|
|
3
|
+
@prefix string: <http://www.w3.org/2000/10/swap/string#>.
|
|
4
|
+
@prefix : <https://eyereasoner.github.io/eyeling/examples/digital-product-passport#>.
|
|
5
|
+
|
|
6
|
+
:bike1 :serial "EU-BIKE-001"; :batteryId "BAT-77"; :recycledContent "32%".
|
|
7
|
+
:toy1 :serial "TOY-9"; :batteryId ""; :recycledContent "0%".
|
|
8
|
+
|
|
9
|
+
{ ?P :serial ?S. ?S string:startsWith "EU-". } => { ?P :hasEuSerial true. }.
|
|
10
|
+
{ ?P :batteryId ?B. ?B string:startsWith "BAT-". } => { ?P :hasBatteryPassport true. }.
|
|
11
|
+
{ ?P :hasEuSerial true. ?P :hasBatteryPassport true. } => { ?P :passportStatus :ready. }.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Adapted from eyeling/examples/dijkstra.n3.
|
|
2
|
+
# Tiny weighted path expansion without aggregate minimization.
|
|
3
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
4
|
+
@prefix : <https://eyereasoner.github.io/eyeling/examples/dijkstra#>.
|
|
5
|
+
|
|
6
|
+
:e1 :from :a; :to :b; :cost 2.
|
|
7
|
+
:e2 :from :a; :to :c; :cost 5.
|
|
8
|
+
:e3 :from :b; :to :c; :cost 1.
|
|
9
|
+
:e4 :from :b; :to :d; :cost 4.
|
|
10
|
+
:e5 :from :c; :to :d; :cost 1.
|
|
11
|
+
|
|
12
|
+
{ ?E :from ?S; :to ?O; :cost ?C. } => { (?S ?O) :pathCost ?C. }.
|
|
13
|
+
{ (?S ?M) :pathCost ?C1. ?E :from ?M; :to ?O; :cost ?C2. (?C1 ?C2) math:sum ?CT. } => { (?S ?O) :pathCost ?CT. }.
|
|
14
|
+
{ (:a :d) :pathCost ?C. ?C math:notGreaterThan 6. } => { :route :candidateCost ?C. }.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Adapted from eyeling/examples/dog.n3.
|
|
2
|
+
# The original uses log:collectAllIn; this compatibility example supplies the count directly.
|
|
3
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
4
|
+
@prefix : <https://eyereasoner.github.io/ns#>.
|
|
5
|
+
|
|
6
|
+
:alice :hasDog :dog1, :dog2, :dog3, :dog4, :dog5;
|
|
7
|
+
:dogCount 5.
|
|
8
|
+
:bob :hasDog :dog6, :dog7;
|
|
9
|
+
:dogCount 2.
|
|
10
|
+
|
|
11
|
+
{ ?Subject :dogCount ?Count. ?Count math:greaterThan 4. } => {
|
|
12
|
+
?Subject :mustHave :dogLicense.
|
|
13
|
+
}.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Adapted from eyeling/examples/drone-corridor-planner.n3.
|
|
2
|
+
# Finds allowed drone corridor hops under wind limits.
|
|
3
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
4
|
+
@prefix : <https://eyereasoner.github.io/eyeling/examples/drone-corridor#>.
|
|
5
|
+
|
|
6
|
+
:c1 :from :dock; :to :tower; :wind 12.
|
|
7
|
+
:c2 :from :tower; :to :field; :wind 18.
|
|
8
|
+
:c3 :from :dock; :to :field; :wind 25.
|
|
9
|
+
:policy :maxWind 20.
|
|
10
|
+
|
|
11
|
+
{ ?C :from ?A; :to ?B; :wind ?W. :policy :maxWind ?M. ?W math:notGreaterThan ?M. } => { ?C :allowed true. }.
|
|
12
|
+
{ ?C :allowed true; :from ?A; :to ?B. } => { ?A :canFlyTo ?B. }.
|
|
13
|
+
{ :dock :canFlyTo :tower. :tower :canFlyTo :field. } => { :mission :hasTwoHopRoute true. }.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Adapted from eyeling/examples/equivalence-classes-overlap-implies-same-class.n3.
|
|
2
|
+
# If two class sets share a member, they are linked as the same class.
|
|
3
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
|
|
4
|
+
@prefix : <https://eyereasoner.github.io/eyeling/examples/equivalence-classes#>.
|
|
5
|
+
|
|
6
|
+
:classA :member :alice, :bob.
|
|
7
|
+
:classB :member :bob, :carol.
|
|
8
|
+
:classC :member :diana.
|
|
9
|
+
|
|
10
|
+
{ ?C1 :member ?X. ?C2 :member ?X. ?C1 log:notEqualTo ?C2. } => { ?C1 :sameClassAs ?C2. }.
|
|
11
|
+
{ ?C1 :sameClassAs ?C2. } => { ?C2 :sameClassAs ?C1. }.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Adapted from eyeling/examples/euler-identity.n3.
|
|
2
|
+
# Numeric trigonometric builtins around pi.
|
|
3
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
4
|
+
@prefix : <https://eyereasoner.github.io/eyeling/examples/euler-identity#>.
|
|
5
|
+
|
|
6
|
+
:pi :radians 3.141592653589793.
|
|
7
|
+
|
|
8
|
+
{ :pi :radians ?P. ?P math:cos ?C. ?P math:sin ?S. } => { :euler :cosPi ?C; :sinPi ?S. }.
|
|
9
|
+
{ :euler :cosPi ?C. ?C math:notGreaterThan -1. } => { :euler :cosPiAtMinusOne true. }.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Adapted from eyeling/examples/existential-rule.n3.
|
|
2
|
+
# Uses explicit blank-node witnesses in the rule head.
|
|
3
|
+
@prefix : <https://eyereasoner.github.io/eyeling/examples/existential-rule#>.
|
|
4
|
+
|
|
5
|
+
:Socrates a :Human.
|
|
6
|
+
:Plato a :Human.
|
|
7
|
+
|
|
8
|
+
{ ?S a :Human. } => { ?S :hasNature _:humanNature. }.
|
|
9
|
+
{ ?S :hasNature _:humanNature. } => { ?S :witnessed true. }.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Adapted from eyeling/examples/expression-eval.n3.
|
|
2
|
+
# Evaluates a small expression tree using arithmetic builtins.
|
|
3
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
4
|
+
@prefix : <https://eyereasoner.github.io/eyeling/examples/expression-eval#>.
|
|
5
|
+
|
|
6
|
+
:e1 :op :add; :left 2; :right 3.
|
|
7
|
+
:e2 :op :mul; :left :e1; :right 4.
|
|
8
|
+
|
|
9
|
+
{ ?E :op :add; :left ?A; :right ?B. (?A ?B) math:sum ?V. } => { ?E :value ?V. }.
|
|
10
|
+
{ ?E :op :mul; :left ?L; :right ?B. ?L :value ?A. (?A ?B) math:product ?V. } => { ?E :value ?V. }.
|
|
11
|
+
{ :e2 :value ?V. } => { :answer :value ?V. }.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Adapted from eyeling/examples/family-cousins.n3.
|
|
2
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
|
|
3
|
+
@prefix : <https://eyereasoner.github.io/ns#>.
|
|
4
|
+
|
|
5
|
+
:alice :parentOf :bob, :carol.
|
|
6
|
+
:bob :parentOf :dave.
|
|
7
|
+
:carol :parentOf :erin.
|
|
8
|
+
:erin :parentOf :fay.
|
|
9
|
+
|
|
10
|
+
{ ?p :parentOf ?x. ?p :parentOf ?y. ?x log:notEqualTo ?y. } => { ?x :siblingOf ?y. }.
|
|
11
|
+
{ ?a :parentOf ?x. ?b :parentOf ?y. ?a :siblingOf ?b. ?x log:notEqualTo ?y. } => { ?x :cousinOf ?y. }.
|
|
12
|
+
{ ?x :cousinOf ?y. } => { ?x :relatedTo ?y. }.
|