eyeling 1.24.4 → 1.24.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (301) hide show
  1. package/HANDBOOK.md +2 -101
  2. package/README.md +2 -2
  3. package/dist/browser/eyeling.browser.js +256 -4
  4. package/examples/annotation.n3 +3 -4
  5. package/{see/examples/n3/backward_recursion.n3 → examples/backward-recursion.n3} +0 -2
  6. package/examples/collection.n3 +1 -2
  7. package/examples/context-association.n3 +56 -30
  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/{see/examples/input/dijkstra_risk_path.trig → examples/input/dijkstra-risk-path.trig} +4 -4
  16. package/{see/examples/input/eco_route_insight.trig → examples/input/eco-route-insight.trig} +4 -4
  17. package/{see/examples/input/genetic_knapsack_selection.trig → examples/input/genetic-knapsack-selection.trig} +4 -4
  18. package/{see/examples/input/rc_discharge_envelope.trig → examples/input/rc-discharge-envelope.trig} +4 -4
  19. package/{see/examples/input/rdf_dataset.trig → examples/input/rdf-dataset.trig} +4 -4
  20. package/{see/examples/input/rdf_message_flow.trig → examples/input/rdf-message-flow.trig} +3 -3
  21. package/{see/examples/input/rdf_messages.trig → examples/input/rdf-messages.trig} +4 -4
  22. package/{see/examples/input/school_placement_audit.trig → examples/input/school-placement-audit.trig} +4 -4
  23. package/{see/examples/input/smoke_arithmetic.trig → examples/input/smoke-arithmetic.trig} +3 -3
  24. package/{see/examples/input/triple_terms.trig → examples/input/triple-terms.trig} +3 -3
  25. package/examples/output/backward-recursion.n3 +4 -0
  26. package/examples/output/context-association.n3 +9 -0
  27. package/examples/output/dijkstra-risk-path.n3 +3 -0
  28. package/examples/output/eco-route-insight.n3 +3 -0
  29. package/examples/output/genetic-knapsack-selection.n3 +3 -0
  30. package/examples/output/rc-discharge-envelope.n3 +9 -0
  31. package/examples/output/rc-discharge-envelope.txt +9 -0
  32. package/examples/output/rdf-dataset.n3 +5 -0
  33. package/examples/output/rdf-message-flow.n3 +7 -0
  34. package/examples/output/rdf-messages.n3 +7 -0
  35. package/examples/output/school-placement-audit.n3 +3 -0
  36. package/examples/output/smoke-arithmetic.n3 +5 -0
  37. package/examples/output/smoke-arithmetic.txt +5 -0
  38. package/examples/output/triple-terms.n3 +5 -0
  39. package/{see/examples/n3/rc_discharge_envelope.n3 → examples/rc-discharge-envelope.n3} +2 -15
  40. package/{see/examples/n3/rdf_dataset.n3 → examples/rdf-dataset.n3} +2 -11
  41. package/{see/examples/n3/rdf_message_flow.n3 → examples/rdf-message-flow.n3} +9 -75
  42. package/{see/examples/n3/rdf_messages.n3 → examples/rdf-messages.n3} +6 -43
  43. package/{see/examples/n3/school_placement_audit.n3 → examples/school-placement-audit.n3} +2 -14
  44. package/{see/examples/n3/smoke_arithmetic.n3 → examples/smoke-arithmetic.n3} +3 -5
  45. package/{see/examples/n3/triple_terms.n3 → examples/triple-terms.n3} +1 -4
  46. package/eyeling.js +256 -4
  47. package/lib/builtins.js +6 -0
  48. package/lib/lexer.js +250 -4
  49. package/package.json +4 -7
  50. package/test/api.test.js +65 -8
  51. package/test/examples.test.js +22 -2
  52. package/test/package.test.js +16 -2
  53. package/examples/arcling/README.md +0 -11
  54. package/examples/input/annotation.ttl +0 -6
  55. package/examples/input/collection.ttl +0 -13
  56. package/examples/input/reifies.ttl +0 -10
  57. package/examples/input/triple-term.ttl +0 -8
  58. package/examples/output/triple-term.n3 +0 -0
  59. package/examples/reifies.n3 +0 -8
  60. package/examples/triple-term.n3 +0 -7
  61. package/see/README.md +0 -149
  62. package/see/examples/_see.js +0 -249
  63. package/see/examples/age.js +0 -1459
  64. package/see/examples/annotation.js +0 -1320
  65. package/see/examples/backward.js +0 -1405
  66. package/see/examples/backward_recursion.js +0 -1504
  67. package/see/examples/bayes_diagnosis.js +0 -2883
  68. package/see/examples/bayes_therapy.js +0 -4152
  69. package/see/examples/bmi.js +0 -3038
  70. package/see/examples/builtin_coverage.js +0 -2524
  71. package/see/examples/collection.js +0 -1320
  72. package/see/examples/complex.js +0 -3762
  73. package/see/examples/complex_matrix_stability.js +0 -2973
  74. package/see/examples/composition_of_injective_functions_is_injective.js +0 -2170
  75. package/see/examples/control_system.js +0 -1918
  76. package/see/examples/crypto_builtins_tests.js +0 -1489
  77. package/see/examples/delfour.js +0 -3174
  78. package/see/examples/digital_product_passport.js +0 -2856
  79. package/see/examples/dijkstra.js +0 -2070
  80. package/see/examples/dijkstra_risk_path.js +0 -1874
  81. package/see/examples/doc/age.md +0 -27
  82. package/see/examples/doc/annotation.md +0 -24
  83. package/see/examples/doc/backward.md +0 -26
  84. package/see/examples/doc/backward_recursion.md +0 -26
  85. package/see/examples/doc/bayes_diagnosis.md +0 -41
  86. package/see/examples/doc/bayes_therapy.md +0 -40
  87. package/see/examples/doc/bmi.md +0 -38
  88. package/see/examples/doc/builtin_coverage.md +0 -53
  89. package/see/examples/doc/collection.md +0 -24
  90. package/see/examples/doc/complex.md +0 -38
  91. package/see/examples/doc/complex_matrix_stability.md +0 -35
  92. package/see/examples/doc/composition_of_injective_functions_is_injective.md +0 -24
  93. package/see/examples/doc/control_system.md +0 -32
  94. package/see/examples/doc/crypto_builtins_tests.md +0 -27
  95. package/see/examples/doc/delfour.md +0 -37
  96. package/see/examples/doc/digital_product_passport.md +0 -36
  97. package/see/examples/doc/dijkstra.md +0 -28
  98. package/see/examples/doc/dijkstra_risk_path.md +0 -30
  99. package/see/examples/doc/dog.md +0 -28
  100. package/see/examples/doc/eco_route_insight.md +0 -33
  101. package/see/examples/doc/equals.md +0 -26
  102. package/see/examples/doc/equivalence_classes_overlap_implies_same_class.md +0 -24
  103. package/see/examples/doc/euler_identity.md +0 -39
  104. package/see/examples/doc/ev_roundtrip_planner.md +0 -32
  105. package/see/examples/doc/existential_rule.md +0 -24
  106. package/see/examples/doc/expression_eval.md +0 -26
  107. package/see/examples/doc/family_cousins.md +0 -24
  108. package/see/examples/doc/fastpow.md +0 -29
  109. package/see/examples/doc/fibonacci.md +0 -28
  110. package/see/examples/doc/french_cities.md +0 -28
  111. package/see/examples/doc/fundamental_theorem_arithmetic.md +0 -36
  112. package/see/examples/doc/genetic_knapsack_selection.md +0 -29
  113. package/see/examples/doc/goldbach_1000.md +0 -31
  114. package/see/examples/doc/good_cobbler.md +0 -27
  115. package/see/examples/doc/gps.md +0 -35
  116. package/see/examples/doc/gray_code_counter.md +0 -31
  117. package/see/examples/doc/greatest_lower_bound_uniqueness.md +0 -24
  118. package/see/examples/doc/group_inverse_uniqueness.md +0 -24
  119. package/see/examples/doc/hadamard_approx.md +0 -32
  120. package/see/examples/doc/hanoi.md +0 -26
  121. package/see/examples/doc/odrl_dpv_risk_ranked.md +0 -57
  122. package/see/examples/doc/path_discovery.md +0 -33
  123. package/see/examples/doc/rc_discharge_envelope.md +0 -33
  124. package/see/examples/doc/rdf_dataset.md +0 -26
  125. package/see/examples/doc/rdf_message_flow.md +0 -35
  126. package/see/examples/doc/rdf_messages.md +0 -37
  127. package/see/examples/doc/school_placement_audit.md +0 -31
  128. package/see/examples/doc/smoke_arithmetic.md +0 -31
  129. package/see/examples/doc/socrates.md +0 -24
  130. package/see/examples/doc/triple_terms.md +0 -26
  131. package/see/examples/doc/wind_turbine.md +0 -37
  132. package/see/examples/doc/witch.md +0 -28
  133. package/see/examples/dog.js +0 -1436
  134. package/see/examples/eco_route_insight.js +0 -2110
  135. package/see/examples/equals.js +0 -1363
  136. package/see/examples/equivalence_classes_overlap_implies_same_class.js +0 -1792
  137. package/see/examples/euler_identity.js +0 -2038
  138. package/see/examples/ev_roundtrip_planner.js +0 -2562
  139. package/see/examples/existential_rule.js +0 -1363
  140. package/see/examples/expression_eval.js +0 -1798
  141. package/see/examples/family_cousins.js +0 -1586
  142. package/see/examples/fastpow.js +0 -2207
  143. package/see/examples/fibonacci.js +0 -1594
  144. package/see/examples/french_cities.js +0 -1492
  145. package/see/examples/fundamental_theorem_arithmetic.js +0 -2106
  146. package/see/examples/genetic_knapsack_selection.js +0 -1743
  147. package/see/examples/goldbach_1000.js +0 -1798
  148. package/see/examples/good_cobbler.js +0 -1396
  149. package/see/examples/gps.js +0 -2813
  150. package/see/examples/gray_code_counter.js +0 -1641
  151. package/see/examples/greatest_lower_bound_uniqueness.js +0 -1918
  152. package/see/examples/group_inverse_uniqueness.js +0 -1897
  153. package/see/examples/hadamard_approx.js +0 -4417
  154. package/see/examples/hanoi.js +0 -1625
  155. package/see/examples/input/age.trig +0 -27
  156. package/see/examples/input/backward.trig +0 -25
  157. package/see/examples/input/bayes_diagnosis.trig +0 -111
  158. package/see/examples/input/bayes_therapy.trig +0 -130
  159. package/see/examples/input/bmi.trig +0 -28
  160. package/see/examples/input/complex.trig +0 -26
  161. package/see/examples/input/complex_matrix_stability.trig +0 -65
  162. package/see/examples/input/composition_of_injective_functions_is_injective.trig +0 -35
  163. package/see/examples/input/control_system.trig +0 -31
  164. package/see/examples/input/crypto_builtins_tests.trig +0 -25
  165. package/see/examples/input/delfour.trig +0 -90
  166. package/see/examples/input/digital_product_passport.trig +0 -116
  167. package/see/examples/input/dijkstra.trig +0 -34
  168. package/see/examples/input/dog.trig +0 -31
  169. package/see/examples/input/equals.trig +0 -25
  170. package/see/examples/input/equivalence_classes_overlap_implies_same_class.trig +0 -28
  171. package/see/examples/input/euler_identity.trig +0 -34
  172. package/see/examples/input/ev_roundtrip_planner.trig +0 -90
  173. package/see/examples/input/existential_rule.trig +0 -26
  174. package/see/examples/input/expression_eval.trig +0 -41
  175. package/see/examples/input/family_cousins.trig +0 -39
  176. package/see/examples/input/fastpow.trig +0 -25
  177. package/see/examples/input/fibonacci.trig +0 -51
  178. package/see/examples/input/french_cities.trig +0 -38
  179. package/see/examples/input/fundamental_theorem_arithmetic.trig +0 -42
  180. package/see/examples/input/goldbach_1000.trig +0 -53
  181. package/see/examples/input/good_cobbler.trig +0 -24
  182. package/see/examples/input/gps.trig +0 -35
  183. package/see/examples/input/gray_code_counter.trig +0 -33
  184. package/see/examples/input/greatest_lower_bound_uniqueness.trig +0 -29
  185. package/see/examples/input/group_inverse_uniqueness.trig +0 -29
  186. package/see/examples/input/hadamard_approx.trig +0 -32
  187. package/see/examples/input/hanoi.trig +0 -26
  188. package/see/examples/input/odrl_dpv_risk_ranked.trig +0 -107
  189. package/see/examples/input/path-discovery.trig +0 -96448
  190. package/see/examples/input/path_discovery.trig +0 -29
  191. package/see/examples/input/socrates.trig +0 -26
  192. package/see/examples/input/wind_turbine.trig +0 -48
  193. package/see/examples/input/witch.trig +0 -26
  194. package/see/examples/n3/age.n3 +0 -28
  195. package/see/examples/n3/annotation.n3 +0 -7
  196. package/see/examples/n3/backward.n3 +0 -22
  197. package/see/examples/n3/bayes_diagnosis.n3 +0 -122
  198. package/see/examples/n3/bayes_therapy.n3 +0 -149
  199. package/see/examples/n3/bmi.n3 +0 -145
  200. package/see/examples/n3/collection.n3 +0 -3
  201. package/see/examples/n3/complex.n3 +0 -140
  202. package/see/examples/n3/complex_matrix_stability.n3 +0 -113
  203. package/see/examples/n3/composition_of_injective_functions_is_injective.n3 +0 -27
  204. package/see/examples/n3/control_system.n3 +0 -59
  205. package/see/examples/n3/crypto_builtins_tests.n3 +0 -18
  206. package/see/examples/n3/delfour.n3 +0 -167
  207. package/see/examples/n3/digital_product_passport.n3 +0 -156
  208. package/see/examples/n3/dijkstra.n3 +0 -46
  209. package/see/examples/n3/dog.n3 +0 -20
  210. package/see/examples/n3/equals.n3 +0 -11
  211. package/see/examples/n3/equivalence_classes_overlap_implies_same_class.n3 +0 -19
  212. package/see/examples/n3/euler_identity.n3 +0 -41
  213. package/see/examples/n3/ev_roundtrip_planner.n3 +0 -82
  214. package/see/examples/n3/existential_rule.n3 +0 -10
  215. package/see/examples/n3/expression_eval.n3 +0 -21
  216. package/see/examples/n3/family_cousins.n3 +0 -62
  217. package/see/examples/n3/fastpow.n3 +0 -56
  218. package/see/examples/n3/fibonacci.n3 +0 -44
  219. package/see/examples/n3/french_cities.n3 +0 -28
  220. package/see/examples/n3/fundamental_theorem_arithmetic.n3 +0 -84
  221. package/see/examples/n3/goldbach_1000.n3 +0 -66
  222. package/see/examples/n3/good_cobbler.n3 +0 -10
  223. package/see/examples/n3/gps.n3 +0 -70
  224. package/see/examples/n3/gray_code_counter.n3 +0 -53
  225. package/see/examples/n3/greatest_lower_bound_uniqueness.n3 +0 -20
  226. package/see/examples/n3/group_inverse_uniqueness.n3 +0 -19
  227. package/see/examples/n3/hadamard_approx.n3 +0 -43
  228. package/see/examples/n3/hanoi.n3 +0 -16
  229. package/see/examples/n3/odrl_dpv_risk_ranked.n3 +0 -460
  230. package/see/examples/n3/path_discovery.n3 +0 -43
  231. package/see/examples/n3/socrates.n3 +0 -21
  232. package/see/examples/n3/wind_turbine.n3 +0 -85
  233. package/see/examples/n3/witch.n3 +0 -30
  234. package/see/examples/odrl_dpv_risk_ranked.js +0 -5128
  235. package/see/examples/output/age.md +0 -48
  236. package/see/examples/output/annotation.md +0 -43
  237. package/see/examples/output/backward.md +0 -50
  238. package/see/examples/output/backward_recursion.md +0 -54
  239. package/see/examples/output/bayes_diagnosis.md +0 -103
  240. package/see/examples/output/bayes_therapy.md +0 -84
  241. package/see/examples/output/bmi.md +0 -164
  242. package/see/examples/output/builtin_coverage.md +0 -99
  243. package/see/examples/output/collection.md +0 -44
  244. package/see/examples/output/complex.md +0 -61
  245. package/see/examples/output/complex_matrix_stability.md +0 -55
  246. package/see/examples/output/composition_of_injective_functions_is_injective.md +0 -62
  247. package/see/examples/output/control_system.md +0 -61
  248. package/see/examples/output/crypto_builtins_tests.md +0 -68
  249. package/see/examples/output/delfour.md +0 -100
  250. package/see/examples/output/digital_product_passport.md +0 -100
  251. package/see/examples/output/dijkstra.md +0 -74
  252. package/see/examples/output/dijkstra_risk_path.md +0 -76
  253. package/see/examples/output/dog.md +0 -50
  254. package/see/examples/output/eco_route_insight.md +0 -88
  255. package/see/examples/output/equals.md +0 -50
  256. package/see/examples/output/equivalence_classes_overlap_implies_same_class.md +0 -86
  257. package/see/examples/output/euler_identity.md +0 -73
  258. package/see/examples/output/ev_roundtrip_planner.md +0 -79
  259. package/see/examples/output/existential_rule.md +0 -54
  260. package/see/examples/output/expression_eval.md +0 -50
  261. package/see/examples/output/family_cousins.md +0 -187
  262. package/see/examples/output/fastpow.md +0 -36
  263. package/see/examples/output/fibonacci.md +0 -53
  264. package/see/examples/output/french_cities.md +0 -70
  265. package/see/examples/output/fundamental_theorem_arithmetic.md +0 -101
  266. package/see/examples/output/genetic_knapsack_selection.md +0 -66
  267. package/see/examples/output/goldbach_1000.md +0 -58
  268. package/see/examples/output/good_cobbler.md +0 -54
  269. package/see/examples/output/gps.md +0 -102
  270. package/see/examples/output/gray_code_counter.md +0 -68
  271. package/see/examples/output/greatest_lower_bound_uniqueness.md +0 -60
  272. package/see/examples/output/group_inverse_uniqueness.md +0 -60
  273. package/see/examples/output/hadamard_approx.md +0 -510
  274. package/see/examples/output/hanoi.md +0 -51
  275. package/see/examples/output/odrl_dpv_risk_ranked.md +0 -139
  276. package/see/examples/output/path_discovery.md +0 -65
  277. package/see/examples/output/rc_discharge_envelope.md +0 -102
  278. package/see/examples/output/rdf_dataset.md +0 -54
  279. package/see/examples/output/rdf_message_flow.md +0 -198
  280. package/see/examples/output/rdf_messages.md +0 -134
  281. package/see/examples/output/school_placement_audit.md +0 -99
  282. package/see/examples/output/smoke_arithmetic.md +0 -54
  283. package/see/examples/output/socrates.md +0 -55
  284. package/see/examples/output/triple_terms.md +0 -53
  285. package/see/examples/output/wind_turbine.md +0 -108
  286. package/see/examples/output/witch.md +0 -87
  287. package/see/examples/path_discovery.js +0 -1774
  288. package/see/examples/rc_discharge_envelope.js +0 -1993
  289. package/see/examples/rdf_dataset.js +0 -1512
  290. package/see/examples/rdf_message_flow.js +0 -2580
  291. package/see/examples/rdf_messages.js +0 -2176
  292. package/see/examples/school_placement_audit.js +0 -1867
  293. package/see/examples/smoke_arithmetic.js +0 -1483
  294. package/see/examples/socrates.js +0 -1420
  295. package/see/examples/triple_terms.js +0 -1442
  296. package/see/examples/wind_turbine.js +0 -2853
  297. package/see/examples/witch.js +0 -1519
  298. package/see/see.js +0 -2179
  299. package/test/see.test.js +0 -159
  300. /package/{see/examples/n3/builtin_coverage.n3 → examples/builtin-coverage.n3} +0 -0
  301. /package/examples/output/{reifies.n3 → builtin-coverage.n3} +0 -0
