eyeling 1.23.4 → 1.24.0

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 (263) hide show
  1. package/HANDBOOK.md +6 -6
  2. package/README.md +1 -0
  3. package/dist/browser/eyeling.browser.js +11812 -11836
  4. package/eyeling.js +40 -12
  5. package/lib/prelude.js +40 -12
  6. package/package.json +7 -5
  7. package/see/README.md +146 -0
  8. package/see/examples/_see.js +218 -0
  9. package/see/examples/age.js +1433 -0
  10. package/see/examples/annotation.js +1294 -0
  11. package/see/examples/backward.js +1379 -0
  12. package/see/examples/backward_recursion.js +1478 -0
  13. package/see/examples/bayes_diagnosis.js +2857 -0
  14. package/see/examples/bayes_therapy.js +4126 -0
  15. package/see/examples/bmi.js +3012 -0
  16. package/see/examples/builtin_coverage.js +2498 -0
  17. package/see/examples/collection.js +1294 -0
  18. package/see/examples/complex.js +3736 -0
  19. package/see/examples/complex_matrix_stability.js +2947 -0
  20. package/see/examples/composition_of_injective_functions_is_injective.js +2144 -0
  21. package/see/examples/control_system.js +1892 -0
  22. package/see/examples/crypto_builtins_tests.js +1463 -0
  23. package/see/examples/delfour.js +3148 -0
  24. package/see/examples/digital_product_passport.js +2830 -0
  25. package/see/examples/dijkstra.js +2044 -0
  26. package/see/examples/dijkstra_risk_path.js +1848 -0
  27. package/see/examples/doc/age.md +27 -0
  28. package/see/examples/doc/annotation.md +24 -0
  29. package/see/examples/doc/backward.md +26 -0
  30. package/see/examples/doc/backward_recursion.md +26 -0
  31. package/see/examples/doc/bayes_diagnosis.md +41 -0
  32. package/see/examples/doc/bayes_therapy.md +40 -0
  33. package/see/examples/doc/bmi.md +38 -0
  34. package/see/examples/doc/builtin_coverage.md +53 -0
  35. package/see/examples/doc/collection.md +24 -0
  36. package/see/examples/doc/complex.md +38 -0
  37. package/see/examples/doc/complex_matrix_stability.md +35 -0
  38. package/see/examples/doc/composition_of_injective_functions_is_injective.md +24 -0
  39. package/see/examples/doc/control_system.md +32 -0
  40. package/see/examples/doc/crypto_builtins_tests.md +27 -0
  41. package/see/examples/doc/delfour.md +37 -0
  42. package/see/examples/doc/digital_product_passport.md +36 -0
  43. package/see/examples/doc/dijkstra.md +28 -0
  44. package/see/examples/doc/dijkstra_risk_path.md +30 -0
  45. package/see/examples/doc/dog.md +28 -0
  46. package/see/examples/doc/eco_route_insight.md +33 -0
  47. package/see/examples/doc/equals.md +26 -0
  48. package/see/examples/doc/equivalence_classes_overlap_implies_same_class.md +24 -0
  49. package/see/examples/doc/euler_identity.md +39 -0
  50. package/see/examples/doc/ev_roundtrip_planner.md +32 -0
  51. package/see/examples/doc/existential_rule.md +24 -0
  52. package/see/examples/doc/expression_eval.md +26 -0
  53. package/see/examples/doc/family_cousins.md +24 -0
  54. package/see/examples/doc/fastpow.md +29 -0
  55. package/see/examples/doc/fibonacci.md +28 -0
  56. package/see/examples/doc/french_cities.md +28 -0
  57. package/see/examples/doc/fundamental_theorem_arithmetic.md +36 -0
  58. package/see/examples/doc/genetic_knapsack_selection.md +29 -0
  59. package/see/examples/doc/goldbach_1000.md +31 -0
  60. package/see/examples/doc/good_cobbler.md +27 -0
  61. package/see/examples/doc/gps.md +35 -0
  62. package/see/examples/doc/gray_code_counter.md +31 -0
  63. package/see/examples/doc/greatest_lower_bound_uniqueness.md +24 -0
  64. package/see/examples/doc/group_inverse_uniqueness.md +24 -0
  65. package/see/examples/doc/hadamard_approx.md +32 -0
  66. package/see/examples/doc/hanoi.md +26 -0
  67. package/see/examples/doc/odrl_dpv_risk_ranked.md +57 -0
  68. package/see/examples/doc/path_discovery.md +33 -0
  69. package/see/examples/doc/rc_discharge_envelope.md +33 -0
  70. package/see/examples/doc/rdf_message_flow.md +35 -0
  71. package/see/examples/doc/rdf_messages.md +37 -0
  72. package/see/examples/doc/school_placement_audit.md +31 -0
  73. package/see/examples/doc/smoke_arithmetic.md +31 -0
  74. package/see/examples/doc/socrates.md +24 -0
  75. package/see/examples/doc/wind_turbine.md +37 -0
  76. package/see/examples/doc/witch.md +28 -0
  77. package/see/examples/dog.js +1410 -0
  78. package/see/examples/eco_route_insight.js +2084 -0
  79. package/see/examples/equals.js +1337 -0
  80. package/see/examples/equivalence_classes_overlap_implies_same_class.js +1766 -0
  81. package/see/examples/euler_identity.js +2012 -0
  82. package/see/examples/ev_roundtrip_planner.js +2536 -0
  83. package/see/examples/existential_rule.js +1337 -0
  84. package/see/examples/expression_eval.js +1772 -0
  85. package/see/examples/family_cousins.js +1560 -0
  86. package/see/examples/fastpow.js +2181 -0
  87. package/see/examples/fibonacci.js +1568 -0
  88. package/see/examples/french_cities.js +1466 -0
  89. package/see/examples/fundamental_theorem_arithmetic.js +2080 -0
  90. package/see/examples/genetic_knapsack_selection.js +1717 -0
  91. package/see/examples/goldbach_1000.js +1772 -0
  92. package/see/examples/good_cobbler.js +1370 -0
  93. package/see/examples/gps.js +2787 -0
  94. package/see/examples/gray_code_counter.js +1615 -0
  95. package/see/examples/greatest_lower_bound_uniqueness.js +1892 -0
  96. package/see/examples/group_inverse_uniqueness.js +1871 -0
  97. package/see/examples/hadamard_approx.js +4391 -0
  98. package/see/examples/hanoi.js +1599 -0
  99. package/see/examples/input/age.trig +27 -0
  100. package/see/examples/input/annotation.trig +31 -0
  101. package/see/examples/input/backward.trig +25 -0
  102. package/see/examples/input/backward_recursion.trig +25 -0
  103. package/see/examples/input/bayes_diagnosis.trig +111 -0
  104. package/see/examples/input/bayes_therapy.trig +130 -0
  105. package/see/examples/input/bmi.trig +28 -0
  106. package/see/examples/input/builtin_coverage.trig +24 -0
  107. package/see/examples/input/collection.trig +25 -0
  108. package/see/examples/input/complex.trig +26 -0
  109. package/see/examples/input/complex_matrix_stability.trig +65 -0
  110. package/see/examples/input/composition_of_injective_functions_is_injective.trig +35 -0
  111. package/see/examples/input/control_system.trig +31 -0
  112. package/see/examples/input/crypto_builtins_tests.trig +25 -0
  113. package/see/examples/input/delfour.trig +90 -0
  114. package/see/examples/input/digital_product_passport.trig +116 -0
  115. package/see/examples/input/dijkstra.trig +34 -0
  116. package/see/examples/input/dijkstra_risk_path.trig +46 -0
  117. package/see/examples/input/dog.trig +31 -0
  118. package/see/examples/input/eco_route_insight.trig +58 -0
  119. package/see/examples/input/equals.trig +25 -0
  120. package/see/examples/input/equivalence_classes_overlap_implies_same_class.trig +28 -0
  121. package/see/examples/input/euler_identity.trig +34 -0
  122. package/see/examples/input/ev_roundtrip_planner.trig +90 -0
  123. package/see/examples/input/existential_rule.trig +26 -0
  124. package/see/examples/input/expression_eval.trig +41 -0
  125. package/see/examples/input/family_cousins.trig +39 -0
  126. package/see/examples/input/fastpow.trig +25 -0
  127. package/see/examples/input/fibonacci.trig +51 -0
  128. package/see/examples/input/french_cities.trig +38 -0
  129. package/see/examples/input/fundamental_theorem_arithmetic.trig +42 -0
  130. package/see/examples/input/genetic_knapsack_selection.trig +39 -0
  131. package/see/examples/input/goldbach_1000.trig +53 -0
  132. package/see/examples/input/good_cobbler.trig +24 -0
  133. package/see/examples/input/gps.trig +35 -0
  134. package/see/examples/input/gray_code_counter.trig +33 -0
  135. package/see/examples/input/greatest_lower_bound_uniqueness.trig +29 -0
  136. package/see/examples/input/group_inverse_uniqueness.trig +29 -0
  137. package/see/examples/input/hadamard_approx.trig +32 -0
  138. package/see/examples/input/hanoi.trig +26 -0
  139. package/see/examples/input/odrl_dpv_risk_ranked.trig +107 -0
  140. package/see/examples/input/path-discovery.trig +96448 -0
  141. package/see/examples/input/path_discovery.trig +29 -0
  142. package/see/examples/input/rc_discharge_envelope.trig +37 -0
  143. package/see/examples/input/rdf_message_flow.trig +100 -0
  144. package/see/examples/input/rdf_messages.trig +69 -0
  145. package/see/examples/input/school_placement_audit.trig +51 -0
  146. package/see/examples/input/smoke_arithmetic.trig +27 -0
  147. package/see/examples/input/socrates.trig +26 -0
  148. package/see/examples/input/wind_turbine.trig +48 -0
  149. package/see/examples/input/witch.trig +26 -0
  150. package/see/examples/n3/age.n3 +28 -0
  151. package/see/examples/n3/annotation.n3 +7 -0
  152. package/see/examples/n3/backward.n3 +22 -0
  153. package/see/examples/n3/backward_recursion.n3 +12 -0
  154. package/see/examples/n3/bayes_diagnosis.n3 +122 -0
  155. package/see/examples/n3/bayes_therapy.n3 +149 -0
  156. package/see/examples/n3/bmi.n3 +145 -0
  157. package/see/examples/n3/builtin_coverage.n3 +68 -0
  158. package/see/examples/n3/collection.n3 +3 -0
  159. package/see/examples/n3/complex.n3 +140 -0
  160. package/see/examples/n3/complex_matrix_stability.n3 +113 -0
  161. package/see/examples/n3/composition_of_injective_functions_is_injective.n3 +27 -0
  162. package/see/examples/n3/control_system.n3 +59 -0
  163. package/see/examples/n3/crypto_builtins_tests.n3 +18 -0
  164. package/see/examples/n3/delfour.n3 +167 -0
  165. package/see/examples/n3/digital_product_passport.n3 +156 -0
  166. package/see/examples/n3/dijkstra.n3 +46 -0
  167. package/see/examples/n3/dijkstra_risk_path.n3 +67 -0
  168. package/see/examples/n3/dog.n3 +20 -0
  169. package/see/examples/n3/eco_route_insight.n3 +88 -0
  170. package/see/examples/n3/equals.n3 +11 -0
  171. package/see/examples/n3/equivalence_classes_overlap_implies_same_class.n3 +19 -0
  172. package/see/examples/n3/euler_identity.n3 +41 -0
  173. package/see/examples/n3/ev_roundtrip_planner.n3 +82 -0
  174. package/see/examples/n3/existential_rule.n3 +10 -0
  175. package/see/examples/n3/expression_eval.n3 +21 -0
  176. package/see/examples/n3/family_cousins.n3 +62 -0
  177. package/see/examples/n3/fastpow.n3 +56 -0
  178. package/see/examples/n3/fibonacci.n3 +44 -0
  179. package/see/examples/n3/french_cities.n3 +28 -0
  180. package/see/examples/n3/fundamental_theorem_arithmetic.n3 +84 -0
  181. package/see/examples/n3/genetic_knapsack_selection.n3 +54 -0
  182. package/see/examples/n3/goldbach_1000.n3 +66 -0
  183. package/see/examples/n3/good_cobbler.n3 +10 -0
  184. package/see/examples/n3/gps.n3 +70 -0
  185. package/see/examples/n3/gray_code_counter.n3 +53 -0
  186. package/see/examples/n3/greatest_lower_bound_uniqueness.n3 +20 -0
  187. package/see/examples/n3/group_inverse_uniqueness.n3 +19 -0
  188. package/see/examples/n3/hadamard_approx.n3 +43 -0
  189. package/see/examples/n3/hanoi.n3 +16 -0
  190. package/see/examples/n3/odrl_dpv_risk_ranked.n3 +460 -0
  191. package/see/examples/n3/path_discovery.n3 +43 -0
  192. package/see/examples/n3/rc_discharge_envelope.n3 +61 -0
  193. package/see/examples/n3/rdf_message_flow.n3 +209 -0
  194. package/see/examples/n3/rdf_messages.n3 +143 -0
  195. package/see/examples/n3/school_placement_audit.n3 +63 -0
  196. package/see/examples/n3/smoke_arithmetic.n3 +22 -0
  197. package/see/examples/n3/socrates.n3 +21 -0
  198. package/see/examples/n3/wind_turbine.n3 +85 -0
  199. package/see/examples/n3/witch.n3 +30 -0
  200. package/see/examples/odrl_dpv_risk_ranked.js +5102 -0
  201. package/see/examples/output/age.md +48 -0
  202. package/see/examples/output/annotation.md +43 -0
  203. package/see/examples/output/backward.md +50 -0
  204. package/see/examples/output/backward_recursion.md +54 -0
  205. package/see/examples/output/bayes_diagnosis.md +103 -0
  206. package/see/examples/output/bayes_therapy.md +84 -0
  207. package/see/examples/output/bmi.md +164 -0
  208. package/see/examples/output/builtin_coverage.md +99 -0
  209. package/see/examples/output/collection.md +44 -0
  210. package/see/examples/output/complex.md +61 -0
  211. package/see/examples/output/complex_matrix_stability.md +55 -0
  212. package/see/examples/output/composition_of_injective_functions_is_injective.md +62 -0
  213. package/see/examples/output/control_system.md +61 -0
  214. package/see/examples/output/crypto_builtins_tests.md +68 -0
  215. package/see/examples/output/delfour.md +100 -0
  216. package/see/examples/output/digital_product_passport.md +100 -0
  217. package/see/examples/output/dijkstra.md +74 -0
  218. package/see/examples/output/dijkstra_risk_path.md +76 -0
  219. package/see/examples/output/dog.md +50 -0
  220. package/see/examples/output/eco_route_insight.md +88 -0
  221. package/see/examples/output/equals.md +50 -0
  222. package/see/examples/output/equivalence_classes_overlap_implies_same_class.md +86 -0
  223. package/see/examples/output/euler_identity.md +73 -0
  224. package/see/examples/output/ev_roundtrip_planner.md +79 -0
  225. package/see/examples/output/existential_rule.md +54 -0
  226. package/see/examples/output/expression_eval.md +50 -0
  227. package/see/examples/output/family_cousins.md +187 -0
  228. package/see/examples/output/fastpow.md +36 -0
  229. package/see/examples/output/fibonacci.md +53 -0
  230. package/see/examples/output/french_cities.md +70 -0
  231. package/see/examples/output/fundamental_theorem_arithmetic.md +101 -0
  232. package/see/examples/output/genetic_knapsack_selection.md +66 -0
  233. package/see/examples/output/goldbach_1000.md +58 -0
  234. package/see/examples/output/good_cobbler.md +54 -0
  235. package/see/examples/output/gps.md +102 -0
  236. package/see/examples/output/gray_code_counter.md +68 -0
  237. package/see/examples/output/greatest_lower_bound_uniqueness.md +60 -0
  238. package/see/examples/output/group_inverse_uniqueness.md +60 -0
  239. package/see/examples/output/hadamard_approx.md +510 -0
  240. package/see/examples/output/hanoi.md +51 -0
  241. package/see/examples/output/odrl_dpv_risk_ranked.md +139 -0
  242. package/see/examples/output/path_discovery.md +65 -0
  243. package/see/examples/output/rc_discharge_envelope.md +102 -0
  244. package/see/examples/output/rdf_message_flow.md +198 -0
  245. package/see/examples/output/rdf_messages.md +134 -0
  246. package/see/examples/output/school_placement_audit.md +99 -0
  247. package/see/examples/output/smoke_arithmetic.md +54 -0
  248. package/see/examples/output/socrates.md +55 -0
  249. package/see/examples/output/wind_turbine.md +108 -0
  250. package/see/examples/output/witch.md +87 -0
  251. package/see/examples/path_discovery.js +1748 -0
  252. package/see/examples/rc_discharge_envelope.js +1967 -0
  253. package/see/examples/rdf_message_flow.js +2554 -0
  254. package/see/examples/rdf_messages.js +2150 -0
  255. package/see/examples/school_placement_audit.js +1841 -0
  256. package/see/examples/smoke_arithmetic.js +1457 -0
  257. package/see/examples/socrates.js +1394 -0
  258. package/see/examples/wind_turbine.js +2827 -0
  259. package/see/examples/witch.js +1493 -0
  260. package/see/see.js +1794 -0
  261. package/test/api.test.js +27 -0
  262. package/test/see.test.js +159 -0
  263. package/tools/n3gen.js +1 -1
