eyeling 1.24.1 → 1.24.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.
Files changed (77) hide show
  1. package/HANDBOOK.md +134 -0
  2. package/dist/browser/eyeling.browser.js +454 -22
  3. package/eyeling.js +454 -22
  4. package/index.js +2 -0
  5. package/lib/cli.js +27 -10
  6. package/lib/engine.js +17 -7
  7. package/lib/lexer.js +295 -2
  8. package/lib/multisource.js +9 -2
  9. package/lib/printing.js +106 -1
  10. package/package.json +1 -1
  11. package/see/README.md +4 -0
  12. package/see/examples/_see.js +33 -2
  13. package/see/examples/age.js +27 -1
  14. package/see/examples/annotation.js +27 -1
  15. package/see/examples/backward.js +27 -1
  16. package/see/examples/backward_recursion.js +27 -1
  17. package/see/examples/bayes_diagnosis.js +27 -1
  18. package/see/examples/bayes_therapy.js +27 -1
  19. package/see/examples/bmi.js +27 -1
  20. package/see/examples/builtin_coverage.js +27 -1
  21. package/see/examples/collection.js +27 -1
  22. package/see/examples/complex.js +27 -1
  23. package/see/examples/complex_matrix_stability.js +27 -1
  24. package/see/examples/composition_of_injective_functions_is_injective.js +27 -1
  25. package/see/examples/control_system.js +27 -1
  26. package/see/examples/crypto_builtins_tests.js +27 -1
  27. package/see/examples/delfour.js +27 -1
  28. package/see/examples/digital_product_passport.js +27 -1
  29. package/see/examples/dijkstra.js +27 -1
  30. package/see/examples/dijkstra_risk_path.js +27 -1
  31. package/see/examples/doc/rdf_dataset.md +26 -0
  32. package/see/examples/doc/triple_terms.md +26 -0
  33. package/see/examples/dog.js +27 -1
  34. package/see/examples/eco_route_insight.js +27 -1
  35. package/see/examples/equals.js +27 -1
  36. package/see/examples/equivalence_classes_overlap_implies_same_class.js +27 -1
  37. package/see/examples/euler_identity.js +27 -1
  38. package/see/examples/ev_roundtrip_planner.js +27 -1
  39. package/see/examples/existential_rule.js +27 -1
  40. package/see/examples/expression_eval.js +27 -1
  41. package/see/examples/family_cousins.js +27 -1
  42. package/see/examples/fastpow.js +27 -1
  43. package/see/examples/fibonacci.js +27 -1
  44. package/see/examples/french_cities.js +27 -1
  45. package/see/examples/fundamental_theorem_arithmetic.js +27 -1
  46. package/see/examples/genetic_knapsack_selection.js +27 -1
  47. package/see/examples/goldbach_1000.js +27 -1
  48. package/see/examples/good_cobbler.js +27 -1
  49. package/see/examples/gps.js +27 -1
  50. package/see/examples/gray_code_counter.js +27 -1
  51. package/see/examples/greatest_lower_bound_uniqueness.js +27 -1
  52. package/see/examples/group_inverse_uniqueness.js +27 -1
  53. package/see/examples/hadamard_approx.js +27 -1
  54. package/see/examples/hanoi.js +27 -1
  55. package/see/examples/input/rdf_dataset.trig +34 -0
  56. package/see/examples/input/triple_terms.trig +28 -0
  57. package/see/examples/n3/rdf_dataset.n3 +34 -0
  58. package/see/examples/n3/triple_terms.n3 +23 -0
  59. package/see/examples/odrl_dpv_risk_ranked.js +27 -1
  60. package/see/examples/output/rdf_dataset.md +54 -0
  61. package/see/examples/output/triple_terms.md +53 -0
  62. package/see/examples/path_discovery.js +27 -1
  63. package/see/examples/rc_discharge_envelope.js +27 -1
  64. package/see/examples/rdf_dataset.js +1512 -0
  65. package/see/examples/rdf_message_flow.js +27 -1
  66. package/see/examples/rdf_messages.js +27 -1
  67. package/see/examples/school_placement_audit.js +27 -1
  68. package/see/examples/smoke_arithmetic.js +27 -1
  69. package/see/examples/socrates.js +27 -1
  70. package/see/examples/triple_terms.js +1442 -0
  71. package/see/examples/wind_turbine.js +27 -1
  72. package/see/examples/witch.js +27 -1
  73. package/see/see.js +101 -4
  74. package/test/api.test.js +86 -0
  75. package/test/see.test.js +0 -0
  76. package/tools/bundle.js +0 -0
  77. package/tools/n3gen.js +0 -0
