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
|
@@ -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) {
|
|
@@ -1238,7 +1238,7 @@ const RULES = [
|
|
|
1238
1238
|
}
|
|
1239
1239
|
];
|
|
1240
1240
|
const QUERIES = [];
|
|
1241
|
-
const DOC_MARKDOWN = "# Existential rule\n\nGenerated by `see.js` from a Notation3 source file.\n\n## Compilation summary\n\n- Example name: `existential_rule`\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/existential_rule.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/existential_rule.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/existential-rule.trig` or `examples/input/existential_rule.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/existential_rule.js` produces a SEE-style Markdown report with an **
|
|
1241
|
+
const DOC_MARKDOWN = "# Existential rule\n\nGenerated by `see.js` from a Notation3 source file.\n\n## Compilation summary\n\n- Example name: `existential_rule`\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/existential_rule.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/existential_rule.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/existential-rule.trig` or `examples/input/existential_rule.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/existential_rule.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";
|
|
1242
1242
|
function seeMetadata(data) { return (data && data.__see) || {}; }
|
|
1243
1243
|
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 !== "f47b48d679b4bf2149782d40e01abb6f0d72cbbd0582bd7ab8a0ed2046f991f7") 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 === "f47b48d679b4bf2149782d40e01abb6f0d72cbbd0582bd7ab8a0ed2046f991f7", '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 === 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 }; }
|
|
1244
1244
|
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) {
|
|
@@ -1673,7 +1673,7 @@ const RULES = [
|
|
|
1673
1673
|
}
|
|
1674
1674
|
];
|
|
1675
1675
|
const QUERIES = [];
|
|
1676
|
-
const DOC_MARKDOWN = "# A tiny expression evaluator in N3\n\nGenerated by `see.js` from a Notation3 source file.\n\n## Compilation summary\n\n- Example name: `expression_eval`\n- Input facts emitted: 17\n- Forward rules compiled: 1\n- Backward predicate rules compiled: 4\n- Fuses compiled: 0\n- Predicate count: 11\n\n## Built-ins used\n\n- `math:difference`\n- `math:product`\n- `math:sum`\n\n## Runtime model\n\nThe generated `examples/expression_eval.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/expression_eval.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/expression-eval.trig` or `examples/input/expression_eval.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/expression_eval.js` produces a SEE-style Markdown report with an **
|
|
1676
|
+
const DOC_MARKDOWN = "# A tiny expression evaluator in N3\n\nGenerated by `see.js` from a Notation3 source file.\n\n## Compilation summary\n\n- Example name: `expression_eval`\n- Input facts emitted: 17\n- Forward rules compiled: 1\n- Backward predicate rules compiled: 4\n- Fuses compiled: 0\n- Predicate count: 11\n\n## Built-ins used\n\n- `math:difference`\n- `math:product`\n- `math:sum`\n\n## Runtime model\n\nThe generated `examples/expression_eval.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/expression_eval.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/expression-eval.trig` or `examples/input/expression_eval.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/expression_eval.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";
|
|
1677
1677
|
function seeMetadata(data) { return (data && data.__see) || {}; }
|
|
1678
1678
|
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 !== "8b33d5122b55a40c19af6d1504d29871bcd864dce595d6824acd4515d76e360c") 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 === "8b33d5122b55a40c19af6d1504d29871bcd864dce595d6824acd4515d76e360c", 'input evidence facts were loaded': expectedFacts > 0 ? facts.length === expectedFacts : facts.length >= 0, 'compiled rules were loaded': RULES.length === 5, '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 }; }
|
|
1679
1679
|
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) {
|
|
@@ -1461,7 +1461,7 @@ const RULES = [
|
|
|
1461
1461
|
}
|
|
1462
1462
|
];
|
|
1463
1463
|
const QUERIES = [];
|
|
1464
|
-
const DOC_MARKDOWN = "# Family cousins\n\nGenerated by `see.js` from a Notation3 source file.\n\n## Compilation summary\n\n- Example name: `family_cousins`\n- Input facts emitted: 15\n- Forward rules compiled: 4\n- Backward predicate rules compiled: 0\n- Fuses compiled: 0\n- Predicate count: 6\n\n## Built-ins used\n\n- `math:sum`\n\n## Runtime model\n\nThe generated `examples/family_cousins.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/family_cousins.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/family-cousins.trig` or `examples/input/family_cousins.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/family_cousins.js` produces a SEE-style Markdown report with an **
|
|
1464
|
+
const DOC_MARKDOWN = "# Family cousins\n\nGenerated by `see.js` from a Notation3 source file.\n\n## Compilation summary\n\n- Example name: `family_cousins`\n- Input facts emitted: 15\n- Forward rules compiled: 4\n- Backward predicate rules compiled: 0\n- Fuses compiled: 0\n- Predicate count: 6\n\n## Built-ins used\n\n- `math:sum`\n\n## Runtime model\n\nThe generated `examples/family_cousins.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/family_cousins.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/family-cousins.trig` or `examples/input/family_cousins.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/family_cousins.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";
|
|
1465
1465
|
function seeMetadata(data) { return (data && data.__see) || {}; }
|
|
1466
1466
|
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 !== "5254e987fd72e71aafad53c8e3e9eb91d034cfd06878fcd02f611539200ab3e4") 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 === "5254e987fd72e71aafad53c8e3e9eb91d034cfd06878fcd02f611539200ab3e4", '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 === 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 }; }
|
|
1467
1467
|
function snapshotMarkdown(markdown) { return markdown.split(/\n/).map((line) => line ? line + ' \n' : '\n').join(''); }
|
package/see/examples/fastpow.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) {
|
|
@@ -2082,7 +2082,7 @@ const RULES = [
|
|
|
2082
2082
|
}
|
|
2083
2083
|
];
|
|
2084
2084
|
const QUERIES = [];
|
|
2085
|
-
const DOC_MARKDOWN = "# Fast exponentiation demo\n\nGenerated by `see.js` from a Notation3 source file.\n\n## Compilation summary\n\n- Example name: `fastpow`\n- Input facts emitted: 0\n- Forward rules compiled: 1\n- Backward predicate rules compiled: 7\n- Fuses compiled: 0\n- Predicate count: 12\n\n## Built-ins used\n\n- `math:difference`\n- `math:equalTo`\n- `math:exponentiation`\n- `math:greaterThan`\n- `math:product`\n- `math:remainder`\n\n## Runtime model\n\nThe generated `examples/fastpow.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/fastpow.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/fastpow.trig` or `examples/input/fastpow.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/fastpow.js` produces a SEE-style Markdown report with an **
|
|
2085
|
+
const DOC_MARKDOWN = "# Fast exponentiation demo\n\nGenerated by `see.js` from a Notation3 source file.\n\n## Compilation summary\n\n- Example name: `fastpow`\n- Input facts emitted: 0\n- Forward rules compiled: 1\n- Backward predicate rules compiled: 7\n- Fuses compiled: 0\n- Predicate count: 12\n\n## Built-ins used\n\n- `math:difference`\n- `math:equalTo`\n- `math:exponentiation`\n- `math:greaterThan`\n- `math:product`\n- `math:remainder`\n\n## Runtime model\n\nThe generated `examples/fastpow.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/fastpow.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/fastpow.trig` or `examples/input/fastpow.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/fastpow.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";
|
|
2086
2086
|
function seeMetadata(data) { return (data && data.__see) || {}; }
|
|
2087
2087
|
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 !== "be6ae46e774f3887cf89f2302ba55a826a08d3c846b77dd3c78a90e32d0ebc14") 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 === "be6ae46e774f3887cf89f2302ba55a826a08d3c846b77dd3c78a90e32d0ebc14", 'input evidence facts were loaded': expectedFacts > 0 ? facts.length === expectedFacts : facts.length >= 0, 'compiled rules were loaded': RULES.length === 8, '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 }; }
|
|
2088
2088
|
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) {
|
|
@@ -1469,7 +1469,7 @@ const QUERIES = [
|
|
|
1469
1469
|
]
|
|
1470
1470
|
}
|
|
1471
1471
|
];
|
|
1472
|
-
const DOC_MARKDOWN = "# Fibonacci Example (Big)\n\nGenerated by `see.js` from a Notation3 source file.\n\nN3-compiled version of the exact Fibonacci example. The target and sample indices are represented as formal TriG input\nevidence when this source is compiled.\n\n## Compilation summary\n\n- Example name: `fibonacci`\n- Input facts emitted: 27\n- Forward rules compiled: 1\n- Backward predicate rules compiled: 0\n- Fuses compiled: 0\n- Predicate count: 11\n\n## Built-ins used\n\n- `log:outputString`\n- `string:format`\n\n## Runtime model\n\nThe generated `examples/fibonacci.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/fibonacci.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/fibonacci.trig` or `examples/input/fibonacci.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/fibonacci.js` produces a SEE-style Markdown report with an **
|
|
1472
|
+
const DOC_MARKDOWN = "# Fibonacci Example (Big)\n\nGenerated by `see.js` from a Notation3 source file.\n\nN3-compiled version of the exact Fibonacci example. The target and sample indices are represented as formal TriG input\nevidence when this source is compiled.\n\n## Compilation summary\n\n- Example name: `fibonacci`\n- Input facts emitted: 27\n- Forward rules compiled: 1\n- Backward predicate rules compiled: 0\n- Fuses compiled: 0\n- Predicate count: 11\n\n## Built-ins used\n\n- `log:outputString`\n- `string:format`\n\n## Runtime model\n\nThe generated `examples/fibonacci.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/fibonacci.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/fibonacci.trig` or `examples/input/fibonacci.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/fibonacci.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";
|
|
1473
1473
|
function seeMetadata(data) { return (data && data.__see) || {}; }
|
|
1474
1474
|
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 !== "25d93f4de352e797e1afb277f9f5805b1cdaface366f199b1195cc601555a172") 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 === "25d93f4de352e797e1afb277f9f5805b1cdaface366f199b1195cc601555a172", '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 }; }
|
|
1475
1475
|
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) {
|
|
@@ -1367,7 +1367,7 @@ const QUERIES = [
|
|
|
1367
1367
|
]
|
|
1368
1368
|
}
|
|
1369
1369
|
];
|
|
1370
|
-
const DOC_MARKDOWN = "# French cities — graph path traversal.\n\nGenerated by `see.js` from a Notation3 source file.\n\nBased on the EYE reasoning/graph example: graph.axiom.n3 plus graph.filter.n3.\nIt asks whether Paris can reach Nantes by following one-way links, using a\nsubproperty rule and a transitive-property rule.\n\n## Compilation summary\n\n- Example name: `french_cities`\n- Input facts emitted: 12\n- Forward rules compiled: 2\n- Backward predicate rules compiled: 0\n- Fuses compiled: 0\n- Predicate count: 6\n\n## Built-ins used\n\n- none\n\n## Runtime model\n\nThe generated `examples/french_cities.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/french_cities.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/french-cities.trig` or `examples/input/french_cities.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/french_cities.js` produces a SEE-style Markdown report with an **
|
|
1370
|
+
const DOC_MARKDOWN = "# French cities — graph path traversal.\n\nGenerated by `see.js` from a Notation3 source file.\n\nBased on the EYE reasoning/graph example: graph.axiom.n3 plus graph.filter.n3.\nIt asks whether Paris can reach Nantes by following one-way links, using a\nsubproperty rule and a transitive-property rule.\n\n## Compilation summary\n\n- Example name: `french_cities`\n- Input facts emitted: 12\n- Forward rules compiled: 2\n- Backward predicate rules compiled: 0\n- Fuses compiled: 0\n- Predicate count: 6\n\n## Built-ins used\n\n- none\n\n## Runtime model\n\nThe generated `examples/french_cities.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/french_cities.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/french-cities.trig` or `examples/input/french_cities.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/french_cities.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";
|
|
1371
1371
|
function seeMetadata(data) { return (data && data.__see) || {}; }
|
|
1372
1372
|
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 !== "7e3672e6ab314845d44cdd16e7a91484c205de77ff8c9a06971f857612692be4") 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 === "7e3672e6ab314845d44cdd16e7a91484c205de77ff8c9a06971f857612692be4", '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 === 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 }; }
|
|
1373
1373
|
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) {
|
|
@@ -1981,7 +1981,7 @@ const QUERIES = [
|
|
|
1981
1981
|
]
|
|
1982
1982
|
}
|
|
1983
1983
|
];
|
|
1984
|
-
const DOC_MARKDOWN = "# Fundamental Theorem Arithmetic\n\nGenerated by `see.js` from a Notation3 source file.\n\nN3-compiled version of the hand-written SEE example. The primary case mirrors\nEyeling's fundamental-theorem-arithmetic.n3: n = 202692987 is validated against\nthe factorization 3^2 * 7 * 829 * 3881. Extra sample summaries are kept as\ndata so the SEE report still documents the larger regression set.\n\n## Compilation summary\n\n- Example name: `fundamental_theorem_arithmetic`\n- Input facts emitted: 16\n- Forward rules compiled: 4\n- Backward predicate rules compiled: 0\n- Fuses compiled: 3\n- Predicate count: 25\n\n## Built-ins used\n\n- `list:reverse`\n- `list:sort`\n- `log:equalTo`\n- `log:notIncludes`\n- `log:outputString`\n- `math:equalTo`\n- `math:product`\n- `string:format`\n\n## Runtime model\n\nThe generated `examples/fundamental_theorem_arithmetic.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/fundamental_theorem_arithmetic.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/fundamental-theorem-arithmetic.trig` or `examples/input/fundamental_theorem_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/fundamental_theorem_arithmetic.js` produces a SEE-style Markdown report with an **
|
|
1984
|
+
const DOC_MARKDOWN = "# Fundamental Theorem Arithmetic\n\nGenerated by `see.js` from a Notation3 source file.\n\nN3-compiled version of the hand-written SEE example. The primary case mirrors\nEyeling's fundamental-theorem-arithmetic.n3: n = 202692987 is validated against\nthe factorization 3^2 * 7 * 829 * 3881. Extra sample summaries are kept as\ndata so the SEE report still documents the larger regression set.\n\n## Compilation summary\n\n- Example name: `fundamental_theorem_arithmetic`\n- Input facts emitted: 16\n- Forward rules compiled: 4\n- Backward predicate rules compiled: 0\n- Fuses compiled: 3\n- Predicate count: 25\n\n## Built-ins used\n\n- `list:reverse`\n- `list:sort`\n- `log:equalTo`\n- `log:notIncludes`\n- `log:outputString`\n- `math:equalTo`\n- `math:product`\n- `string:format`\n\n## Runtime model\n\nThe generated `examples/fundamental_theorem_arithmetic.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/fundamental_theorem_arithmetic.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/fundamental-theorem-arithmetic.trig` or `examples/input/fundamental_theorem_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/fundamental_theorem_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";
|
|
1985
1985
|
function seeMetadata(data) { return (data && data.__see) || {}; }
|
|
1986
1986
|
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 !== "d88eca366c590d49544e49453cbe69ba38938f8bc23919278bfaadd0bed0cd2d") 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 === "d88eca366c590d49544e49453cbe69ba38938f8bc23919278bfaadd0bed0cd2d", 'input evidence facts were loaded': expectedFacts > 0 ? facts.length === expectedFacts : facts.length >= 0, 'compiled rules were loaded': RULES.length === 7, '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 }; }
|
|
1987
1987
|
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) {
|
|
@@ -1618,7 +1618,7 @@ const QUERIES = [
|
|
|
1618
1618
|
]
|
|
1619
1619
|
}
|
|
1620
1620
|
];
|
|
1621
|
-
const DOC_MARKDOWN = "# Genetic Knapsack Selection\n\nGenerated by `see.js` from a Notation3 source file.\n\nN3-compiled version of the deterministic one-bit mutation knapsack example.\nThe original item list JSON is preserved as the data-input sidecar.\n\n## Compilation summary\n\n- Example name: `genetic_knapsack_selection`\n- Input facts emitted: 14\n- Forward rules compiled: 2\n- Backward predicate rules compiled: 0\n- Fuses compiled: 0\n- Predicate count: 17\n\n## Built-ins used\n\n- `log:outputString`\n- `math:notGreaterThan`\n- `string:format`\n\n## Runtime model\n\nThe generated `examples/genetic_knapsack_selection.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/genetic_knapsack_selection.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/genetic-knapsack-selection.trig` or `examples/input/genetic_knapsack_selection.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/genetic_knapsack_selection.js` produces a SEE-style Markdown report with an **
|
|
1621
|
+
const DOC_MARKDOWN = "# Genetic Knapsack Selection\n\nGenerated by `see.js` from a Notation3 source file.\n\nN3-compiled version of the deterministic one-bit mutation knapsack example.\nThe original item list JSON is preserved as the data-input sidecar.\n\n## Compilation summary\n\n- Example name: `genetic_knapsack_selection`\n- Input facts emitted: 14\n- Forward rules compiled: 2\n- Backward predicate rules compiled: 0\n- Fuses compiled: 0\n- Predicate count: 17\n\n## Built-ins used\n\n- `log:outputString`\n- `math:notGreaterThan`\n- `string:format`\n\n## Runtime model\n\nThe generated `examples/genetic_knapsack_selection.js` is a specialized JavaScript derivation program. For ordinary sources, `see.js` emits the source facts as `examples/input/genetic_knapsack_selection.trig`. For rules-only sources, generation can reuse an existing external evidence file such as `examples/input/genetic-knapsack-selection.trig` or `examples/input/genetic_knapsack_selection.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/genetic_knapsack_selection.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";
|
|
1622
1622
|
function seeMetadata(data) { return (data && data.__see) || {}; }
|
|
1623
1623
|
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 !== "c8fb351156e7656f2e3600f0d1eaf8a624742a91f688425564822cea78530855") 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 === "c8fb351156e7656f2e3600f0d1eaf8a624742a91f688425564822cea78530855", '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 === 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 }; }
|
|
1624
1624
|
function snapshotMarkdown(markdown) { return markdown.split(/\n/).map((line) => line ? line + ' \n' : '\n').join(''); }
|