eyeling 1.24.4 → 1.24.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/HANDBOOK.md +2 -101
- package/README.md +2 -2
- package/dist/browser/eyeling.browser.js +256 -4
- package/examples/annotation.n3 +3 -4
- package/{see/examples/n3/backward_recursion.n3 → examples/backward-recursion.n3} +0 -2
- package/examples/collection.n3 +1 -2
- package/examples/context-association.n3 +56 -30
- package/{see/examples/n3/dijkstra_risk_path.n3 → examples/dijkstra-risk-path.n3} +3 -18
- package/{see/examples/n3/eco_route_insight.n3 → examples/eco-route-insight.n3} +2 -47
- package/{see/examples/n3/genetic_knapsack_selection.n3 → examples/genetic-knapsack-selection.n3} +2 -24
- package/{see/examples → examples}/input/annotation.trig +3 -3
- package/{see/examples/input/backward_recursion.trig → examples/input/backward-recursion.trig} +2 -2
- package/{see/examples/input/builtin_coverage.trig → examples/input/builtin-coverage.trig} +2 -2
- package/{see/examples → examples}/input/collection.trig +3 -3
- package/{see/examples/input/dijkstra_risk_path.trig → examples/input/dijkstra-risk-path.trig} +4 -4
- package/{see/examples/input/eco_route_insight.trig → examples/input/eco-route-insight.trig} +4 -4
- package/{see/examples/input/genetic_knapsack_selection.trig → examples/input/genetic-knapsack-selection.trig} +4 -4
- package/{see/examples/input/rc_discharge_envelope.trig → examples/input/rc-discharge-envelope.trig} +4 -4
- package/{see/examples/input/rdf_dataset.trig → examples/input/rdf-dataset.trig} +4 -4
- package/{see/examples/input/rdf_message_flow.trig → examples/input/rdf-message-flow.trig} +3 -3
- package/{see/examples/input/rdf_messages.trig → examples/input/rdf-messages.trig} +4 -4
- package/{see/examples/input/school_placement_audit.trig → examples/input/school-placement-audit.trig} +4 -4
- package/{see/examples/input/smoke_arithmetic.trig → examples/input/smoke-arithmetic.trig} +3 -3
- package/{see/examples/input/triple_terms.trig → examples/input/triple-terms.trig} +3 -3
- package/examples/output/backward-recursion.n3 +4 -0
- package/examples/output/context-association.n3 +9 -0
- package/examples/output/dijkstra-risk-path.n3 +3 -0
- package/examples/output/eco-route-insight.n3 +3 -0
- package/examples/output/genetic-knapsack-selection.n3 +3 -0
- package/examples/output/rc-discharge-envelope.n3 +9 -0
- package/examples/output/rc-discharge-envelope.txt +9 -0
- package/examples/output/rdf-dataset.n3 +5 -0
- package/examples/output/rdf-message-flow.n3 +7 -0
- package/examples/output/rdf-messages.n3 +7 -0
- package/examples/output/school-placement-audit.n3 +3 -0
- package/examples/output/smoke-arithmetic.n3 +5 -0
- package/examples/output/smoke-arithmetic.txt +5 -0
- package/examples/output/triple-terms.n3 +5 -0
- package/{see/examples/n3/rc_discharge_envelope.n3 → examples/rc-discharge-envelope.n3} +2 -15
- package/{see/examples/n3/rdf_dataset.n3 → examples/rdf-dataset.n3} +2 -11
- package/{see/examples/n3/rdf_message_flow.n3 → examples/rdf-message-flow.n3} +9 -75
- package/{see/examples/n3/rdf_messages.n3 → examples/rdf-messages.n3} +6 -43
- package/{see/examples/n3/school_placement_audit.n3 → examples/school-placement-audit.n3} +2 -14
- package/{see/examples/n3/smoke_arithmetic.n3 → examples/smoke-arithmetic.n3} +3 -5
- package/{see/examples/n3/triple_terms.n3 → examples/triple-terms.n3} +1 -4
- package/eyeling.js +256 -4
- package/lib/builtins.js +6 -0
- package/lib/lexer.js +250 -4
- package/package.json +4 -7
- package/test/api.test.js +65 -8
- package/test/examples.test.js +22 -2
- package/test/package.test.js +16 -2
- package/examples/arcling/README.md +0 -11
- package/examples/input/annotation.ttl +0 -6
- package/examples/input/collection.ttl +0 -13
- package/examples/input/reifies.ttl +0 -10
- package/examples/input/triple-term.ttl +0 -8
- package/examples/output/triple-term.n3 +0 -0
- package/examples/reifies.n3 +0 -8
- package/examples/triple-term.n3 +0 -7
- package/see/README.md +0 -149
- package/see/examples/_see.js +0 -249
- package/see/examples/age.js +0 -1459
- package/see/examples/annotation.js +0 -1320
- package/see/examples/backward.js +0 -1405
- package/see/examples/backward_recursion.js +0 -1504
- package/see/examples/bayes_diagnosis.js +0 -2883
- package/see/examples/bayes_therapy.js +0 -4152
- package/see/examples/bmi.js +0 -3038
- package/see/examples/builtin_coverage.js +0 -2524
- package/see/examples/collection.js +0 -1320
- package/see/examples/complex.js +0 -3762
- package/see/examples/complex_matrix_stability.js +0 -2973
- package/see/examples/composition_of_injective_functions_is_injective.js +0 -2170
- package/see/examples/control_system.js +0 -1918
- package/see/examples/crypto_builtins_tests.js +0 -1489
- package/see/examples/delfour.js +0 -3174
- package/see/examples/digital_product_passport.js +0 -2856
- package/see/examples/dijkstra.js +0 -2070
- package/see/examples/dijkstra_risk_path.js +0 -1874
- package/see/examples/doc/age.md +0 -27
- package/see/examples/doc/annotation.md +0 -24
- package/see/examples/doc/backward.md +0 -26
- package/see/examples/doc/backward_recursion.md +0 -26
- package/see/examples/doc/bayes_diagnosis.md +0 -41
- package/see/examples/doc/bayes_therapy.md +0 -40
- package/see/examples/doc/bmi.md +0 -38
- package/see/examples/doc/builtin_coverage.md +0 -53
- package/see/examples/doc/collection.md +0 -24
- package/see/examples/doc/complex.md +0 -38
- package/see/examples/doc/complex_matrix_stability.md +0 -35
- package/see/examples/doc/composition_of_injective_functions_is_injective.md +0 -24
- package/see/examples/doc/control_system.md +0 -32
- package/see/examples/doc/crypto_builtins_tests.md +0 -27
- package/see/examples/doc/delfour.md +0 -37
- package/see/examples/doc/digital_product_passport.md +0 -36
- package/see/examples/doc/dijkstra.md +0 -28
- package/see/examples/doc/dijkstra_risk_path.md +0 -30
- package/see/examples/doc/dog.md +0 -28
- package/see/examples/doc/eco_route_insight.md +0 -33
- package/see/examples/doc/equals.md +0 -26
- package/see/examples/doc/equivalence_classes_overlap_implies_same_class.md +0 -24
- package/see/examples/doc/euler_identity.md +0 -39
- package/see/examples/doc/ev_roundtrip_planner.md +0 -32
- package/see/examples/doc/existential_rule.md +0 -24
- package/see/examples/doc/expression_eval.md +0 -26
- package/see/examples/doc/family_cousins.md +0 -24
- package/see/examples/doc/fastpow.md +0 -29
- package/see/examples/doc/fibonacci.md +0 -28
- package/see/examples/doc/french_cities.md +0 -28
- package/see/examples/doc/fundamental_theorem_arithmetic.md +0 -36
- package/see/examples/doc/genetic_knapsack_selection.md +0 -29
- package/see/examples/doc/goldbach_1000.md +0 -31
- package/see/examples/doc/good_cobbler.md +0 -27
- package/see/examples/doc/gps.md +0 -35
- package/see/examples/doc/gray_code_counter.md +0 -31
- package/see/examples/doc/greatest_lower_bound_uniqueness.md +0 -24
- package/see/examples/doc/group_inverse_uniqueness.md +0 -24
- package/see/examples/doc/hadamard_approx.md +0 -32
- package/see/examples/doc/hanoi.md +0 -26
- package/see/examples/doc/odrl_dpv_risk_ranked.md +0 -57
- package/see/examples/doc/path_discovery.md +0 -33
- package/see/examples/doc/rc_discharge_envelope.md +0 -33
- package/see/examples/doc/rdf_dataset.md +0 -26
- package/see/examples/doc/rdf_message_flow.md +0 -35
- package/see/examples/doc/rdf_messages.md +0 -37
- package/see/examples/doc/school_placement_audit.md +0 -31
- package/see/examples/doc/smoke_arithmetic.md +0 -31
- package/see/examples/doc/socrates.md +0 -24
- package/see/examples/doc/triple_terms.md +0 -26
- package/see/examples/doc/wind_turbine.md +0 -37
- package/see/examples/doc/witch.md +0 -28
- package/see/examples/dog.js +0 -1436
- package/see/examples/eco_route_insight.js +0 -2110
- package/see/examples/equals.js +0 -1363
- package/see/examples/equivalence_classes_overlap_implies_same_class.js +0 -1792
- package/see/examples/euler_identity.js +0 -2038
- package/see/examples/ev_roundtrip_planner.js +0 -2562
- package/see/examples/existential_rule.js +0 -1363
- package/see/examples/expression_eval.js +0 -1798
- package/see/examples/family_cousins.js +0 -1586
- package/see/examples/fastpow.js +0 -2207
- package/see/examples/fibonacci.js +0 -1594
- package/see/examples/french_cities.js +0 -1492
- package/see/examples/fundamental_theorem_arithmetic.js +0 -2106
- package/see/examples/genetic_knapsack_selection.js +0 -1743
- package/see/examples/goldbach_1000.js +0 -1798
- package/see/examples/good_cobbler.js +0 -1396
- package/see/examples/gps.js +0 -2813
- package/see/examples/gray_code_counter.js +0 -1641
- package/see/examples/greatest_lower_bound_uniqueness.js +0 -1918
- package/see/examples/group_inverse_uniqueness.js +0 -1897
- package/see/examples/hadamard_approx.js +0 -4417
- package/see/examples/hanoi.js +0 -1625
- package/see/examples/input/age.trig +0 -27
- package/see/examples/input/backward.trig +0 -25
- package/see/examples/input/bayes_diagnosis.trig +0 -111
- package/see/examples/input/bayes_therapy.trig +0 -130
- package/see/examples/input/bmi.trig +0 -28
- package/see/examples/input/complex.trig +0 -26
- package/see/examples/input/complex_matrix_stability.trig +0 -65
- package/see/examples/input/composition_of_injective_functions_is_injective.trig +0 -35
- package/see/examples/input/control_system.trig +0 -31
- package/see/examples/input/crypto_builtins_tests.trig +0 -25
- package/see/examples/input/delfour.trig +0 -90
- package/see/examples/input/digital_product_passport.trig +0 -116
- package/see/examples/input/dijkstra.trig +0 -34
- package/see/examples/input/dog.trig +0 -31
- package/see/examples/input/equals.trig +0 -25
- package/see/examples/input/equivalence_classes_overlap_implies_same_class.trig +0 -28
- package/see/examples/input/euler_identity.trig +0 -34
- package/see/examples/input/ev_roundtrip_planner.trig +0 -90
- package/see/examples/input/existential_rule.trig +0 -26
- package/see/examples/input/expression_eval.trig +0 -41
- package/see/examples/input/family_cousins.trig +0 -39
- package/see/examples/input/fastpow.trig +0 -25
- package/see/examples/input/fibonacci.trig +0 -51
- package/see/examples/input/french_cities.trig +0 -38
- package/see/examples/input/fundamental_theorem_arithmetic.trig +0 -42
- package/see/examples/input/goldbach_1000.trig +0 -53
- package/see/examples/input/good_cobbler.trig +0 -24
- package/see/examples/input/gps.trig +0 -35
- package/see/examples/input/gray_code_counter.trig +0 -33
- package/see/examples/input/greatest_lower_bound_uniqueness.trig +0 -29
- package/see/examples/input/group_inverse_uniqueness.trig +0 -29
- package/see/examples/input/hadamard_approx.trig +0 -32
- package/see/examples/input/hanoi.trig +0 -26
- package/see/examples/input/odrl_dpv_risk_ranked.trig +0 -107
- package/see/examples/input/path-discovery.trig +0 -96448
- package/see/examples/input/path_discovery.trig +0 -29
- package/see/examples/input/socrates.trig +0 -26
- package/see/examples/input/wind_turbine.trig +0 -48
- package/see/examples/input/witch.trig +0 -26
- package/see/examples/n3/age.n3 +0 -28
- package/see/examples/n3/annotation.n3 +0 -7
- package/see/examples/n3/backward.n3 +0 -22
- package/see/examples/n3/bayes_diagnosis.n3 +0 -122
- package/see/examples/n3/bayes_therapy.n3 +0 -149
- package/see/examples/n3/bmi.n3 +0 -145
- package/see/examples/n3/collection.n3 +0 -3
- package/see/examples/n3/complex.n3 +0 -140
- package/see/examples/n3/complex_matrix_stability.n3 +0 -113
- package/see/examples/n3/composition_of_injective_functions_is_injective.n3 +0 -27
- package/see/examples/n3/control_system.n3 +0 -59
- package/see/examples/n3/crypto_builtins_tests.n3 +0 -18
- package/see/examples/n3/delfour.n3 +0 -167
- package/see/examples/n3/digital_product_passport.n3 +0 -156
- package/see/examples/n3/dijkstra.n3 +0 -46
- package/see/examples/n3/dog.n3 +0 -20
- package/see/examples/n3/equals.n3 +0 -11
- package/see/examples/n3/equivalence_classes_overlap_implies_same_class.n3 +0 -19
- package/see/examples/n3/euler_identity.n3 +0 -41
- package/see/examples/n3/ev_roundtrip_planner.n3 +0 -82
- package/see/examples/n3/existential_rule.n3 +0 -10
- package/see/examples/n3/expression_eval.n3 +0 -21
- package/see/examples/n3/family_cousins.n3 +0 -62
- package/see/examples/n3/fastpow.n3 +0 -56
- package/see/examples/n3/fibonacci.n3 +0 -44
- package/see/examples/n3/french_cities.n3 +0 -28
- package/see/examples/n3/fundamental_theorem_arithmetic.n3 +0 -84
- package/see/examples/n3/goldbach_1000.n3 +0 -66
- package/see/examples/n3/good_cobbler.n3 +0 -10
- package/see/examples/n3/gps.n3 +0 -70
- package/see/examples/n3/gray_code_counter.n3 +0 -53
- package/see/examples/n3/greatest_lower_bound_uniqueness.n3 +0 -20
- package/see/examples/n3/group_inverse_uniqueness.n3 +0 -19
- package/see/examples/n3/hadamard_approx.n3 +0 -43
- package/see/examples/n3/hanoi.n3 +0 -16
- package/see/examples/n3/odrl_dpv_risk_ranked.n3 +0 -460
- package/see/examples/n3/path_discovery.n3 +0 -43
- package/see/examples/n3/socrates.n3 +0 -21
- package/see/examples/n3/wind_turbine.n3 +0 -85
- package/see/examples/n3/witch.n3 +0 -30
- package/see/examples/odrl_dpv_risk_ranked.js +0 -5128
- package/see/examples/output/age.md +0 -48
- package/see/examples/output/annotation.md +0 -43
- package/see/examples/output/backward.md +0 -50
- package/see/examples/output/backward_recursion.md +0 -54
- package/see/examples/output/bayes_diagnosis.md +0 -103
- package/see/examples/output/bayes_therapy.md +0 -84
- package/see/examples/output/bmi.md +0 -164
- package/see/examples/output/builtin_coverage.md +0 -99
- package/see/examples/output/collection.md +0 -44
- package/see/examples/output/complex.md +0 -61
- package/see/examples/output/complex_matrix_stability.md +0 -55
- package/see/examples/output/composition_of_injective_functions_is_injective.md +0 -62
- package/see/examples/output/control_system.md +0 -61
- package/see/examples/output/crypto_builtins_tests.md +0 -68
- package/see/examples/output/delfour.md +0 -100
- package/see/examples/output/digital_product_passport.md +0 -100
- package/see/examples/output/dijkstra.md +0 -74
- package/see/examples/output/dijkstra_risk_path.md +0 -76
- package/see/examples/output/dog.md +0 -50
- package/see/examples/output/eco_route_insight.md +0 -88
- package/see/examples/output/equals.md +0 -50
- package/see/examples/output/equivalence_classes_overlap_implies_same_class.md +0 -86
- package/see/examples/output/euler_identity.md +0 -73
- package/see/examples/output/ev_roundtrip_planner.md +0 -79
- package/see/examples/output/existential_rule.md +0 -54
- package/see/examples/output/expression_eval.md +0 -50
- package/see/examples/output/family_cousins.md +0 -187
- package/see/examples/output/fastpow.md +0 -36
- package/see/examples/output/fibonacci.md +0 -53
- package/see/examples/output/french_cities.md +0 -70
- package/see/examples/output/fundamental_theorem_arithmetic.md +0 -101
- package/see/examples/output/genetic_knapsack_selection.md +0 -66
- package/see/examples/output/goldbach_1000.md +0 -58
- package/see/examples/output/good_cobbler.md +0 -54
- package/see/examples/output/gps.md +0 -102
- package/see/examples/output/gray_code_counter.md +0 -68
- package/see/examples/output/greatest_lower_bound_uniqueness.md +0 -60
- package/see/examples/output/group_inverse_uniqueness.md +0 -60
- package/see/examples/output/hadamard_approx.md +0 -510
- package/see/examples/output/hanoi.md +0 -51
- package/see/examples/output/odrl_dpv_risk_ranked.md +0 -139
- package/see/examples/output/path_discovery.md +0 -65
- package/see/examples/output/rc_discharge_envelope.md +0 -102
- package/see/examples/output/rdf_dataset.md +0 -54
- package/see/examples/output/rdf_message_flow.md +0 -198
- package/see/examples/output/rdf_messages.md +0 -134
- package/see/examples/output/school_placement_audit.md +0 -99
- package/see/examples/output/smoke_arithmetic.md +0 -54
- package/see/examples/output/socrates.md +0 -55
- package/see/examples/output/triple_terms.md +0 -53
- package/see/examples/output/wind_turbine.md +0 -108
- package/see/examples/output/witch.md +0 -87
- package/see/examples/path_discovery.js +0 -1774
- package/see/examples/rc_discharge_envelope.js +0 -1993
- package/see/examples/rdf_dataset.js +0 -1512
- package/see/examples/rdf_message_flow.js +0 -2580
- package/see/examples/rdf_messages.js +0 -2176
- package/see/examples/school_placement_audit.js +0 -1867
- package/see/examples/smoke_arithmetic.js +0 -1483
- package/see/examples/socrates.js +0 -1420
- package/see/examples/triple_terms.js +0 -1442
- package/see/examples/wind_turbine.js +0 -2853
- package/see/examples/witch.js +0 -1519
- package/see/see.js +0 -2179
- package/test/see.test.js +0 -159
- /package/{see/examples/n3/builtin_coverage.n3 → examples/builtin-coverage.n3} +0 -0
- /package/examples/output/{reifies.n3 → builtin-coverage.n3} +0 -0
package/see/README.md
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
# SEE
|
|
2
|
-
|
|
3
|
-
**Specialized Eyeling Executables**
|
|
4
|
-
|
|
5
|
-
SEE (**Specialized Eyeling Executables**) is a small compiler and example suite for turning Eyeling-style Notation3 programs into specialized JavaScript executables with human-readable explanations.
|
|
6
|
-
|
|
7
|
-
```text
|
|
8
|
-
input facts -> rules -> trust gate -> entailment + explanation
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
Each example starts from a Notation3 source and is compiled by `see.js` into a small Node.js program:
|
|
12
|
-
|
|
13
|
-
- `examples/n3/<name>.n3` contains the N3 facts, rules, gates, and query.
|
|
14
|
-
- `examples/input/<name>.trig` contains the formal RDF 1.2 TriG input evidence read by the runner.
|
|
15
|
-
- `examples/<name>.js` is generated by `see.js` and derives the entailment.
|
|
16
|
-
- `examples/output/<name>.md` is the reference Markdown output used by `npm run test:see`.
|
|
17
|
-
- `examples/doc/<name>.md` explains the compiled example.
|
|
18
|
-
|
|
19
|
-
The trust gate is executable verification. If a required fact is missing, the program fails instead of emitting an unsupported entailment.
|
|
20
|
-
|
|
21
|
-
The `triple_terms` and `rdf_dataset` examples use RDF 1.2 `<<( ... )>>` triple-term syntax. Eyeling accepts that syntax only with `-r, --rdf`, where it normalizes triple terms to existing N3 singleton graph terms `{ ... }` and prints feasible output graph terms back as RDF 1.2 triple terms. The `rdf_dataset` example also uses an RDF/TriG named graph block, which RDF compatibility mode normalizes to the N3 `log:nameOf { ... }` graph-term shape and prints back as a TriG named graph block where feasible; SEE keeps the committed `.trig` input and formal output in RDF 1.2/TriG form.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
## Run
|
|
25
|
-
|
|
26
|
-
Run all examples:
|
|
27
|
-
|
|
28
|
-
```sh
|
|
29
|
-
npm run test:see
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
Render one N3 example through `see.js` without writing files:
|
|
33
|
-
|
|
34
|
-
```sh
|
|
35
|
-
node see/see.js render see/examples/n3/delfour.n3
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
Refresh the four committed SEE artefacts for one N3 example:
|
|
39
|
-
|
|
40
|
-
```sh
|
|
41
|
-
node see/see.js generate see/examples/n3/delfour.n3 --force
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
Compare one rendered output:
|
|
45
|
-
|
|
46
|
-
```sh
|
|
47
|
-
node see/examples/bmi.js > /tmp/bmi.md
|
|
48
|
-
diff -u see/examples/output/bmi.md /tmp/bmi.md
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
## Compile a Notation3 example into SEE JavaScript
|
|
53
|
-
|
|
54
|
-
`see.js` is a small Notation3-to-JavaScript compiler. It parses a supported N3 subset once and writes a specialized Node.js example. The `examples/<name>.js` generated by `see.js` does the derivation itself: it loads generated TriG evidence from `examples/input/<name>.trig`, contains compiled rules, fuses, built-in operations, fixpoint evaluation, and report rendering. It does not parse the program source at runtime and does not shell out to Eyeling or EYE.
|
|
55
|
-
|
|
56
|
-
Generate the four SEE artefacts from an N3 source:
|
|
57
|
-
|
|
58
|
-
```sh
|
|
59
|
-
node see/see.js generate path/to/example.n3 --name my_example
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
During generation, `see.js` writes the specialized runner and TriG input evidence first, then invokes the compiled runner with `--write`. That generated `examples/<name>.js` is responsible for producing both `examples/output/<name>.md` and `examples/doc/<name>.md`.
|
|
63
|
-
|
|
64
|
-
Render an N3 source without writing files:
|
|
65
|
-
|
|
66
|
-
```sh
|
|
67
|
-
node see/see.js render path/to/example.n3
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
Validate that the source is inside the supported compiler subset:
|
|
71
|
-
|
|
72
|
-
```sh
|
|
73
|
-
node see/see.js inspect path/to/example.n3
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
The compiler currently supports ordinary triples, semicolon/comma property lists, RDF lists, blank nodes, variable predicates, formula-valued conclusions, forward rules, recursive backward rules (`<=`), top-level `log:query`, `=> false` fuses, and a broad native builtin registry for Eyeling-style `math:`, `string:`, `list:`, `crypto:`, `time:`, and `log:` predicates. The compiled JavaScript covers multi-solution predicates such as `list:member`, `list:in`, `list:iterate`, `list:memberAt`, and `list:map`, plus relation-like reverse modes such as `math:exponentiation`, unary trig/degree relations, `list:reverse`, and `list:append` splitting. Offline dereferencing/parsing builtins (`log:content`, `log:semantics`, `log:semanticsOrError`, `log:parsedAsN3`) fail explicitly in compiled SEE examples instead of doing network or parser work at runtime. Unsupported constructs fail rather than jumping directly to a prewritten `log:outputString`. When no authored `log:outputString` report is derived, the compiled runner still emits a SEE-style report with just **Entailment** and **Explanation** sections instead of dumping the whole graph; supporting facts are folded into the explanation, including concise support trees that trace selected entailments back to source facts when the compiler has rule-premise evidence available.
|
|
77
|
-
|
|
78
|
-
## Files
|
|
79
|
-
|
|
80
|
-
```text
|
|
81
|
-
examples/
|
|
82
|
-
<name>.js executable example
|
|
83
|
-
_see.js shared helper
|
|
84
|
-
input/<name>.trig formal RDF 1.2 TriG evidence
|
|
85
|
-
output/<name>.md reference entailment and explanation
|
|
86
|
-
doc/<name>.md guide
|
|
87
|
-
n3/<name>.n3 Notation3 source
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
## Current examples
|
|
91
|
-
|
|
92
|
-
The repository currently contains **50 N3-compiled SEE examples**. Each example has a Notation3 source, an executable `examples/<name>.js`, TriG input evidence, a reference output, and a documentation page. `node see/see.js generate ... --force` regenerates individual examples from files under `see/examples/n3/`.
|
|
93
|
-
|
|
94
|
-
### N3-compiled SEE examples
|
|
95
|
-
|
|
96
|
-
| Example | Idea | Files |
|
|
97
|
-
|---|---|---|
|
|
98
|
-
| <a id="example-age-threshold"></a>[Age threshold](#example-age-threshold) | compiled from Notation3 by `see.js`; date/duration comparison evaluates whether a person is older than a configured age threshold. | [doc](examples/doc/age.md), [js](examples/age.js), [input](examples/input/age.trig), [output](examples/output/age.md), [n3](examples/n3/age.n3) |
|
|
99
|
-
| <a id="example-annotation"></a>[Annotation](#example-annotation) | compiled from Notation3 by `see.js`; formula-valued annotation data with `log:nameOf` and typed literals. | [doc](examples/doc/annotation.md), [js](examples/annotation.js), [input](examples/input/annotation.trig), [output](examples/output/annotation.md), [n3](examples/n3/annotation.n3) |
|
|
100
|
-
| <a id="example-backward-rule-example"></a>[Backward rule example](#example-backward-rule-example) | compiled from Notation3 by `see.js`; Eyeling backward-rule example with a `math:greaterThan` guard. | [doc](examples/doc/backward.md), [js](examples/backward.js), [input](examples/input/backward.trig), [output](examples/output/backward.md), [n3](examples/n3/backward.n3) |
|
|
101
|
-
| <a id="example-backward-recursion-coverage"></a>[Backward recursion coverage](#example-backward-recursion-coverage) | compiled from Notation3 by `see.js`; recursive `<=` ancestor rules compiled into JavaScript goal solving. | [doc](examples/doc/backward_recursion.md), [js](examples/backward_recursion.js), [input](examples/input/backward_recursion.trig), [output](examples/output/backward_recursion.md), [n3](examples/n3/backward_recursion.n3) |
|
|
102
|
-
| <a id="example-bayes-diagnosis"></a>[Bayes diagnosis](#example-bayes-diagnosis) | compiled from Notation3 by `see.js`; Naive Bayes evidence factors are multiplied, normalized, and compared to select the highest-posterior disease. | [doc](examples/doc/bayes_diagnosis.md), [js](examples/bayes_diagnosis.js), [input](examples/input/bayes_diagnosis.trig), [output](examples/output/bayes_diagnosis.md), [n3](examples/n3/bayes_diagnosis.n3) |
|
|
103
|
-
| <a id="example-bayes-therapy"></a>[Bayes therapy](#example-bayes-therapy) | compiled from Notation3 by `see.js`; Bayesian disease posteriors feed a therapy expected-utility calculation with recursive best-therapy selection. | [doc](examples/doc/bayes_therapy.md), [js](examples/bayes_therapy.js), [input](examples/input/bayes_therapy.trig), [output](examples/output/bayes_therapy.md), [n3](examples/n3/bayes_therapy.n3) |
|
|
104
|
-
| <a id="example-bmi"></a>[BMI](#example-bmi) | compiled from Notation3 by `see.js`; unit normalization, BMI category selection, and healthy-weight range validations are derived from N3 rules. | [doc](examples/doc/bmi.md), [js](examples/bmi.js), [input](examples/input/bmi.trig), [output](examples/output/bmi.md), [n3](examples/n3/bmi.n3) |
|
|
105
|
-
| <a id="example-builtin-coverage-smoke"></a>[Builtin coverage smoke](#example-builtin-coverage-smoke) | compiled from Notation3 by `see.js`; smoke test for compiled math, string, list, crypto, time, and log builtins. | [doc](examples/doc/builtin_coverage.md), [js](examples/builtin_coverage.js), [input](examples/input/builtin_coverage.trig), [output](examples/output/builtin_coverage.md), [n3](examples/n3/builtin_coverage.n3) |
|
|
106
|
-
| <a id="example-collection"></a>[Collection](#example-collection) | compiled from Notation3 by `see.js`; RDF collection/list data with a blank node inside the list. | [doc](examples/doc/collection.md), [js](examples/collection.js), [input](examples/input/collection.trig), [output](examples/output/collection.md), [n3](examples/n3/collection.n3) |
|
|
107
|
-
| <a id="example-complex-numbers"></a>[Complex numbers](#example-complex-numbers) | compiled from Notation3 by `see.js`; complex arithmetic rules and formula-valued entailment. | [doc](examples/doc/complex.md), [js](examples/complex.js), [input](examples/input/complex.trig), [output](examples/output/complex.md), [n3](examples/n3/complex.n3) |
|
|
108
|
-
| <a id="example-complex-matrix-stability"></a>[Complex matrix stability](#example-complex-matrix-stability) | compiled from Notation3 by `see.js`; diagonal 2x2 complex matrices are classified from squared eigenvalue moduli, with complex product and scaling validations. | [doc](examples/doc/complex_matrix_stability.md), [js](examples/complex_matrix_stability.js), [input](examples/input/complex_matrix_stability.trig), [output](examples/output/complex_matrix_stability.md), [n3](examples/n3/complex_matrix_stability.n3) |
|
|
109
|
-
| <a id="example-composition-of-injective-functions"></a>[Composition of injective functions](#example-composition-of-injective-functions) | compiled from Notation3 by `see.js`; proof-style rules show that the composition of injective functions is injective. | [doc](examples/doc/composition_of_injective_functions_is_injective.md), [js](examples/composition_of_injective_functions_is_injective.js), [input](examples/input/composition_of_injective_functions_is_injective.trig), [output](examples/output/composition_of_injective_functions_is_injective.md), [n3](examples/n3/composition_of_injective_functions_is_injective.n3) |
|
|
110
|
-
| <a id="example-control-system"></a>[Control system](#example-control-system) | compiled from Notation3 by `see.js`; compact EYE-style sensor, disturbance, and target facts derive two actuator commands. | [doc](examples/doc/control_system.md), [js](examples/control_system.js), [input](examples/input/control_system.trig), [output](examples/output/control_system.md), [n3](examples/n3/control_system.n3) |
|
|
111
|
-
| <a id="example-crypto-builtin-tests"></a>[Crypto builtin tests](#example-crypto-builtin-tests) | compiled from Notation3 by `see.js`; SHA-1, MD5, SHA-256, and SHA-512 builtin validations become pass facts. | [doc](examples/doc/crypto_builtins_tests.md), [js](examples/crypto_builtins_tests.js), [input](examples/input/crypto_builtins_tests.trig), [output](examples/output/crypto_builtins_tests.md), [n3](examples/n3/crypto_builtins_tests.n3) |
|
|
112
|
-
| <a id="example-dijkstra-shortest-path"></a>[Dijkstra shortest path](#example-dijkstra-shortest-path) | compiled from Notation3 by `see.js`; list, collection, sorting, and recursive backward rules derive the shortest path from `:a` to `:f`. | [doc](examples/doc/dijkstra.md), [js](examples/dijkstra.js), [input](examples/input/dijkstra.trig), [output](examples/output/dijkstra.md), [n3](examples/n3/dijkstra.n3) |
|
|
113
|
-
| <a id="example-dijkstra-risk-path"></a>[Dijkstra risk path](#example-dijkstra-risk-path) | compiled from Notation3 by `see.js`; risk-adjusted route selection derives the best path from edge costs, route risk, and threshold rules. | [doc](examples/doc/dijkstra_risk_path.md), [js](examples/dijkstra_risk_path.js), [input](examples/input/dijkstra_risk_path.trig), [output](examples/output/dijkstra_risk_path.md), [n3](examples/n3/dijkstra_risk_path.n3) |
|
|
114
|
-
| <a id="example-dog-license-example"></a>[Dog license example](#example-dog-license-example) | compiled from Notation3 by `see.js`; `log:collectAllIn` and `math:sum` derive that a multi-dog household needs a license. | [doc](examples/doc/dog.md), [js](examples/dog.js), [input](examples/input/dog.trig), [output](examples/output/dog.md), [n3](examples/n3/dog.n3) |
|
|
115
|
-
| <a id="example-eco-route-insight"></a>[Eco route entailment](#example-eco-route-insight) | compiled from Notation3 by `see.js`; privacy-preserving route evidence derives an eco-route recommendation with signed-envelope explanation data. | [doc](examples/doc/eco_route_insight.md), [js](examples/eco_route_insight.js), [input](examples/input/eco_route_insight.trig), [output](examples/output/eco_route_insight.md), [n3](examples/n3/eco_route_insight.n3) |
|
|
116
|
-
| <a id="example-delfour"></a>[Delfour](#example-delfour) | compiled from Notation3 by `see.js`; scoped policy facts, cryptographic hash validation, and product rules authorize a lower-sugar scanner recommendation. | [doc](examples/doc/delfour.md), [js](examples/delfour.js), [input](examples/input/delfour.trig), [output](examples/output/delfour.md), [n3](examples/n3/delfour.n3) |
|
|
117
|
-
| <a id="example-digital-product-passport"></a>[Digital product passport](#example-digital-product-passport) | compiled from Notation3 by `see.js`; component, document, access-policy, and footprint facts fold into a public passport PASS decision. | [doc](examples/doc/digital_product_passport.md), [js](examples/digital_product_passport.js), [input](examples/input/digital_product_passport.trig), [output](examples/output/digital_product_passport.md), [n3](examples/n3/digital_product_passport.n3) |
|
|
118
|
-
| <a id="example-equals-test"></a>[Equals test](#example-equals-test) | compiled from Notation3 by `see.js`; N3 `=` / `owl:sameAs` shorthand compiled into a normal derivation. | [doc](examples/doc/equals.md), [js](examples/equals.js), [input](examples/input/equals.trig), [output](examples/output/equals.md), [n3](examples/n3/equals.n3) |
|
|
119
|
-
| <a id="example-equivalence-class-overlap"></a>[Equivalence class overlap](#example-equivalence-class-overlap) | compiled from Notation3 by `see.js`; equivalence-relation closure proves overlapping equivalence classes are the same class. | [doc](examples/doc/equivalence_classes_overlap_implies_same_class.md), [js](examples/equivalence_classes_overlap_implies_same_class.js), [input](examples/input/equivalence_classes_overlap_implies_same_class.trig), [output](examples/output/equivalence_classes_overlap_implies_same_class.md), [n3](examples/n3/equivalence_classes_overlap_implies_same_class.n3) |
|
|
120
|
-
| <a id="example-euler-identity"></a>[Euler identity](#example-euler-identity) | compiled from Notation3 by `see.js`; exact integer-style certificate for exp(i*pi) + 1 = 0 with `log:query` projection. | [doc](examples/doc/euler_identity.md), [js](examples/euler_identity.js), [input](examples/input/euler_identity.trig), [output](examples/output/euler_identity.md), [n3](examples/n3/euler_identity.n3) |
|
|
121
|
-
| <a id="example-ev-roadtrip-planner"></a>[EV roadtrip planner](#example-ev-roadtrip-planner) | compiled from Notation3 by `see.js`; EV route candidates are evaluated against belief, cost, duration, and fuel thresholds before selecting the fastest acceptable plan. | [doc](examples/doc/ev_roundtrip_planner.md), [js](examples/ev_roundtrip_planner.js), [input](examples/input/ev_roundtrip_planner.trig), [output](examples/output/ev_roundtrip_planner.md), [n3](examples/n3/ev_roundtrip_planner.n3) |
|
|
122
|
-
| <a id="example-existential-rule"></a>[Existential rule](#example-existential-rule) | compiled from Notation3 by `see.js`; rule-head blank nodes compile into deterministic existential witnesses. | [doc](examples/doc/existential_rule.md), [js](examples/existential_rule.js), [input](examples/input/existential_rule.trig), [output](examples/output/existential_rule.md), [n3](examples/n3/existential_rule.n3) |
|
|
123
|
-
| <a id="example-expression-evaluator"></a>[Expression evaluator](#example-expression-evaluator) | compiled from Notation3 by `see.js`; recursive backward rules evaluate `(2 * 3) + (10 - 4)`. | [doc](examples/doc/expression_eval.md), [js](examples/expression_eval.js), [input](examples/input/expression_eval.trig), [output](examples/output/expression_eval.md), [n3](examples/n3/expression_eval.n3) |
|
|
124
|
-
| <a id="example-family-cousins"></a>[Family cousins](#example-family-cousins) | compiled from Notation3 by `see.js`; family-tree rules derive cousin relationships from parent facts. | [doc](examples/doc/family_cousins.md), [js](examples/family_cousins.js), [input](examples/input/family_cousins.trig), [output](examples/output/family_cousins.md), [n3](examples/n3/family_cousins.n3) |
|
|
125
|
-
| <a id="example-fast-exponentiation"></a>[Fast exponentiation](#example-fast-exponentiation) | compiled from Notation3 by `see.js`; exponentiation, remainder, and recursive backward rules compute fast powers and power towers. | [doc](examples/doc/fastpow.md), [js](examples/fastpow.js), [input](examples/input/fastpow.trig), [output](examples/output/fastpow.md), [n3](examples/n3/fastpow.n3) |
|
|
126
|
-
| <a id="example-fibonacci-big"></a>[Fibonacci example big](#example-fibonacci-big) | compiled from Notation3 by `see.js`; exact Fibonacci target and sample indices are represented as formal TriG evidence and reported through generated rules. | [doc](examples/doc/fibonacci.md), [js](examples/fibonacci.js), [input](examples/input/fibonacci.trig), [output](examples/output/fibonacci.md), [n3](examples/n3/fibonacci.n3) |
|
|
127
|
-
| <a id="example-french-cities"></a>[French cities](#example-french-cities) | compiled from Notation3 by `see.js`; compact graph path traversal with subproperty and transitive-property closure, based on EYE `reasoning/graph`. | [doc](examples/doc/french_cities.md), [js](examples/french_cities.js), [input](examples/input/french_cities.trig), [output](examples/output/french_cities.md), [n3](examples/n3/french_cities.n3) |
|
|
128
|
-
| <a id="example-fundamental-theorem-arithmetic"></a>[Fundamental theorem arithmetic](#example-fundamental-theorem-arithmetic) | compiled from Notation3 by `see.js`; primary factorization is validated by product reconstruction, reverse-order sorting, and prime witnesses, with sample summaries retained as data. | [doc](examples/doc/fundamental_theorem_arithmetic.md), [js](examples/fundamental_theorem_arithmetic.js), [input](examples/input/fundamental_theorem_arithmetic.trig), [output](examples/output/fundamental_theorem_arithmetic.md), [n3](examples/n3/fundamental_theorem_arithmetic.n3) |
|
|
129
|
-
| <a id="example-genetic-knapsack-selection"></a>[Genetic knapsack selection](#example-genetic-knapsack-selection) | compiled from Notation3 by `see.js`; deterministic one-bit mutation candidates are scored against knapsack capacity and value constraints. | [doc](examples/doc/genetic_knapsack_selection.md), [js](examples/genetic_knapsack_selection.js), [input](examples/input/genetic_knapsack_selection.trig), [output](examples/output/genetic_knapsack_selection.md), [n3](examples/n3/genetic_knapsack_selection.n3) |
|
|
130
|
-
| <a id="example-goldbach-1000"></a>[Goldbach 1000](#example-goldbach-1000) | compiled from Notation3 by `see.js`; bounded Goldbach run data is validated through representative prime-sum witnesses and a zero-counterexample condition. | [doc](examples/doc/goldbach_1000.md), [js](examples/goldbach_1000.js), [input](examples/input/goldbach_1000.trig), [output](examples/output/goldbach_1000.md), [n3](examples/n3/goldbach_1000.n3) |
|
|
131
|
-
| <a id="example-good-cobbler"></a>[Good cobbler](#example-good-cobbler) | compiled from Notation3 by `see.js`; term-logic-style list pattern and formula-valued entailment. | [doc](examples/doc/good_cobbler.md), [js](examples/good_cobbler.js), [input](examples/input/good_cobbler.trig), [output](examples/output/good_cobbler.md), [n3](examples/n3/good_cobbler.n3) |
|
|
132
|
-
| <a id="example-gps-route-planning"></a>[GPS route planning](#example-gps-route-planning) | compiled from Notation3 by `see.js`; recursive path rules compare western-Belgium routes by duration, cost, belief, and comfort. | [doc](examples/doc/gps.md), [js](examples/gps.js), [input](examples/input/gps.trig), [output](examples/output/gps.md), [n3](examples/n3/gps.n3) |
|
|
133
|
-
| <a id="example-gray-code-counter"></a>[Gray code counter](#example-gray-code-counter) | compiled from Notation3 by `see.js`; a 4-bit reflected Gray-code cycle is validated as a complete one-bit-transition sequence. | [doc](examples/doc/gray_code_counter.md), [js](examples/gray_code_counter.js), [input](examples/input/gray_code_counter.trig), [output](examples/output/gray_code_counter.md), [n3](examples/n3/gray_code_counter.n3) |
|
|
134
|
-
| <a id="example-greatest-lower-bound-uniqueness"></a>[Greatest lower bound uniqueness](#example-greatest-lower-bound-uniqueness) | compiled from Notation3 by `see.js`; partial-order rules prove two greatest lower bounds of the same pair coincide. | [doc](examples/doc/greatest_lower_bound_uniqueness.md), [js](examples/greatest_lower_bound_uniqueness.js), [input](examples/input/greatest_lower_bound_uniqueness.trig), [output](examples/output/greatest_lower_bound_uniqueness.md), [n3](examples/n3/greatest_lower_bound_uniqueness.n3) |
|
|
135
|
-
| <a id="example-group-inverse-uniqueness"></a>[Group inverse uniqueness](#example-group-inverse-uniqueness) | compiled from Notation3 by `see.js`; group-law rules derive uniqueness of an inverse element. | [doc](examples/doc/group_inverse_uniqueness.md), [js](examples/group_inverse_uniqueness.js), [input](examples/input/group_inverse_uniqueness.trig), [output](examples/output/group_inverse_uniqueness.md), [n3](examples/n3/group_inverse_uniqueness.n3) |
|
|
136
|
-
| <a id="example-hadamard-approximation"></a>[Hadamard approximation](#example-hadamard-approximation) | compiled from Notation3 by `see.js`; dyadic integer bounds certify a Hadamard-gate approximation and project selected results with `log:query`. | [doc](examples/doc/hadamard_approx.md), [js](examples/hadamard_approx.js), [input](examples/input/hadamard_approx.trig), [output](examples/output/hadamard_approx.md), [n3](examples/n3/hadamard_approx.n3) |
|
|
137
|
-
| <a id="example-towers-of-hanoi"></a>[Towers of Hanoi](#example-towers-of-hanoi) | compiled from Notation3 by `see.js`; recursive backward rules and list append produce the three-disk move sequence. | [doc](examples/doc/hanoi.md), [js](examples/hanoi.js), [input](examples/input/hanoi.trig), [output](examples/output/hanoi.md), [n3](examples/n3/hanoi.n3) |
|
|
138
|
-
| <a id="example-odrl-dpv-risk-ranking"></a>[ODRL + DPV risk ranking](#example-odrl-dpv-risk-ranking) | compiled from Notation3 by `see.js`; policy and data-protection evidence are ranked by risk level and selected through rule-derived comparisons. | [doc](examples/doc/odrl_dpv_risk_ranked.md), [js](examples/odrl_dpv_risk_ranked.js), [input](examples/input/odrl_dpv_risk_ranked.trig), [output](examples/output/odrl_dpv_risk_ranked.md), [n3](examples/n3/odrl_dpv_risk_ranked.n3) |
|
|
139
|
-
| <a id="example-path-discovery"></a>[Path discovery](#example-path-discovery) | compiled from the upstream path-discovery rules; the runner loads the full 96k-fact airroutes graph from TriG and evaluates the bounded route query with an indexed adjacency list. | [doc](examples/doc/path_discovery.md), [js](examples/path_discovery.js), [input](examples/input/path-discovery.trig), [output](examples/output/path_discovery.md), [n3](examples/n3/path_discovery.n3) |
|
|
140
|
-
| <a id="example-rc-discharge-envelope"></a>[RC discharge envelope](#example-rc-discharge-envelope) | compiled from Notation3 by `see.js`; exponentiation over an upper decay bound certifies the first sampled capacitor step below tolerance. | [doc](examples/doc/rc_discharge_envelope.md), [js](examples/rc_discharge_envelope.js), [input](examples/input/rc_discharge_envelope.trig), [output](examples/output/rc_discharge_envelope.md), [n3](examples/n3/rc_discharge_envelope.n3) |
|
|
141
|
-
| <a id="example-rdf-dataset-compatibility"></a>[RDF dataset compatibility](#example-rdf-dataset-compatibility) | compiled from Notation3 by `see.js`; RDF/TriG named graph input and RDF 1.2 triple terms demonstrate the same N3 graph-term normalization used by Eyeling's explicit RDF compatibility mode. | [doc](examples/doc/rdf_dataset.md), [js](examples/rdf_dataset.js), [input](examples/input/rdf_dataset.trig), [output](examples/output/rdf_dataset.md), [n3](examples/n3/rdf_dataset.n3) |
|
|
142
|
-
| <a id="example-rdf-message-flow"></a>[RDF Message Flow](#example-rdf-message-flow) | compiled from Notation3 by `see.js`; live RDF Messages advance through ingest, validate, interpret, route, and sink stages, with each completed message releasing the next one. | [doc](examples/doc/rdf_message_flow.md), [js](examples/rdf_message_flow.js), [input](examples/input/rdf_message_flow.trig), [output](examples/output/rdf_message_flow.md), [n3](examples/n3/rdf_message_flow.n3) |
|
|
143
|
-
| <a id="example-rdf-messages"></a>[RDF Messages](#example-rdf-messages) | compiled from Notation3 by `see.js`; ordered RDF Message Log example preserving explicit message boundaries, an empty heartbeat, message-local payloads, and reused blank-node labels. | [doc](examples/doc/rdf_messages.md), [js](examples/rdf_messages.js), [input](examples/input/rdf_messages.trig), [output](examples/output/rdf_messages.md), [n3](examples/n3/rdf_messages.n3) |
|
|
144
|
-
| <a id="example-school-placement-route-audit"></a>[School placement route audit](#example-school-placement-route-audit) | compiled from Notation3 by `see.js`; student, school, distance, and policy facts derive an auditable school-placement route decision. | [doc](examples/doc/school_placement_audit.md), [js](examples/school_placement_audit.js), [input](examples/input/school_placement_audit.trig), [output](examples/output/school_placement_audit.md), [n3](examples/n3/school_placement_audit.n3) |
|
|
145
|
-
| <a id="example-smoke-arithmetic"></a>[Smoke Arithmetic](#example-smoke-arithmetic) | compiled from Notation3 by `see.js`; arithmetic compiler smoke test deriving 6 × 7 through rules and builtins. | [doc](examples/doc/smoke_arithmetic.md), [js](examples/smoke_arithmetic.js), [input](examples/input/smoke_arithmetic.trig), [output](examples/output/smoke_arithmetic.md), [n3](examples/n3/smoke_arithmetic.n3) |
|
|
146
|
-
| <a id="example-socrates-inference"></a>[Socrates inference](#example-socrates-inference) | compiled from Notation3 by `see.js`; subclass closure with top-level `log:query` projection. | [doc](examples/doc/socrates.md), [js](examples/socrates.js), [input](examples/input/socrates.trig), [output](examples/output/socrates.md), [n3](examples/n3/socrates.n3) |
|
|
147
|
-
| <a id="example-triple-terms"></a>[Triple terms](#example-triple-terms) | compiled from Notation3 by `see.js`; RDF 1.2 TriG triple terms are used as input evidence and as a derived entailment. | [doc](examples/doc/triple_terms.md), [js](examples/triple_terms.js), [input](examples/input/triple_terms.trig), [output](examples/output/triple_terms.md), [n3](examples/n3/triple_terms.n3) |
|
|
148
|
-
| <a id="example-wind-turbine-envelope"></a>[Wind turbine envelope](#example-wind-turbine-envelope) | compiled from Notation3 by `see.js`; wind-speed samples are classified against cut-in, rated, and cut-out thresholds and accumulated into energy. | [doc](examples/doc/wind_turbine.md), [js](examples/wind_turbine.js), [input](examples/input/wind_turbine.trig), [output](examples/output/wind_turbine.md), [n3](examples/n3/wind_turbine.n3) |
|
|
149
|
-
| <a id="example-burn-the-witch"></a>[Burn the witch](#example-burn-the-witch) | compiled from Notation3 by `see.js`; rule-chain explanation for the witch entailment. | [doc](examples/doc/witch.md), [js](examples/witch.js), [input](examples/input/witch.trig), [output](examples/output/witch.md), [n3](examples/n3/witch.n3) |
|
package/see/examples/_see.js
DELETED
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const INPUT_DIR = path.join(__dirname, 'input');
|
|
4
|
-
|
|
5
|
-
function iri(value) { return { kind: 'iri', value }; }
|
|
6
|
-
function lit(value) { return { kind: 'lit', value }; }
|
|
7
|
-
function blank(value) { return { kind: 'blank', value }; }
|
|
8
|
-
function list(items) { return { kind: 'list', items }; }
|
|
9
|
-
function formula(atoms) { return { kind: 'formula', atoms }; }
|
|
10
|
-
function triple(s, p, o) { return { kind: 'triple', s, p, o }; }
|
|
11
|
-
|
|
12
|
-
function readTermToken(text, start = 0) {
|
|
13
|
-
let i = start;
|
|
14
|
-
while (/\s/.test(text[i])) i += 1;
|
|
15
|
-
const begin = i;
|
|
16
|
-
if (text.startsWith('<<(', i)) {
|
|
17
|
-
let depth = 0;
|
|
18
|
-
while (i < text.length) {
|
|
19
|
-
if (text[i] === '"') {
|
|
20
|
-
const [, next] = readTermToken(text, i);
|
|
21
|
-
i = next;
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
if (text.startsWith('<<(', i)) { depth += 1; i += 3; continue; }
|
|
25
|
-
if (text.startsWith(')>>', i)) {
|
|
26
|
-
depth -= 1;
|
|
27
|
-
i += 3;
|
|
28
|
-
if (depth === 0) break;
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
i += 1;
|
|
32
|
-
}
|
|
33
|
-
return [text.slice(begin, i), i];
|
|
34
|
-
}
|
|
35
|
-
if (text[i] === '"') {
|
|
36
|
-
i += 1;
|
|
37
|
-
let escaped = false;
|
|
38
|
-
while (i < text.length) {
|
|
39
|
-
const ch = text[i++];
|
|
40
|
-
if (escaped) { escaped = false; continue; }
|
|
41
|
-
if (ch === '\\') { escaped = true; continue; }
|
|
42
|
-
if (ch === '"') break;
|
|
43
|
-
}
|
|
44
|
-
return [text.slice(begin, i), i];
|
|
45
|
-
}
|
|
46
|
-
if (text[i] === '<') {
|
|
47
|
-
i += 1;
|
|
48
|
-
while (i < text.length && text[i] !== '>') i += 1;
|
|
49
|
-
if (text[i] === '>') i += 1;
|
|
50
|
-
return [text.slice(begin, i), i];
|
|
51
|
-
}
|
|
52
|
-
if (text[i] === '(') {
|
|
53
|
-
let depth = 0;
|
|
54
|
-
while (i < text.length) {
|
|
55
|
-
if (text[i] === '"') {
|
|
56
|
-
const [, next] = readTermToken(text, i);
|
|
57
|
-
i = next;
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
if (text[i] === '(') depth += 1;
|
|
61
|
-
else if (text[i] === ')') {
|
|
62
|
-
depth -= 1;
|
|
63
|
-
i += 1;
|
|
64
|
-
if (depth === 0) break;
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
i += 1;
|
|
68
|
-
}
|
|
69
|
-
return [text.slice(begin, i), i];
|
|
70
|
-
}
|
|
71
|
-
while (i < text.length && !/\s/.test(text[i])) i += 1;
|
|
72
|
-
return [text.slice(begin, i), i];
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function stripDot(text) { return String(text || '').replace(/\s*\.\s*$/, '').trim(); }
|
|
76
|
-
function splitListItems(text) {
|
|
77
|
-
const out = [];
|
|
78
|
-
let i = 0;
|
|
79
|
-
while (i < text.length) {
|
|
80
|
-
while (/\s/.test(text[i])) i += 1;
|
|
81
|
-
if (i >= text.length) break;
|
|
82
|
-
const start = i;
|
|
83
|
-
if (text.startsWith('<<(', i)) {
|
|
84
|
-
const [, next] = readTermToken(text, i);
|
|
85
|
-
i = next;
|
|
86
|
-
} else if (text[i] === '"') {
|
|
87
|
-
i += 1;
|
|
88
|
-
let escaped = false;
|
|
89
|
-
while (i < text.length) {
|
|
90
|
-
const ch = text[i++];
|
|
91
|
-
if (escaped) { escaped = false; continue; }
|
|
92
|
-
if (ch === '\\') { escaped = true; continue; }
|
|
93
|
-
if (ch === '"') break;
|
|
94
|
-
}
|
|
95
|
-
} else if (text[i] === '(') {
|
|
96
|
-
let depth = 1; i += 1;
|
|
97
|
-
while (i < text.length && depth) {
|
|
98
|
-
if (text[i] === '(') depth += 1;
|
|
99
|
-
else if (text[i] === ')') depth -= 1;
|
|
100
|
-
i += 1;
|
|
101
|
-
}
|
|
102
|
-
} else {
|
|
103
|
-
while (i < text.length && !/\s/.test(text[i])) i += 1;
|
|
104
|
-
}
|
|
105
|
-
out.push(text.slice(start, i));
|
|
106
|
-
}
|
|
107
|
-
return out;
|
|
108
|
-
}
|
|
109
|
-
function parseTripleTermBody(text) {
|
|
110
|
-
const [s, i1] = readTermToken(text, 0);
|
|
111
|
-
const [p, i2] = readTermToken(text, i1);
|
|
112
|
-
const [o, i3] = readTermToken(text, i2);
|
|
113
|
-
if (!s || !p || !o || text.slice(i3).trim()) throw new Error('bad triple term: ' + text);
|
|
114
|
-
return triple(parseTerm(s), parseTerm(p), parseTerm(o));
|
|
115
|
-
}
|
|
116
|
-
function parseTerm(text) {
|
|
117
|
-
const t = String(text || '').trim();
|
|
118
|
-
if (!t) throw new Error('empty term');
|
|
119
|
-
if (t.startsWith('<<(') && t.endsWith(')>>')) return parseTripleTermBody(t.slice(3, -3).trim());
|
|
120
|
-
const first = t[0];
|
|
121
|
-
if (first === '"') return lit(JSON.parse(t));
|
|
122
|
-
if (first === '(' && t[t.length - 1] === ')') return list(splitListItems(t.slice(1, -1)).map(parseTerm));
|
|
123
|
-
if (t.startsWith('_:')) return blank(t);
|
|
124
|
-
if (first !== '+' && first !== '-' && (first < '0' || first > '9')) {
|
|
125
|
-
if (t === 'true') return lit(true);
|
|
126
|
-
if (t === 'false') return lit(false);
|
|
127
|
-
return iri(t);
|
|
128
|
-
}
|
|
129
|
-
if (/^[+-]?\d+$/.test(t)) return lit(Number.parseInt(t, 10));
|
|
130
|
-
if (/^[+-]?(?:\d+\.\d*|\d*\.\d+|\d+[eE][+-]?\d+)$/.test(t)) return lit(Number(t));
|
|
131
|
-
return iri(t);
|
|
132
|
-
}
|
|
133
|
-
function parseTripleLine(line) {
|
|
134
|
-
const body = stripDot(line);
|
|
135
|
-
const [s, i1] = readTermToken(body, 0);
|
|
136
|
-
const [p, i2] = readTermToken(body, i1);
|
|
137
|
-
const rest = body.slice(i2).trim();
|
|
138
|
-
if (!s || !p || !rest) throw new Error('bad triple: ' + line);
|
|
139
|
-
return { s: parseTerm(s), p: parseTerm(p), o: parseTerm(rest) };
|
|
140
|
-
}
|
|
141
|
-
function parseInputTrigFast(trig) {
|
|
142
|
-
const facts = [];
|
|
143
|
-
const lines = String(trig || '').split(/\r?\n/);
|
|
144
|
-
for (let i = 0; i < lines.length; i += 1) {
|
|
145
|
-
const line = lines[i].trim();
|
|
146
|
-
if (!line || line.startsWith('#') || line.toLowerCase().startsWith('@prefix ') || /^(@version|version)\s+/i.test(line)) continue;
|
|
147
|
-
const graphStart = line.match(/^(\S+)\s*\{\s*$/);
|
|
148
|
-
if (graphStart) {
|
|
149
|
-
const atoms = [];
|
|
150
|
-
for (i += 1; i < lines.length; i += 1) {
|
|
151
|
-
const inner = lines[i].trim();
|
|
152
|
-
if (!inner || inner.startsWith('#')) continue;
|
|
153
|
-
if (/^}\s*\.?\s*$/.test(inner)) break;
|
|
154
|
-
atoms.push(parseTripleLine(inner));
|
|
155
|
-
}
|
|
156
|
-
facts.push({ s: parseTerm(graphStart[1]), p: iri('log:nameOf'), o: formula(atoms) });
|
|
157
|
-
continue;
|
|
158
|
-
}
|
|
159
|
-
if (line.includes('{') || line.includes('}')) throw new Error('unsupported inline formula');
|
|
160
|
-
facts.push(parseTripleLine(line));
|
|
161
|
-
}
|
|
162
|
-
return facts;
|
|
163
|
-
}
|
|
164
|
-
function extractMetadata(facts) {
|
|
165
|
-
const meta = {}, rem = [];
|
|
166
|
-
const map = {
|
|
167
|
-
'see:name': 'Name', 'see:title': 'Title', 'see:sourceFile': 'SourceFile',
|
|
168
|
-
'see:sourceSHA256': 'SourceSHA256', 'see:description': 'Description',
|
|
169
|
-
'see:compiler': 'Compiler', 'see:inputFacts': 'InputFacts',
|
|
170
|
-
'see:compiledRules': 'CompiledRules', 'see:compiledBackwardRules': 'CompiledBackwardRules',
|
|
171
|
-
'see:compiledFuses': 'CompiledFuses', 'see:compiledQueries': 'CompiledQueries'
|
|
172
|
-
};
|
|
173
|
-
for (const f of facts) {
|
|
174
|
-
if (f.s?.value === 'in:metadata' && f.p?.value === 'log:nameOf' && f.o?.kind === 'formula') {
|
|
175
|
-
for (const a of f.o.atoms || []) {
|
|
176
|
-
const k = map[a.p?.value];
|
|
177
|
-
if (k && a.o?.kind === 'lit') meta[k] = a.o.value;
|
|
178
|
-
}
|
|
179
|
-
continue;
|
|
180
|
-
}
|
|
181
|
-
rem.push(f);
|
|
182
|
-
}
|
|
183
|
-
return { meta, facts: rem };
|
|
184
|
-
}
|
|
185
|
-
function inflateFormulaLinks(facts) {
|
|
186
|
-
const by = new Map();
|
|
187
|
-
for (const f of facts) if (/^in:formula\d+$/.test(f.s?.value || '') && f.p?.value === 'log:nameOf' && f.o?.kind === 'formula') by.set(f.s.value, f.o);
|
|
188
|
-
if (!by.size) return facts;
|
|
189
|
-
const out = [];
|
|
190
|
-
for (const f of facts) {
|
|
191
|
-
if (by.has(f.s?.value || '') && f.p?.value === 'log:nameOf') continue;
|
|
192
|
-
if (by.has(f.o?.value || '')) { out.push({ ...f, o: by.get(f.o.value) }); continue; }
|
|
193
|
-
out.push(f);
|
|
194
|
-
}
|
|
195
|
-
return out;
|
|
196
|
-
}
|
|
197
|
-
function inputNameCandidates(name) {
|
|
198
|
-
const out = [name];
|
|
199
|
-
const dashed = name.replace(/_/g, '-');
|
|
200
|
-
if (!out.includes(dashed)) out.push(dashed);
|
|
201
|
-
return out;
|
|
202
|
-
}
|
|
203
|
-
function inputFactsFromTrigText(trig) {
|
|
204
|
-
const m = String(trig || '').match(/\bsee:inputFacts\s+([0-9]+)\s*\./);
|
|
205
|
-
return m ? Number.parseInt(m[1], 10) : null;
|
|
206
|
-
}
|
|
207
|
-
function inputCandidateScore(file) {
|
|
208
|
-
try {
|
|
209
|
-
const stat = fs.statSync(file);
|
|
210
|
-
const text = fs.readFileSync(file, 'utf8');
|
|
211
|
-
const facts = inputFactsFromTrigText(text);
|
|
212
|
-
return { facts: facts ?? -1, size: stat.size };
|
|
213
|
-
} catch (_) {
|
|
214
|
-
return { facts: -1, size: -1 };
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
function inputBase(name) {
|
|
218
|
-
const candidates = inputNameCandidates(name)
|
|
219
|
-
.map((base, order) => ({ base, order, file: path.join(INPUT_DIR, `${base}.trig`) }))
|
|
220
|
-
.filter((c) => fs.existsSync(c.file))
|
|
221
|
-
.map((c) => ({ ...c, score: inputCandidateScore(c.file) }));
|
|
222
|
-
if (!candidates.length) return name;
|
|
223
|
-
candidates.sort((a, b) =>
|
|
224
|
-
(b.score.facts - a.score.facts) ||
|
|
225
|
-
(b.score.size - a.score.size) ||
|
|
226
|
-
(a.order - b.order)
|
|
227
|
-
);
|
|
228
|
-
return candidates[0].base;
|
|
229
|
-
}
|
|
230
|
-
function parseInput(trig) { return parseInputTrigFast(trig); }
|
|
231
|
-
function loadInput(name) {
|
|
232
|
-
const base = inputBase(name);
|
|
233
|
-
const trigFile = path.join(INPUT_DIR, `${base}.trig`);
|
|
234
|
-
const trig = fs.readFileSync(trigFile, 'utf8');
|
|
235
|
-
const ex = extractMetadata(parseInput(trig));
|
|
236
|
-
return { __see: ex.meta, facts: inflateFormulaLinks(ex.facts), trig };
|
|
237
|
-
}
|
|
238
|
-
function emit(l = '') { process.stdout.write(l ? `${l} \n` : '\n'); }
|
|
239
|
-
function emitLines(ls) { for (const l of ls) emit(l); }
|
|
240
|
-
function fail(p, o) { const f = Object.entries(o).filter(([, ok]) => !ok).map(([n]) => n); if (f.length) throw new Error(`${p}: ${f.join(', ')}`); }
|
|
241
|
-
function sum(v) { return v.reduce((a, b) => a + b, 0); }
|
|
242
|
-
function compareKeys(a, b) { const aa = Array.isArray(a) ? a : [a], bb = Array.isArray(b) ? b : [b], n = Math.min(aa.length, bb.length); for (let i = 0; i < n; i += 1) { if (aa[i] < bb[i]) return -1; if (aa[i] > bb[i]) return 1; } return aa.length - bb.length; }
|
|
243
|
-
function minBy(v, k) { let best = v[0], bk = k(best); for (let i = 1; i < v.length; i += 1) { const kk = k(v[i]); if (compareKeys(kk, bk) < 0) { best = v[i]; bk = kk; } } return best; }
|
|
244
|
-
function maxBy(v, k) { let best = v[0], bk = k(best); for (let i = 1; i < v.length; i += 1) { const kk = k(v[i]); if (compareKeys(kk, bk) > 0) { best = v[i]; bk = kk; } } return best; }
|
|
245
|
-
function range(start, stop, step = 1) { if (stop === undefined) { stop = start; start = 0; } const o = []; for (let i = start; step > 0 ? i < stop : i > stop; i += step) o.push(i); return o; }
|
|
246
|
-
function roundTo(v, d = 0) { const f = 10 ** d; return Math.round((v + Number.EPSILON) * f) / f; }
|
|
247
|
-
function boolText(v) { return v ? 'true' : 'false'; }
|
|
248
|
-
|
|
249
|
-
module.exports = { loadInput, emit, emitLines, fail, sum, minBy, maxBy, compareKeys, range, roundTo, boolText };
|