eyeling 1.24.0 → 1.24.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 +4 -4
- package/package.json +1 -1
- package/see/README.md +10 -11
- package/see/examples/age.js +10 -10
- package/see/examples/annotation.js +10 -10
- package/see/examples/backward.js +10 -10
- package/see/examples/backward_recursion.js +10 -10
- package/see/examples/bayes_diagnosis.js +10 -10
- package/see/examples/bayes_therapy.js +10 -10
- package/see/examples/bmi.js +10 -10
- package/see/examples/builtin_coverage.js +10 -10
- package/see/examples/collection.js +10 -10
- package/see/examples/complex.js +10 -10
- package/see/examples/complex_matrix_stability.js +10 -10
- package/see/examples/composition_of_injective_functions_is_injective.js +10 -10
- package/see/examples/control_system.js +10 -10
- package/see/examples/crypto_builtins_tests.js +10 -10
- package/see/examples/delfour.js +10 -10
- package/see/examples/digital_product_passport.js +10 -10
- package/see/examples/dijkstra.js +10 -10
- package/see/examples/dijkstra_risk_path.js +10 -10
- package/see/examples/doc/age.md +1 -1
- package/see/examples/doc/annotation.md +1 -1
- package/see/examples/doc/backward.md +1 -1
- package/see/examples/doc/backward_recursion.md +1 -1
- package/see/examples/doc/bayes_diagnosis.md +1 -1
- package/see/examples/doc/bayes_therapy.md +1 -1
- package/see/examples/doc/bmi.md +1 -1
- package/see/examples/doc/builtin_coverage.md +1 -1
- package/see/examples/doc/collection.md +1 -1
- package/see/examples/doc/complex.md +1 -1
- package/see/examples/doc/complex_matrix_stability.md +1 -1
- package/see/examples/doc/composition_of_injective_functions_is_injective.md +1 -1
- package/see/examples/doc/control_system.md +1 -1
- package/see/examples/doc/crypto_builtins_tests.md +1 -1
- package/see/examples/doc/delfour.md +1 -1
- package/see/examples/doc/digital_product_passport.md +1 -1
- package/see/examples/doc/dijkstra.md +1 -1
- package/see/examples/doc/dijkstra_risk_path.md +1 -1
- package/see/examples/doc/dog.md +1 -1
- package/see/examples/doc/eco_route_insight.md +1 -1
- package/see/examples/doc/equals.md +1 -1
- package/see/examples/doc/equivalence_classes_overlap_implies_same_class.md +1 -1
- package/see/examples/doc/euler_identity.md +1 -1
- package/see/examples/doc/ev_roundtrip_planner.md +1 -1
- package/see/examples/doc/existential_rule.md +1 -1
- package/see/examples/doc/expression_eval.md +1 -1
- package/see/examples/doc/family_cousins.md +1 -1
- package/see/examples/doc/fastpow.md +1 -1
- package/see/examples/doc/fibonacci.md +1 -1
- package/see/examples/doc/french_cities.md +1 -1
- package/see/examples/doc/fundamental_theorem_arithmetic.md +1 -1
- package/see/examples/doc/genetic_knapsack_selection.md +1 -1
- package/see/examples/doc/goldbach_1000.md +1 -1
- package/see/examples/doc/good_cobbler.md +1 -1
- package/see/examples/doc/gps.md +1 -1
- package/see/examples/doc/gray_code_counter.md +1 -1
- package/see/examples/doc/greatest_lower_bound_uniqueness.md +1 -1
- package/see/examples/doc/group_inverse_uniqueness.md +1 -1
- package/see/examples/doc/hadamard_approx.md +1 -1
- package/see/examples/doc/hanoi.md +1 -1
- package/see/examples/doc/odrl_dpv_risk_ranked.md +1 -1
- package/see/examples/doc/path_discovery.md +1 -1
- package/see/examples/doc/rc_discharge_envelope.md +1 -1
- package/see/examples/doc/rdf_message_flow.md +1 -1
- package/see/examples/doc/rdf_messages.md +1 -1
- package/see/examples/doc/school_placement_audit.md +1 -1
- package/see/examples/doc/smoke_arithmetic.md +1 -1
- package/see/examples/doc/socrates.md +1 -1
- package/see/examples/doc/wind_turbine.md +1 -1
- package/see/examples/doc/witch.md +1 -1
- package/see/examples/dog.js +10 -10
- package/see/examples/eco_route_insight.js +10 -10
- package/see/examples/equals.js +10 -10
- package/see/examples/equivalence_classes_overlap_implies_same_class.js +10 -10
- package/see/examples/euler_identity.js +10 -10
- package/see/examples/ev_roundtrip_planner.js +10 -10
- package/see/examples/existential_rule.js +10 -10
- package/see/examples/expression_eval.js +10 -10
- package/see/examples/family_cousins.js +10 -10
- package/see/examples/fastpow.js +10 -10
- package/see/examples/fibonacci.js +10 -10
- package/see/examples/french_cities.js +10 -10
- package/see/examples/fundamental_theorem_arithmetic.js +10 -10
- package/see/examples/genetic_knapsack_selection.js +10 -10
- package/see/examples/goldbach_1000.js +10 -10
- package/see/examples/good_cobbler.js +10 -10
- package/see/examples/gps.js +10 -10
- package/see/examples/gray_code_counter.js +10 -10
- package/see/examples/greatest_lower_bound_uniqueness.js +10 -10
- package/see/examples/group_inverse_uniqueness.js +10 -10
- package/see/examples/hadamard_approx.js +10 -10
- package/see/examples/hanoi.js +10 -10
- package/see/examples/odrl_dpv_risk_ranked.js +10 -10
- package/see/examples/output/age.md +3 -3
- package/see/examples/output/annotation.md +4 -4
- package/see/examples/output/backward.md +3 -3
- package/see/examples/output/backward_recursion.md +3 -3
- package/see/examples/output/bayes_diagnosis.md +1 -1
- package/see/examples/output/bayes_therapy.md +1 -1
- package/see/examples/output/bmi.md +1 -1
- package/see/examples/output/builtin_coverage.md +3 -3
- package/see/examples/output/collection.md +3 -3
- package/see/examples/output/complex.md +4 -4
- package/see/examples/output/complex_matrix_stability.md +1 -1
- package/see/examples/output/composition_of_injective_functions_is_injective.md +3 -3
- package/see/examples/output/control_system.md +3 -3
- package/see/examples/output/crypto_builtins_tests.md +3 -3
- package/see/examples/output/delfour.md +1 -1
- package/see/examples/output/digital_product_passport.md +1 -1
- package/see/examples/output/dijkstra.md +3 -3
- package/see/examples/output/dijkstra_risk_path.md +1 -1
- package/see/examples/output/dog.md +3 -3
- package/see/examples/output/eco_route_insight.md +1 -1
- package/see/examples/output/equals.md +3 -3
- package/see/examples/output/equivalence_classes_overlap_implies_same_class.md +3 -3
- package/see/examples/output/euler_identity.md +3 -3
- package/see/examples/output/ev_roundtrip_planner.md +1 -1
- package/see/examples/output/existential_rule.md +3 -3
- package/see/examples/output/expression_eval.md +3 -3
- package/see/examples/output/family_cousins.md +3 -3
- package/see/examples/output/fastpow.md +1 -1
- package/see/examples/output/fibonacci.md +1 -1
- package/see/examples/output/french_cities.md +3 -3
- package/see/examples/output/fundamental_theorem_arithmetic.md +1 -1
- package/see/examples/output/genetic_knapsack_selection.md +1 -1
- package/see/examples/output/goldbach_1000.md +1 -1
- package/see/examples/output/good_cobbler.md +4 -4
- package/see/examples/output/gps.md +1 -1
- package/see/examples/output/gray_code_counter.md +1 -1
- package/see/examples/output/greatest_lower_bound_uniqueness.md +3 -3
- package/see/examples/output/group_inverse_uniqueness.md +3 -3
- package/see/examples/output/hadamard_approx.md +3 -3
- package/see/examples/output/hanoi.md +3 -3
- package/see/examples/output/odrl_dpv_risk_ranked.md +3 -3
- package/see/examples/output/path_discovery.md +3 -3
- package/see/examples/output/rc_discharge_envelope.md +1 -1
- package/see/examples/output/rdf_message_flow.md +1 -1
- package/see/examples/output/rdf_messages.md +1 -1
- package/see/examples/output/school_placement_audit.md +1 -1
- package/see/examples/output/smoke_arithmetic.md +1 -1
- package/see/examples/output/socrates.md +3 -3
- package/see/examples/output/wind_turbine.md +1 -1
- package/see/examples/output/witch.md +3 -3
- package/see/examples/path_discovery.js +10 -10
- package/see/examples/rc_discharge_envelope.js +10 -10
- package/see/examples/rdf_message_flow.js +10 -10
- package/see/examples/rdf_messages.js +10 -10
- package/see/examples/school_placement_audit.js +10 -10
- package/see/examples/smoke_arithmetic.js +10 -10
- package/see/examples/socrates.js +10 -10
- package/see/examples/wind_turbine.js +10 -10
- package/see/examples/witch.js +10 -10
- package/see/see.js +381 -93
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ echo '@prefix : <http://example.org/> .
|
|
|
14
14
|
|
|
15
15
|
## Read more
|
|
16
16
|
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
17
|
+
- [Handbook](https://eyereasoner.github.io/eyeling/HANDBOOK)
|
|
18
|
+
- [Playground](https://eyereasoner.github.io/eyeling/demo)
|
|
19
|
+
- [SEE: Specialized Eyeling Executables](https://github.com/eyereasoner/eyeling/tree/main/see)
|
|
20
|
+
- [Conformance report](https://codeberg.org/phochste/notation3tests/src/branch/main/reports/report.md)
|
package/package.json
CHANGED
package/see/README.md
CHANGED
|
@@ -5,20 +5,19 @@
|
|
|
5
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
6
|
|
|
7
7
|
```text
|
|
8
|
-
input facts -> rules -> trust gate ->
|
|
8
|
+
input facts -> rules -> trust gate -> entailment + explanation
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
Each example starts from a Notation3 source and is compiled by `see.js` into a small Node.js program:
|
|
12
12
|
|
|
13
13
|
- `examples/n3/<name>.n3` contains the N3 facts, rules, gates, and query.
|
|
14
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
|
|
15
|
+
- `examples/<name>.js` is generated by `see.js` and derives the entailment.
|
|
16
16
|
- `examples/output/<name>.md` is the reference Markdown output used by `npm run test:see`.
|
|
17
17
|
- `examples/doc/<name>.md` explains the compiled example.
|
|
18
18
|
|
|
19
|
-
The trust gate is executable verification. If a required fact is missing, the program fails instead of emitting an unsupported
|
|
19
|
+
The trust gate is executable verification. If a required fact is missing, the program fails instead of emitting an unsupported entailment.
|
|
20
20
|
|
|
21
|
-
SEE was largely inspired by Prof. Ruben Verborgh's essay [Inside the Insight Economy](https://ruben.verborgh.org/blog/2025/08/12/inside-the-insight-economy/).
|
|
22
21
|
|
|
23
22
|
## Run
|
|
24
23
|
|
|
@@ -72,7 +71,7 @@ Validate that the source is inside the supported compiler subset:
|
|
|
72
71
|
node see/see.js inspect path/to/example.n3
|
|
73
72
|
```
|
|
74
73
|
|
|
75
|
-
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 **
|
|
74
|
+
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.
|
|
76
75
|
|
|
77
76
|
## Files
|
|
78
77
|
|
|
@@ -81,7 +80,7 @@ examples/
|
|
|
81
80
|
<name>.js executable example
|
|
82
81
|
_see.js shared helper
|
|
83
82
|
input/<name>.trig formal RDF 1.2 TriG evidence
|
|
84
|
-
output/<name>.md reference
|
|
83
|
+
output/<name>.md reference entailment and explanation
|
|
85
84
|
doc/<name>.md guide
|
|
86
85
|
n3/<name>.n3 Notation3 source
|
|
87
86
|
```
|
|
@@ -103,7 +102,7 @@ The repository currently contains **50 N3-compiled SEE examples**. Each example
|
|
|
103
102
|
| <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) |
|
|
104
103
|
| <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) |
|
|
105
104
|
| <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) |
|
|
106
|
-
| <a id="example-complex-numbers"></a>[Complex numbers](#example-complex-numbers) | compiled from Notation3 by `see.js`; complex arithmetic rules and formula-valued
|
|
105
|
+
| <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) |
|
|
107
106
|
| <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) |
|
|
108
107
|
| <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) |
|
|
109
108
|
| <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,8 +110,8 @@ The repository currently contains **50 N3-compiled SEE examples**. Each example
|
|
|
111
110
|
| <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) |
|
|
112
111
|
| <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) |
|
|
113
112
|
| <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) |
|
|
114
|
-
| <a id="example-eco-route-insight"></a>[Eco route
|
|
115
|
-
| <a id="example-delfour"></a>[Delfour](#example-delfour) | compiled from Notation3 by `see.js`; scoped
|
|
113
|
+
| <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) |
|
|
114
|
+
| <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) |
|
|
116
115
|
| <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) |
|
|
117
116
|
| <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) |
|
|
118
117
|
| <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) |
|
|
@@ -127,7 +126,7 @@ The repository currently contains **50 N3-compiled SEE examples**. Each example
|
|
|
127
126
|
| <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) |
|
|
128
127
|
| <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) |
|
|
129
128
|
| <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) |
|
|
130
|
-
| <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
|
|
129
|
+
| <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) |
|
|
131
130
|
| <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) |
|
|
132
131
|
| <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) |
|
|
133
132
|
| <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) |
|
|
@@ -143,4 +142,4 @@ The repository currently contains **50 N3-compiled SEE examples**. Each example
|
|
|
143
142
|
| <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) |
|
|
144
143
|
| <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) |
|
|
145
144
|
| <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) |
|
|
146
|
-
| <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
|
|
145
|
+
| <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/age.js
CHANGED
|
@@ -1040,19 +1040,19 @@ function renderStructuredOutput({ title, graph, queries = [], rules = [], initia
|
|
|
1040
1040
|
const lines = [];
|
|
1041
1041
|
lines.push('# ' + title);
|
|
1042
1042
|
lines.push('');
|
|
1043
|
-
lines.push('##
|
|
1043
|
+
lines.push('## Entailment');
|
|
1044
1044
|
if (mode === 'query') {
|
|
1045
1045
|
lines.push('The compiled query selected ' + selected.length + ' fact(s) after the rule closure was computed.');
|
|
1046
1046
|
} else if (mode === 'formula') {
|
|
1047
|
-
lines.push('The derivation produced ' + selected.length + ' formula-valued
|
|
1047
|
+
lines.push('The derivation produced ' + selected.length + ' formula-valued entailment(s).');
|
|
1048
1048
|
} else {
|
|
1049
1049
|
lines.push('The derivation produced ' + derived.length + ' new fact(s) from ' + initialFacts.length + ' stated fact(s).');
|
|
1050
1050
|
}
|
|
1051
|
-
if (keyFact) lines.push('Main
|
|
1051
|
+
if (keyFact) lines.push('Main entailment: **' + factSentence(keyFact) + '**');
|
|
1052
1052
|
const bullets = selected.slice(-6).reverse();
|
|
1053
1053
|
if (bullets.length) {
|
|
1054
1054
|
lines.push('');
|
|
1055
|
-
lines.push('Selected
|
|
1055
|
+
lines.push('Selected entailments:');
|
|
1056
1056
|
for (const fact of bullets) lines.push('- ' + codeFact(fact));
|
|
1057
1057
|
}
|
|
1058
1058
|
lines.push('');
|
|
@@ -1114,15 +1114,15 @@ function dedupeExplanationHeadings(text) {
|
|
|
1114
1114
|
function normalizePublicReport(markdown, title) {
|
|
1115
1115
|
let text = String(markdown || '').trimEnd();
|
|
1116
1116
|
if (!/^\s*#\s+/m.test(text)) text = '# ' + title + '\n\n' + text;
|
|
1117
|
-
if (!/^##\s+
|
|
1118
|
-
text = text.replace(/^(#\s+[^\n]+\n*)/, '$1\n##
|
|
1117
|
+
if (!/^##\s+Entailment\s*$/mi.test(text)) {
|
|
1118
|
+
text = text.replace(/^(#\s+[^\n]+\n*)/, '$1\n## Entailment\n');
|
|
1119
1119
|
}
|
|
1120
1120
|
if (!/^##\s+Explanation\s*$/mi.test(text)) {
|
|
1121
1121
|
text += '\n\n## Explanation\nNo additional explanation was provided by the generated output.';
|
|
1122
1122
|
}
|
|
1123
1123
|
text = text.replace(/^##\s+([^\n]+?)\s*$/gm, (line, heading) => {
|
|
1124
1124
|
const normalized = heading.trim().toLowerCase();
|
|
1125
|
-
if (normalized === 'insight' || normalized === 'explanation') return '## ' + (normalized === '
|
|
1125
|
+
if (normalized === 'insight' || normalized === 'conclusion' || normalized === 'entailment' || normalized === 'explanation') return '## ' + (normalized === 'explanation' ? 'Explanation' : 'Entailment');
|
|
1126
1126
|
return '**' + heading.trim() + '**';
|
|
1127
1127
|
});
|
|
1128
1128
|
text = dedupeExplanationHeadings(text);
|
|
@@ -1131,13 +1131,13 @@ function normalizePublicReport(markdown, title) {
|
|
|
1131
1131
|
function markdownize(raw, title) {
|
|
1132
1132
|
let text = String(raw || '');
|
|
1133
1133
|
text = text
|
|
1134
|
-
.replace(/===\s*Answer\s*===/g, '##
|
|
1134
|
+
.replace(/===\s*Answer\s*===/g, '## Entailment')
|
|
1135
1135
|
.replace(/===\s*Reason\s+Why\s*===/gi, '## Explanation')
|
|
1136
1136
|
.replace(/===\s*Explanation\s*===/gi, '## Explanation')
|
|
1137
1137
|
.replace(/===\s*([^=]+?)\s*===/g, (_, h) => '**' + h.trim() + '**');
|
|
1138
1138
|
text = text.replace(/^C(\d+)\s+OK\s*-\s*/gm, 'C$1: ');
|
|
1139
1139
|
text = dedupeExplanationHeadings(text);
|
|
1140
|
-
if (!text.trim()) text = '##
|
|
1140
|
+
if (!text.trim()) text = '## Entailment\nNo log:outputString facts were derived.\n\n## Explanation\nThe compiled derivation did not produce authored report text.';
|
|
1141
1141
|
return normalizePublicReport(text, title);
|
|
1142
1142
|
}
|
|
1143
1143
|
function authoredSupportAppendix(graph, queries, rules, initialFacts, trace) {
|
|
@@ -1334,7 +1334,7 @@ const QUERIES = [
|
|
|
1334
1334
|
]
|
|
1335
1335
|
}
|
|
1336
1336
|
];
|
|
1337
|
-
const DOC_MARKDOWN = "# Age checker\n\nGenerated by `see.js` from a Notation3 source file.\n\nIs the age of a person above some duration?\n\n## Compilation summary\n\n- Example name: `age`\n- Input facts emitted: 1\n- Forward rules compiled: 0\n- Backward predicate rules compiled: 1\n- Fuses compiled: 0\n- Predicate count: 6\n\n## Built-ins used\n\n- `math:difference`\n- `math:greaterThan`\n\n## Runtime model\n\nThe generated `examples/age.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/age.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/age.trig` or `examples/input/age.trig`. The runner reads that TriG evidence directly and performs a local fixpoint derivation; it does not parse the program source or call an external reasoner.\n\n## Output model\n\nRunning `node examples/age.js` produces a SEE-style Markdown report with an **
|
|
1337
|
+
const DOC_MARKDOWN = "# Age checker\n\nGenerated by `see.js` from a Notation3 source file.\n\nIs the age of a person above some duration?\n\n## Compilation summary\n\n- Example name: `age`\n- Input facts emitted: 1\n- Forward rules compiled: 0\n- Backward predicate rules compiled: 1\n- Fuses compiled: 0\n- Predicate count: 6\n\n## Built-ins used\n\n- `math:difference`\n- `math:greaterThan`\n\n## Runtime model\n\nThe generated `examples/age.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/age.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/age.trig` or `examples/input/age.trig`. The runner reads that TriG evidence directly and performs a local fixpoint derivation; it does not parse the program source or call an external reasoner.\n\n## Output model\n\nRunning `node examples/age.js` produces a SEE-style Markdown report with an **Entailment** section, an **Explanation** section, and a **Formal TriG Output** section containing the selected derived/query facts.\n";
|
|
1338
1338
|
function seeMetadata(data) { return (data && data.__see) || {}; }
|
|
1339
1339
|
function trustedDerivation(data) { const meta = seeMetadata(data); const facts = data && Array.isArray(data.facts) ? data.facts : []; const expectedFacts = EXPECTED_INPUT_FACTS || Number(meta.InputFacts || 0); if (meta.SourceSHA256 && meta.SourceSHA256 !== "bf52bb918b595bb68a0a6304729e8129f3a851dc16cd3980ec5932115f2e7aea") throw new Error('input evidence does not match the N3 source compiled into this example'); const result = saturate(facts, RULES); const rawOutput = renderRawOutput(result.graph, QUERIES, RULES, facts); fail('Compiled N3 derivation failed', { 'input evidence metadata is present and matches compiled source': meta.SourceSHA256 === "bf52bb918b595bb68a0a6304729e8129f3a851dc16cd3980ec5932115f2e7aea", 'input evidence facts were loaded': expectedFacts > 0 ? facts.length === expectedFacts : facts.length >= 0, 'compiled rules were loaded': RULES.length === 1, 'compiled query directives were loaded': QUERIES.length === 1, 'a derivation fixpoint was reached': result.graph.facts.length >= facts.length, 'query or output facts were produced': rawOutput.length > 0 }); return { ...result, rawOutput, inputFacts: facts }; }
|
|
1340
1340
|
function snapshotMarkdown(markdown) { return markdown.split(/\n/).map((line) => line ? line + ' \n' : '\n').join(''); }
|
|
@@ -1040,19 +1040,19 @@ function renderStructuredOutput({ title, graph, queries = [], rules = [], initia
|
|
|
1040
1040
|
const lines = [];
|
|
1041
1041
|
lines.push('# ' + title);
|
|
1042
1042
|
lines.push('');
|
|
1043
|
-
lines.push('##
|
|
1043
|
+
lines.push('## Entailment');
|
|
1044
1044
|
if (mode === 'query') {
|
|
1045
1045
|
lines.push('The compiled query selected ' + selected.length + ' fact(s) after the rule closure was computed.');
|
|
1046
1046
|
} else if (mode === 'formula') {
|
|
1047
|
-
lines.push('The derivation produced ' + selected.length + ' formula-valued
|
|
1047
|
+
lines.push('The derivation produced ' + selected.length + ' formula-valued entailment(s).');
|
|
1048
1048
|
} else {
|
|
1049
1049
|
lines.push('The derivation produced ' + derived.length + ' new fact(s) from ' + initialFacts.length + ' stated fact(s).');
|
|
1050
1050
|
}
|
|
1051
|
-
if (keyFact) lines.push('Main
|
|
1051
|
+
if (keyFact) lines.push('Main entailment: **' + factSentence(keyFact) + '**');
|
|
1052
1052
|
const bullets = selected.slice(-6).reverse();
|
|
1053
1053
|
if (bullets.length) {
|
|
1054
1054
|
lines.push('');
|
|
1055
|
-
lines.push('Selected
|
|
1055
|
+
lines.push('Selected entailments:');
|
|
1056
1056
|
for (const fact of bullets) lines.push('- ' + codeFact(fact));
|
|
1057
1057
|
}
|
|
1058
1058
|
lines.push('');
|
|
@@ -1114,15 +1114,15 @@ function dedupeExplanationHeadings(text) {
|
|
|
1114
1114
|
function normalizePublicReport(markdown, title) {
|
|
1115
1115
|
let text = String(markdown || '').trimEnd();
|
|
1116
1116
|
if (!/^\s*#\s+/m.test(text)) text = '# ' + title + '\n\n' + text;
|
|
1117
|
-
if (!/^##\s+
|
|
1118
|
-
text = text.replace(/^(#\s+[^\n]+\n*)/, '$1\n##
|
|
1117
|
+
if (!/^##\s+Entailment\s*$/mi.test(text)) {
|
|
1118
|
+
text = text.replace(/^(#\s+[^\n]+\n*)/, '$1\n## Entailment\n');
|
|
1119
1119
|
}
|
|
1120
1120
|
if (!/^##\s+Explanation\s*$/mi.test(text)) {
|
|
1121
1121
|
text += '\n\n## Explanation\nNo additional explanation was provided by the generated output.';
|
|
1122
1122
|
}
|
|
1123
1123
|
text = text.replace(/^##\s+([^\n]+?)\s*$/gm, (line, heading) => {
|
|
1124
1124
|
const normalized = heading.trim().toLowerCase();
|
|
1125
|
-
if (normalized === 'insight' || normalized === 'explanation') return '## ' + (normalized === '
|
|
1125
|
+
if (normalized === 'insight' || normalized === 'conclusion' || normalized === 'entailment' || normalized === 'explanation') return '## ' + (normalized === 'explanation' ? 'Explanation' : 'Entailment');
|
|
1126
1126
|
return '**' + heading.trim() + '**';
|
|
1127
1127
|
});
|
|
1128
1128
|
text = dedupeExplanationHeadings(text);
|
|
@@ -1131,13 +1131,13 @@ function normalizePublicReport(markdown, title) {
|
|
|
1131
1131
|
function markdownize(raw, title) {
|
|
1132
1132
|
let text = String(raw || '');
|
|
1133
1133
|
text = text
|
|
1134
|
-
.replace(/===\s*Answer\s*===/g, '##
|
|
1134
|
+
.replace(/===\s*Answer\s*===/g, '## Entailment')
|
|
1135
1135
|
.replace(/===\s*Reason\s+Why\s*===/gi, '## Explanation')
|
|
1136
1136
|
.replace(/===\s*Explanation\s*===/gi, '## Explanation')
|
|
1137
1137
|
.replace(/===\s*([^=]+?)\s*===/g, (_, h) => '**' + h.trim() + '**');
|
|
1138
1138
|
text = text.replace(/^C(\d+)\s+OK\s*-\s*/gm, 'C$1: ');
|
|
1139
1139
|
text = dedupeExplanationHeadings(text);
|
|
1140
|
-
if (!text.trim()) text = '##
|
|
1140
|
+
if (!text.trim()) text = '## Entailment\nNo log:outputString facts were derived.\n\n## Explanation\nThe compiled derivation did not produce authored report text.';
|
|
1141
1141
|
return normalizePublicReport(text, title);
|
|
1142
1142
|
}
|
|
1143
1143
|
function authoredSupportAppendix(graph, queries, rules, initialFacts, trace) {
|
|
@@ -1195,7 +1195,7 @@ const TITLE = "Annotation";
|
|
|
1195
1195
|
const EXPECTED_INPUT_FACTS = 4;
|
|
1196
1196
|
const RULES = [];
|
|
1197
1197
|
const QUERIES = [];
|
|
1198
|
-
const DOC_MARKDOWN = "# Annotation\n\nGenerated by `see.js` from a Notation3 source file.\n\n## Compilation summary\n\n- Example name: `annotation`\n- Input facts emitted: 4\n- Forward rules compiled: 0\n- Backward predicate rules compiled: 0\n- Fuses compiled: 0\n- Predicate count: 4\n\n## Built-ins used\n\n- `log:nameOf`\n\n## Runtime model\n\nThe generated `examples/annotation.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/annotation.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/annotation.trig` or `examples/input/annotation.trig`. The runner reads that TriG evidence directly and performs a local fixpoint derivation; it does not parse the program source or call an external reasoner.\n\n## Output model\n\nRunning `node examples/annotation.js` produces a SEE-style Markdown report with an **
|
|
1198
|
+
const DOC_MARKDOWN = "# Annotation\n\nGenerated by `see.js` from a Notation3 source file.\n\n## Compilation summary\n\n- Example name: `annotation`\n- Input facts emitted: 4\n- Forward rules compiled: 0\n- Backward predicate rules compiled: 0\n- Fuses compiled: 0\n- Predicate count: 4\n\n## Built-ins used\n\n- `log:nameOf`\n\n## Runtime model\n\nThe generated `examples/annotation.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/annotation.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/annotation.trig` or `examples/input/annotation.trig`. The runner reads that TriG evidence directly and performs a local fixpoint derivation; it does not parse the program source or call an external reasoner.\n\n## Output model\n\nRunning `node examples/annotation.js` produces a SEE-style Markdown report with an **Entailment** section, an **Explanation** section, and a **Formal TriG Output** section containing the selected derived/query facts.\n";
|
|
1199
1199
|
function seeMetadata(data) { return (data && data.__see) || {}; }
|
|
1200
1200
|
function trustedDerivation(data) { const meta = seeMetadata(data); const facts = data && Array.isArray(data.facts) ? data.facts : []; const expectedFacts = EXPECTED_INPUT_FACTS || Number(meta.InputFacts || 0); if (meta.SourceSHA256 && meta.SourceSHA256 !== "fa6faef8fac2e328ccfb894c21eef260b0935a936b5e9806f8889719e7f39e4f") throw new Error('input evidence does not match the N3 source compiled into this example'); const result = saturate(facts, RULES); const rawOutput = renderRawOutput(result.graph, QUERIES, RULES, facts); fail('Compiled N3 derivation failed', { 'input evidence metadata is present and matches compiled source': meta.SourceSHA256 === "fa6faef8fac2e328ccfb894c21eef260b0935a936b5e9806f8889719e7f39e4f", 'input evidence facts were loaded': expectedFacts > 0 ? facts.length === expectedFacts : facts.length >= 0, 'compiled rules were loaded': RULES.length === 0, 'compiled query directives were loaded': QUERIES.length === 0, 'a derivation fixpoint was reached': result.graph.facts.length >= facts.length, 'query or output facts were produced': rawOutput.length > 0 }); return { ...result, rawOutput, inputFacts: facts }; }
|
|
1201
1201
|
function snapshotMarkdown(markdown) { return markdown.split(/\n/).map((line) => line ? line + ' \n' : '\n').join(''); }
|
package/see/examples/backward.js
CHANGED
|
@@ -1040,19 +1040,19 @@ function renderStructuredOutput({ title, graph, queries = [], rules = [], initia
|
|
|
1040
1040
|
const lines = [];
|
|
1041
1041
|
lines.push('# ' + title);
|
|
1042
1042
|
lines.push('');
|
|
1043
|
-
lines.push('##
|
|
1043
|
+
lines.push('## Entailment');
|
|
1044
1044
|
if (mode === 'query') {
|
|
1045
1045
|
lines.push('The compiled query selected ' + selected.length + ' fact(s) after the rule closure was computed.');
|
|
1046
1046
|
} else if (mode === 'formula') {
|
|
1047
|
-
lines.push('The derivation produced ' + selected.length + ' formula-valued
|
|
1047
|
+
lines.push('The derivation produced ' + selected.length + ' formula-valued entailment(s).');
|
|
1048
1048
|
} else {
|
|
1049
1049
|
lines.push('The derivation produced ' + derived.length + ' new fact(s) from ' + initialFacts.length + ' stated fact(s).');
|
|
1050
1050
|
}
|
|
1051
|
-
if (keyFact) lines.push('Main
|
|
1051
|
+
if (keyFact) lines.push('Main entailment: **' + factSentence(keyFact) + '**');
|
|
1052
1052
|
const bullets = selected.slice(-6).reverse();
|
|
1053
1053
|
if (bullets.length) {
|
|
1054
1054
|
lines.push('');
|
|
1055
|
-
lines.push('Selected
|
|
1055
|
+
lines.push('Selected entailments:');
|
|
1056
1056
|
for (const fact of bullets) lines.push('- ' + codeFact(fact));
|
|
1057
1057
|
}
|
|
1058
1058
|
lines.push('');
|
|
@@ -1114,15 +1114,15 @@ function dedupeExplanationHeadings(text) {
|
|
|
1114
1114
|
function normalizePublicReport(markdown, title) {
|
|
1115
1115
|
let text = String(markdown || '').trimEnd();
|
|
1116
1116
|
if (!/^\s*#\s+/m.test(text)) text = '# ' + title + '\n\n' + text;
|
|
1117
|
-
if (!/^##\s+
|
|
1118
|
-
text = text.replace(/^(#\s+[^\n]+\n*)/, '$1\n##
|
|
1117
|
+
if (!/^##\s+Entailment\s*$/mi.test(text)) {
|
|
1118
|
+
text = text.replace(/^(#\s+[^\n]+\n*)/, '$1\n## Entailment\n');
|
|
1119
1119
|
}
|
|
1120
1120
|
if (!/^##\s+Explanation\s*$/mi.test(text)) {
|
|
1121
1121
|
text += '\n\n## Explanation\nNo additional explanation was provided by the generated output.';
|
|
1122
1122
|
}
|
|
1123
1123
|
text = text.replace(/^##\s+([^\n]+?)\s*$/gm, (line, heading) => {
|
|
1124
1124
|
const normalized = heading.trim().toLowerCase();
|
|
1125
|
-
if (normalized === 'insight' || normalized === 'explanation') return '## ' + (normalized === '
|
|
1125
|
+
if (normalized === 'insight' || normalized === 'conclusion' || normalized === 'entailment' || normalized === 'explanation') return '## ' + (normalized === 'explanation' ? 'Explanation' : 'Entailment');
|
|
1126
1126
|
return '**' + heading.trim() + '**';
|
|
1127
1127
|
});
|
|
1128
1128
|
text = dedupeExplanationHeadings(text);
|
|
@@ -1131,13 +1131,13 @@ function normalizePublicReport(markdown, title) {
|
|
|
1131
1131
|
function markdownize(raw, title) {
|
|
1132
1132
|
let text = String(raw || '');
|
|
1133
1133
|
text = text
|
|
1134
|
-
.replace(/===\s*Answer\s*===/g, '##
|
|
1134
|
+
.replace(/===\s*Answer\s*===/g, '## Entailment')
|
|
1135
1135
|
.replace(/===\s*Reason\s+Why\s*===/gi, '## Explanation')
|
|
1136
1136
|
.replace(/===\s*Explanation\s*===/gi, '## Explanation')
|
|
1137
1137
|
.replace(/===\s*([^=]+?)\s*===/g, (_, h) => '**' + h.trim() + '**');
|
|
1138
1138
|
text = text.replace(/^C(\d+)\s+OK\s*-\s*/gm, 'C$1: ');
|
|
1139
1139
|
text = dedupeExplanationHeadings(text);
|
|
1140
|
-
if (!text.trim()) text = '##
|
|
1140
|
+
if (!text.trim()) text = '## Entailment\nNo log:outputString facts were derived.\n\n## Explanation\nThe compiled derivation did not produce authored report text.';
|
|
1141
1141
|
return normalizePublicReport(text, title);
|
|
1142
1142
|
}
|
|
1143
1143
|
function authoredSupportAppendix(graph, queries, rules, initialFacts, trace) {
|
|
@@ -1280,7 +1280,7 @@ const RULES = [
|
|
|
1280
1280
|
}
|
|
1281
1281
|
];
|
|
1282
1282
|
const QUERIES = [];
|
|
1283
|
-
const DOC_MARKDOWN = "# Backward rule example\n\nGenerated by `see.js` from a Notation3 source file.\n\nSee https://www.w3.org/2000/10/swap/doc/tutorial-1.pdf page 17\n\n## Compilation summary\n\n- Example name: `backward`\n- Input facts emitted: 0\n- Forward rules compiled: 1\n- Backward predicate rules compiled: 1\n- Fuses compiled: 0\n- Predicate count: 3\n\n## Built-ins used\n\n- `math:greaterThan`\n\n## Runtime model\n\nThe generated `examples/backward.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/backward.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/backward.trig` or `examples/input/backward.trig`. The runner reads that TriG evidence directly and performs a local fixpoint derivation; it does not parse the program source or call an external reasoner.\n\n## Output model\n\nRunning `node examples/backward.js` produces a SEE-style Markdown report with an **
|
|
1283
|
+
const DOC_MARKDOWN = "# Backward rule example\n\nGenerated by `see.js` from a Notation3 source file.\n\nSee https://www.w3.org/2000/10/swap/doc/tutorial-1.pdf page 17\n\n## Compilation summary\n\n- Example name: `backward`\n- Input facts emitted: 0\n- Forward rules compiled: 1\n- Backward predicate rules compiled: 1\n- Fuses compiled: 0\n- Predicate count: 3\n\n## Built-ins used\n\n- `math:greaterThan`\n\n## Runtime model\n\nThe generated `examples/backward.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/backward.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/backward.trig` or `examples/input/backward.trig`. The runner reads that TriG evidence directly and performs a local fixpoint derivation; it does not parse the program source or call an external reasoner.\n\n## Output model\n\nRunning `node examples/backward.js` produces a SEE-style Markdown report with an **Entailment** section, an **Explanation** section, and a **Formal TriG Output** section containing the selected derived/query facts.\n";
|
|
1284
1284
|
function seeMetadata(data) { return (data && data.__see) || {}; }
|
|
1285
1285
|
function trustedDerivation(data) { const meta = seeMetadata(data); const facts = data && Array.isArray(data.facts) ? data.facts : []; const expectedFacts = EXPECTED_INPUT_FACTS || Number(meta.InputFacts || 0); if (meta.SourceSHA256 && meta.SourceSHA256 !== "328d66402900d98dda0c02e3c64a7f3633f01a0ba148031c17e8fbf353057d33") throw new Error('input evidence does not match the N3 source compiled into this example'); const result = saturate(facts, RULES); const rawOutput = renderRawOutput(result.graph, QUERIES, RULES, facts); fail('Compiled N3 derivation failed', { 'input evidence metadata is present and matches compiled source': meta.SourceSHA256 === "328d66402900d98dda0c02e3c64a7f3633f01a0ba148031c17e8fbf353057d33", 'input evidence facts were loaded': expectedFacts > 0 ? facts.length === expectedFacts : facts.length >= 0, 'compiled rules were loaded': RULES.length === 2, 'compiled query directives were loaded': QUERIES.length === 0, 'a derivation fixpoint was reached': result.graph.facts.length >= facts.length, 'query or output facts were produced': rawOutput.length > 0 }); return { ...result, rawOutput, inputFacts: facts }; }
|
|
1286
1286
|
function snapshotMarkdown(markdown) { return markdown.split(/\n/).map((line) => line ? line + ' \n' : '\n').join(''); }
|
|
@@ -1040,19 +1040,19 @@ function renderStructuredOutput({ title, graph, queries = [], rules = [], initia
|
|
|
1040
1040
|
const lines = [];
|
|
1041
1041
|
lines.push('# ' + title);
|
|
1042
1042
|
lines.push('');
|
|
1043
|
-
lines.push('##
|
|
1043
|
+
lines.push('## Entailment');
|
|
1044
1044
|
if (mode === 'query') {
|
|
1045
1045
|
lines.push('The compiled query selected ' + selected.length + ' fact(s) after the rule closure was computed.');
|
|
1046
1046
|
} else if (mode === 'formula') {
|
|
1047
|
-
lines.push('The derivation produced ' + selected.length + ' formula-valued
|
|
1047
|
+
lines.push('The derivation produced ' + selected.length + ' formula-valued entailment(s).');
|
|
1048
1048
|
} else {
|
|
1049
1049
|
lines.push('The derivation produced ' + derived.length + ' new fact(s) from ' + initialFacts.length + ' stated fact(s).');
|
|
1050
1050
|
}
|
|
1051
|
-
if (keyFact) lines.push('Main
|
|
1051
|
+
if (keyFact) lines.push('Main entailment: **' + factSentence(keyFact) + '**');
|
|
1052
1052
|
const bullets = selected.slice(-6).reverse();
|
|
1053
1053
|
if (bullets.length) {
|
|
1054
1054
|
lines.push('');
|
|
1055
|
-
lines.push('Selected
|
|
1055
|
+
lines.push('Selected entailments:');
|
|
1056
1056
|
for (const fact of bullets) lines.push('- ' + codeFact(fact));
|
|
1057
1057
|
}
|
|
1058
1058
|
lines.push('');
|
|
@@ -1114,15 +1114,15 @@ function dedupeExplanationHeadings(text) {
|
|
|
1114
1114
|
function normalizePublicReport(markdown, title) {
|
|
1115
1115
|
let text = String(markdown || '').trimEnd();
|
|
1116
1116
|
if (!/^\s*#\s+/m.test(text)) text = '# ' + title + '\n\n' + text;
|
|
1117
|
-
if (!/^##\s+
|
|
1118
|
-
text = text.replace(/^(#\s+[^\n]+\n*)/, '$1\n##
|
|
1117
|
+
if (!/^##\s+Entailment\s*$/mi.test(text)) {
|
|
1118
|
+
text = text.replace(/^(#\s+[^\n]+\n*)/, '$1\n## Entailment\n');
|
|
1119
1119
|
}
|
|
1120
1120
|
if (!/^##\s+Explanation\s*$/mi.test(text)) {
|
|
1121
1121
|
text += '\n\n## Explanation\nNo additional explanation was provided by the generated output.';
|
|
1122
1122
|
}
|
|
1123
1123
|
text = text.replace(/^##\s+([^\n]+?)\s*$/gm, (line, heading) => {
|
|
1124
1124
|
const normalized = heading.trim().toLowerCase();
|
|
1125
|
-
if (normalized === 'insight' || normalized === 'explanation') return '## ' + (normalized === '
|
|
1125
|
+
if (normalized === 'insight' || normalized === 'conclusion' || normalized === 'entailment' || normalized === 'explanation') return '## ' + (normalized === 'explanation' ? 'Explanation' : 'Entailment');
|
|
1126
1126
|
return '**' + heading.trim() + '**';
|
|
1127
1127
|
});
|
|
1128
1128
|
text = dedupeExplanationHeadings(text);
|
|
@@ -1131,13 +1131,13 @@ function normalizePublicReport(markdown, title) {
|
|
|
1131
1131
|
function markdownize(raw, title) {
|
|
1132
1132
|
let text = String(raw || '');
|
|
1133
1133
|
text = text
|
|
1134
|
-
.replace(/===\s*Answer\s*===/g, '##
|
|
1134
|
+
.replace(/===\s*Answer\s*===/g, '## Entailment')
|
|
1135
1135
|
.replace(/===\s*Reason\s+Why\s*===/gi, '## Explanation')
|
|
1136
1136
|
.replace(/===\s*Explanation\s*===/gi, '## Explanation')
|
|
1137
1137
|
.replace(/===\s*([^=]+?)\s*===/g, (_, h) => '**' + h.trim() + '**');
|
|
1138
1138
|
text = text.replace(/^C(\d+)\s+OK\s*-\s*/gm, 'C$1: ');
|
|
1139
1139
|
text = dedupeExplanationHeadings(text);
|
|
1140
|
-
if (!text.trim()) text = '##
|
|
1140
|
+
if (!text.trim()) text = '## Entailment\nNo log:outputString facts were derived.\n\n## Explanation\nThe compiled derivation did not produce authored report text.';
|
|
1141
1141
|
return normalizePublicReport(text, title);
|
|
1142
1142
|
}
|
|
1143
1143
|
function authoredSupportAppendix(graph, queries, rules, initialFacts, trace) {
|
|
@@ -1379,7 +1379,7 @@ const QUERIES = [
|
|
|
1379
1379
|
]
|
|
1380
1380
|
}
|
|
1381
1381
|
];
|
|
1382
|
-
const DOC_MARKDOWN = "# Backward recursion coverage\n\nGenerated by `see.js` from a Notation3 source file.\n\nDemonstrates recursive <= rules compiled into specialized JavaScript.\n\n## Compilation summary\n\n- Example name: `backward_recursion`\n- Input facts emitted: 2\n- Forward rules compiled: 1\n- Backward predicate rules compiled: 2\n- Fuses compiled: 0\n- Predicate count: 3\n\n## Built-ins used\n\n- none\n\n## Runtime model\n\nThe generated `examples/backward_recursion.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/backward_recursion.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/backward-recursion.trig` or `examples/input/backward_recursion.trig`. The runner reads that TriG evidence directly and performs a local fixpoint derivation; it does not parse the program source or call an external reasoner.\n\n## Output model\n\nRunning `node examples/backward_recursion.js` produces a SEE-style Markdown report with an **
|
|
1382
|
+
const DOC_MARKDOWN = "# Backward recursion coverage\n\nGenerated by `see.js` from a Notation3 source file.\n\nDemonstrates recursive <= rules compiled into specialized JavaScript.\n\n## Compilation summary\n\n- Example name: `backward_recursion`\n- Input facts emitted: 2\n- Forward rules compiled: 1\n- Backward predicate rules compiled: 2\n- Fuses compiled: 0\n- Predicate count: 3\n\n## Built-ins used\n\n- none\n\n## Runtime model\n\nThe generated `examples/backward_recursion.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/backward_recursion.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/backward-recursion.trig` or `examples/input/backward_recursion.trig`. The runner reads that TriG evidence directly and performs a local fixpoint derivation; it does not parse the program source or call an external reasoner.\n\n## Output model\n\nRunning `node examples/backward_recursion.js` produces a SEE-style Markdown report with an **Entailment** section, an **Explanation** section, and a **Formal TriG Output** section containing the selected derived/query facts.\n";
|
|
1383
1383
|
function seeMetadata(data) { return (data && data.__see) || {}; }
|
|
1384
1384
|
function trustedDerivation(data) { const meta = seeMetadata(data); const facts = data && Array.isArray(data.facts) ? data.facts : []; const expectedFacts = EXPECTED_INPUT_FACTS || Number(meta.InputFacts || 0); if (meta.SourceSHA256 && meta.SourceSHA256 !== "1249b9825793b7f0174c87a4d0e44752cb63f3940cc332c0d00fc6bb15a081d1") throw new Error('input evidence does not match the N3 source compiled into this example'); const result = saturate(facts, RULES); const rawOutput = renderRawOutput(result.graph, QUERIES, RULES, facts); fail('Compiled N3 derivation failed', { 'input evidence metadata is present and matches compiled source': meta.SourceSHA256 === "1249b9825793b7f0174c87a4d0e44752cb63f3940cc332c0d00fc6bb15a081d1", 'input evidence facts were loaded': expectedFacts > 0 ? facts.length === expectedFacts : facts.length >= 0, 'compiled rules were loaded': RULES.length === 3, 'compiled query directives were loaded': QUERIES.length === 1, 'a derivation fixpoint was reached': result.graph.facts.length >= facts.length, 'query or output facts were produced': rawOutput.length > 0 }); return { ...result, rawOutput, inputFacts: facts }; }
|
|
1385
1385
|
function snapshotMarkdown(markdown) { return markdown.split(/\n/).map((line) => line ? line + ' \n' : '\n').join(''); }
|
|
@@ -1040,19 +1040,19 @@ function renderStructuredOutput({ title, graph, queries = [], rules = [], initia
|
|
|
1040
1040
|
const lines = [];
|
|
1041
1041
|
lines.push('# ' + title);
|
|
1042
1042
|
lines.push('');
|
|
1043
|
-
lines.push('##
|
|
1043
|
+
lines.push('## Entailment');
|
|
1044
1044
|
if (mode === 'query') {
|
|
1045
1045
|
lines.push('The compiled query selected ' + selected.length + ' fact(s) after the rule closure was computed.');
|
|
1046
1046
|
} else if (mode === 'formula') {
|
|
1047
|
-
lines.push('The derivation produced ' + selected.length + ' formula-valued
|
|
1047
|
+
lines.push('The derivation produced ' + selected.length + ' formula-valued entailment(s).');
|
|
1048
1048
|
} else {
|
|
1049
1049
|
lines.push('The derivation produced ' + derived.length + ' new fact(s) from ' + initialFacts.length + ' stated fact(s).');
|
|
1050
1050
|
}
|
|
1051
|
-
if (keyFact) lines.push('Main
|
|
1051
|
+
if (keyFact) lines.push('Main entailment: **' + factSentence(keyFact) + '**');
|
|
1052
1052
|
const bullets = selected.slice(-6).reverse();
|
|
1053
1053
|
if (bullets.length) {
|
|
1054
1054
|
lines.push('');
|
|
1055
|
-
lines.push('Selected
|
|
1055
|
+
lines.push('Selected entailments:');
|
|
1056
1056
|
for (const fact of bullets) lines.push('- ' + codeFact(fact));
|
|
1057
1057
|
}
|
|
1058
1058
|
lines.push('');
|
|
@@ -1114,15 +1114,15 @@ function dedupeExplanationHeadings(text) {
|
|
|
1114
1114
|
function normalizePublicReport(markdown, title) {
|
|
1115
1115
|
let text = String(markdown || '').trimEnd();
|
|
1116
1116
|
if (!/^\s*#\s+/m.test(text)) text = '# ' + title + '\n\n' + text;
|
|
1117
|
-
if (!/^##\s+
|
|
1118
|
-
text = text.replace(/^(#\s+[^\n]+\n*)/, '$1\n##
|
|
1117
|
+
if (!/^##\s+Entailment\s*$/mi.test(text)) {
|
|
1118
|
+
text = text.replace(/^(#\s+[^\n]+\n*)/, '$1\n## Entailment\n');
|
|
1119
1119
|
}
|
|
1120
1120
|
if (!/^##\s+Explanation\s*$/mi.test(text)) {
|
|
1121
1121
|
text += '\n\n## Explanation\nNo additional explanation was provided by the generated output.';
|
|
1122
1122
|
}
|
|
1123
1123
|
text = text.replace(/^##\s+([^\n]+?)\s*$/gm, (line, heading) => {
|
|
1124
1124
|
const normalized = heading.trim().toLowerCase();
|
|
1125
|
-
if (normalized === 'insight' || normalized === 'explanation') return '## ' + (normalized === '
|
|
1125
|
+
if (normalized === 'insight' || normalized === 'conclusion' || normalized === 'entailment' || normalized === 'explanation') return '## ' + (normalized === 'explanation' ? 'Explanation' : 'Entailment');
|
|
1126
1126
|
return '**' + heading.trim() + '**';
|
|
1127
1127
|
});
|
|
1128
1128
|
text = dedupeExplanationHeadings(text);
|
|
@@ -1131,13 +1131,13 @@ function normalizePublicReport(markdown, title) {
|
|
|
1131
1131
|
function markdownize(raw, title) {
|
|
1132
1132
|
let text = String(raw || '');
|
|
1133
1133
|
text = text
|
|
1134
|
-
.replace(/===\s*Answer\s*===/g, '##
|
|
1134
|
+
.replace(/===\s*Answer\s*===/g, '## Entailment')
|
|
1135
1135
|
.replace(/===\s*Reason\s+Why\s*===/gi, '## Explanation')
|
|
1136
1136
|
.replace(/===\s*Explanation\s*===/gi, '## Explanation')
|
|
1137
1137
|
.replace(/===\s*([^=]+?)\s*===/g, (_, h) => '**' + h.trim() + '**');
|
|
1138
1138
|
text = text.replace(/^C(\d+)\s+OK\s*-\s*/gm, 'C$1: ');
|
|
1139
1139
|
text = dedupeExplanationHeadings(text);
|
|
1140
|
-
if (!text.trim()) text = '##
|
|
1140
|
+
if (!text.trim()) text = '## Entailment\nNo log:outputString facts were derived.\n\n## Explanation\nThe compiled derivation did not produce authored report text.';
|
|
1141
1141
|
return normalizePublicReport(text, title);
|
|
1142
1142
|
}
|
|
1143
1143
|
function authoredSupportAppendix(graph, queries, rules, initialFacts, trace) {
|
|
@@ -2758,7 +2758,7 @@ const QUERIES = [
|
|
|
2758
2758
|
]
|
|
2759
2759
|
}
|
|
2760
2760
|
];
|
|
2761
|
-
const DOC_MARKDOWN = "# Bayes Diagnosis\n\nGenerated by `see.js` from a Notation3 source file.\n\nNaive Bayes diagnosis example, adapted from Eyeling's bayes-diagnosis.n3.\nThe facts and rules compute unnormalized likelihoods, normalize them into\nposterior probabilities, and emit a SEE report for the highest posterior.\nValues are illustrative only and are not medical advice.\n\n## Compilation summary\n\n- Example name: `bayes_diagnosis`\n- Input facts emitted: 85\n- Forward rules compiled: 4\n- Backward predicate rules compiled: 5\n- Fuses compiled: 4\n- Predicate count: 34\n\n## Built-ins used\n\n- `list:firstRest`\n- `list:iterate`\n- `list:map`\n- `list:memberAt`\n- `log:outputString`\n- `math:difference`\n- `math:greaterThan`\n- `math:lessThan`\n- `math:notLessThan`\n- `math:product`\n- `math:quotient`\n- `math:sum`\n- `string:format`\n\n## Runtime model\n\nThe generated `examples/bayes_diagnosis.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/bayes_diagnosis.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/bayes-diagnosis.trig` or `examples/input/bayes_diagnosis.trig`. The runner reads that TriG evidence directly and performs a local fixpoint derivation; it does not parse the program source or call an external reasoner.\n\n## Output model\n\nRunning `node examples/bayes_diagnosis.js` produces a SEE-style Markdown report with an **
|
|
2761
|
+
const DOC_MARKDOWN = "# Bayes Diagnosis\n\nGenerated by `see.js` from a Notation3 source file.\n\nNaive Bayes diagnosis example, adapted from Eyeling's bayes-diagnosis.n3.\nThe facts and rules compute unnormalized likelihoods, normalize them into\nposterior probabilities, and emit a SEE report for the highest posterior.\nValues are illustrative only and are not medical advice.\n\n## Compilation summary\n\n- Example name: `bayes_diagnosis`\n- Input facts emitted: 85\n- Forward rules compiled: 4\n- Backward predicate rules compiled: 5\n- Fuses compiled: 4\n- Predicate count: 34\n\n## Built-ins used\n\n- `list:firstRest`\n- `list:iterate`\n- `list:map`\n- `list:memberAt`\n- `log:outputString`\n- `math:difference`\n- `math:greaterThan`\n- `math:lessThan`\n- `math:notLessThan`\n- `math:product`\n- `math:quotient`\n- `math:sum`\n- `string:format`\n\n## Runtime model\n\nThe generated `examples/bayes_diagnosis.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/bayes_diagnosis.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/bayes-diagnosis.trig` or `examples/input/bayes_diagnosis.trig`. The runner reads that TriG evidence directly and performs a local fixpoint derivation; it does not parse the program source or call an external reasoner.\n\n## Output model\n\nRunning `node examples/bayes_diagnosis.js` produces a SEE-style Markdown report with an **Entailment** section, an **Explanation** section, and a **Formal TriG Output** section containing the selected derived/query facts.\n";
|
|
2762
2762
|
function seeMetadata(data) { return (data && data.__see) || {}; }
|
|
2763
2763
|
function trustedDerivation(data) { const meta = seeMetadata(data); const facts = data && Array.isArray(data.facts) ? data.facts : []; const expectedFacts = EXPECTED_INPUT_FACTS || Number(meta.InputFacts || 0); if (meta.SourceSHA256 && meta.SourceSHA256 !== "46feebe5109b413a4143b7bcb4bc77ac6c0b18a8fdd8f6a62ab06c42287035d9") throw new Error('input evidence does not match the N3 source compiled into this example'); const result = saturate(facts, RULES); const rawOutput = renderRawOutput(result.graph, QUERIES, RULES, facts); fail('Compiled N3 derivation failed', { 'input evidence metadata is present and matches compiled source': meta.SourceSHA256 === "46feebe5109b413a4143b7bcb4bc77ac6c0b18a8fdd8f6a62ab06c42287035d9", 'input evidence facts were loaded': expectedFacts > 0 ? facts.length === expectedFacts : facts.length >= 0, 'compiled rules were loaded': RULES.length === 13, 'compiled query directives were loaded': QUERIES.length === 1, 'a derivation fixpoint was reached': result.graph.facts.length >= facts.length, 'query or output facts were produced': rawOutput.length > 0 }); return { ...result, rawOutput, inputFacts: facts }; }
|
|
2764
2764
|
function snapshotMarkdown(markdown) { return markdown.split(/\n/).map((line) => line ? line + ' \n' : '\n').join(''); }
|
|
@@ -1040,19 +1040,19 @@ function renderStructuredOutput({ title, graph, queries = [], rules = [], initia
|
|
|
1040
1040
|
const lines = [];
|
|
1041
1041
|
lines.push('# ' + title);
|
|
1042
1042
|
lines.push('');
|
|
1043
|
-
lines.push('##
|
|
1043
|
+
lines.push('## Entailment');
|
|
1044
1044
|
if (mode === 'query') {
|
|
1045
1045
|
lines.push('The compiled query selected ' + selected.length + ' fact(s) after the rule closure was computed.');
|
|
1046
1046
|
} else if (mode === 'formula') {
|
|
1047
|
-
lines.push('The derivation produced ' + selected.length + ' formula-valued
|
|
1047
|
+
lines.push('The derivation produced ' + selected.length + ' formula-valued entailment(s).');
|
|
1048
1048
|
} else {
|
|
1049
1049
|
lines.push('The derivation produced ' + derived.length + ' new fact(s) from ' + initialFacts.length + ' stated fact(s).');
|
|
1050
1050
|
}
|
|
1051
|
-
if (keyFact) lines.push('Main
|
|
1051
|
+
if (keyFact) lines.push('Main entailment: **' + factSentence(keyFact) + '**');
|
|
1052
1052
|
const bullets = selected.slice(-6).reverse();
|
|
1053
1053
|
if (bullets.length) {
|
|
1054
1054
|
lines.push('');
|
|
1055
|
-
lines.push('Selected
|
|
1055
|
+
lines.push('Selected entailments:');
|
|
1056
1056
|
for (const fact of bullets) lines.push('- ' + codeFact(fact));
|
|
1057
1057
|
}
|
|
1058
1058
|
lines.push('');
|
|
@@ -1114,15 +1114,15 @@ function dedupeExplanationHeadings(text) {
|
|
|
1114
1114
|
function normalizePublicReport(markdown, title) {
|
|
1115
1115
|
let text = String(markdown || '').trimEnd();
|
|
1116
1116
|
if (!/^\s*#\s+/m.test(text)) text = '# ' + title + '\n\n' + text;
|
|
1117
|
-
if (!/^##\s+
|
|
1118
|
-
text = text.replace(/^(#\s+[^\n]+\n*)/, '$1\n##
|
|
1117
|
+
if (!/^##\s+Entailment\s*$/mi.test(text)) {
|
|
1118
|
+
text = text.replace(/^(#\s+[^\n]+\n*)/, '$1\n## Entailment\n');
|
|
1119
1119
|
}
|
|
1120
1120
|
if (!/^##\s+Explanation\s*$/mi.test(text)) {
|
|
1121
1121
|
text += '\n\n## Explanation\nNo additional explanation was provided by the generated output.';
|
|
1122
1122
|
}
|
|
1123
1123
|
text = text.replace(/^##\s+([^\n]+?)\s*$/gm, (line, heading) => {
|
|
1124
1124
|
const normalized = heading.trim().toLowerCase();
|
|
1125
|
-
if (normalized === 'insight' || normalized === 'explanation') return '## ' + (normalized === '
|
|
1125
|
+
if (normalized === 'insight' || normalized === 'conclusion' || normalized === 'entailment' || normalized === 'explanation') return '## ' + (normalized === 'explanation' ? 'Explanation' : 'Entailment');
|
|
1126
1126
|
return '**' + heading.trim() + '**';
|
|
1127
1127
|
});
|
|
1128
1128
|
text = dedupeExplanationHeadings(text);
|
|
@@ -1131,13 +1131,13 @@ function normalizePublicReport(markdown, title) {
|
|
|
1131
1131
|
function markdownize(raw, title) {
|
|
1132
1132
|
let text = String(raw || '');
|
|
1133
1133
|
text = text
|
|
1134
|
-
.replace(/===\s*Answer\s*===/g, '##
|
|
1134
|
+
.replace(/===\s*Answer\s*===/g, '## Entailment')
|
|
1135
1135
|
.replace(/===\s*Reason\s+Why\s*===/gi, '## Explanation')
|
|
1136
1136
|
.replace(/===\s*Explanation\s*===/gi, '## Explanation')
|
|
1137
1137
|
.replace(/===\s*([^=]+?)\s*===/g, (_, h) => '**' + h.trim() + '**');
|
|
1138
1138
|
text = text.replace(/^C(\d+)\s+OK\s*-\s*/gm, 'C$1: ');
|
|
1139
1139
|
text = dedupeExplanationHeadings(text);
|
|
1140
|
-
if (!text.trim()) text = '##
|
|
1140
|
+
if (!text.trim()) text = '## Entailment\nNo log:outputString facts were derived.\n\n## Explanation\nThe compiled derivation did not produce authored report text.';
|
|
1141
1141
|
return normalizePublicReport(text, title);
|
|
1142
1142
|
}
|
|
1143
1143
|
function authoredSupportAppendix(graph, queries, rules, initialFacts, trace) {
|
|
@@ -4027,7 +4027,7 @@ const QUERIES = [
|
|
|
4027
4027
|
]
|
|
4028
4028
|
}
|
|
4029
4029
|
];
|
|
4030
|
-
const DOC_MARKDOWN = "# Bayes Therapy\n\nGenerated by `see.js` from a Notation3 source file.\n\nExtends the Bayesian diagnosis model with a therapy utility layer. Adapted\nfrom Eyeling's bayes-therapy.n3. Values are illustrative only and are not\nmedical advice.\n\n## Compilation summary\n\n- Example name: `bayes_therapy`\n- Input facts emitted: 104\n- Forward rules compiled: 5\n- Backward predicate rules compiled: 15\n- Fuses compiled: 8\n- Predicate count: 45\n\n## Built-ins used\n\n- `list:firstRest`\n- `list:iterate`\n- `list:map`\n- `list:memberAt`\n- `log:outputString`\n- `math:difference`\n- `math:greaterThan`\n- `math:lessThan`\n- `math:notLessThan`\n- `math:product`\n- `math:quotient`\n- `math:sum`\n- `string:format`\n\n## Runtime model\n\nThe generated `examples/bayes_therapy.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/bayes_therapy.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/bayes-therapy.trig` or `examples/input/bayes_therapy.trig`. The runner reads that TriG evidence directly and performs a local fixpoint derivation; it does not parse the program source or call an external reasoner.\n\n## Output model\n\nRunning `node examples/bayes_therapy.js` produces a SEE-style Markdown report with an **
|
|
4030
|
+
const DOC_MARKDOWN = "# Bayes Therapy\n\nGenerated by `see.js` from a Notation3 source file.\n\nExtends the Bayesian diagnosis model with a therapy utility layer. Adapted\nfrom Eyeling's bayes-therapy.n3. Values are illustrative only and are not\nmedical advice.\n\n## Compilation summary\n\n- Example name: `bayes_therapy`\n- Input facts emitted: 104\n- Forward rules compiled: 5\n- Backward predicate rules compiled: 15\n- Fuses compiled: 8\n- Predicate count: 45\n\n## Built-ins used\n\n- `list:firstRest`\n- `list:iterate`\n- `list:map`\n- `list:memberAt`\n- `log:outputString`\n- `math:difference`\n- `math:greaterThan`\n- `math:lessThan`\n- `math:notLessThan`\n- `math:product`\n- `math:quotient`\n- `math:sum`\n- `string:format`\n\n## Runtime model\n\nThe generated `examples/bayes_therapy.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/bayes_therapy.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/bayes-therapy.trig` or `examples/input/bayes_therapy.trig`. The runner reads that TriG evidence directly and performs a local fixpoint derivation; it does not parse the program source or call an external reasoner.\n\n## Output model\n\nRunning `node examples/bayes_therapy.js` produces a SEE-style Markdown report with an **Entailment** section, an **Explanation** section, and a **Formal TriG Output** section containing the selected derived/query facts.\n";
|
|
4031
4031
|
function seeMetadata(data) { return (data && data.__see) || {}; }
|
|
4032
4032
|
function trustedDerivation(data) { const meta = seeMetadata(data); const facts = data && Array.isArray(data.facts) ? data.facts : []; const expectedFacts = EXPECTED_INPUT_FACTS || Number(meta.InputFacts || 0); if (meta.SourceSHA256 && meta.SourceSHA256 !== "18244b81f37328f7d77c8e88a4749891c3d773ffbf19affecd7f118c6208395d") throw new Error('input evidence does not match the N3 source compiled into this example'); const result = saturate(facts, RULES); const rawOutput = renderRawOutput(result.graph, QUERIES, RULES, facts); fail('Compiled N3 derivation failed', { 'input evidence metadata is present and matches compiled source': meta.SourceSHA256 === "18244b81f37328f7d77c8e88a4749891c3d773ffbf19affecd7f118c6208395d", 'input evidence facts were loaded': expectedFacts > 0 ? facts.length === expectedFacts : facts.length >= 0, 'compiled rules were loaded': RULES.length === 28, 'compiled query directives were loaded': QUERIES.length === 1, 'a derivation fixpoint was reached': result.graph.facts.length >= facts.length, 'query or output facts were produced': rawOutput.length > 0 }); return { ...result, rawOutput, inputFacts: facts }; }
|
|
4033
4033
|
function snapshotMarkdown(markdown) { return markdown.split(/\n/).map((line) => line ? line + ' \n' : '\n').join(''); }
|