eyeling 1.29.3 → 1.30.1
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 +153 -0
- package/dist/browser/eyeling.browser.js +561 -13
- package/examples/input/rdf-surfaces-all-values-from-reverse.ttl +17 -0
- package/examples/input/rdf-surfaces-all-values-from.ttl +13 -0
- package/examples/input/rdf-surfaces-ancestor.ttl +20 -0
- package/examples/input/rdf-surfaces-city.ttl +11 -0
- package/examples/input/rdf-surfaces-domain.ttl +11 -0
- package/examples/input/rdf-surfaces-multi-premise.ttl +13 -0
- package/examples/input/rdf-surfaces-owl-all-values-from-codex.ttl +35 -0
- package/examples/input/rdf-surfaces-property-chain.ttl +13 -0
- package/examples/input/rdf-surfaces-range.ttl +11 -0
- package/examples/input/rdf-surfaces-rdfs-range-codex.ttl +18 -0
- package/examples/input/rdf-surfaces-rdfs-subclass-codex.ttl +18 -0
- package/examples/output/rdf-surfaces-all-values-from-reverse.n3 +3 -0
- package/examples/output/rdf-surfaces-all-values-from.n3 +3 -0
- package/examples/output/rdf-surfaces-ancestor.n3 +5 -0
- package/examples/output/rdf-surfaces-city.n3 +3 -0
- package/examples/output/rdf-surfaces-domain.n3 +3 -0
- package/examples/output/rdf-surfaces-multi-premise.n3 +3 -0
- package/examples/output/rdf-surfaces-owl-all-values-from-codex.n3 +6 -0
- package/examples/output/rdf-surfaces-property-chain.n3 +3 -0
- package/examples/output/rdf-surfaces-range.n3 +3 -0
- package/examples/output/rdf-surfaces-rdfs-range-codex.n3 +3 -0
- package/examples/output/rdf-surfaces-rdfs-subclass-codex.n3 +3 -0
- package/examples/rdf-surfaces-all-values-from-reverse.n3 +6 -0
- package/examples/rdf-surfaces-all-values-from.n3 +6 -0
- package/examples/rdf-surfaces-ancestor.n3 +6 -0
- package/examples/rdf-surfaces-city.n3 +6 -0
- package/examples/rdf-surfaces-domain.n3 +6 -0
- package/examples/rdf-surfaces-multi-premise.n3 +6 -0
- package/examples/rdf-surfaces-owl-all-values-from-codex.n3 +10 -0
- package/examples/rdf-surfaces-property-chain.n3 +6 -0
- package/examples/rdf-surfaces-range.n3 +6 -0
- package/examples/rdf-surfaces-rdfs-range-codex.n3 +6 -0
- package/examples/rdf-surfaces-rdfs-subclass-codex.n3 +6 -0
- package/eyeling.js +561 -13
- package/index.d.ts +4 -0
- package/index.js +2 -1
- package/lib/cli.js +11 -4
- package/lib/engine.js +14 -6
- package/lib/lexer.js +4 -0
- package/lib/multisource.js +5 -3
- package/lib/rdf_surfaces.js +524 -0
- package/package.json +8 -5
- package/test/examples.test.js +37 -5
- package/test/rdf_surfaces.test.js +204 -0
package/README.md
CHANGED
|
@@ -292,6 +292,7 @@ eyeling --rdf --stream-messages rules.n3 messages.trig
|
|
|
292
292
|
| `-h`, `--help` | Show help and exit. |
|
|
293
293
|
| `-p`, `--proof` | Enable proof explanations. |
|
|
294
294
|
| `-r`, `--rdf` | Enable RDF/TriG input and output compatibility. |
|
|
295
|
+
| `--rdf-surfaces` | Enable RDF Surfaces `%not[ ... %]` syntax. Implies `--rdf`. |
|
|
295
296
|
| `--stream-messages` | Process RDF Message Logs one message at a time under `--rdf`. |
|
|
296
297
|
| `-s`, `--super-restricted` | Disable all built-ins except implication handling. |
|
|
297
298
|
| `-t`, `--stream` | Stream derived triples as soon as they are derived. |
|
|
@@ -356,6 +357,7 @@ Useful options:
|
|
|
356
357
|
|---|---|
|
|
357
358
|
| `proof` | Include proof explanations when true. Defaults to false for API output. |
|
|
358
359
|
| `rdf` | Enable RDF/TriG compatibility mode. |
|
|
360
|
+
| `rdfSurfaces` | Enable RDF Surfaces syntax. Implies RDF compatibility in the bundled CLI path. |
|
|
359
361
|
| `args` | Extra CLI-style arguments. |
|
|
360
362
|
| `maxBuffer` | Child-process output buffer limit. |
|
|
361
363
|
| `builtinModules` | Custom built-in module path or paths. |
|
|
@@ -427,6 +429,7 @@ Useful options:
|
|
|
427
429
|
| `onDerived` | Callback called for derived or query-selected output. |
|
|
428
430
|
| `enforceHttps` | Apply HTTPS rewriting for dereferencing built-ins. |
|
|
429
431
|
| `rdf` | Enable RDF/TriG compatibility mode. |
|
|
432
|
+
| `rdfSurfaces` | Enable RDF Surfaces syntax. Implies RDF compatibility. |
|
|
430
433
|
| `rdfjs` | Also emit RDF-JS quads where conversion is possible. |
|
|
431
434
|
| `dataFactory` | Custom RDF-JS DataFactory. |
|
|
432
435
|
| `skipUnsupportedRdfJs` | Skip N3-only terms when producing RDF-JS quads. |
|
|
@@ -588,6 +591,153 @@ In RDF mode, Eyeling accepts and serializes RDF-compatible forms such as:
|
|
|
588
591
|
|
|
589
592
|
RDF 1.2 triple terms require explicit RDF compatibility mode. This protects ordinary N3 users from accidentally mixing parser modes.
|
|
590
593
|
|
|
594
|
+
### RDF Surfaces
|
|
595
|
+
|
|
596
|
+
RDF Surfaces are enabled with `--rdf-surfaces` on the CLI or `{ rdfSurfaces: true }` in the API. The option implies RDF compatibility mode. The syntax follows the BLOGIC text convention from Pat Hayes' ISWC 2009 slides: `%not[` and `%]` surface parentheses plus explicit blank-node binding graffiti at the beginning of a surface. Because this is Turtle plus the surface extension, the examples use `.ttl` for RDF Surface input files.
|
|
597
|
+
|
|
598
|
+
The examples keep RDF Surface input separate from Eyeling queries:
|
|
599
|
+
|
|
600
|
+
- `examples/input/<name>.ttl` contains ordinary RDF triples and RDF Surface rules.
|
|
601
|
+
- `examples/<name>.n3` contains only the corresponding `log:query`.
|
|
602
|
+
|
|
603
|
+
Use separate non-indented lines for triples and surface closes. Put only newly bound blank marks on the surface-opening line; marks already bound by an outer surface are reused in inner triples and are not repeated after `%not[`.
|
|
604
|
+
|
|
605
|
+
```turtle
|
|
606
|
+
@prefix ex: <http://example.org/> .
|
|
607
|
+
|
|
608
|
+
ex:Brussels a ex:City .
|
|
609
|
+
|
|
610
|
+
%not[ _:x
|
|
611
|
+
_:x a ex:City .
|
|
612
|
+
%not[
|
|
613
|
+
_:x a ex:HumanCommunity .
|
|
614
|
+
%]
|
|
615
|
+
%]
|
|
616
|
+
```
|
|
617
|
+
|
|
618
|
+
The slide-32 shape above is normalized as:
|
|
619
|
+
|
|
620
|
+
```n3
|
|
621
|
+
{ ?x a ex:City . }
|
|
622
|
+
=>
|
|
623
|
+
{ ?x a ex:HumanCommunity . } .
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
The first slide-33 abbreviation, range, is written as:
|
|
627
|
+
|
|
628
|
+
```turtle
|
|
629
|
+
%not[ _:x _:y
|
|
630
|
+
_:x ex:parent _:y .
|
|
631
|
+
%not[
|
|
632
|
+
_:y a ex:Person .
|
|
633
|
+
%]
|
|
634
|
+
%]
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
and behaves like:
|
|
638
|
+
|
|
639
|
+
```n3
|
|
640
|
+
{ ?x ex:parent ?y . }
|
|
641
|
+
=>
|
|
642
|
+
{ ?y a ex:Person . } .
|
|
643
|
+
```
|
|
644
|
+
|
|
645
|
+
Eyeling also recognizes codex-style surfaces that introduce rules from RDF/OWL vocabulary facts. For example, this `rdfs:range` codex:
|
|
646
|
+
|
|
647
|
+
```turtle
|
|
648
|
+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
|
649
|
+
|
|
650
|
+
%not[ _:p _:c
|
|
651
|
+
_:p rdfs:range _:c .
|
|
652
|
+
%not[
|
|
653
|
+
%not[ _:s _:o
|
|
654
|
+
_:s _:p _:o .
|
|
655
|
+
%not[
|
|
656
|
+
_:o a _:c .
|
|
657
|
+
%]
|
|
658
|
+
%]
|
|
659
|
+
%]
|
|
660
|
+
%]
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
is normalized to the Horn rule shape:
|
|
664
|
+
|
|
665
|
+
```n3
|
|
666
|
+
{
|
|
667
|
+
?p rdfs:range ?c .
|
|
668
|
+
?s ?p ?o .
|
|
669
|
+
}
|
|
670
|
+
=>
|
|
671
|
+
{ ?o a ?c . } .
|
|
672
|
+
```
|
|
673
|
+
|
|
674
|
+
The slide-33 `owl:allValuesFrom` codex is supported in both directions:
|
|
675
|
+
|
|
676
|
+
```turtle
|
|
677
|
+
@prefix owl: <http://www.w3.org/2002/07/owl#> .
|
|
678
|
+
|
|
679
|
+
%not[ _:a _:b _:c
|
|
680
|
+
_:a owl:onProperty _:b .
|
|
681
|
+
_:a owl:allValuesFrom _:c .
|
|
682
|
+
%not[
|
|
683
|
+
%not[ _:x _:y
|
|
684
|
+
_:x a _:a .
|
|
685
|
+
_:x _:b _:y .
|
|
686
|
+
%not[
|
|
687
|
+
_:y a _:c .
|
|
688
|
+
%]
|
|
689
|
+
%]
|
|
690
|
+
%not[ _:x
|
|
691
|
+
%not[ _:y
|
|
692
|
+
_:x _:b _:y .
|
|
693
|
+
%not[
|
|
694
|
+
_:y a _:c .
|
|
695
|
+
%]
|
|
696
|
+
%]
|
|
697
|
+
%not[
|
|
698
|
+
_:x a _:a .
|
|
699
|
+
%]
|
|
700
|
+
%]
|
|
701
|
+
%]
|
|
702
|
+
%]
|
|
703
|
+
```
|
|
704
|
+
|
|
705
|
+
The forward part derives filler types. The reverse part is compiled into a data-driven scoped check using `log:forAllIn`: for each resource with at least one property value, if all those values are known to have the target class, infer the restricted class.
|
|
706
|
+
|
|
707
|
+
A top-level negative surface without a nested negative child is treated as an inference fuse:
|
|
708
|
+
|
|
709
|
+
```turtle
|
|
710
|
+
%not[ _:x
|
|
711
|
+
_:x a ex:Impossible .
|
|
712
|
+
%]
|
|
713
|
+
```
|
|
714
|
+
|
|
715
|
+
which behaves like:
|
|
716
|
+
|
|
717
|
+
```n3
|
|
718
|
+
{ ?x a ex:Impossible . } => false .
|
|
719
|
+
```
|
|
720
|
+
|
|
721
|
+
The implementation is intentionally conservative: it supports the practical Horn fragment used by the included RDF Surfaces examples, including slide-32 implication, slide-33 range/allValuesFrom codices, nested codices that flatten to Horn rules, scoped `log:forAllIn` reverse checks, and top-level negative-surface fuses. It does not claim to be a complete first-order RDF Surfaces theorem prover.
|
|
722
|
+
|
|
723
|
+
Run the included examples:
|
|
724
|
+
|
|
725
|
+
```bash
|
|
726
|
+
eyeling --rdf-surfaces examples/input/rdf-surfaces-city.ttl examples/rdf-surfaces-city.n3
|
|
727
|
+
eyeling --rdf-surfaces examples/input/rdf-surfaces-range.ttl examples/rdf-surfaces-range.n3
|
|
728
|
+
eyeling --rdf-surfaces examples/input/rdf-surfaces-domain.ttl examples/rdf-surfaces-domain.n3
|
|
729
|
+
eyeling --rdf-surfaces examples/input/rdf-surfaces-property-chain.ttl examples/rdf-surfaces-property-chain.n3
|
|
730
|
+
eyeling --rdf-surfaces examples/input/rdf-surfaces-ancestor.ttl examples/rdf-surfaces-ancestor.n3
|
|
731
|
+
eyeling --rdf-surfaces examples/input/rdf-surfaces-multi-premise.ttl examples/rdf-surfaces-multi-premise.n3
|
|
732
|
+
eyeling --rdf-surfaces examples/input/rdf-surfaces-all-values-from.ttl examples/rdf-surfaces-all-values-from.n3
|
|
733
|
+
eyeling --rdf-surfaces examples/input/rdf-surfaces-all-values-from-reverse.ttl examples/rdf-surfaces-all-values-from-reverse.n3
|
|
734
|
+
eyeling --rdf-surfaces examples/input/rdf-surfaces-rdfs-range-codex.ttl examples/rdf-surfaces-rdfs-range-codex.n3
|
|
735
|
+
eyeling --rdf-surfaces examples/input/rdf-surfaces-rdfs-subclass-codex.ttl examples/rdf-surfaces-rdfs-subclass-codex.n3
|
|
736
|
+
eyeling --rdf-surfaces examples/input/rdf-surfaces-owl-all-values-from-codex.ttl examples/rdf-surfaces-owl-all-values-from-codex.n3
|
|
737
|
+
```
|
|
738
|
+
|
|
739
|
+
The additional examples show ordinary Horn-style RDF Surface patterns beyond the exact slide-33 abbreviations: subject typing (`rdf-surfaces-domain`), a two-hop property chain (`rdf-surfaces-property-chain`), recursive transitive closure (`rdf-surfaces-ancestor`), a conjunctive classification rule (`rdf-surfaces-multi-premise`), and codex-style RDFS/OWL rule generation (`rdf-surfaces-rdfs-range-codex`, `rdf-surfaces-rdfs-subclass-codex`, `rdf-surfaces-owl-all-values-from-codex`).
|
|
740
|
+
|
|
591
741
|
---
|
|
592
742
|
|
|
593
743
|
## RDF Message Logs
|
|
@@ -963,6 +1113,7 @@ input text / RDF-JS / AST
|
|
|
963
1113
|
│
|
|
964
1114
|
▼
|
|
965
1115
|
lib/lexer.js tokenization and RDF compatibility normalization
|
|
1116
|
+
lib/rdf_surfaces.js RDF Surfaces `%not[...%]` normalization
|
|
966
1117
|
│
|
|
967
1118
|
▼
|
|
968
1119
|
lib/parser.js N3/TriG-ish parser to internal AST
|
|
@@ -1112,6 +1263,7 @@ Package scripts are defined in `package.json`.
|
|
|
1112
1263
|
| `npm run test:package` | Verify package-level behavior. |
|
|
1113
1264
|
| `npm run test:store` | Verify memory and persistent fact-store matching. |
|
|
1114
1265
|
| `npm run test:rdf12` | Run RDF 1.2 Turtle, N-Triples, N-Quads, and TriG syntax suites. |
|
|
1266
|
+
| `npm run test:rdf-surfaces` | Run RDF Surfaces syntax and reasoning checks. |
|
|
1115
1267
|
| `npm test` | Build and run the full suite. |
|
|
1116
1268
|
|
|
1117
1269
|
### Recommended local check before committing
|
|
@@ -1147,6 +1299,7 @@ The tests exercise:
|
|
|
1147
1299
|
- RDF-JS input and output;
|
|
1148
1300
|
- custom built-ins;
|
|
1149
1301
|
- RDF 1.2 compatibility mode;
|
|
1302
|
+
- RDF Surfaces compatibility mode;
|
|
1150
1303
|
- RDF Message Log parsing and streaming;
|
|
1151
1304
|
- package exports and browser playground behavior.
|
|
1152
1305
|
|