eyeling 1.33.5 → 1.33.6
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 +50 -106
- package/docs/eyelang-guide.md +551 -0
- package/package.json +1 -1
- package/test/eyelang/run-regression.mjs +2 -2
- package/test/packlist.test.js +1 -0
- package/examples/eyelang/INTEGRATION.md +0 -20
- package/examples/eyelang/README.md +0 -553
package/README.md
CHANGED
|
@@ -28,21 +28,14 @@ Eyeling is characterized by:
|
|
|
28
28
|
|
|
29
29
|
This README is the primary guide to using, extending, and maintaining Eyeling.
|
|
30
30
|
|
|
31
|
-
| Project fact | Value |
|
|
32
|
-
|---|---|
|
|
33
|
-
| Package | `eyeling` |
|
|
34
|
-
| Runtime | Node.js `>=18` |
|
|
35
|
-
| License | MIT |
|
|
36
|
-
| Main entry point | `index.js` |
|
|
37
|
-
| CLI binary | `eyeling` |
|
|
38
|
-
| Browser entry point | `eyeling/browser` |
|
|
39
|
-
|
|
40
31
|
Eyeling is designed for people who want a small, inspectable reasoner that can run N3 rules in Node.js, the browser, tests, and RDF-oriented data pipelines.
|
|
41
32
|
|
|
42
33
|
## Project links
|
|
43
34
|
|
|
44
35
|
- [Playground](https://eyereasoner.github.io/eyeling/playground)
|
|
45
36
|
- [Conformance report](https://codeberg.org/phochste/notation3tests/src/branch/main/reports/report.md)
|
|
37
|
+
- [eyelang guide](docs/eyelang-guide.md)
|
|
38
|
+
- [eyelang language reference](docs/eyelang-language-reference.md)
|
|
46
39
|
|
|
47
40
|
---
|
|
48
41
|
|
|
@@ -304,22 +297,34 @@ Process an RDF Message Log one message at a time:
|
|
|
304
297
|
eyeling --rdf --stream-messages rules.n3 messages.trig
|
|
305
298
|
```
|
|
306
299
|
|
|
300
|
+
Run an eyelang program through the bundled second engine:
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
eyeling --engine eyelang examples/eyelang/ancestor.pl
|
|
304
|
+
```
|
|
305
|
+
|
|
307
306
|
### CLI options
|
|
308
307
|
|
|
309
308
|
| Option | Meaning |
|
|
310
309
|
|---|---|
|
|
311
310
|
| `-a`, `--ast` | Print the parsed AST as JSON and exit. |
|
|
312
|
-
| `--builtin <module.js>` | Load a custom built-in module. Repeatable. |
|
|
311
|
+
| `--builtin <module.js>` | Load a custom N3 built-in module. Repeatable. |
|
|
312
|
+
| `--engine <n3\|eyelang>` | Select the default N3 engine or route the remaining arguments to the eyelang engine. |
|
|
313
313
|
| `-d`, `--deterministic-skolem` | Make `log:skolem` stable across reasoning runs. |
|
|
314
314
|
| `-e`, `--enforce-https` | Rewrite `http://` IRIs to `https://` for log dereferencing built-ins. |
|
|
315
315
|
| `-h`, `--help` | Show help and exit. |
|
|
316
316
|
| `-p`, `--proof` | Enable proof explanations. |
|
|
317
317
|
| `-r`, `--rdf` | Enable RDF/TriG input and output compatibility. |
|
|
318
318
|
| `--stream-messages` | Process RDF Message Logs one message at a time under `--rdf`. |
|
|
319
|
-
|
|
|
319
|
+
| `--store <name>` | Use an optional persistent fact store. |
|
|
320
|
+
| `--store-clear` | Clear the named persistent store before the run. |
|
|
321
|
+
| `--store-path <dir>` | Use a Node.js persistent-store directory. |
|
|
322
|
+
| `-s`, `--super-restricted` | Disable all N3 built-ins except implication handling. |
|
|
320
323
|
| `-t`, `--stream` | Stream derived triples as soon as they are derived. |
|
|
321
324
|
| `-v`, `--version` | Print the package version and exit. |
|
|
322
325
|
|
|
326
|
+
When `--engine eyelang` is selected, the remaining arguments are handled by the eyelang CLI. Its supported options are `--help`, `--proof`, `--stats`, `--version`, and `--` to stop option parsing. See the [eyelang guide](docs/eyelang-guide.md) for examples.
|
|
327
|
+
|
|
323
328
|
### Output behavior
|
|
324
329
|
|
|
325
330
|
The CLI has three important output modes:
|
|
@@ -664,7 +669,7 @@ console.log(result.stdout);
|
|
|
664
669
|
|
|
665
670
|
The two engines intentionally keep separate parsers, term models, solvers, and built-ins. Shared package entry points, examples, documentation, and CLI routing make them convenient to use together while keeping their execution models inspectable.
|
|
666
671
|
|
|
667
|
-
|
|
672
|
+
The [eyelang guide](docs/eyelang-guide.md) introduces the CLI, output model, examples, and testing workflow. The [eyelang language reference](docs/eyelang-language-reference.md) defines syntax, terms, clauses, built-ins, declarations, output, and conformance boundaries. Runnable examples live under `examples/eyelang/`. The embedded engine runtime stays under `lib/eyelang/`, while the conformance corpus and test runners live under `test/eyelang/` so runtime code and test assets stay separate:
|
|
668
673
|
|
|
669
674
|
```bash
|
|
670
675
|
npm run test:eyelang # integration check plus eyelang corpus
|
|
@@ -769,28 +774,20 @@ The Alma RDF Message Log example intentionally keeps the message log as a URL, b
|
|
|
769
774
|
|
|
770
775
|
## Built-ins
|
|
771
776
|
|
|
772
|
-
Eyeling implements SWAP-style built-ins across these namespaces
|
|
773
|
-
|
|
774
|
-
| Namespace |
|
|
775
|
-
|
|
776
|
-
| `crypto:` | `sha`, `md5`, `sha256`, `sha512` |
|
|
777
|
-
| `math:` | `sum`, `product`, `difference`, `
|
|
778
|
-
| `time:` | `
|
|
779
|
-
| `list:` | `first`, `rest`, `
|
|
780
|
-
| `rdf:` | `first`, `rest` |
|
|
781
|
-
| `log:` | `
|
|
782
|
-
| `string:` | `contains`, `matches`, `replace`, `format`, `length`
|
|
783
|
-
| `dt:` | `datatype`, `lexicalForm`, `validForDatatype`, `sameValueAs`, `canonicalLiteral` |
|
|
784
|
-
|
|
785
|
-
The
|
|
786
|
-
|
|
787
|
-
- `ex:Test`: succeeds or fails without necessarily binding variables;
|
|
788
|
-
- `ex:Function`: computes an output and may bind variables;
|
|
789
|
-
- `ex:Relation`: unification-based relation;
|
|
790
|
-
- `ex:Generator`: may yield multiple solutions;
|
|
791
|
-
- `ex:IO`: may dereference or parse external content;
|
|
792
|
-
- `ex:Meta`: operates on formulas or types;
|
|
793
|
-
- `ex:SideEffect`: produces output.
|
|
777
|
+
Eyeling implements SWAP-style built-ins for the N3 engine across these namespaces. The authoritative machine-readable catalog is [`eyeling-builtins.ttl`](eyeling-builtins.ttl); this README lists the public names so users do not need to infer support from examples.
|
|
778
|
+
|
|
779
|
+
| Namespace | Built-ins |
|
|
780
|
+
|---|---|
|
|
781
|
+
| `crypto:` | `sha`, `md5`, `sha256`, `sha512` |
|
|
782
|
+
| `math:` | `equalTo`, `notEqualTo`, `greaterThan`, `lessThan`, `notLessThan`, `notGreaterThan`, `sum`, `product`, `difference`, `quotient`, `integerQuotient`, `remainder`, `rounded`, `exponentiation`, `absoluteValue`, `acos`, `asin`, `atan`, `sin`, `cos`, `tan`, `sinh`, `cosh`, `tanh`, `degrees`, `negation` |
|
|
783
|
+
| `time:` | `day`, `hour`, `minute`, `month`, `second`, `timeZone`, `year`, `localTime` |
|
|
784
|
+
| `list:` | `append`, `first`, `rest`, `iterate`, `last`, `memberAt`, `remove`, `member`, `in`, `length`, `notMember`, `reverse`, `sort`, `map`, `firstRest` |
|
|
785
|
+
| `rdf:` | `first`, `rest` |
|
|
786
|
+
| `log:` | `equalTo`, `notEqualTo`, `conjunction`, `conclusion`, `content`, `semantics`, `semanticsOrError`, `parsedAsN3`, `rawType`, `dtlit`, `langlit`, `implies`, `impliedBy`, `query`, `includes`, `notIncludes`, `collectAllIn`, `forAllIn`, `skolem`, `uri`, `trace`, `outputString` |
|
|
787
|
+
| `string:` | `concatenation`, `contains`, `containsIgnoringCase`, `endsWith`, `startsWith`, `equalIgnoringCase`, `notEqualIgnoringCase`, `greaterThan`, `lessThan`, `notGreaterThan`, `notLessThan`, `matches`, `notMatches`, `replace`, `scrape`, `format`, `length`, `charAt`, `setCharAt` |
|
|
788
|
+
| `dt:` | `datatype`, `lexicalForm`, `language`, `validForDatatype`, `invalidForDatatype`, `sameValueAs`, `differentValueFrom`, `canonicalLiteral` |
|
|
789
|
+
|
|
790
|
+
The catalog marks each built-in with a coarse kind: `ex:Test`, `ex:Function`, `ex:Relation`, `ex:Generator`, `ex:IO`, `ex:Meta`, or `ex:SideEffect`.
|
|
794
791
|
|
|
795
792
|
### Datatype built-ins
|
|
796
793
|
|
|
@@ -805,89 +802,36 @@ Supported operations include:
|
|
|
805
802
|
|
|
806
803
|
The built-ins use strict datatype lexical validation for these checks, including exact dateTime rollover/canonicalization such as `24:00:00` normalizing to the following day. They cover RDF language strings, `rdf:PlainLiteral`, `rdf:XMLLiteral`, `rdfs:Literal`, and the OWL 2 RL-relevant XSD set: `xsd:string`, `xsd:normalizedString`, `xsd:token`, `xsd:language`, `xsd:Name`, `xsd:NCName`, `xsd:NMTOKEN`, `xsd:boolean`, `xsd:decimal`, `xsd:integer` and its bounded integer subtypes, `xsd:float`, `xsd:double`, `xsd:hexBinary`, `xsd:base64Binary`, `xsd:anyURI`, `xsd:dateTime`, and `xsd:dateTimeStamp`. Lexical validation is intentionally strict for conformance: string-derived datatypes with whitespace-collapse facets must already be written in canonical collapsed lexical form, `xsd:float` and `xsd:double` enforce finite value ranges, `xsd:anyURI` rejects spaces, unsafe delimiters, and malformed percent escapes, and XML literals must be well-formed XML fragments.
|
|
807
804
|
|
|
808
|
-
Example:
|
|
809
|
-
|
|
810
|
-
```n3
|
|
811
|
-
@prefix : <http://example.org/> .
|
|
812
|
-
@prefix dt: <https://eyereasoner.github.io/eyeling/datatype#> .
|
|
813
|
-
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
|
814
|
-
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
|
815
|
-
|
|
816
|
-
{
|
|
817
|
-
"01"^^xsd:integer dt:sameValueAs "1.0"^^xsd:decimal .
|
|
818
|
-
"hello@EN"^^rdf:PlainLiteral dt:sameValueAs "hello@en"^^rdf:PlainLiteral .
|
|
819
|
-
"<a/>"^^rdf:XMLLiteral dt:validForDatatype rdf:XMLLiteral .
|
|
820
|
-
"2026-06-10T12:00:00Z"^^xsd:dateTime
|
|
821
|
-
dt:sameValueAs "2026-06-10T14:00:00+02:00"^^xsd:dateTime .
|
|
822
|
-
("abc"^^xsd:integer xsd:integer) dt:validForDatatype false .
|
|
823
|
-
}
|
|
824
|
-
=>
|
|
825
|
-
{
|
|
826
|
-
:check :status :pass .
|
|
827
|
-
} .
|
|
828
|
-
```
|
|
829
|
-
|
|
830
805
|
### Numeric built-ins
|
|
831
806
|
|
|
832
807
|
Numeric built-ins support common XSD numeric literals. Integer-oriented operations use `BigInt` where possible, with safety limits to avoid accidental memory exhaustion. Date/time comparisons and timestamp arithmetic are supported for relevant operations.
|
|
833
808
|
|
|
834
|
-
Example:
|
|
835
|
-
|
|
836
|
-
```n3
|
|
837
|
-
@prefix : <http://example.org/> .
|
|
838
|
-
@prefix math: <http://www.w3.org/2000/10/swap/math#> .
|
|
839
|
-
|
|
840
|
-
{
|
|
841
|
-
(2 3 5) math:sum ?total .
|
|
842
|
-
}
|
|
843
|
-
=>
|
|
844
|
-
{
|
|
845
|
-
:calculation :total ?total .
|
|
846
|
-
} .
|
|
847
|
-
```
|
|
848
|
-
|
|
849
809
|
### List built-ins
|
|
850
810
|
|
|
851
811
|
Eyeling supports both native N3 list terms and materialized RDF collections. Anonymous `rdf:first`/`rdf:rest` collections can be materialized into list terms, while named list nodes keep their identity.
|
|
852
812
|
|
|
853
|
-
Example:
|
|
854
|
-
|
|
855
|
-
```n3
|
|
856
|
-
@prefix : <http://example.org/> .
|
|
857
|
-
@prefix list: <http://www.w3.org/2000/10/swap/list#> .
|
|
858
|
-
|
|
859
|
-
{
|
|
860
|
-
("red" "green" "blue") list:length ?n .
|
|
861
|
-
}
|
|
862
|
-
=>
|
|
863
|
-
{
|
|
864
|
-
:palette :size ?n .
|
|
865
|
-
} .
|
|
866
|
-
```
|
|
867
|
-
|
|
868
813
|
### Formula and log built-ins
|
|
869
814
|
|
|
870
|
-
Formula-aware built-ins make Eyeling useful for meta-reasoning:
|
|
815
|
+
Formula-aware built-ins make Eyeling useful for meta-reasoning. `log:includes`, `log:notIncludes`, `log:collectAllIn`, and `log:forAllIn` prove goals inside formula scopes. `log:query` selects output triples, while `log:outputString` writes selected string values directly to stdout.
|
|
871
816
|
|
|
872
|
-
|
|
873
|
-
@prefix : <http://example.org/> .
|
|
874
|
-
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
|
|
817
|
+
`log:semantics`, `log:content`, and related built-ins may dereference sources. Use `--enforce-https` or `{ enforceHttps: true }` in environments where HTTP-to-HTTPS rewriting is required.
|
|
875
818
|
|
|
876
|
-
|
|
819
|
+
### eyelang built-ins
|
|
877
820
|
|
|
878
|
-
|
|
879
|
-
:doc :graph ?g .
|
|
880
|
-
?g log:includes { :alice :knows ?person } .
|
|
881
|
-
}
|
|
882
|
-
=>
|
|
883
|
-
{
|
|
884
|
-
:doc :mentions ?person .
|
|
885
|
-
} .
|
|
886
|
-
```
|
|
887
|
-
|
|
888
|
-
`log:semantics`, `log:content`, and related built-ins may dereference sources. Use `--enforce-https` or `{ enforceHttps: true }` in environments where HTTP-to-HTTPS rewriting is required.
|
|
821
|
+
The eyelang engine has its own built-in registry under `lib/eyelang/builtins/`. These are separate from the N3 namespaces above and are called as ordinary eyelang predicates. See the [eyelang language reference](docs/eyelang-language-reference.md#9-standard-built-in-predicates) for the portable profile. The bundled implementation currently registers:
|
|
889
822
|
|
|
890
|
-
|
|
823
|
+
| Family | Built-ins |
|
|
824
|
+
|---|---|
|
|
825
|
+
| Core and host | `eq/2`, `neq/2`, `local_time/1`, `difference/3` |
|
|
826
|
+
| Arithmetic and comparison | `neg/2`, `abs/2`, `sin/2`, `cos/2`, `asin/2`, `acos/2`, `rounded/2`, `log/2`, `add/3`, `sub/3`, `mul/3`, `div/3`, `mod/3`, `min/3`, `pow/3`, `lt/2`, `gt/2`, `le/2`, `ge/2`, `between/3`, `smallest_divisor_from/3` |
|
|
827
|
+
| Strings | `str_concat/3`, `contains/2`, `matches/2`, `not_matches/2` |
|
|
828
|
+
| Lists | `append/3`, `nth0/3`, `set_nth0/4`, `rest/2`, `member/2`, `select/3`, `not_member/2`, `reverse/2`, `length/2`, `sort/2` |
|
|
829
|
+
| Aggregation | `findall/3`, `countall/2`, `sumall/3`, `aggregate_min/5`, `aggregate_max/5` |
|
|
830
|
+
| Control | `not/1`, `once/1` |
|
|
831
|
+
| Formula terms | `formula_binary/4` |
|
|
832
|
+
| Search and optimization helpers | `n_queens/2`, `weighted_hamiltonian_cycle/4`, `weighted_hamiltonian_path/4`, `hamiltonian_cycle/3`, `fixed_length_cycle/4`, `bounded_path/5`, `bounded_subset/7`, `cnf_model/3`, `qm_prime_implicants/4`, `qm_minimal_cover/4`, `alphametic_sum/5` |
|
|
833
|
+
| Numeric extension helpers | `extended_gcd/5`, `collatz_trajectory/2`, `kaprekar_steps/2`, `goldbach_pair/3` |
|
|
834
|
+
| Matrix helpers | `matrix_sum/2`, `matrix_multiply/2`, `cholesky_decomposition/2`, `determinant/2`, `matrix_inv_triang/2`, `matrix_inversion/2` |
|
|
891
835
|
|
|
892
836
|
## Custom built-ins
|
|
893
837
|
|
|
@@ -1153,8 +1097,8 @@ Everything else should be treated as internal unless explicitly documented.
|
|
|
1153
1097
|
├── bin/ CLI executable shim
|
|
1154
1098
|
├── lib/ Source modules
|
|
1155
1099
|
├── dist/browser/ Browser bundle and ESM wrapper
|
|
1156
|
-
├── docs/ Project documentation, including the eyelang language reference
|
|
1157
|
-
├── examples/ N3 examples, RDF message inputs, and generated decks
|
|
1100
|
+
├── docs/ Project documentation, including the eyelang guide and language reference
|
|
1101
|
+
├── examples/ N3 examples, eyelang examples, RDF message inputs, and generated decks
|
|
1158
1102
|
├── spec/ RDF 1.2 parser test adapter
|
|
1159
1103
|
├── test/ API, built-in, store, example, package, playground, and stream tests
|
|
1160
1104
|
├── tools/ Build tooling
|
|
@@ -1168,7 +1112,7 @@ The package publishes the source modules, tests, examples, bundled runtime, brow
|
|
|
1168
1112
|
|
|
1169
1113
|
## Examples guide
|
|
1170
1114
|
|
|
1171
|
-
The repository contains more than two hundred N3 examples under `examples/`,
|
|
1115
|
+
The repository contains more than two hundred N3 examples under `examples/`, eyelang `.pl` examples under `examples/eyelang/`, RDF Message input files under `examples/input/`, and presentation-oriented Markdown decks under `examples/deck/`. See the [eyelang guide](docs/eyelang-guide.md#example-catalog) for the eyelang example catalog.
|
|
1172
1116
|
|
|
1173
1117
|
### Good first examples
|
|
1174
1118
|
|