eyeling 1.24.5 → 1.24.6

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