@@ -1,29 +0,0 @@
1
- @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
2
- @prefix nepo: <http://neptune.aws.com/ontology/airroutes/> .
3
- @prefix res: <http://neptune.aws.com/ontology/airroutes/resource#> .
4
- @prefix math: <http://www.w3.org/2000/10/swap/math#> .
5
- @prefix list: <http://www.w3.org/2000/10/swap/list#> .
6
- @prefix log: <http://www.w3.org/2000/10/swap/log#> .
7
- @prefix : <http://example.org/#> .
8
- @prefix see: <https://example.org/see#> .
9
- @prefix in: <https://example.org/see/input#> .
10
-
11
- # Formal SEE input evidence in RDF 1.2 TriG.
12
- # The generated runner reads this TriG evidence directly in RDF compatibility mode.
13
-
14
- # No source facts were present in the N3 program.
15
-
16
- in:metadata {
17
- in:run a see:InputDataset .
18
- in:run see:name "path_discovery" .
19
- in:run see:title "Path Discovery" .
20
- in:run see:sourceFile "examples/n3/path_discovery.n3" .
21
- in:run see:sourceSHA256 "9481a2b27a6cae4d73f312c7d8403d1abd7beab573f627f591ea8301073fe4db" .
22
- in:run see:description "SEE version of the Eyeling airport path-discovery example.\nThe full airroutes evidence is intentionally stored in\nexamples/input/path-discovery.trig, not in this source file. This file keeps\nonly the path-finding rules and the query shape from the upstream example." .
23
- in:run see:compiler "see.js N3-to-JS compiler" .
24
- in:run see:inputFacts 0 .
25
- in:run see:compiledRules 1 .
26
- in:run see:compiledBackwardRules 2 .
27
- in:run see:compiledFuses 0 .
28
- in:run see:compiledQueries 0 .
29
- }
@@ -1,26 +0,0 @@
1
- @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
2
- @prefix log: <http://www.w3.org/2000/10/swap/log#> .
3
- @prefix : <http://example.org/socrates#> .
4
- @prefix see: <https://example.org/see#> .
5
- @prefix in: <https://example.org/see/input#> .
6
-
7
- # Formal SEE input evidence in RDF 1.2 TriG.
8
- # The generated runner reads this TriG evidence directly.
9
-
10
- :Socrates rdf:type :Human .
11
- :Human rdfs:subClassOf :Mortal .
12
-
13
- in:metadata {
14
- in:run a see:InputDataset .
15
- in:run see:name "socrates" .
16
- in:run see:title "Socrates inference" .
17
- in:run see:sourceFile "examples/n3/socrates.n3" .
18
- in:run see:sourceSHA256 "a0c8a488401f3247c2371978378e7f4c532c8b6c22d5f5642665e93fd8c576a4" .
19
- in:run see:description "" .
20
- in:run see:compiler "see.js N3-to-JS compiler" .
21
- in:run see:inputFacts 2 .
22
- in:run see:compiledRules 1 .
23
- in:run see:compiledBackwardRules 0 .
24
- in:run see:compiledFuses 0 .
25
- in:run see:compiledQueries 1 .
26
- }
@@ -1,48 +0,0 @@
1
- @prefix : <https://eyereasoner.github.io/see/examples/wind-turbine#> .
2
- @prefix math: <http://www.w3.org/2000/10/swap/math#> .
3
- @prefix log: <http://www.w3.org/2000/10/swap/log#> .
4
- @prefix string: <http://www.w3.org/2000/10/swap/string#> .
5
- @prefix see: <https://example.org/see#> .
6
- @prefix in: <https://example.org/see/input#> .
7
-
8
- # Formal SEE input evidence in RDF 1.2 TriG.
9
- # The generated runner reads this TriG evidence directly.
10
-
11
- :case :cutInMS 3.5 .
12
- :case :ratedMS 12 .
13
- :case :cutOutMS 25 .
14
- :case :ratedPowerMW 3.2 .
15
- :case :intervalMinutes 10 .
16
- :case :sample :t1 .
17
- :case :sample :t2 .
18
- :case :sample :t3 .
19
- :case :sample :t4 .
20
- :case :sample :t5 .
21
- :case :sample :t6 .
22
- :t1 :index 1 .
23
- :t1 :speedMS 3 .
24
- :t2 :index 2 .
25
- :t2 :speedMS 6.5 .
26
- :t3 :index 3 .
27
- :t3 :speedMS 11.2 .
28
- :t4 :index 4 .
29
- :t4 :speedMS 15 .
30
- :t5 :index 5 .
31
- :t5 :speedMS 24.5 .
32
- :t6 :index 6 .
33
- :t6 :speedMS 27 .
34
-
35
- in:metadata {
36
- in:run a see:InputDataset .
37
- in:run see:name "wind_turbine" .
38
- in:run see:title "Wind Turbine Envelope" .
39
- in:run see:sourceFile "examples/n3/wind_turbine.n3" .
40
- in:run see:sourceSHA256 "cf2129430d3165b9e304a078ce1b40c0f4634b4c98a14832c096ac0c1a70a049" .
41
- in:run see:description "Classify wind-speed samples against a turbine operating envelope and compute\ninterval energy. The classification and cubic power curve are expressed in N3\nrules and compiled into a standalone SEE JavaScript example." .
42
- in:run see:compiler "see.js N3-to-JS compiler" .
43
- in:run see:inputFacts 23 .
44
- in:run see:compiledRules 7 .
45
- in:run see:compiledBackwardRules 0 .
46
- in:run see:compiledFuses 0 .
47
- in:run see:compiledQueries 0 .
48
- }
@@ -1,26 +0,0 @@
1
- @prefix : <http://example.org/witch#> .
2
- @prefix log: <http://www.w3.org/2000/10/swap/log#> .
3
- @prefix see: <https://example.org/see#> .
4
- @prefix in: <https://example.org/see/input#> .
5
-
6
- # Formal SEE input evidence in RDF 1.2 TriG.
7
- # The generated runner reads this TriG evidence directly.
8
-
9
- :GIRL rdf:type :WOMAN .
10
- :DUCK rdf:type :FLOATS .
11
- :DUCK :SAMEWEIGHT :GIRL .
12
-
13
- in:metadata {
14
- in:run a see:InputDataset .
15
- in:run see:name "witch" .
16
- in:run see:title "Burn the witch" .
17
- in:run see:sourceFile "examples/n3/witch.n3" .
18
- in:run see:sourceSHA256 "bc0a493c490136926a3e3086f6b8bc63a8ae97334d723c7737eeaea837428045" .
19
- in:run see:description "http://clarkparsia.com/weblog/2007/01/02/burn-the-witch/\nhttp://www.netfunny.com/rhf/jokes/90q4/burnher.html\noriginal http://www.w3.org/2000/10/swap/test/reason/witch.n3" .
20
- in:run see:compiler "see.js N3-to-JS compiler" .
21
- in:run see:inputFacts 3 .
22
- in:run see:compiledRules 4 .
23
- in:run see:compiledBackwardRules 0 .
24
- in:run see:compiledFuses 0 .
25
- in:run see:compiledQueries 0 .
26
- }
@@ -1,28 +0,0 @@
1
- # ===========================================
2
- # Age checker
3
- # Is the age of a person above some duration?
4
- # ===========================================
5
-
6
- @prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
7
- @prefix time: <http://www.w3.org/2000/10/swap/time#>.
8
- @prefix math: <http://www.w3.org/2000/10/swap/math#>.
9
- @prefix log: <http://www.w3.org/2000/10/swap/log#>.
10
- @prefix : <https://example.org/#>.
11
-
12
- # person data
13
- :patH :birthDay "1944-08-21"^^xsd:date.
14
-
15
- # is the age of a person above some duration?
16
- { ?S :ageAbove ?A } <= {
17
- ?S :birthDay ?B.
18
- "" time:localTime ?D.
19
- (?D ?B) math:difference ?F.
20
- ?F math:greaterThan ?A.
21
- }.
22
-
23
- # test
24
- {
25
- ?S :ageAbove "P80Y"^^xsd:duration.
26
- } log:query {
27
- :test :is true.
28
- }.
@@ -1,7 +0,0 @@
1
- @prefix : <https://eyereasoner.github.io/see/examples/annotation#>.
2
- @prefix log: <http://www.w3.org/2000/10/swap/log#>.
3
- @prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
4
- :a :name "Alice" .
5
- :t log:nameOf { :a :name "Alice" . } .
6
- :t :statedBy :bob .
7
- :t :recorded "2021-07-07"^^xsd:date .
@@ -1,22 +0,0 @@
1
- # ==============================================================
2
- # Backward rule example
3
- # See https://www.w3.org/2000/10/swap/doc/tutorial-1.pdf page 17
4
- # ==============================================================
5
-
6
- @prefix math: <http://www.w3.org/2000/10/swap/math#>.
7
- @prefix log: <http://www.w3.org/2000/10/swap/log#>.
8
- @prefix : <http://example.org/#>.
9
-
10
- # something is more interesting if it is greater
11
- {
12
- ?X :moreInterestingThan ?Y.
13
- } <= {
14
- ?X math:greaterThan ?Y.
15
- }.
16
-
17
- # derivation (forward)
18
- {
19
- 5 :moreInterestingThan 3.
20
- } => {
21
- 5 :isIndeedMoreInterestingThan 3.
22
- }.
@@ -1,122 +0,0 @@
1
- # ===============
2
- # Bayes Diagnosis
3
- # ===============
4
- # Naive Bayes diagnosis example, adapted from Eyeling's bayes-diagnosis.n3.
5
- # The facts and rules compute unnormalized likelihoods, normalize them into
6
- # posterior probabilities, and emit a SEE report for the highest posterior.
7
- # Values are illustrative only and are not medical advice.
8
-
9
- @prefix : <https://eyereasoner.github.io/see/examples/bayes-diagnosis#>.
10
- @prefix math: <http://www.w3.org/2000/10/swap/math#>.
11
- @prefix list: <http://www.w3.org/2000/10/swap/list#>.
12
- @prefix log: <http://www.w3.org/2000/10/swap/log#>.
13
- @prefix string: <http://www.w3.org/2000/10/swap/string#>.
14
-
15
- :COVID19 a :Disease; :label "COVID-19"; :prior 0.05.
16
- :Influenza a :Disease; :label "Influenza"; :prior 0.03.
17
- :AllergicRhinitis a :Disease; :label "Allergic rhinitis"; :prior 0.10.
18
- :BacterialPneumonia a :Disease; :label "Bacterial pneumonia"; :prior 0.01.
19
-
20
- :COVID19 :pGiven [ :symptom :Fever; :p 0.70 ], [ :symptom :DryCough; :p 0.65 ], [ :symptom :LossOfSmell; :p 0.40 ], [ :symptom :Sneezing; :p 0.15 ], [ :symptom :ShortBreath; :p 0.20 ].
21
- :Influenza :pGiven [ :symptom :Fever; :p 0.80 ], [ :symptom :DryCough; :p 0.50 ], [ :symptom :LossOfSmell; :p 0.05 ], [ :symptom :Sneezing; :p 0.20 ], [ :symptom :ShortBreath; :p 0.10 ].
22
- :AllergicRhinitis :pGiven [ :symptom :Fever; :p 0.05 ], [ :symptom :DryCough; :p 0.15 ], [ :symptom :LossOfSmell; :p 0.10 ], [ :symptom :Sneezing; :p 0.80 ], [ :symptom :ShortBreath; :p 0.05 ].
23
- :BacterialPneumonia :pGiven [ :symptom :Fever; :p 0.70 ], [ :symptom :DryCough; :p 0.60 ], [ :symptom :LossOfSmell; :p 0.02 ], [ :symptom :Sneezing; :p 0.05 ], [ :symptom :ShortBreath; :p 0.60 ].
24
-
25
- :Case a :PatientCase;
26
- :diseases (:COVID19 :Influenza :AllergicRhinitis :BacterialPneumonia);
27
- :evidence (
28
- [ :symptom :Fever; :present true ]
29
- [ :symptom :DryCough; :present true ]
30
- [ :symptom :LossOfSmell; :present true ]
31
- [ :symptom :Sneezing; :present false ]
32
- [ :symptom :ShortBreath; :present true ]
33
- ).
34
-
35
- # Probability guard rails: the compiler turns these fuses into runtime guards.
36
- { ?d :prior ?p. ?p math:lessThan 0. } => false.
37
- { ?d :prior ?p. ?p math:greaterThan 1. } => false.
38
- { ?d :pGiven [ :p ?p ]. ?p math:lessThan 0. } => false.
39
- { ?d :pGiven [ :p ?p ]. ?p math:greaterThan 1. } => false.
40
-
41
- # pairList(d, (x1 x2 ...)) -> ((d x1) (d x2) ...)
42
- { ( ?d () ) :pairList () } <= true.
43
- { ( ?d ?xs ) :pairList ?pairs } <= {
44
- ?xs list:firstRest ( ?x ?rest ).
45
- ( ?d ?rest ) :pairList ?tailPairs.
46
- ?pairs list:firstRest ( ( ?d ?x ) ?tailPairs ).
47
- }.
48
-
49
- # Evidence factor: present symptoms use P(symptom|disease), absent symptoms use 1-P.
50
- { ( ?d ?ev ) :factor ?p } <= {
51
- ?ev :symptom ?s; :present true.
52
- ?d :pGiven [ :symptom ?s; :p ?p ].
53
- }.
54
- { ( ?d ?ev ) :factor ?q } <= {
55
- ?ev :symptom ?s; :present false.
56
- ?d :pGiven [ :symptom ?s; :p ?p ].
57
- ( 1 ?p ) math:difference ?q.
58
- }.
59
-
60
- # unnormalized score(d) = prior(d) * product of evidence factors.
61
- { ?d :scoreFor ?score } <= {
62
- ?d :prior ?prior.
63
- :Case :evidence ?evs.
64
- ( ?d ?evs ) :pairList ?pairs.
65
- ( ?pairs :factor ) list:map ?factors.
66
- ?factors math:product ?likelihood.
67
- ( ?prior ?likelihood ) math:product ?score.
68
- }.
69
-
70
- # Normalize scores into posteriors.
71
- {
72
- :Case :diseases ?ds.
73
- ( ?ds :scoreFor ) list:map ?scores.
74
- ?scores math:sum ?total.
75
- } => {
76
- :Case :scores ?scores;
77
- :evidenceTotal ?total.
78
- }.
79
- {
80
- :Case :diseases ?ds;
81
- :scores ?scores;
82
- :evidenceTotal ?total.
83
- ?ds list:iterate ( ?i ?d ).
84
- ( ?scores ?i ) list:memberAt ?score.
85
- ( ?score ?total ) math:quotient ?post.
86
- } => {
87
- :Case :result [ :disease ?d; :unnormalized ?score; :posterior ?post ].
88
- ?d :posterior ?post.
89
- }.
90
-
91
- # Pick the posterior maximum by comparing to every case disease.
92
- {
93
- :Case :result [ :disease ?d; :posterior ?p ].
94
- :COVID19 :posterior ?pCOVID.
95
- :Influenza :posterior ?pFlu.
96
- :AllergicRhinitis :posterior ?pAllergy.
97
- :BacterialPneumonia :posterior ?pPneumonia.
98
- ?p math:notLessThan ?pCOVID.
99
- ?p math:notLessThan ?pFlu.
100
- ?p math:notLessThan ?pAllergy.
101
- ?p math:notLessThan ?pPneumonia.
102
- } => {
103
- :Case :winner ?d;
104
- :winnerPosterior ?p.
105
- }.
106
-
107
- {
108
- :Case :winner ?winner;
109
- :winnerPosterior ?winnerPost;
110
- :evidenceTotal ?total.
111
- ?winner :label ?winnerLabel.
112
- :COVID19 :posterior ?covidPost; :scoreFor ?covidScore.
113
- :Influenza :posterior ?fluPost; :scoreFor ?fluScore.
114
- :AllergicRhinitis :posterior ?allergyPost; :scoreFor ?allergyScore.
115
- :BacterialPneumonia :posterior ?pneuPost; :scoreFor ?pneuScore.
116
- ("=== Answer ===\nThe most likely disease is %s (posterior = %.6f).\n\nFull posterior distribution:\n COVID-19 posterior = %.6f (unnormalized = %.8f)\n Influenza posterior = %.6f (unnormalized = %.8f)\n Allergic rhinitis posterior = %.6f (unnormalized = %.8f)\n Bacterial pneumonia posterior = %.6f (unnormalized = %.8f)\n\n=== Explanation ===\nEvidence: Fever=present, DryCough=present, LossOfSmell=present, Sneezing=absent, ShortBreath=present. Evidence total (normalizing constant) = %.8f. Each posterior is prior(d) times the product of symptom likelihood factors, divided by the evidence total." ?winnerLabel ?winnerPost ?covidPost ?covidScore ?fluPost ?fluScore ?allergyPost ?allergyScore ?pneuPost ?pneuScore ?total) string:format ?Block.
117
- } => {
118
- :bayesDiagnosis log:outputString ?Block.
119
- :bayesDiagnosis :recommends ?winner.
120
- }.
121
-
122
- { :bayesDiagnosis :recommends ?Disease } log:query { :bayesDiagnosis :recommends ?Disease }.
@@ -1,149 +0,0 @@
1
- # ==============
2
- # Bayes Therapy
3
- # ==============
4
- # Extends the Bayesian diagnosis model with a therapy utility layer. Adapted
5
- # from Eyeling's bayes-therapy.n3. Values are illustrative only and are not
6
- # medical advice.
7
-
8
- @prefix : <https://eyereasoner.github.io/see/examples/bayes-therapy#>.
9
- @prefix math: <http://www.w3.org/2000/10/swap/math#>.
10
- @prefix list: <http://www.w3.org/2000/10/swap/list#>.
11
- @prefix log: <http://www.w3.org/2000/10/swap/log#>.
12
- @prefix string: <http://www.w3.org/2000/10/swap/string#>.
13
-
14
- :COVID19 a :Disease; :prior 0.05.
15
- :Influenza a :Disease; :prior 0.03.
16
- :AllergicRhinitis a :Disease; :prior 0.10.
17
- :BacterialPneumonia a :Disease; :prior 0.01.
18
-
19
- :COVID19 :pGiven [ :symptom :Fever; :p 0.70 ], [ :symptom :DryCough; :p 0.65 ], [ :symptom :LossOfSmell; :p 0.40 ], [ :symptom :Sneezing; :p 0.15 ], [ :symptom :ShortBreath; :p 0.20 ].
20
- :Influenza :pGiven [ :symptom :Fever; :p 0.80 ], [ :symptom :DryCough; :p 0.50 ], [ :symptom :LossOfSmell; :p 0.05 ], [ :symptom :Sneezing; :p 0.20 ], [ :symptom :ShortBreath; :p 0.10 ].
21
- :AllergicRhinitis :pGiven [ :symptom :Fever; :p 0.05 ], [ :symptom :DryCough; :p 0.15 ], [ :symptom :LossOfSmell; :p 0.10 ], [ :symptom :Sneezing; :p 0.80 ], [ :symptom :ShortBreath; :p 0.05 ].
22
- :BacterialPneumonia :pGiven [ :symptom :Fever; :p 0.70 ], [ :symptom :DryCough; :p 0.60 ], [ :symptom :LossOfSmell; :p 0.02 ], [ :symptom :Sneezing; :p 0.05 ], [ :symptom :ShortBreath; :p 0.60 ].
23
-
24
- :Paxlovid a :Therapy; :label "Paxlovid"; :successByDisease ( 0.75 0.05 0.02 0.05 ); :adverse 0.10.
25
- :Oseltamivir a :Therapy; :label "Oseltamivir"; :successByDisease ( 0.05 0.60 0.02 0.05 ); :adverse 0.08.
26
- :Antihistamine a :Therapy; :label "Antihistamine"; :successByDisease ( 0.10 0.10 0.75 0.05 ); :adverse 0.03.
27
- :Antibiotic a :Therapy; :label "Antibiotic"; :successByDisease ( 0.05 0.05 0.02 0.80 ); :adverse 0.07.
28
- :SupportiveCare a :Therapy; :label "Supportive care"; :successByDisease ( 0.30 0.30 0.25 0.20 ); :adverse 0.01.
29
-
30
- :Model :benefitWeight 10; :harmWeight 3.
31
- :Case a :PatientCase;
32
- :diseases (:COVID19 :Influenza :AllergicRhinitis :BacterialPneumonia);
33
- :therapies (:Paxlovid :Oseltamivir :SupportiveCare :Antibiotic :Antihistamine);
34
- :evidence (
35
- [ :symptom :Fever; :present true ]
36
- [ :symptom :DryCough; :present true ]
37
- [ :symptom :LossOfSmell; :present false ]
38
- [ :symptom :Sneezing; :present false ]
39
- [ :symptom :ShortBreath; :present false ]
40
- ).
41
-
42
- { ?d :prior ?p. ?p math:lessThan 0. } => false.
43
- { ?d :prior ?p. ?p math:greaterThan 1. } => false.
44
- { ?d :pGiven [ :p ?p ]. ?p math:lessThan 0. } => false.
45
- { ?d :pGiven [ :p ?p ]. ?p math:greaterThan 1. } => false.
46
- { ?t a :Therapy; :adverse ?p. ?p math:lessThan 0. } => false.
47
- { ?t a :Therapy; :adverse ?p. ?p math:greaterThan 1. } => false.
48
- { ?t a :Therapy; :successByDisease ?ps. ?ps list:iterate ( ?i ?p ). ?p math:lessThan 0. } => false.
49
- { ?t a :Therapy; :successByDisease ?ps. ?ps list:iterate ( ?i ?p ). ?p math:greaterThan 1. } => false.
50
-
51
- { ( ?d () ) :pairList () } <= true.
52
- { ( ?d ?xs ) :pairList ?pairs } <= {
53
- ?xs list:firstRest ( ?x ?rest ).
54
- ( ?d ?rest ) :pairList ?tailPairs.
55
- ?pairs list:firstRest ( ( ?d ?x ) ?tailPairs ).
56
- }.
57
- { ( () ?c ) :pairWithConst () } <= true.
58
- { ( ?xs ?c ) :pairWithConst ?pairs } <= {
59
- ?xs list:firstRest ( ?x ?rest ).
60
- ( ?rest ?c ) :pairWithConst ?tailPairs.
61
- ?pairs list:firstRest ( ( ?x ?c ) ?tailPairs ).
62
- }.
63
- { ( () () ) :zip () } <= true.
64
- { ( ?as ?bs ) :zip ?pairs } <= {
65
- ?as list:firstRest ( ?a ?arest ).
66
- ?bs list:firstRest ( ?b ?brest ).
67
- ( ?arest ?brest ) :zip ?tailPairs.
68
- ?pairs list:firstRest ( ( ?a ?b ) ?tailPairs ).
69
- }.
70
- { ?pair :mul ?p } <= { ?pair math:product ?p }.
71
- { ?pair :quot2 ?q } <= { ?pair math:quotient ?q }.
72
-
73
- { ( ?d ?ev ) :factor ?p } <= {
74
- ?ev :symptom ?s; :present true.
75
- ?d :pGiven [ :symptom ?s; :p ?p ].
76
- }.
77
- { ( ?d ?ev ) :factor ?q } <= {
78
- ?ev :symptom ?s; :present false.
79
- ?d :pGiven [ :symptom ?s; :p ?p ].
80
- ( 1 ?p ) math:difference ?q.
81
- }.
82
- { ?d :scoreFor ?score } <= {
83
- ?d :prior ?prior.
84
- :Case :evidence ?evs.
85
- ( ?d ?evs ) :pairList ?pairs.
86
- ( ?pairs :factor ) list:map ?factors.
87
- ?factors math:product ?likelihood.
88
- ( ?prior ?likelihood ) math:product ?score.
89
- }.
90
- {
91
- :Case :diseases ?ds.
92
- ( ?ds :scoreFor ) list:map ?scores.
93
- ?scores math:sum ?total.
94
- ( ?scores ?total ) :pairWithConst ?scorePairs.
95
- ( ?scorePairs :quot2 ) list:map ?posteriors.
96
- } => {
97
- :Case :scores ?scores; :evidenceTotal ?total; :posteriors ?posteriors.
98
- }.
99
- {
100
- :Case :diseases ?ds; :posteriors ?posts.
101
- ?ds list:iterate ( ?i ?d ).
102
- ( ?posts ?i ) list:memberAt ?p.
103
- } => {
104
- ?d :posterior ?p.
105
- }.
106
-
107
- # expectedSuccess(t) = sum_i posterior[i] * P(success | disease_i, t)
108
- {
109
- :Case :posteriors ?posts.
110
- ?t a :Therapy; :successByDisease ?succ; :adverse ?adverse.
111
- ( ?posts ?succ ) :zip ?pairs.
112
- ( ?pairs :mul ) list:map ?terms.
113
- ?terms math:sum ?expectedSuccess.
114
- :Model :benefitWeight ?bw; :harmWeight ?hw.
115
- ( ?bw ?expectedSuccess ) math:product ?benefit.
116
- ( ?hw ?adverse ) math:product ?harmCost.
117
- ( ?benefit ?harmCost ) math:difference ?utility.
118
- } => {
119
- ?t :expectedSuccess ?expectedSuccess;
120
- :expectedAdverse ?adverse;
121
- :utility ?utility.
122
- }.
123
-
124
- { ( ?t1 ?t2 ) :betterOf ?t1 } <= { ?t1 :utility ?u1. ?t2 :utility ?u2. ?u1 math:notLessThan ?u2. }.
125
- { ( ?t1 ?t2 ) :betterOf ?t2 } <= { ?t1 :utility ?u1. ?t2 :utility ?u2. ?u1 math:lessThan ?u2. }.
126
- { ( ?ts ) :bestTherapy ?t } <= { ?ts list:firstRest ( ?t () ). }.
127
- { ( ?ts ) :bestTherapy ?best } <= {
128
- ?ts list:firstRest ( ?head ?rest ).
129
- ?rest list:firstRest ( ?_ ?__ ).
130
- ( ?rest ) :bestTherapy ?bestRest.
131
- ( ?head ?bestRest ) :betterOf ?best.
132
- }.
133
- { :Case :therapies ?ts. ( ?ts ) :bestTherapy ?best. } => { :Case :recommendedTherapy ?best. }.
134
-
135
- {
136
- :Case :recommendedTherapy ?best.
137
- ?best :label ?bestLabel; :expectedSuccess ?bestSuccess; :expectedAdverse ?bestAdverse; :utility ?bestUtility.
138
- :Paxlovid :utility ?paxU; :expectedSuccess ?paxS; :expectedAdverse ?paxA.
139
- :Oseltamivir :utility ?oseU; :expectedSuccess ?oseS; :expectedAdverse ?oseA.
140
- :SupportiveCare :utility ?supU; :expectedSuccess ?supS; :expectedAdverse ?supA.
141
- :Antibiotic :utility ?antibU; :expectedSuccess ?antibS; :expectedAdverse ?antibA.
142
- :Antihistamine :utility ?antiU; :expectedSuccess ?antiS; :expectedAdverse ?antiA.
143
- ("=== Answer ===\nRecommended therapy: %s (utility = %.6f).\nexpected success : %.6f\nadverse probability : %.6f\n\nTherapy utilities:\n Paxlovid utility = %.6f success = %.6f adverse = %.6f\n Oseltamivir utility = %.6f success = %.6f adverse = %.6f\n Supportive care utility = %.6f success = %.6f adverse = %.6f\n Antibiotic utility = %.6f success = %.6f adverse = %.6f\n Antihistamine utility = %.6f success = %.6f adverse = %.6f\n\n=== Explanation ===\nThe N3 source first computes disease posteriors from the symptom evidence. It then combines those posterior probabilities with therapy-specific success probabilities, subtracting the weighted adverse-effect penalty from the weighted expected benefit." ?bestLabel ?bestUtility ?bestSuccess ?bestAdverse ?paxU ?paxS ?paxA ?oseU ?oseS ?oseA ?supU ?supS ?supA ?antibU ?antibS ?antibA ?antiU ?antiS ?antiA) string:format ?Block.
144
- } => {
145
- :bayesTherapy log:outputString ?Block.
146
- :bayesTherapy :recommends ?best.
147
- }.
148
-
149
- { :bayesTherapy :recommends ?Therapy } log:query { :bayesTherapy :recommends ?Therapy }.
@@ -1,145 +0,0 @@
1
- # ============================================================================
2
- # BMI — Body Mass Index example.
3
- #
4
- # This example turns a familiar health calculation into a small, inspectable
5
- # SEE example. It normalizes either metric or US inputs, computes BMI, assigns
6
- # a WHO adult category, and derives a healthy-range weight band for the given
7
- # height. The report explains the result and includes independent validations for
8
- # boundary handling and category behavior.
9
- #
10
- # For reproducibility and documentation only; not medical advice.
11
- # ============================================================================
12
-
13
- @prefix : <https://example.org/bmi#> .
14
- @prefix log: <http://www.w3.org/2000/10/swap/log#> .
15
- @prefix math: <http://www.w3.org/2000/10/swap/math#> .
16
- @prefix string: <http://www.w3.org/2000/10/swap/string#> .
17
-
18
- # --------------
19
- # Editable input
20
- # --------------
21
- :Input
22
- :unitSystem "metric";
23
- :weight 72.0;
24
- :height 178.0.
25
-
26
- # US alternative:
27
- # :Input
28
- # :unitSystem "us";
29
- # :weight 158.73;
30
- # :height 70.08.
31
-
32
- # ---------------------------------
33
- # Normalization and BMI calculation
34
- # ---------------------------------
35
- { :Input :unitSystem "metric"; :weight ?W; :height ?H.
36
- (?H 100.0) math:quotient ?M. }
37
- =>
38
- { :Case :weightKg ?W; :heightM ?M.
39
- :Reason :units "Inputs were already metric, so kilograms stay kilograms and centimeters are divided by 100 to obtain meters.". } .
40
-
41
- { :Input :unitSystem "us"; :weight ?W; :height ?H.
42
- (?W 0.45359237) math:product ?Kg.
43
- (?H 0.0254) math:product ?M. }
44
- =>
45
- { :Case :weightKg ?Kg; :heightM ?M.
46
- :Reason :units "US inputs were converted to SI units: pounds to kilograms and inches to meters.". } .
47
-
48
- { :Case :weightKg ?Kg; :heightM ?M.
49
- (?M ?M) math:product ?M2.
50
- (?Kg ?M2) math:quotient ?Bmi.
51
- (?Bmi 100.0) math:product ?BmiX100.
52
- ?BmiX100 math:rounded ?BmiRoundedInt.
53
- (?BmiRoundedInt 100.0) math:quotient ?BmiRounded.
54
- (18.5 ?M2) math:product ?HealthyMin.
55
- (24.9 ?M2) math:product ?HealthyMax.
56
- (?HealthyMin 10.0) math:product ?MinX10.
57
- (?HealthyMax 10.0) math:product ?MaxX10.
58
- ?MinX10 math:rounded ?MinRoundedInt.
59
- ?MaxX10 math:rounded ?MaxRoundedInt.
60
- (?MinRoundedInt 10.0) math:quotient ?HealthyMinRounded.
61
- (?MaxRoundedInt 10.0) math:quotient ?HealthyMaxRounded. }
62
- =>
63
- { :Case :heightSquared ?M2;
64
- :bmi ?Bmi;
65
- :bmiRounded ?BmiRounded;
66
- :healthyMinKg ?HealthyMin;
67
- :healthyMaxKg ?HealthyMax;
68
- :healthyMinKgRounded ?HealthyMinRounded;
69
- :healthyMaxKgRounded ?HealthyMaxRounded. } .
70
-
71
- # ------------------------------------------
72
- # WHO adult categories (half-open intervals)
73
- # ------------------------------------------
74
- { :Case :bmi ?Bmi. ?Bmi math:lessThan 18.5. }
75
- => { :Decision :category "Underweight". } .
76
-
77
- { :Case :bmi ?Bmi. ?Bmi math:notLessThan 18.5. ?Bmi math:lessThan 25.0. }
78
- => { :Decision :category "Normal". } .
79
-
80
- { :Case :bmi ?Bmi. ?Bmi math:notLessThan 25.0. ?Bmi math:lessThan 30.0. }
81
- => { :Decision :category "Overweight". } .
82
-
83
- { :Case :bmi ?Bmi. ?Bmi math:notLessThan 30.0. ?Bmi math:lessThan 35.0. }
84
- => { :Decision :category "Obesity I". } .
85
-
86
- { :Case :bmi ?Bmi. ?Bmi math:notLessThan 35.0. ?Bmi math:lessThan 40.0. }
87
- => { :Decision :category "Obesity II". } .
88
-
89
- { :Case :bmi ?Bmi. ?Bmi math:notLessThan 40.0. }
90
- => { :Decision :category "Obesity III". } .
91
-
92
- # ---------------------
93
- # Answer and reason why
94
- # ---------------------
95
- { :Case :bmiRounded ?BmiRounded;
96
- :healthyMinKgRounded ?HealthyMinRounded;
97
- :healthyMaxKgRounded ?HealthyMaxRounded;
98
- :heightM ?M.
99
- :Decision :category ?Category.
100
- (?M 100.0) math:product ?Cm.
101
- ?Cm math:rounded ?CmRounded. }
102
- =>
103
- { :Answer :bmi ?BmiRounded;
104
- :category ?Category;
105
- :healthyMinKg ?HealthyMinRounded;
106
- :healthyMaxKg ?HealthyMaxRounded;
107
- :heightCm ?CmRounded. } .
108
-
109
- { :Case :weightKg ?Kg; :heightM ?M; :heightSquared ?M2; :bmiRounded ?BmiRounded.
110
- :Reason :units ?Units.
111
- :Decision :category ?Category. }
112
- =>
113
- { :Reason :formula "BMI is defined as weight in kilograms divided by height in meters squared.";
114
- :calculation "The normalized weight and height were used to compute BMI, then the result was mapped to the WHO adult category table.";
115
- :categoryRule ?Category;
116
- :unitsExplanation ?Units. } .
117
-
118
- # -----
119
- # Fuses
120
- # -----
121
- { :Decision :category ?C1, ?C2.
122
- ?C1 log:notEqualTo ?C2. }
123
- => false .
124
-
125
- # ---------------------------------------------
126
- # Report (built from actual derived values)
127
- # ---------------------------------------------
128
- { :Answer :bmi ?BmiRounded;
129
- :category ?Category;
130
- :healthyMinKg ?HealthyMinRounded;
131
- :healthyMaxKg ?HealthyMaxRounded;
132
- :heightCm ?CmRounded.
133
- (
134
- "=== Answer ===\n"
135
- "BMI = " ?BmiRounded "\n"
136
- "Category = " ?Category "\n"
137
- "At height " ?CmRounded " cm, a healthy-weight range is about " ?HealthyMinRounded "–" ?HealthyMaxRounded " kg (BMI 18.5–24.9).\n\n"
138
- "=== Explanation ===\n"
139
- "BMI is defined as weight in kilograms divided by height in meters squared. "
140
- "This program first normalizes the input to SI units, computes BMI, and then applies WHO adult categories as half-open intervals. "
141
- "The healthy-weight band is the weight range at the same height that corresponds to BMI 18.5 through 24.9.\n\n"
142
- ) string:concatenation ?Block. }
143
- =>
144
- { :report log:outputString ?Block. } .
145
-
@@ -1,3 +0,0 @@
1
- @prefix : <https://eyereasoner.github.io/see/examples/collection#>.
2
- (1 _:b2 (2)) :p2 :q2 .
3
- _:b2 :p :q .