package/HANDBOOK.md CHANGED
@@ -36,6 +36,7 @@
36
36
  - [Appendix I — The Eyeling Playground](#app-i)
37
37
  - [Appendix J — Formalism Is Fine](#app-j)
38
38
  - [Appendix K — Whitehead-inspired becoming examples](#app-k)
39
+ - [Appendix L — SEE: Specialized Eyeling Executables](#app-l)
39
40
 
40
41
  ---
41
42
 
@@ -236,6 +237,38 @@ The lexer turns the input into tokens like:
236
237
 
237
238
  Parsing becomes dramatically simpler because tokenization already decided where strings end, where numbers are, and so on.
238
239
 
240
+ By default, Eyeling parses ordinary N3. Selected RDF/TriG surface syntax is accepted only when RDF compatibility is explicitly enabled with `eyeling -r file.trig`, `eyeling --rdf file.trig`, or API option `{ rdf: true }`. In that mode, the lexer normalizes RDF/TriG input syntax to ordinary N3 graph terms before normal parsing, and the printer emits RDF/TriG-compatible output where feasible. Eyeling remains an N3 reasoner; this is syntax compatibility, not a separate RDF dataset reasoning model.
241
+
242
+ In RDF compatibility mode, RDF 1.2 triple terms written as `<<( s p o )>>` are normalized to Eyeling's existing singleton quoted-formula term `{ s p o }`. A leading `VERSION "1.2"` or `@version "1.2"` directive is ignored for the same reason. On output, `--rdf` converts a singleton graph term back to `<<( ... )>>` only when its inner triple is valid as an RDF triple term; otherwise it stays in N3 graph-term form. It also prints `log:nameOf` graph-term triples back as TriG named graph blocks. For example:
243
+
244
+ ```n3
245
+ :observation rdf:reifies <<( :sensor :reports :overheating )>> .
246
+ ```
247
+
248
+ is treated internally like:
249
+
250
+ ```n3
251
+ :observation rdf:reifies { :sensor :reports :overheating } .
252
+ ```
253
+
254
+ RDF/TriG named graph blocks are normalized in the same style as `tools/n3gen`:
255
+
256
+ ```trig
257
+ :factoryDataset {
258
+ :observation rdf:reifies <<( :sensor :reports :overheating )>> .
259
+ }
260
+ ```
261
+
262
+ is treated internally like:
263
+
264
+ ```n3
265
+ :factoryDataset log:nameOf {
266
+ :observation rdf:reifies { :sensor :reports :overheating } .
267
+ } .
268
+ ```
269
+
270
+ This keeps Eyeling's N3 model stable while allowing small RDF 1.1/RDF 1.2 dataset-shaped inputs to run through the existing `GraphTerm` machinery when the caller opts in. More exotic future RDF forms should be added only if they can be mapped cleanly onto Eyeling's quoted-formula term model.
271
+
239
272
  ### 4.2 Parsing triples, with Turtle-style convenience
240
273
 
241
274
  The parser supports:
@@ -2561,6 +2594,8 @@ Quoted graphs/formulas use `{ ... }`. Inside a quoted formula, directive scope m
2561
2594
 
2562
2595
  - `@prefix/@base` and `PREFIX/BASE` directives may appear at top level **or inside `{ ... }`**, and apply to the formula they occur in (formula-local scoping).
2563
2596
 
2597
+ With `-r, --rdf` / `{ rdf: true }`, Eyeling also accepts the RDF 1.2 triple-term surface form `<<( s p o )>>` as a compatibility spelling for a singleton quoted formula `{ s p o }`. In the same mode, feasible singleton graph terms are printed back as RDF 1.2 triple terms, while invalid cases such as a literal subject remain ordinary N3 graph terms. This is useful for inputs that use `rdf:reifies` or other predicates whose objects are RDF 1.2 triple terms, while keeping the default language and the rest of Eyeling on its N3 formula-term model.
2598
+
2564
2599
  For the formal grammar, see the N3 spec grammar:
2565
2600
 
2566
2601
  - [https://w3c.github.io/N3/spec/#grammar](https://w3c.github.io/N3/spec/#grammar)
@@ -3794,3 +3829,102 @@ The becoming examples should therefore be read as **executable schemata** rather
3794
3829
  For the handbook, these examples matter for two reasons. First, they provide a concrete demonstration that Eyeling can handle a style of reasoning that feels closer to **becoming, development, and transformation** than to static classification. Second, they show how expressive gains can come from modeling choices rather than from adding new machinery to the engine. The same forward-chaining core that proves `:Socrates a :Mortal` can also prove that a lineage becomes evolvable, that a controller becomes approved, or that a wake switch becomes serviceable under a low-bias regime.
3795
3830
 
3796
3831
  That is why this appendix belongs after Appendix J. “Formalism is fine” not only because it supports rigor, but because it can remain flexible enough to describe worlds in motion. The becoming examples are small demonstrations of that claim. They show that a compact N3 reasoner can host process-oriented models without ceasing to be simple, readable, and executable.
3832
+
3833
+ ---
3834
+
3835
+ <a id="app-l"></a>
3836
+
3837
+ ## Appendix L — SEE: Specialized Eyeling Executables
3838
+
3839
+ SEE, **Specialized Eyeling Executables**, is the companion example system under `see/`. It compiles selected Eyeling-style N3 programs into small, standalone JavaScript runners. The goal is not to replace the main reasoner. The goal is to turn a particular reasoning task into an executable artifact that carries its input evidence, derivation logic, entailment, explanation, and reference output together.
3840
+
3841
+ The short mental model is:
3842
+
3843
+ ```text
3844
+ N3 source + TriG evidence -> specialized JavaScript -> entailment + explanation
3845
+ ```
3846
+
3847
+ ### L.1 Why SEE exists
3848
+
3849
+ The normal Eyeling CLI is a general reasoner: it parses an input file, runs the engine, and prints the resulting closure, selected query output, or rendered `log:outputString` report.
3850
+
3851
+ SEE is narrower and more packageable. For each committed example, `see.js` generates:
3852
+
3853
+ - `see/examples/<name>.js` — a runnable JavaScript derivation program,
3854
+ - `see/examples/input/<name>.trig` — the RDF/TriG evidence read by the runner,
3855
+ - `see/examples/output/<name>.md` — the expected Markdown result,
3856
+ - `see/examples/doc/<name>.md` — a short generated explanation of the compiled example.
3857
+
3858
+ That makes each example easier to audit. A reviewer can inspect the source N3, the generated runner, the input evidence, and the expected entailment/explanation without reconstructing the whole test setup.
3859
+
3860
+ ### L.2 Entailment plus explanation
3861
+
3862
+ SEE reports use an **Entailment** section and an **Explanation** section. The entailment is the selected result of the reasoning task. The explanation records how the compiled runner reached it: source facts, rules, selected support trees, and the formal TriG output when relevant.
3863
+
3864
+ This vocabulary is deliberately more precise than a generic “result”. It says: the program is not merely presenting a suggestion; it is presenting something that follows from the encoded facts, rules, gates, and query projection.
3865
+
3866
+ ### L.3 Direct TriG input
3867
+
3868
+ Generated SEE runners read their committed `.trig` input directly. Earlier versions used an intermediate `.n3` conversion step, but the current design keeps the evidence in TriG and lets the runner parse that committed input. This matters for examples that are closer to RDF data exchange than to hand-written N3 rule files.
3869
+
3870
+ SEE includes RDF compatibility examples. The `triple_terms` example uses RDF 1.2 triple terms, and the `rdf_dataset` example combines ordinary default-graph triples, an RDF/TriG named graph block, and RDF 1.2 triple terms.
3871
+
3872
+ A triple-term input can contain:
3873
+
3874
+ ```trig
3875
+ VERSION "1.2"
3876
+
3877
+ :observation rdf:reifies <<( :sensor :reports :overheating )>> .
3878
+ ```
3879
+
3880
+ In RDF compatibility mode, Eyeling accepts this surface form by translating the triple term to a singleton quoted formula internally:
3881
+
3882
+ ```n3
3883
+ :observation rdf:reifies { :sensor :reports :overheating } .
3884
+ ```
3885
+
3886
+ The dataset example also uses named graph syntax, which RDF compatibility mode normalizes to `log:nameOf` graph terms, matching `tools/n3gen`:
3887
+
3888
+ ```trig
3889
+ :factoryDataset {
3890
+ :observation rdf:reifies <<( :sensor :reports :overheating )>> .
3891
+ }
3892
+ ```
3893
+
3894
+ is compiled through the same internal N3 shape:
3895
+
3896
+ ```n3
3897
+ :factoryDataset log:nameOf {
3898
+ :observation rdf:reifies { :sensor :reports :overheating } .
3899
+ } .
3900
+ ```
3901
+
3902
+ That is enough for SEE to demonstrate RDF 1.1/RDF 1.2-style dataset input and triple-term output without forcing Eyeling to implement a separate full RDF dataset model. The compatibility layer is explicit rather than default, so ordinary N3 files remain strict N3.
3903
+
3904
+ ### L.4 Generation and tests
3905
+
3906
+ The root package scripts treat SEE as part of the normal repository workflow:
3907
+
3908
+ ```bash
3909
+ npm run generate
3910
+ npm run test:see
3911
+ ```
3912
+
3913
+ `npm run generate` refreshes the generated SEE artifacts from `see/examples/n3/*.n3`. `npm run test:see` runs every generated SEE example and compares its Markdown output with the committed reference output.
3914
+
3915
+ In the full test suite, this means SEE is not just documentation. It is executable regression coverage for a broad range of Eyeling behavior: forward rules, backward rules, builtins, fuses, queries, RDF lists, formula-valued terms, generated explanations, opt-in RDF 1.2 triple-term compatibility, and opt-in RDF/TriG dataset-syntax compatibility.
3916
+
3917
+ ### L.5 When to add a SEE example
3918
+
3919
+ A normal Eyeling example is best when you want to demonstrate a language feature or a compact reasoning pattern directly in N3.
3920
+
3921
+ A SEE example is best when you want a more self-contained artifact:
3922
+
3923
+ - the input evidence matters,
3924
+ - the final entailment should be explained in Markdown,
3925
+ - the example should be runnable without an external reasoner at runtime,
3926
+ - the generated JavaScript itself is worth inspecting,
3927
+ - or the example should become stable regression coverage for a specific reasoning workflow.
3928
+
3929
+ In that sense, SEE is an executable publication format for selected Eyeling examples: small enough to read, deterministic enough to test, and explicit enough to audit.
3930
+