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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# RDF Message Flow
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## Entailment
|
|
4
4
|
Continuous RDF Message flow accepted: 5 ordered messages moved through the ingest → validate → interpret → route → sink pipeline. The threshold was 26, so results 21 and 22 were archived, the heartbeat kept the stream alive, and results 28 and 29 were emitted as alerts.
|
|
5
5
|
|
|
6
6
|
## Explanation
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# Socrates inference
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## Entailment
|
|
4
4
|
The compiled query selected 2 fact(s) after the rule closure was computed.
|
|
5
|
-
Main
|
|
5
|
+
Main entailment: **:Socrates is a :Mortal.**
|
|
6
6
|
|
|
7
|
-
Selected
|
|
7
|
+
Selected entailments:
|
|
8
8
|
- :Socrates rdf:type :Mortal .
|
|
9
9
|
- :Socrates rdf:type :Human .
|
|
10
10
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Wind Turbine Envelope
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## Entailment
|
|
4
4
|
operating thresholds : cut-in 3.5 m/s, rated 12.0 m/s, cut-out 25.0 m/s
|
|
5
5
|
rated power : 3.2 MW
|
|
6
6
|
interval classifications : t1 3.0 m/s stopped 0.000 MW; t2 6.5 m/s partial 0.440 MW; t3 11.2 m/s partial 2.586 MW; t4 15.0 m/s rated 3.200 MW; t5 24.5 m/s rated 3.200 MW; t6 27.0 m/s stopped 0.000 MW
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# Burn the witch
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## Entailment
|
|
4
4
|
The derivation produced 6 new fact(s) from 3 stated fact(s).
|
|
5
|
-
Main
|
|
5
|
+
Main entailment: **:GIRL is a :WITCH.**
|
|
6
6
|
|
|
7
|
-
Selected
|
|
7
|
+
Selected entailments:
|
|
8
8
|
- :GIRL rdf:type :WITCH .
|
|
9
9
|
- :GIRL rdf:type :BURNS .
|
|
10
10
|
- :GIRL rdf:type :ISMADEOFWOOD .
|
|
@@ -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) {
|
|
@@ -1649,7 +1649,7 @@ const RULES = [
|
|
|
1649
1649
|
}
|
|
1650
1650
|
];
|
|
1651
1651
|
const QUERIES = [];
|
|
1652
|
-
const DOC_MARKDOWN = "# Path Discovery\n\nGenerated by `see.js` from a Notation3 source file.\n\nSEE version of the Eyeling airport path-discovery example.\nThe full airroutes evidence is intentionally stored in\nexamples/input/path-discovery.trig, not in this source file. This file keeps\nonly the path-finding rules and the query shape from the upstream example.\n\n## Compilation summary\n\n- Example name: `path_discovery`\n- Input facts emitted: 0\n- Forward rules compiled: 1\n- Backward predicate rules compiled: 2\n- Fuses compiled: 0\n- Predicate count: 9\n\n## Built-ins used\n\n- `list:firstRest`\n- `list:notMember`\n- `log:collectAllIn`\n- `math:notGreaterThan`\n- `math:sum`\n\n## Runtime model\n\nThe generated `examples/path_discovery.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/path_discovery.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/path-discovery.trig` or `examples/input/path_discovery.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/path_discovery.js` produces a SEE-style Markdown report with an **
|
|
1652
|
+
const DOC_MARKDOWN = "# Path Discovery\n\nGenerated by `see.js` from a Notation3 source file.\n\nSEE version of the Eyeling airport path-discovery example.\nThe full airroutes evidence is intentionally stored in\nexamples/input/path-discovery.trig, not in this source file. This file keeps\nonly the path-finding rules and the query shape from the upstream example.\n\n## Compilation summary\n\n- Example name: `path_discovery`\n- Input facts emitted: 0\n- Forward rules compiled: 1\n- Backward predicate rules compiled: 2\n- Fuses compiled: 0\n- Predicate count: 9\n\n## Built-ins used\n\n- `list:firstRest`\n- `list:notMember`\n- `log:collectAllIn`\n- `math:notGreaterThan`\n- `math:sum`\n\n## Runtime model\n\nThe generated `examples/path_discovery.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/path_discovery.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/path-discovery.trig` or `examples/input/path_discovery.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/path_discovery.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";
|
|
1653
1653
|
function seeMetadata(data) { return (data && data.__see) || {}; }
|
|
1654
1654
|
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 !== "9481a2b27a6cae4d73f312c7d8403d1abd7beab573f627f591ea8301073fe4db") 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 === "9481a2b27a6cae4d73f312c7d8403d1abd7beab573f627f591ea8301073fe4db", '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 === 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 }; }
|
|
1655
1655
|
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) {
|
|
@@ -1868,7 +1868,7 @@ const RULES = [
|
|
|
1868
1868
|
}
|
|
1869
1869
|
];
|
|
1870
1870
|
const QUERIES = [];
|
|
1871
|
-
const DOC_MARKDOWN = "# RC Discharge Envelope\n\nGenerated by `see.js` from a Notation3 source file.\n\nCertify when a sampled RC capacitor is guaranteed below tolerance using an\nupper decay bound. The witness is derived by N3 rules and compiled to SEE.\n\n## Compilation summary\n\n- Example name: `rc_discharge_envelope`\n- Input facts emitted: 12\n- Forward rules compiled: 6\n- Backward predicate rules compiled: 0\n- Fuses compiled: 0\n- Predicate count: 22\n\n## Built-ins used\n\n- `log:outputString`\n- `math:exponentiation`\n- `math:lessThan`\n- `math:notGreaterThan`\n- `math:notLessThan`\n- `math:product`\n- `string:format`\n\n## Runtime model\n\nThe generated `examples/rc_discharge_envelope.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/rc_discharge_envelope.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/rc-discharge-envelope.trig` or `examples/input/rc_discharge_envelope.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/rc_discharge_envelope.js` produces a SEE-style Markdown report with an **
|
|
1871
|
+
const DOC_MARKDOWN = "# RC Discharge Envelope\n\nGenerated by `see.js` from a Notation3 source file.\n\nCertify when a sampled RC capacitor is guaranteed below tolerance using an\nupper decay bound. The witness is derived by N3 rules and compiled to SEE.\n\n## Compilation summary\n\n- Example name: `rc_discharge_envelope`\n- Input facts emitted: 12\n- Forward rules compiled: 6\n- Backward predicate rules compiled: 0\n- Fuses compiled: 0\n- Predicate count: 22\n\n## Built-ins used\n\n- `log:outputString`\n- `math:exponentiation`\n- `math:lessThan`\n- `math:notGreaterThan`\n- `math:notLessThan`\n- `math:product`\n- `string:format`\n\n## Runtime model\n\nThe generated `examples/rc_discharge_envelope.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/rc_discharge_envelope.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/rc-discharge-envelope.trig` or `examples/input/rc_discharge_envelope.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/rc_discharge_envelope.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";
|
|
1872
1872
|
function seeMetadata(data) { return (data && data.__see) || {}; }
|
|
1873
1873
|
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 !== "41acff69cd2994230faedf5a466b4c43d47cdff9dc6d834baecd9865979160b8") 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 === "41acff69cd2994230faedf5a466b4c43d47cdff9dc6d834baecd9865979160b8", 'input evidence facts were loaded': expectedFacts > 0 ? facts.length === expectedFacts : facts.length >= 0, 'compiled rules were loaded': RULES.length === 6, '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 }; }
|
|
1874
1874
|
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) {
|
|
@@ -2455,7 +2455,7 @@ const QUERIES = [
|
|
|
2455
2455
|
]
|
|
2456
2456
|
}
|
|
2457
2457
|
];
|
|
2458
|
-
const DOC_MARKDOWN = "# RDF Message Flow\n\nGenerated by `see.js` from a Notation3 source file.\n\nA companion to rdf_messages.n3. This example focuses on a live stream where\nRDF Messages continuously flow through a small processing pipeline. The next\nmessage is released only after the current message reaches the sink, so the\nstream behaves as an ordered, replayable flow rather than a single merged RDF\ngraph.\n\n## Compilation summary\n\n- Example name: `rdf_message_flow`\n- Input facts emitted: 42\n- Forward rules compiled: 9\n- Backward predicate rules compiled: 0\n- Fuses compiled: 0\n- Predicate count: 25\n\n## Built-ins used\n\n- `list:length`\n- `log:includes`\n- `log:outputString`\n- `math:greaterThan`\n- `math:notGreaterThan`\n- `string:format`\n\n## Runtime model\n\nThe generated `examples/rdf_message_flow.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/rdf_message_flow.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/rdf-message-flow.trig` or `examples/input/rdf_message_flow.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/rdf_message_flow.js` produces a SEE-style Markdown report with an **
|
|
2458
|
+
const DOC_MARKDOWN = "# RDF Message Flow\n\nGenerated by `see.js` from a Notation3 source file.\n\nA companion to rdf_messages.n3. This example focuses on a live stream where\nRDF Messages continuously flow through a small processing pipeline. The next\nmessage is released only after the current message reaches the sink, so the\nstream behaves as an ordered, replayable flow rather than a single merged RDF\ngraph.\n\n## Compilation summary\n\n- Example name: `rdf_message_flow`\n- Input facts emitted: 42\n- Forward rules compiled: 9\n- Backward predicate rules compiled: 0\n- Fuses compiled: 0\n- Predicate count: 25\n\n## Built-ins used\n\n- `list:length`\n- `log:includes`\n- `log:outputString`\n- `math:greaterThan`\n- `math:notGreaterThan`\n- `string:format`\n\n## Runtime model\n\nThe generated `examples/rdf_message_flow.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/rdf_message_flow.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/rdf-message-flow.trig` or `examples/input/rdf_message_flow.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/rdf_message_flow.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";
|
|
2459
2459
|
function seeMetadata(data) { return (data && data.__see) || {}; }
|
|
2460
2460
|
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 !== "e4e534c8ac3c2aa276e7158cca8d3146531879033f73685c302b486be2ab0099") 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 === "e4e534c8ac3c2aa276e7158cca8d3146531879033f73685c302b486be2ab0099", 'input evidence facts were loaded': expectedFacts > 0 ? facts.length === expectedFacts : facts.length >= 0, 'compiled rules were loaded': RULES.length === 9, '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 }; }
|
|
2461
2461
|
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) {
|
|
@@ -2051,7 +2051,7 @@ const QUERIES = [
|
|
|
2051
2051
|
]
|
|
2052
2052
|
}
|
|
2053
2053
|
];
|
|
2054
|
-
const DOC_MARKDOWN = "# RDF Messages\n\nGenerated by `see.js` from a Notation3 source file.\n\nThis SEE example models the main idea from\nhttps://pietercolpaert.be/papers/eswc2026-rdf-messages/:\na message stream/log is not just one freely mergeable RDF graph. It is an\nordered sequence of RDF Datasets that are interpreted atomically, one message\nat a time. The middle message is deliberately empty to model a heartbeat, and\nthe local blank-node label \"_:b0\" is deliberately reused by two messages to\nshow message-scoped blank nodes.\n\n## Compilation summary\n\n- Example name: `rdf_messages`\n- Input facts emitted: 25\n- Forward rules compiled: 6\n- Backward predicate rules compiled: 0\n- Fuses compiled: 0\n- Predicate count: 26\n\n## Built-ins used\n\n- `list:length`\n- `log:includes`\n- `log:notEqualTo`\n- `log:outputString`\n- `math:notEqualTo`\n- `string:format`\n\n## Runtime model\n\nThe generated `examples/rdf_messages.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/rdf_messages.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/rdf-messages.trig` or `examples/input/rdf_messages.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/rdf_messages.js` produces a SEE-style Markdown report with an **
|
|
2054
|
+
const DOC_MARKDOWN = "# RDF Messages\n\nGenerated by `see.js` from a Notation3 source file.\n\nThis SEE example models the main idea from\nhttps://pietercolpaert.be/papers/eswc2026-rdf-messages/:\na message stream/log is not just one freely mergeable RDF graph. It is an\nordered sequence of RDF Datasets that are interpreted atomically, one message\nat a time. The middle message is deliberately empty to model a heartbeat, and\nthe local blank-node label \"_:b0\" is deliberately reused by two messages to\nshow message-scoped blank nodes.\n\n## Compilation summary\n\n- Example name: `rdf_messages`\n- Input facts emitted: 25\n- Forward rules compiled: 6\n- Backward predicate rules compiled: 0\n- Fuses compiled: 0\n- Predicate count: 26\n\n## Built-ins used\n\n- `list:length`\n- `log:includes`\n- `log:notEqualTo`\n- `log:outputString`\n- `math:notEqualTo`\n- `string:format`\n\n## Runtime model\n\nThe generated `examples/rdf_messages.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/rdf_messages.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/rdf-messages.trig` or `examples/input/rdf_messages.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/rdf_messages.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";
|
|
2055
2055
|
function seeMetadata(data) { return (data && data.__see) || {}; }
|
|
2056
2056
|
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 !== "2ea8b414b92e65531cf384000955ca47811d5b7c779a8d2c9fb007515e745f32") 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 === "2ea8b414b92e65531cf384000955ca47811d5b7c779a8d2c9fb007515e745f32", 'input evidence facts were loaded': expectedFacts > 0 ? facts.length === expectedFacts : facts.length >= 0, 'compiled rules were loaded': RULES.length === 6, '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 }; }
|
|
2057
2057
|
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) {
|
|
@@ -1742,7 +1742,7 @@ const QUERIES = [
|
|
|
1742
1742
|
]
|
|
1743
1743
|
}
|
|
1744
1744
|
];
|
|
1745
|
-
const DOC_MARKDOWN = "# School Placement Route Audit\n\nGenerated by `see.js` from a Notation3 source file.\n\nN3-compiled version of the school placement audit. The original student,\nschool, distance, and policy JSON is preserved as the data-input sidecar.\n\n## Compilation summary\n\n- Example name: `school_placement_audit`\n- Input facts emitted: 26\n- Forward rules compiled: 4\n- Backward predicate rules compiled: 0\n- Fuses compiled: 0\n- Predicate count: 19\n\n## Built-ins used\n\n- `log:notEqualTo`\n- `log:outputString`\n- `math:greaterThan`\n- `math:lessThan`\n- `string:format`\n\n## Runtime model\n\nThe generated `examples/school_placement_audit.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/school_placement_audit.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/school-placement-audit.trig` or `examples/input/school_placement_audit.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/school_placement_audit.js` produces a SEE-style Markdown report with an **
|
|
1745
|
+
const DOC_MARKDOWN = "# School Placement Route Audit\n\nGenerated by `see.js` from a Notation3 source file.\n\nN3-compiled version of the school placement audit. The original student,\nschool, distance, and policy JSON is preserved as the data-input sidecar.\n\n## Compilation summary\n\n- Example name: `school_placement_audit`\n- Input facts emitted: 26\n- Forward rules compiled: 4\n- Backward predicate rules compiled: 0\n- Fuses compiled: 0\n- Predicate count: 19\n\n## Built-ins used\n\n- `log:notEqualTo`\n- `log:outputString`\n- `math:greaterThan`\n- `math:lessThan`\n- `string:format`\n\n## Runtime model\n\nThe generated `examples/school_placement_audit.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/school_placement_audit.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/school-placement-audit.trig` or `examples/input/school_placement_audit.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/school_placement_audit.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";
|
|
1746
1746
|
function seeMetadata(data) { return (data && data.__see) || {}; }
|
|
1747
1747
|
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 !== "8bea39b2ea4c3045fed64b6e7adef0ca8cdf8d14c3735e28e831a759dae600fd") 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 === "8bea39b2ea4c3045fed64b6e7adef0ca8cdf8d14c3735e28e831a759dae600fd", 'input evidence facts were loaded': expectedFacts > 0 ? facts.length === expectedFacts : facts.length >= 0, 'compiled rules were loaded': RULES.length === 4, '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 }; }
|
|
1748
1748
|
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) {
|
|
@@ -1358,7 +1358,7 @@ const RULES = [
|
|
|
1358
1358
|
}
|
|
1359
1359
|
];
|
|
1360
1360
|
const QUERIES = [];
|
|
1361
|
-
const DOC_MARKDOWN = "# Smoke Arithmetic\n\nGenerated by `see.js` from a Notation3 source file.\n\nSmall Notation3 source used to prove that see.js generates a specialized JS\nexample which derives its answer from facts, math built-ins, fuses, and string\nformatting instead of reading a prewritten conclusion.\n\n## Compilation summary\n\n- Example name: `smoke_arithmetic`\n- Input facts emitted: 2\n- Forward rules compiled: 2\n- Backward predicate rules compiled: 0\n- Fuses compiled: 0\n- Predicate count: 7\n\n## Built-ins used\n\n- `log:outputString`\n- `math:greaterThan`\n- `math:product`\n- `string:format`\n\n## Runtime model\n\nThe generated `examples/smoke_arithmetic.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/smoke_arithmetic.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/smoke-arithmetic.trig` or `examples/input/smoke_arithmetic.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/smoke_arithmetic.js` produces a SEE-style Markdown report with an **
|
|
1361
|
+
const DOC_MARKDOWN = "# Smoke Arithmetic\n\nGenerated by `see.js` from a Notation3 source file.\n\nSmall Notation3 source used to prove that see.js generates a specialized JS\nexample which derives its answer from facts, math built-ins, fuses, and string\nformatting instead of reading a prewritten conclusion.\n\n## Compilation summary\n\n- Example name: `smoke_arithmetic`\n- Input facts emitted: 2\n- Forward rules compiled: 2\n- Backward predicate rules compiled: 0\n- Fuses compiled: 0\n- Predicate count: 7\n\n## Built-ins used\n\n- `log:outputString`\n- `math:greaterThan`\n- `math:product`\n- `string:format`\n\n## Runtime model\n\nThe generated `examples/smoke_arithmetic.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/smoke_arithmetic.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/smoke-arithmetic.trig` or `examples/input/smoke_arithmetic.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/smoke_arithmetic.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";
|
|
1362
1362
|
function seeMetadata(data) { return (data && data.__see) || {}; }
|
|
1363
1363
|
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 !== "e254b8b9be8207c07f29cf30426466e2d916286b5f93ea4385786a5d80303499") 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 === "e254b8b9be8207c07f29cf30426466e2d916286b5f93ea4385786a5d80303499", '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 }; }
|
|
1364
1364
|
function snapshotMarkdown(markdown) { return markdown.split(/\n/).map((line) => line ? line + ' \n' : '\n').join(''); }
|
package/see/examples/socrates.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) {
|
|
@@ -1295,7 +1295,7 @@ const QUERIES = [
|
|
|
1295
1295
|
]
|
|
1296
1296
|
}
|
|
1297
1297
|
];
|
|
1298
|
-
const DOC_MARKDOWN = "# Socrates inference\n\nGenerated by `see.js` from a Notation3 source file.\n\n## Compilation summary\n\n- Example name: `socrates`\n- Input facts emitted: 2\n- Forward rules compiled: 1\n- Backward predicate rules compiled: 0\n- Fuses compiled: 0\n- Predicate count: 2\n\n## Built-ins used\n\n- none\n\n## Runtime model\n\nThe generated `examples/socrates.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/socrates.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/socrates.trig` or `examples/input/socrates.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/socrates.js` produces a SEE-style Markdown report with an **
|
|
1298
|
+
const DOC_MARKDOWN = "# Socrates inference\n\nGenerated by `see.js` from a Notation3 source file.\n\n## Compilation summary\n\n- Example name: `socrates`\n- Input facts emitted: 2\n- Forward rules compiled: 1\n- Backward predicate rules compiled: 0\n- Fuses compiled: 0\n- Predicate count: 2\n\n## Built-ins used\n\n- none\n\n## Runtime model\n\nThe generated `examples/socrates.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/socrates.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/socrates.trig` or `examples/input/socrates.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/socrates.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";
|
|
1299
1299
|
function seeMetadata(data) { return (data && data.__see) || {}; }
|
|
1300
1300
|
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 !== "a0c8a488401f3247c2371978378e7f4c532c8b6c22d5f5642665e93fd8c576a4") 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 === "a0c8a488401f3247c2371978378e7f4c532c8b6c22d5f5642665e93fd8c576a4", '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 }; }
|
|
1301
1301
|
function snapshotMarkdown(markdown) { return markdown.split(/\n/).map((line) => line ? line + ' \n' : '\n').join(''); }
|