@@ -0,0 +1,41 @@
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. }.
@@ -0,0 +1,82 @@
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 }.
@@ -0,0 +1,10 @@
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. }.
@@ -0,0 +1,21 @@
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. }.
@@ -0,0 +1,62 @@
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
+ } .
@@ -0,0 +1,56 @@
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
+ }.
@@ -0,0 +1,44 @@
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 }.
@@ -0,0 +1,28 @@
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. }.
@@ -0,0 +1,84 @@
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 }.
@@ -0,0 +1,54 @@
1
+ # ===========================
2
+ # Genetic Knapsack Selection
3
+ # ===========================
4
+ # N3-compiled version of the deterministic one-bit mutation knapsack example.
5
+ # The original item list JSON is preserved as the data-input sidecar.
6
+
7
+ @prefix : <https://eyereasoner.github.io/see/examples/genetic-knapsack-selection#>.
8
+ @prefix math: <http://www.w3.org/2000/10/swap/math#>.
9
+ @prefix log: <http://www.w3.org/2000/10/swap/log#>.
10
+ @prefix string: <http://www.w3.org/2000/10/swap/string#>.
11
+
12
+ :Run
13
+ :capacity 50;
14
+ :startGenome "000000000000";
15
+ :maxGenerations 64.
16
+
17
+ :FinalLocal
18
+ :genome "101000000101";
19
+ :selectedItems "item01, item03, item10, item12";
20
+ :weight 50;
21
+ :value 101;
22
+ :fitness 999899;
23
+ :generationsEvaluated 5.
24
+
25
+ :ExhaustiveOptimum
26
+ :genome "001000011111";
27
+ :value 104.
28
+
29
+ :NeighborSummary
30
+ :oneBitNeighborsEvaluated 12;
31
+ :bestNeighborValue 101;
32
+ :capacityRespected true.
33
+
34
+ {
35
+ :Run :capacity ?Capacity.
36
+ :FinalLocal :weight ?Weight; :value ?Value.
37
+ :NeighborSummary :bestNeighborValue ?BestNeighbor; :capacityRespected true.
38
+ ?Weight math:notGreaterThan ?Capacity.
39
+ ?BestNeighbor math:notGreaterThan ?Value.
40
+ } => {
41
+ :Run :localSearchStopsAt :FinalLocal.
42
+ }.
43
+
44
+ {
45
+ :Run :capacity ?Capacity; :localSearchStopsAt :FinalLocal.
46
+ :FinalLocal :genome ?Genome; :selectedItems ?Items; :weight ?Weight; :value ?Value; :fitness ?Fitness; :generationsEvaluated ?Generations.
47
+ :ExhaustiveOptimum :genome ?OptGenome; :value ?OptValue.
48
+ ("=== Answer ===\nfinal genome : %s\nselected items : %s\nweight : %d / %d\nvalue : %d\nfitness : %d\ngenerations evaluated : %d\nexhaustive optimum value : %d at genome %s\n\n=== Explanation ===\nEach genome bit says whether the corresponding item is selected for the knapsack. Feasible candidates get fitness 1000000 minus value, so higher value means lower fitness; overweight candidates are penalized above every feasible candidate. The N3 source records the deterministic local-search result and validates that the final genome respects capacity and has no strictly better one-bit neighbor. For transparency, an exhaustive enumeration also records the global best feasible value, showing this is a local mutation search rather than a global-optimality claim." ?Genome ?Items ?Weight ?Capacity ?Value ?Fitness ?Generations ?OptValue ?OptGenome) string:format ?Block.
49
+ } => {
50
+ :geneticKnapsackSelection log:outputString ?Block.
51
+ :geneticKnapsackSelection :selects :FinalLocal.
52
+ }.
53
+
54
+ { :geneticKnapsackSelection :selects ?Candidate } log:query { :geneticKnapsackSelection :selects ?Candidate }.
@@ -0,0 +1,66 @@
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 }.
@@ -0,0 +1,10 @@
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) }. }.
@@ -0,0 +1,70 @@
1
+ # ==========================================================================
2
+ # GPS route planning
3
+ # ==========================================================================
4
+ # Goal-driven path planning over a tiny western-Belgium map. The N3 source is
5
+ # adapted from Eyeling's GPS example and compiles to a standalone SEE example.
6
+
7
+ @prefix log: <http://www.w3.org/2000/10/swap/log#>.
8
+ @prefix math: <http://www.w3.org/2000/10/swap/math#>.
9
+ @prefix list: <http://www.w3.org/2000/10/swap/list#>.
10
+ @prefix string: <http://www.w3.org/2000/10/swap/string#>.
11
+ @prefix gps: <https://eyereasoner.github.io/see/examples/gps#>.
12
+ @prefix : <https://eyereasoner.github.io/see/examples/gps#>.
13
+
14
+ :i1 :location :Gent.
15
+ :question :text "Which route should we take from Gent to Oostende?".
16
+ :routeDirect :label "Gent -> Brugge -> Oostende".
17
+ :routeViaKortrijk :label "Gent -> Kortrijk -> Brugge -> Oostende".
18
+
19
+ :mapBE gps:segment (:Gent :Brugge :drive_gent_brugge 1500.0 0.006 0.96 0.99).
20
+ :mapBE gps:segment (:Gent :Kortrijk :drive_gent_kortrijk 1600.0 0.007 0.96 0.99).
21
+ :mapBE gps:segment (:Kortrijk :Brugge :drive_kortrijk_brugge 1600.0 0.007 0.96 0.99).
22
+ :mapBE gps:segment (:Brugge :Oostende :drive_brugge_oostende 900.0 0.004 0.98 1.0).
23
+
24
+ { (?From ?To (?Act) ?Dur ?Cost ?Belief ?Comfort) :path true } <= {
25
+ :mapBE gps:segment (?From ?To ?Act ?Dur ?Cost ?Belief ?Comfort).
26
+ }.
27
+
28
+ { (?From ?To ?Actions ?Dur ?Cost ?Belief ?Comfort) :path true } <= {
29
+ :mapBE gps:segment (?From ?Mid ?Act ?Dur1 ?Cost1 ?Bel1 ?Comf1).
30
+ (?Mid ?To ?RestActs ?Dur2 ?Cost2 ?Bel2 ?Comf2) :path true.
31
+ ((?Act) ?RestActs) list:append ?Actions.
32
+ (?Dur1 ?Dur2) math:sum ?Dur.
33
+ (?Cost1 ?Cost2) math:sum ?Cost.
34
+ (?Bel1 ?Bel2) math:product ?Belief.
35
+ (?Comf1 ?Comf2) math:product ?Comfort.
36
+ }.
37
+
38
+ {
39
+ :i1 :location :Gent.
40
+ (:Gent :Oostende ?Acts ?Dur ?Cost ?Bel ?Comf) :path true.
41
+ } => { :i1 gps:path (?Acts ?Dur ?Cost ?Bel ?Comf). }.
42
+
43
+ { :i1 gps:path ((:drive_gent_brugge :drive_brugge_oostende) ?Dur ?Cost ?Bel ?Comf). } => {
44
+ :routeDirect :duration ?Dur; :cost ?Cost; :belief ?Bel; :comfort ?Comf.
45
+ }.
46
+
47
+ { :i1 gps:path ((:drive_gent_kortrijk :drive_kortrijk_brugge :drive_brugge_oostende) ?Dur ?Cost ?Bel ?Comf). } => {
48
+ :routeViaKortrijk :duration ?Dur; :cost ?Cost; :belief ?Bel; :comfort ?Comf.
49
+ }.
50
+
51
+ {
52
+ :routeDirect :duration ?D1; :cost ?C1; :belief ?B1; :comfort ?F1.
53
+ :routeViaKortrijk :duration ?D2; :cost ?C2; :belief ?B2; :comfort ?F2.
54
+ ?D1 math:lessThan ?D2.
55
+ ?C1 math:lessThan ?C2.
56
+ ?B1 math:greaterThan ?B2.
57
+ ?F1 math:greaterThan ?F2.
58
+ } => { :decision :recommendedRoute :routeDirect; :outcome "Take the direct route via Brugge.". }.
59
+
60
+ {
61
+ :decision :recommendedRoute :routeDirect; :outcome ?Outcome.
62
+ :routeDirect :label ?BestLabel; :duration ?BestDur; :cost ?BestCost; :belief ?BestBel; :comfort ?BestComf.
63
+ :routeViaKortrijk :label ?AltLabel; :duration ?AltDur; :cost ?AltCost; :belief ?AltBel; :comfort ?AltComf.
64
+ ("=== Answer ===\n%s\nRecommended route: %s\n\n=== Explanation ===\nFrom Gent to Oostende, the planner found two routes in this small map. The direct route (%s) takes %s seconds at cost %s, with belief %s and comfort %s. The alternative (%s) takes %s seconds at cost %s, with belief %s and comfort %s. So the direct route is faster, cheaper, more reliable, and slightly more comfortable." ?Outcome ?BestLabel ?BestLabel ?BestDur ?BestCost ?BestBel ?BestComf ?AltLabel ?AltDur ?AltCost ?AltBel ?AltComf) string:format ?Block.
65
+ } => { :report log:outputString ?Block. }.
66
+
67
+ { :decision :recommendedRoute :routeDirect. :routeDirect :duration ?D1. :routeViaKortrijk :duration ?D2. ?D1 math:notLessThan ?D2. } => false.
68
+ { :decision :recommendedRoute :routeDirect. :routeDirect :cost ?C1. :routeViaKortrijk :cost ?C2. ?C1 math:notLessThan ?C2. } => false.
69
+ { :decision :recommendedRoute :routeDirect. :routeDirect :belief ?B1. :routeViaKortrijk :belief ?B2. ?B1 math:notGreaterThan ?B2. } => false.
70
+ { :decision :recommendedRoute :routeDirect. :routeDirect :comfort ?F1. :routeViaKortrijk :comfort ?F2. ?F1 math:notGreaterThan ?F2. } => false.