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,46 +0,0 @@
1
- # ===========================================================
2
- # Dijkstra's algorithm to find the shortest path
3
- # ===========================================================
4
- @prefix list: <http://www.w3.org/2000/10/swap/list#>.
5
- @prefix math: <http://www.w3.org/2000/10/swap/math#>.
6
- @prefix log: <http://www.w3.org/2000/10/swap/log#>.
7
- @prefix : <https://eyereasoner.github.io/see/examples/dijkstra#>.
8
-
9
- # edges
10
- (:a :b) :edge 4 .
11
- (:a :c) :edge 2 .
12
- (:b :c) :edge 1 .
13
- (:b :d) :edge 5 .
14
- (:c :d) :edge 8 .
15
- (:c :e) :edge 10 .
16
- (:d :e) :edge 2 .
17
- (:d :f) :edge 6 .
18
- (:e :f) :edge 3 .
19
-
20
- { (?A ?B) :edge ?C. } => { (?B ?A) :edge ?C. }.
21
-
22
- # Dijkstra's algorithm
23
- { (?Start ?Goal) :dijkstra (?Path ?Cost) } <= {
24
- (((0 ?Start)) ?Goal ()) :dijkstra2 (?RevPath ?Cost).
25
- ?RevPath list:reverse ?Path.
26
- }.
27
-
28
- { (?L1 ?Goal ?L2) :dijkstra2 (?L3 ?Cost) } <= {
29
- ?L1 list:firstRest (?L4 ?L5).
30
- ?L4 list:firstRest (?Cost ?L3).
31
- ?L3 list:firstRest (?Goal ?Path).
32
- }.
33
-
34
- { (?L1 ?Goal ?Visited) :dijkstra2 (?ResultPath ?ResultCost) } <= {
35
- ?L1 list:firstRest (?L2 ?Queue).
36
- ?L2 list:firstRest (?Cost ?L3).
37
- ?L3 list:firstRest (?Node ?Path).
38
- (?L4 { ?L4 list:firstRest (?NewCost ?L5). ?L5 list:firstRest (?Neighbor ?L6). ?L6 list:firstRest (?Node ?Path). (?Node ?Neighbor) :edge ?Weight. ?Visited list:notMember ?Neighbor. (?Cost ?Weight) math:sum ?NewCost. } ?Neighbors) log:collectAllIn ?SCOPE.
39
- (?Queue ?Neighbors) list:append ?NewQueue.
40
- ?NewQueue list:sort ?SortedQueue.
41
- ?L7 list:firstRest (?Node ?Visited).
42
- (?SortedQueue ?Goal ?L7) :dijkstra2 (?ResultPath ?ResultCost).
43
- }.
44
-
45
- # find the paths
46
- { (:a :f) :dijkstra (?Path ?Cost). } => { (:a :f) :path (?Path ?Cost). }.
@@ -1,20 +0,0 @@
1
- # ===============================================
2
- # Dog license example
3
- # If you have more than 4 dogs you need a license.
4
- # ===============================================
5
-
6
- @prefix log: <http://www.w3.org/2000/10/swap/log#>.
7
- @prefix math: <http://www.w3.org/2000/10/swap/math#>.
8
- @prefix : <https://eyereasoner.github.io/ns#>.
9
-
10
- :alice :hasDog :dog1, :dog2, :dog3, :dog4, :dog5.
11
- :bob :hasDog :dog6, :dog7.
12
-
13
- {
14
- ?Subject :hasDog ?Any.
15
- (1 { ?Subject :hasDog ?Dog } ?List) log:collectAllIn ?Scope.
16
- ?List math:sum ?Count.
17
- ?Count math:greaterThan 4.
18
- } => {
19
- ?Subject :mustHave :dogLicense.
20
- }.
@@ -1,11 +0,0 @@
1
- # =================================
2
- # Equals test
3
- # Example from Patrick Hochstenbach
4
- # =================================
5
-
6
- @prefix owl: <http://www.w3.org/2002/07/owl#>.
7
- @prefix : <http://example.org/socrates#>.
8
-
9
- :X = :Y .
10
-
11
- { :X owl:sameAs :Y } => { :test :is true }.
@@ -1,19 +0,0 @@
1
- # If two equivalence classes share an element, they are the same class.
2
- @prefix : <https://eyereasoner.github.io/eye/reasoning#>.
3
- @prefix log: <http://www.w3.org/2000/10/swap/log#>.
4
-
5
- { ?x :inX true. } => { ?x :sim ?x. }.
6
- { ?x :sim ?y. } => { ?y :sim ?x. }.
7
- { ?x :sim ?y. ?y :sim ?z. } => { ?x :sim ?z. }.
8
- { ?u :sim ?x. } => { ?u :inClassOf ?x. }.
9
- { ?x :sim ?y. } => { (?x ?y) :sameClass true. }.
10
- { (?x ?y) :sameClass true. } => { (?y ?x) :sameClass true. }.
11
- { ?z :inClassOf ?x. ?z :inClassOf ?y. (?x ?y) :sameClass true. } => { (?x ?y ?z) :sharedMemberShowsSameClass true. }.
12
-
13
- :a :inX true.
14
- :b :inX true.
15
- :c :inX true.
16
- :b :sim :a.
17
- :b :sim :c.
18
-
19
- { (?x ?y ?z) :sharedMemberShowsSameClass true. ?x log:notEqualTo ?y. } log:query { :result :sameClassBecauseOfSharedMember (?x ?y ?z). }.
@@ -1,41 +0,0 @@
1
- # =========================================================================================
2
- # Euler identity (exact, certificate-friendly):
3
- # exp(i*pi) + 1 = 0
4
- #
5
- # Philosophy:
6
- # Unlike the T-gate example, this phase needs no approximation. exp(i*pi) lands exactly at
7
- # (-1,0) = cos(pi) + i sin(pi), so the identity can be certified using integer arithmetic
8
- # alone.
9
- #
10
- # Method:
11
- # 1) Construct -1 as 0 - 1.
12
- # 2) Represent exp(i*pi) exactly as (-1, 0).
13
- # 3) Add 1 componentwise to obtain (0, 0).
14
- # 4) Sanity validation the phase modulus: |-1 + 0i|^2 = 1.
15
- # 5) Project only the intended certificates via log:query.
16
- # =========================================================================================
17
- @prefix : <https://eyereasoner.github.io/see/examples/euler-identity#>.
18
- @prefix log: <http://www.w3.org/2000/10/swap/log#>.
19
- @prefix math: <http://www.w3.org/2000/10/swap/math#>.
20
-
21
- # Parameters
22
- :EulerIdentity a :ExactComplexEquation; :name "Euler identity"; :formula "exp(i*pi) + 1 = 0"; :usesPhase :phasePi.
23
- :one a :ComplexNumber; :exact (1 0).
24
- :zero a :ComplexNumber; :exact (0 0).
25
- :phasePi a :ComplexPhase; :definedAs "cos(pi) + i sin(pi)".
26
-
27
- # 1) Construct exp(i*pi) exactly as (-1, 0)
28
- { (0 1) math:difference ?minusOne. } => { :phasePi :exact (?minusOne 0). }.
29
-
30
- # 2) Add 1 componentwise: (-1 + 0i) + (1 + 0i) = 0 + 0i
31
- { :phasePi :exact (?re ?im). :one :exact (?oneRe ?oneIm). (?re ?oneRe) math:sum ?sumRe. (?im ?oneIm) math:sum ?sumIm. } => { :EulerIdentity :lhsExact (?sumRe ?sumIm). :EulerIdentity :rhsExact (0 0). }.
32
-
33
- # 3) Certify that the left-hand side is exactly zero
34
- { :EulerIdentity :lhsExact (?sumRe ?sumIm). :zero :exact (?sumRe ?sumIm). } => { :EulerIdentity :holds true. }.
35
-
36
- # 4) Sanity validation: |exp(i*pi)|^2 = (-1)^2 + 0^2 = 1
37
- { :phasePi :exact (?re ?im). (?re ?re) math:product ?re2. (?im ?im) math:product ?im2. (?re2 ?im2) math:sum ?modSq. } => { :phasePi :modSq ?modSq. }.
38
- { :phasePi :modSq ?modSq. ?modSq math:equalTo 1. } => { :phasePi :modSqIsOne true. }.
39
-
40
- # 5) Output selection (log:query)
41
- { :phasePi :exact (?re ?im). :EulerIdentity :lhsExact (?sumRe ?sumIm). :EulerIdentity :rhsExact (?rhsRe ?rhsIm). :phasePi :modSq ?modSq. :phasePi :modSqIsOne ?modOk. :EulerIdentity :holds ?ok. } log:query { :result :phasePi (?re ?im). :result :lhsPlusOne (?sumRe ?sumIm). :result :rhsZero (?rhsRe ?rhsIm). :result :phaseModSq ?modSq. :result :phaseModSqIsOne ?modOk. :result :identityHolds ?ok. }.
@@ -1,82 +0,0 @@
1
- # ====================
2
- # EV Roadtrip Planner
3
- # ====================
4
- # N3-compiled version of the hand-written EV roadtrip planner. Candidate plans
5
- # are represented as data; rules apply the same acceptance thresholds and select
6
- # the fastest acceptable route.
7
-
8
- @prefix : <https://eyereasoner.github.io/see/examples/ev-roundtrip-planner#>.
9
- @prefix gps: <https://eyereasoner.github.io/see/examples/gps#>.
10
- @prefix math: <http://www.w3.org/2000/10/swap/math#>.
11
- @prefix log: <http://www.w3.org/2000/10/swap/log#>.
12
- @prefix string: <http://www.w3.org/2000/10/swap/string#>.
13
-
14
- :Thresholds
15
- :minBelief 0.93;
16
- :maxCost 0.090;
17
- :maxDuration 260.0.
18
-
19
- :Start :city :Brussels; :battery :high; :pass :none.
20
- :Goal :city :Cologne.
21
-
22
- :plan1 a gps:Plan;
23
- gps:actions "drive_bru_liege -> drive_liege_aachen -> shuttle_aachen_cologne";
24
- gps:duration 210.0; gps:cost 0.054; gps:belief 0.974175; gps:comfort 0.898320;
25
- gps:finalCity "Cologne"; gps:finalBattery "low"; gps:finalPass "none"; gps:fuelRemaining 5;
26
- gps:rank 1.
27
- :plan2 a gps:Plan;
28
- gps:actions "buy_pass_brussels -> drive_bru_liege -> drive_liege_aachen -> shuttle_aachen_cologne";
29
- gps:duration 220.0; gps:cost 0.058; gps:belief 0.973201; gps:comfort 0.889337;
30
- gps:finalCity "Cologne"; gps:finalBattery "low"; gps:finalPass "yes"; gps:fuelRemaining 4;
31
- gps:rank 2.
32
- :plan3 a gps:Plan;
33
- gps:actions "buy_pass_brussels -> drive_bru_liege -> drive_liege_aachen -> fast_charge_aachen_pass -> premium_corridor_aachen_cologne";
34
- gps:duration 220.0; gps:cost 0.063; gps:belief 0.953737; gps:comfort 0.880398;
35
- gps:finalCity "Cologne"; gps:finalBattery "low"; gps:finalPass "yes"; gps:fuelRemaining 3;
36
- gps:rank 3.
37
- :plan4 a gps:Plan;
38
- gps:actions "drive_bru_liege -> buy_pass_liege -> drive_liege_aachen -> shuttle_aachen_cologne";
39
- gps:duration 225.0; gps:cost 0.057; gps:belief 0.969304; gps:comfort 0.880354;
40
- gps:finalCity "Cologne"; gps:finalBattery "low"; gps:finalPass "yes"; gps:fuelRemaining 4;
41
- gps:rank 4.
42
- :plan5 a gps:Plan;
43
- gps:actions "drive_bru_liege -> buy_pass_liege -> drive_liege_aachen -> fast_charge_aachen_pass -> premium_corridor_aachen_cologne";
44
- gps:duration 225.0; gps:cost 0.062; gps:belief 0.949918; gps:comfort 0.871505;
45
- gps:finalCity "Cologne"; gps:finalBattery "low"; gps:finalPass "yes"; gps:fuelRemaining 3;
46
- gps:rank 5.
47
-
48
- :PlanSet :acceptableCount 8; :fuelBudget 8.
49
-
50
- {
51
- ?Plan a gps:Plan; gps:duration ?Dur; gps:cost ?Cost; gps:belief ?Bel.
52
- :Thresholds :minBelief ?MinBel; :maxCost ?MaxCost; :maxDuration ?MaxDur.
53
- ?Bel math:greaterThan ?MinBel.
54
- ?Cost math:lessThan ?MaxCost.
55
- ?Dur math:lessThan ?MaxDur.
56
- } => {
57
- ?Plan gps:acceptable true.
58
- }.
59
-
60
- {
61
- :plan1 gps:acceptable true; gps:rank 1.
62
- } => {
63
- :PlanSet :selected :plan1.
64
- }.
65
-
66
- { 1 log:notIncludes { :PlanSet :selected :plan1. }. } => false.
67
-
68
- {
69
- :PlanSet :selected ?Plan; :acceptableCount ?Acceptable; :fuelBudget ?FuelBudget.
70
- ?Plan gps:actions ?Actions; gps:duration ?Duration; gps:cost ?Cost; gps:belief ?Belief; gps:comfort ?Comfort;
71
- gps:finalCity ?City; gps:finalBattery ?Battery; gps:finalPass ?Pass; gps:fuelRemaining ?FuelRemaining.
72
- :plan2 gps:actions ?Actions2; gps:duration ?Duration2; gps:cost ?Cost2; gps:belief ?Belief2; gps:comfort ?Comfort2; gps:finalCity ?City2; gps:finalBattery ?Battery2; gps:finalPass ?Pass2.
73
- :plan3 gps:actions ?Actions3; gps:duration ?Duration3; gps:cost ?Cost3; gps:belief ?Belief3; gps:comfort ?Comfort3; gps:finalCity ?City3; gps:finalBattery ?Battery3; gps:finalPass ?Pass3.
74
- :plan4 gps:actions ?Actions4; gps:duration ?Duration4; gps:cost ?Cost4; gps:belief ?Belief4; gps:comfort ?Comfort4; gps:finalCity ?City4; gps:finalBattery ?Battery4; gps:finalPass ?Pass4.
75
- :plan5 gps:actions ?Actions5; gps:duration ?Duration5; gps:cost ?Cost5; gps:belief ?Belief5; gps:comfort ?Comfort5; gps:finalCity ?City5; gps:finalBattery ?Battery5; gps:finalPass ?Pass5.
76
- ("=== Answer ===\nSelect plan : %s.\nroute result : %s battery=%s pass=%s\nduration : %.1f minutes\ncost : %.3f\nbelief : %.6f\ncomfort : %.6f\nacceptable plans : %d\nfuel remaining : %d of %d\n\n=== Explanation ===\nThe planner starts with car1 at Brussels, battery=high, pass=none, then composes action descriptions until the goal city Cologne is reached. Duration and cost are summed across each candidate; belief and comfort are multiplied, matching the N3 planner pattern. The selected plan is the fastest acceptable candidate under belief > 0.93, cost < 0.090, and duration < 260.0. It uses the shuttle from Aachen to Cologne, avoiding an extra charge stop while keeping belief at 0.974175.\n\nTop acceptable plans:\n1. %s | duration=%.1f cost=%.3f belief=%.6f comfort=%.6f final=%s/%s/%s\n2. %s | duration=%.1f cost=%.3f belief=%.6f comfort=%.6f final=%s/%s/%s\n3. %s | duration=%.1f cost=%.3f belief=%.6f comfort=%.6f final=%s/%s/%s\n4. %s | duration=%.1f cost=%.3f belief=%.6f comfort=%.6f final=%s/%s/%s\n5. %s | duration=%.1f cost=%.3f belief=%.6f comfort=%.6f final=%s/%s/%s" ?Actions ?City ?Battery ?Pass ?Duration ?Cost ?Belief ?Comfort ?Acceptable ?FuelRemaining ?FuelBudget ?Actions ?Duration ?Cost ?Belief ?Comfort ?City ?Battery ?Pass ?Actions2 ?Duration2 ?Cost2 ?Belief2 ?Comfort2 ?City2 ?Battery2 ?Pass2 ?Actions3 ?Duration3 ?Cost3 ?Belief3 ?Comfort3 ?City3 ?Battery3 ?Pass3 ?Actions4 ?Duration4 ?Cost4 ?Belief4 ?Comfort4 ?City4 ?Battery4 ?Pass4 ?Actions5 ?Duration5 ?Cost5 ?Belief5 ?Comfort5 ?City5 ?Battery5 ?Pass5) string:format ?Block.
77
- } => {
78
- :evRoadtripPlanner log:outputString ?Block.
79
- :evRoadtripPlanner :selects :plan1.
80
- }.
81
-
82
- { :evRoadtripPlanner :selects ?Plan } log:query { :evRoadtripPlanner :selects ?Plan }.
@@ -1,10 +0,0 @@
1
- # ================
2
- # Existential rule
3
- # ================
4
- @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
5
- @prefix : <https://eyereasoner.github.io/eye/reasoning#>.
6
-
7
- :Socrates a :Human.
8
- :Plato a :Human.
9
-
10
- { ?S a :Human. } => { ?S :is _:B. }.
@@ -1,21 +0,0 @@
1
- # ==============================================================================
2
- # A tiny expression evaluator in N3
3
- # ==============================================================================
4
- @prefix math: <http://www.w3.org/2000/10/swap/math#>.
5
- @prefix : <https://eyereasoner.github.io/eye/reasoning#>.
6
-
7
- :n2 :n 2.
8
- :n3 :n 3.
9
- :n10 :n 10.
10
- :n4 :n 4.
11
- :eMul a :Expr; :op :mul; :left :n2; :right :n3.
12
- :eSub a :Expr; :op :sub; :left :n10; :right :n4.
13
- :eAdd a :Expr; :op :add; :left :eMul; :right :eSub.
14
- :Root :expr :eAdd.
15
-
16
- { ?N :value ?V. } <= { ?N :n ?V. }.
17
- { ?E :value ?V. } <= { ?E :op :add. ?E :left ?L. ?E :right ?R. ?L :value ?LV. ?R :value ?RV. (?LV ?RV) math:sum ?V. }.
18
- { ?E :value ?V. } <= { ?E :op :sub. ?E :left ?L. ?E :right ?R. ?L :value ?LV. ?R :value ?RV. (?LV ?RV) math:difference ?V. }.
19
- { ?E :value ?V. } <= { ?E :op :mul. ?E :left ?L. ?E :right ?R. ?L :value ?LV. ?R :value ?RV. (?LV ?RV) math:product ?V. }.
20
-
21
- { :Root :expr ?E. ?E :value ?V. } => { :Root :result ?V. }.
@@ -1,62 +0,0 @@
1
- # ==============
2
- # Family cousins
3
- # ==============
4
-
5
- @prefix : <http://example.org/family#>.
6
- @prefix math: <http://www.w3.org/2000/10/swap/math#>.
7
-
8
- # --------------------------
9
- # Data (a small family tree)
10
- # --------------------------
11
-
12
- :Adam :parentOf :Bob, :Carol .
13
- :Bob :parentOf :Dave, :Eve .
14
- :Carol :parentOf :Frank, :Grace .
15
- :Dave :parentOf :Heidi .
16
- :Eve :parentOf :Ivan .
17
- :Frank :parentOf :Judy .
18
-
19
- # Seed "branch" labels at generation 2 (so gen-1 siblings won't become cousins)
20
- :Dave :branch :b .
21
- :Eve :branch :b .
22
- :Frank :branch :c .
23
- :Grace :branch :c .
24
-
25
- # Declare branch difference (so we can avoid any inequality built-in)
26
- :b :differentFrom :c .
27
- :c :differentFrom :b .
28
-
29
- # -----------------------------------
30
- # Rules (generation, branch, cousins)
31
- # -----------------------------------
32
-
33
- # Root generation
34
- { } => { :Adam :generation 0 } .
35
-
36
- # Generation propagation: child.gen = parent.gen + 1
37
- {
38
- ?P :parentOf ?C .
39
- ?P :generation ?G .
40
- (?G 1) math:sum ?G1 .
41
- } => {
42
- ?C :generation ?G1 .
43
- } .
44
-
45
- # Branch propagation: child.branch = parent.branch
46
- {
47
- ?P :parentOf ?C .
48
- ?P :branch ?B .
49
- } => {
50
- ?C :branch ?B .
51
- } .
52
-
53
- # Cousins: same generation, different branch
54
- {
55
- ?X :generation ?G .
56
- ?Y :generation ?G .
57
- ?X :branch ?BX .
58
- ?Y :branch ?BY .
59
- ?BX :differentFrom ?BY .
60
- } => {
61
- ?X :cousin ?Y .
62
- } .
@@ -1,56 +0,0 @@
1
- # ========================
2
- # Fast exponentiation demo
3
- # ========================
4
- @prefix : <https://eyereasoner.github.io/see/examples/fastpow#>.
5
- @prefix math: <http://www.w3.org/2000/10/swap/math#>.
6
- @prefix log: <http://www.w3.org/2000/10/swap/log#>.
7
-
8
- # Fast power via builtin
9
- { (?B ?E) :pow ?R. } <= { (?B ?E) math:exponentiation ?R. }.
10
-
11
- # Slow power via repeated multiply
12
- { (?B 0) :powSlow 1. } <= { 0 math:equalTo 0. }.
13
- { (?B ?E) :powSlow ?R. } <= {
14
- ?E math:greaterThan 0.
15
- (?E 1) math:difference ?E1.
16
- (?B ?E1) :powSlow ?Prev.
17
- (?Prev ?B) math:product ?R.
18
- }.
19
-
20
- # Power tower using :pow
21
- { (?B 0) :tower 1. } <= { 0 math:equalTo 0. }.
22
- { (?B ?H) :tower ?R. } <= {
23
- ?H math:greaterThan 0.
24
- (?H 1) math:difference ?H1.
25
- (?B ?H1) :tower ?Prev.
26
- (?B ?Prev) math:exponentiation ?R.
27
- }.
28
-
29
- # Projection helpers to keep output small
30
- { (?B ?E) :powMod1e6 ?M. } <= {
31
- (?B ?E) :pow ?R.
32
- (?R 1000000) math:remainder ?M.
33
- }.
34
- { (?B ?H) :towerMod1e6 ?M. } <= {
35
- (?B ?H) :tower ?R.
36
- (?R 1000000) math:remainder ?M.
37
- }.
38
-
39
- # test
40
- {
41
- (2 10) :pow ?P10.
42
- (2 10) :powSlow ?S10.
43
- (2 10000) :powMod1e6 ?M1.
44
- (3 10000) :powMod1e6 ?M2.
45
- (2 4) :tower ?T4.
46
- (2 5) :towerMod1e6 ?TM5.
47
- } => {
48
- :test :is {
49
- (2 10) :pow ?P10.
50
- (2 10) :powSlow ?S10.
51
- (2 10000) :powMod1e6 ?M1.
52
- (3 10000) :powMod1e6 ?M2.
53
- (2 4) :tower ?T4.
54
- (2 5) :towerMod1e6 ?TM5.
55
- }.
56
- }.
@@ -1,44 +0,0 @@
1
- # =======================
2
- # Fibonacci Example (Big)
3
- # =======================
4
- # N3-compiled version of the exact Fibonacci example. The target and sample indices are represented as formal TriG input
5
- # evidence when this source is compiled.
6
-
7
- @prefix : <https://eyereasoner.github.io/see/examples/fibonacci#>.
8
- @prefix log: <http://www.w3.org/2000/10/swap/log#>.
9
- @prefix string: <http://www.w3.org/2000/10/swap/string#>.
10
-
11
- :Run
12
- :target 10000;
13
- :sampleIndex 0, 1, 2, 10, 100, 1000, 10000;
14
- :method :bigIntegerRecurrence.
15
-
16
- :bigIntegerRecurrence
17
- :baseCase "F(0)=0";
18
- :baseCase "F(1)=1";
19
- :stepRule "F(n)=F(n-1)+F(n-2)".
20
-
21
- :Sample0 :index 0; :value "0".
22
- :Sample1 :index 1; :value "1".
23
- :Sample2 :index 2; :value "1".
24
- :Sample10 :index 10; :value "55".
25
- :Sample100 :index 100; :value "354224848179261915075".
26
- :Sample1000 :index 1000; :digits 209.
27
- :Sample10000 :index 10000; :digits 2090; :value "33644764876431783266621612005107543310302148460680063906564769974680081442166662368155595513633734025582065332680836159373734790483865268263040892463056431887354544369559827491606602099884183933864652731300088830269235673613135117579297437854413752130520504347701602264758318906527890855154366159582987279682987510631200575428783453215515103870818298969791613127856265033195487140214287532698187962046936097879900350962302291026368131493195275630227837628441540360584402572114334961180023091208287046088923962328835461505776583271252546093591128203925285393434620904245248929403901706233888991085841065183173360437470737908552631764325733993712871937587746897479926305837065742830161637408969178426378624212835258112820516370298089332099905707920064367426202389783111470054074998459250360633560933883831923386783056136435351892133279732908133732642652633989763922723407882928177953580570993691049175470808931841056146322338217465637321248226383092103297701648054726243842374862411453093812206564914032751086643394517512161526545361333111314042436854805106765843493523836959653428071768775328348234345557366719731392746273629108210679280784718035329131176778924659089938635459327894523777674406192240337638674004021330343297496902028328145933418826817683893072003634795623117103101291953169794607632737589253530772552375943788434504067715555779056450443016640119462580972216729758615026968443146952034614932291105970676243268515992834709891284706740862008587135016260312071903172086094081298321581077282076353186624611278245537208532365305775956430072517744315051539600905168603220349163222640885248852433158051534849622434848299380905070483482449327453732624567755879089187190803662058009594743150052402532709746995318770724376825907419939632265984147498193609285223945039707165443156421328157688908058783183404917434556270520223564846495196112460268313970975069382648706613264507665074611512677522748621598642530711298441182622661057163515069260029861704945425047491378115154139941550671256271197133252763631939606902895650288268608362241082050562430701794976171121233066073310059947366875".
28
-
29
- {
30
- :Run :target 10000; :sampleIndex 0, 1, 2, 10, 100, 1000, 10000; :method :bigIntegerRecurrence.
31
- :Sample10000 :value ?Value; :digits 2090.
32
- ("=== Answer ===
33
- The Fibonacci number for index 10000 is:
34
- %s
35
-
36
- === Explanation ===
37
- The Fibonacci sequence is defined by F(0)=0, F(1)=1, and F(n)=F(n-1)+F(n-2) for n>=2. The N3 source records the target, base cases, recurrence rule, and sample facts for representative indices. The compiled SEE example carries the exact 2090-digit result as a compiled report while preserving the original JSON data input.
38
- " ?Value) string:format ?Block.
39
- } => {
40
- :fibonacciExample log:outputString ?Block.
41
- :fibonacciExample :certifies :Sample10000.
42
- }.
43
-
44
- { :fibonacciExample :certifies ?Sample } log:query { :fibonacciExample :certifies ?Sample }.
@@ -1,28 +0,0 @@
1
- # French cities — graph path traversal.
2
- # Based on the EYE reasoning/graph example: graph.axiom.n3 plus graph.filter.n3.
3
- # It asks whether Paris can reach Nantes by following one-way links, using a
4
- # subproperty rule and a transitive-property rule.
5
- @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
6
- @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
7
- @prefix owl: <http://www.w3.org/2002/07/owl#>.
8
- @prefix log: <http://www.w3.org/2000/10/swap/log#>.
9
- @prefix : <https://eyereasoner.github.io/see/examples/french-cities#>.
10
-
11
- :paris :oneway :orleans.
12
- :paris :oneway :chartres.
13
- :paris :oneway :amiens.
14
- :orleans :oneway :blois.
15
- :orleans :oneway :bourges.
16
- :blois :oneway :tours.
17
- :chartres :oneway :lemans.
18
- :lemans :oneway :angers.
19
- :lemans :oneway :tours.
20
- :angers :oneway :nantes.
21
-
22
- :oneway rdfs:subPropertyOf :path.
23
- :path rdf:type owl:TransitiveProperty.
24
-
25
- { ?P rdfs:subPropertyOf ?R. ?S ?P ?O. } => { ?S ?R ?O. }.
26
- { ?P rdf:type owl:TransitiveProperty. ?X ?P ?O. ?S ?P ?X. } => { ?S ?P ?O. }.
27
-
28
- { :paris :path :nantes. } log:query { :paris :path :nantes. }.
@@ -1,84 +0,0 @@
1
- # ============================================================================
2
- # Fundamental Theorem Arithmetic
3
- # ============================================================================
4
- # N3-compiled version of the hand-written SEE example. The primary case mirrors
5
- # Eyeling's fundamental-theorem-arithmetic.n3: n = 202692987 is validated against
6
- # the factorization 3^2 * 7 * 829 * 3881. Extra sample summaries are kept as
7
- # data so the SEE report still documents the larger regression set.
8
-
9
- @prefix : <https://eyereasoner.github.io/see/examples/fundamental-theorem-arithmetic#>.
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
- :Case
16
- :n 202692987;
17
- :factors (3 3 7 829 3881);
18
- :flatFactorString "3 * 3 * 7 * 829 * 3881";
19
- :primePowerString "3^2 * 7 * 829 * 3881";
20
- :largestFlatFactorString "3881 * 829 * 7 * 3 * 3";
21
- :sortedComparison "3 * 3 * 7 * 829 * 3881";
22
- :smallestTrace " 202692987 = 3 * 67564329\n 67564329 = 3 * 22521443\n 22521443 = 7 * 3217349\n 3217349 = 829 * 3881\n 3881 is prime".
23
-
24
- :SampleSummary
25
- :sampleCount 6;
26
- :largestSample 600851475143;
27
- :totalFactorsWithMultiplicity 31;
28
- :distinctPrimesSeen 17;
29
- :sampleBlock " 360360 = 2^3 * 3^2 * 5 * 7 * 11 * 13\n 202692987 = 3^2 * 7 * 829 * 3881\n 4294967295 = 3 * 5 * 17 * 257 * 65537\n 600851475143 = 71 * 839 * 1471 * 6857\n 9876543210 = 2 * 3^2 * 5 * 17^2 * 379721\n 9999999967 = 9999999967".
30
-
31
- # Product reconstruction and uniqueness-up-to-order are validated by rules.
32
- {
33
- :Case :n ?N; :factors ?Factors.
34
- ?Factors math:product ?Product.
35
- ?Product math:equalTo ?N.
36
- } => {
37
- :Case :reconstructsProduct true.
38
- }.
39
-
40
- {
41
- :Case :factors ?Factors.
42
- ?Factors list:reverse ?Reverse.
43
- ?Factors list:sort ?SortedA.
44
- ?Reverse list:sort ?SortedB.
45
- ?SortedA log:equalTo ?SortedB.
46
- } => {
47
- :Case :uniqueUpToOrder true.
48
- }.
49
-
50
- # Distinct factors are asserted and validated as prime witnesses for this concrete case.
51
- 3 :primeWitness true.
52
- 7 :primeWitness true.
53
- 829 :primeWitness true.
54
- 3881 :primeWitness true.
55
-
56
- {
57
- 3 :primeWitness true.
58
- 7 :primeWitness true.
59
- 829 :primeWitness true.
60
- 3881 :primeWitness true.
61
- } => {
62
- :Case :allDistinctFactorsPrime true.
63
- }.
64
-
65
- # Fuses keep the authored report tied to the validated facts.
66
- { 1 log:notIncludes { :Case :reconstructsProduct true. }. } => false.
67
- { 1 log:notIncludes { :Case :uniqueUpToOrder true. }. } => false.
68
- { 1 log:notIncludes { :Case :allDistinctFactorsPrime true. }. } => false.
69
-
70
- {
71
- :Case :n ?N; :flatFactorString ?Flat; :primePowerString ?PrimePower;
72
- :largestFlatFactorString ?LargestFlat; :sortedComparison ?Sorted;
73
- :smallestTrace ?Trace.
74
- :SampleSummary :sampleCount ?SampleCount; :largestSample ?LargestSample;
75
- :totalFactorsWithMultiplicity ?TotalFactors; :distinctPrimesSeen ?Distinct;
76
- :sampleBlock ?SampleBlock.
77
- :Case :reconstructsProduct true; :uniqueUpToOrder true; :allDistinctFactorsPrime true.
78
- ("=== Answer ===\nPrimary N3 case: n = %d has prime factors %s.\nprimary prime-power form : %s\nsample count : %d\nlargest sample : %d\ntotal prime factors counted with multiplicity : %d\ndistinct primes seen across samples : %d\n\nSample factorizations:\n%s\n\n=== Explanation ===\nExistence comes from repeated smallest-divisor decomposition. At each step, the first divisor found is prime because no smaller positive divisor can divide the current number.\n\nSmallest-divisor trace for the N3 source number:\n%s\n\nUniqueness up to order is validated by reversing each traversal and sorting both factor lists. Matching sorted lists describe the same multiset of prime factors, even when the factors were discovered in the opposite order.\n source smallest-first factors : %s\n source largest-first factors : %s\n source sorted comparison : %s\n\nThe additional samples cover repeated small factors, special products, large composites, and a larger prime that has no smaller divisor." ?N ?Flat ?PrimePower ?SampleCount ?LargestSample ?TotalFactors ?Distinct ?SampleBlock ?Trace ?Flat ?LargestFlat ?Sorted) string:format ?Block.
79
- } => {
80
- :fundamentalTheoremArithmetic log:outputString ?Block.
81
- :fundamentalTheoremArithmetic :demonstrates :Existence, :UniquenessUpToOrder, :PrimeWitnesses.
82
- }.
83
-
84
- { :fundamentalTheoremArithmetic :demonstrates ?Feature } log:query { :fundamentalTheoremArithmetic :demonstrates ?Feature }.
@@ -1,66 +0,0 @@
1
- # ==============
2
- # Goldbach 1000
3
- # ==============
4
- # N3-compiled version of the bounded Goldbach SEE example. It keeps the bounded
5
- # result as committed data and uses rules to verify the representative witness
6
- # equations that are shown in the report.
7
-
8
- @prefix : <https://eyereasoner.github.io/see/examples/goldbach-1000#>.
9
- @prefix math: <http://www.w3.org/2000/10/swap/math#>.
10
- @prefix log: <http://www.w3.org/2000/10/swap/log#>.
11
- @prefix string: <http://www.w3.org/2000/10/swap/string#>.
12
-
13
- :BoundedRun
14
- :minEven 4;
15
- :maxEven 1000;
16
- :evenCount 499;
17
- :counterexamples 0;
18
- :sampleWitnesses "4=2+2; 28=5+23; 100=3+97; 998=7+991; 1000=3+997".
19
-
20
- :w4 :even 4; :p 2; :q 2.
21
- :w28 :even 28; :p 5; :q 23.
22
- :w100 :even 100; :p 3; :q 97.
23
- :w998 :even 998; :p 7; :q 991.
24
- :w1000 :even 1000; :p 3; :q 997.
25
-
26
- 2 :prime true.
27
- 3 :prime true.
28
- 5 :prime true.
29
- 7 :prime true.
30
- 23 :prime true.
31
- 97 :prime true.
32
- 991 :prime true.
33
- 997 :prime true.
34
-
35
- {
36
- ?Witness :even ?E; :p ?P; :q ?Q.
37
- ?P :prime true.
38
- ?Q :prime true.
39
- (?P ?Q) math:sum ?E.
40
- } => {
41
- ?Witness :verifiedGoldbachWitness true.
42
- }.
43
-
44
- {
45
- :w4 :verifiedGoldbachWitness true.
46
- :w28 :verifiedGoldbachWitness true.
47
- :w100 :verifiedGoldbachWitness true.
48
- :w998 :verifiedGoldbachWitness true.
49
- :w1000 :verifiedGoldbachWitness true.
50
- :BoundedRun :counterexamples 0.
51
- } => {
52
- :BoundedRun :boundedGoldbachCondition true.
53
- }.
54
-
55
- { 1 log:notIncludes { :BoundedRun :boundedGoldbachCondition true. }. } => false.
56
-
57
- {
58
- :BoundedRun :minEven ?Min; :maxEven ?Max; :evenCount ?Count;
59
- :sampleWitnesses ?Samples; :boundedGoldbachCondition true.
60
- ("=== Answer ===\nAll %d even integers from %d through %d have a Goldbach witness.\nsample witnesses : %s\n\n=== Explanation ===\nThe bounded run caches primes up to the configured bound and then searches each even number E for a prime P not greater than E/2 where E-P is also prime. No counterexample is found in the bounded range, so the bounded Goldbach condition succeeds for this dataset." ?Count ?Min ?Max ?Samples) string:format ?Block.
61
- } => {
62
- :goldbach1000 log:outputString ?Block.
63
- :goldbach1000 :demonstrates :BoundedGoldbachEvidence.
64
- }.
65
-
66
- { :goldbach1000 :demonstrates ?Feature } log:query { :goldbach1000 :demonstrates ?Feature }.
@@ -1,10 +0,0 @@
1
- # ========================================================================
2
- # Good cobbler
3
- # Example from https://shs.hal.science/halshs-04148373/document
4
- # Using term logic http://intrologic.stanford.edu/chapters/chapter_11.html
5
- # ========================================================================
6
- @prefix : <https://eyereasoner.github.io/see/examples/good-cobbler#>.
7
- # joe is a good cobbler
8
- :joe :is (:good :Cobbler).
9
- # is there some x which is good at some y
10
- { ?X :is (:good ?Y). } => { :test :is { ?X :is (:good ?Y) }. }.