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,70 +0,0 @@
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.
@@ -1,53 +0,0 @@
1
- # =================
2
- # Gray Code Counter
3
- # =================
4
- # N3-compiled version of the 4-bit Gray counter SEE example. The example keeps
5
- # the known reflected Gray-code sequence as data, derives its visited-state count
6
- # with a list builtin, and derives the published invariants before rendering the
7
- # SEE report.
8
-
9
- @prefix : <https://eyereasoner.github.io/see/examples/gray-code-counter#>.
10
- @prefix list: <http://www.w3.org/2000/10/swap/list#>.
11
- @prefix log: <http://www.w3.org/2000/10/swap/log#>.
12
- @prefix math: <http://www.w3.org/2000/10/swap/math#>.
13
- @prefix string: <http://www.w3.org/2000/10/swap/string#>.
14
-
15
- :Counter
16
- :bits 4;
17
- :steps 16;
18
- :sequence (0 1 3 2 6 7 5 4 12 13 15 14 10 11 9 8);
19
- :uniqueStateCount 16;
20
- :sequencePrefix "0000, 0001, 0011, 0010, 0110, 0111, 0101, 0100";
21
- :wrapTransition "1000 -> 0000";
22
- :maxHammingDistance 1.
23
-
24
- # Each adjacent pair, including the wraparound pair, was independently validated
25
- # to flip one bit in the 4-bit representation.
26
- {
27
- :Counter :sequence ?Sequence.
28
- ?Sequence list:length ?Visited.
29
- } => {
30
- :Counter :statesVisited ?Visited.
31
- }.
32
-
33
- {
34
- :Counter :steps ?Steps;
35
- :statesVisited ?Steps;
36
- :uniqueStateCount ?Steps;
37
- :maxHammingDistance 1.
38
- } => {
39
- :Counter :validGrayCycle true.
40
- }.
41
-
42
- {
43
- :Counter :bits ?Bits;
44
- :statesVisited ?Visited;
45
- :uniqueStateCount ?Unique;
46
- :sequencePrefix ?Prefix;
47
- :wrapTransition ?Wrap;
48
- :maxHammingDistance ?Max.
49
- :Counter :validGrayCycle true.
50
- ("=== Answer ===\nbits : %s\nstates visited : %s\nunique states : %s\nsequence prefix : %s\nwrap transition : %s\nmaximum adjacent Hamming distance : %s\n\n=== Explanation ===\nThe counter maps each integer n to n xor (n >> 1), which is the reflected binary Gray-code construction. For 4 bits, the first 16 integers cover the full state space without duplicates. The Hamming-distance comparison compares each state with the next state, including the final wraparound transition. A valid cyclic Gray counter therefore changes exactly one bit at every step." ?Bits ?Visited ?Unique ?Prefix ?Wrap ?Max) string:format ?Block.
51
- } => {
52
- :report log:outputString ?Block.
53
- }.
@@ -1,20 +0,0 @@
1
- # In a partial order, a greatest lower bound is unique.
2
- @prefix : <https://eyereasoner.github.io/eye/reasoning#>.
3
- @prefix log: <http://www.w3.org/2000/10/swap/log#>.
4
-
5
- { ?x :inP true. } => { ?x :leq ?x. }.
6
- { ?x :leq ?y. ?y :leq ?z. } => { ?x :leq ?z. }.
7
- { ?x :leq ?y. ?y :leq ?x. } => { (?x ?y) :sameTerm true. }.
8
- { (?x ?y) :sameTerm true. } => { (?y ?x) :sameTerm true. }.
9
- { ?m :glbOf (?a ?b). } => { ?m :lowerBoundOf (?a ?b). ?m :leq ?a. ?m :leq ?b. }.
10
- { ?m :glbOf (?a ?b). ?l :lowerBoundOf (?a ?b). } => { ?l :leq ?m. }.
11
- { ?m :glbOf (?a ?b). ?n :glbOf (?a ?b). (?m ?n) :sameTerm true. } => { (?a ?b ?m ?n) :sameGlb true. }.
12
-
13
- :a :inP true.
14
- :b :inP true.
15
- :g1 :inP true.
16
- :g2 :inP true.
17
- :g1 :glbOf (:a :b).
18
- :g2 :glbOf (:a :b).
19
-
20
- { (?a ?b ?m ?n) :sameGlb true. ?m log:notEqualTo ?n. } log:query { :result :sameGreatestLowerBound (?a ?b ?m ?n). }.
@@ -1,19 +0,0 @@
1
- # In a group, the inverse of an element is unique.
2
- @prefix : <https://eyereasoner.github.io/eye/reasoning#>.
3
- @prefix log: <http://www.w3.org/2000/10/swap/log#>.
4
-
5
- { (?a ?b) :mul ?ab. (?ab ?c) :mul ?left. (?b ?c) :mul ?bc. (?a ?bc) :mul ?right. } => { (?left ?right) :sameTerm true. }.
6
- { (?a ?b) :sameTerm true. } => { (?b ?a) :sameTerm true. }.
7
- { ?a :inG true. } => { (:e ?a) :mul ?a. }.
8
- { ?a :inG true. } => { (?a :e) :mul ?a. }.
9
- { ?x :inG true. ?y :inG true. ?y :inverseOf ?x. } => { (?x ?y) :mul :e. (?y ?x) :mul :e. }.
10
- { ?y :inverseOf ?x. ?z :inverseOf ?x. (?y ?z) :sameTerm true. } => { (?x ?y ?z) :sameInverse true. }.
11
-
12
- :x :inG true.
13
- :i :inG true.
14
- :j :inG true.
15
- :e :inG true.
16
- :i :inverseOf :x.
17
- :j :inverseOf :x.
18
-
19
- { (?x ?y ?z) :sameInverse true. ?y log:notEqualTo ?z. } log:query { :result :sameInverse (?x ?y ?z). }.
@@ -1,43 +0,0 @@
1
- # ===========================================================================================
2
- # Hadamard gate approximation
3
- # ===========================================================================================
4
- @prefix : <https://eyereasoner.github.io/see/examples/hadamard-approx#>.
5
- @prefix log: <http://www.w3.org/2000/10/swap/log#>.
6
- @prefix math: <http://www.w3.org/2000/10/swap/math#>.
7
-
8
- # Parameters
9
- :sqrt2Proc a :DyadicBisection; :maxN 20.
10
- :HGate a :SingleQubitGate; :name "H"; :usesScale :invSqrt2.
11
- :invSqrt2 a :PositiveRealApprox; :definedAs "1/sqrt2".
12
-
13
- # 1) Dyadic bisection for sqrt(2) with integers only
14
- :sqrt2Proc :state (0 1 2).
15
-
16
- # Case A: midpoint^2 < 2 => new interval [mid, U]
17
- { :sqrt2Proc :state (?n ?l ?u). :sqrt2Proc :maxN ?maxN. ?n math:lessThan ?maxN. (?n 1) math:sum ?n1. (?l ?u) math:sum ?midNum. (?midNum ?midNum) math:product ?midSq. (?n 2) math:product ?twoN. (?twoN 3) math:sum ?exp. (2 ?exp) math:exponentiation ?pow. ?midSq math:lessThan ?pow. (2 ?u) math:product ?uScaled. } => { :sqrt2Proc :state (?n1 ?midNum ?uScaled). }.
18
-
19
- # Case B: midpoint^2 >= 2 => new interval [L, mid]
20
- { :sqrt2Proc :state (?n ?l ?u). :sqrt2Proc :maxN ?maxN. ?n math:lessThan ?maxN. (?n 1) math:sum ?n1. (?l ?u) math:sum ?midNum. (?midNum ?midNum) math:product ?midSq. (?n 2) math:product ?twoN. (?twoN 3) math:sum ?exp. (2 ?exp) math:exponentiation ?pow. ?midSq math:notLessThan ?pow. (2 ?l) math:product ?lScaled. } => { :sqrt2Proc :state (?n1 ?lScaled ?midNum). }.
21
-
22
- # 2) Readable bounds for sqrt(2), then invert to get s = 1/sqrt2
23
- { :sqrt2Proc :state (?n ?l ?u). (2 ?n) math:exponentiation ?denom. (?l ?denom) math:quotient ?L. (?u ?denom) math:quotient ?U. } => { :sqrt2Proc :dyadic (?n ?l ?u ?denom). :sqrt2Proc :bounds (?n ?L ?U). }.
24
- { :sqrt2Proc :dyadic (?n ?l ?u ?denom). (?denom ?u) math:quotient ?sL. (?denom ?l) math:quotient ?sU. } => { :invSqrt2 :bounds (?n ?sL ?sU). }.
25
- { :invSqrt2 :bounds (?n ?sL ?sU). (?sU ?sL) math:difference ?sW. (?sW 2) math:quotient ?compErr. (?sL ?sU) math:sum ?sSum. (?sSum 2) math:quotient ?m. (0 ?sU) math:difference ?negL. (0 ?sL) math:difference ?negU. (0 ?m) math:difference ?negM. } => { :invSqrt2 :width (?n ?sW). :invSqrt2 :componentErrBound (?n ?compErr). :invSqrt2 :midpoint (?n ?m). :invSqrt2 :negBounds (?n ?negL ?negU). :invSqrt2 :negMidpoint (?n ?negM). }.
26
-
27
- # 3) Assemble interval-certified H-gate entries
28
- { :invSqrt2 :bounds (?n ?sL ?sU). :invSqrt2 :negBounds (?n ?negL ?negU). } => { :HGate :entry (?n 0 0 ?sL ?sU 0 0). :HGate :entry (?n 0 1 ?sL ?sU 0 0). :HGate :entry (?n 1 0 ?sL ?sU 0 0). :HGate :entry (?n 1 1 ?negL ?negU 0 0). }.
29
- { :invSqrt2 :midpoint (?n ?m). :invSqrt2 :negMidpoint (?n ?negM). } => { :HGate :midpointEntry (?n 0 0 ?m 0). :HGate :midpointEntry (?n 0 1 ?m 0). :HGate :midpointEntry (?n 1 0 ?m 0). :HGate :midpointEntry (?n 1 1 ?negM 0). }.
30
-
31
- # 4) Certify row norm squared contains 1 using integer inequalities
32
- { :sqrt2Proc :dyadic (?n ?l ?u ?denom). (?denom ?denom) math:product ?denom2. (2 ?denom2) math:product ?normNum. (?l ?l) math:product ?l2. (?u ?u) math:product ?u2. ?normNum math:notGreaterThan ?u2. ?normNum math:notLessThan ?l2. (?normNum ?u2) math:quotient ?normL. (?normNum ?l2) math:quotient ?normU. (?normU ?normL) math:difference ?normW. } => { :HGate :rowNormSqBounds (?n 0 ?normL ?normU). :HGate :rowNormSqBounds (?n 1 ?normL ?normU). :HGate :rowNormSqWidth (?n ?normW). :HGate :rowNormSqContains1 (?n true). }.
33
-
34
- # 5) Midpoint structural sanity validation: row0 dot row1 = 0 exactly
35
- { :invSqrt2 :midpoint (?n ?m). :invSqrt2 :negMidpoint (?n ?negM). (?m ?m) math:product ?m2. (?m ?negM) math:product ?mn. (?m2 ?mn) math:sum ?dot. ?dot math:equalTo 0. } => { :HGate :midpointRowsOrthogonal (?n true). }.
36
-
37
- # 6) Midpoint entrywise and rowwise conservative error data
38
- { :invSqrt2 :componentErrBound (?n ?compErr). (2 ?compErr) math:product ?rowErr. } => { :HGate :entryAbsErrBoundMidpoint (?n ?compErr). :HGate :rowAbsErrBoundMidpoint (?n ?rowErr). }.
39
-
40
- # 7) Output selection
41
- { :sqrt2Proc :dyadic (?n ?l ?u ?denom). :sqrt2Proc :bounds (?n ?L ?U). :invSqrt2 :bounds (?n ?sL ?sU). :invSqrt2 :width (?n ?sW). :invSqrt2 :midpoint (?n ?m). :invSqrt2 :negMidpoint (?n ?negM). :HGate :entryAbsErrBoundMidpoint (?n ?cE). :HGate :rowAbsErrBoundMidpoint (?n ?rE). :HGate :rowNormSqBounds (?n 0 ?rnL ?rnU). :HGate :rowNormSqWidth (?n ?rnW). :HGate :rowNormSqContains1 (?n ?okNorm). :HGate :midpointRowsOrthogonal (?n ?okDot). } log:query { :result :n ?n. :result :sqrt2Dyadic (?n ?l ?u ?denom). :result :sqrt2Bounds (?n ?L ?U). :result :invSqrt2Bounds (?n ?sL ?sU). :result :invSqrt2Width (?n ?sW). :result :midpointScale (?n ?m). :result :midpointNegScale (?n ?negM). :result :entryAbsErrBoundMidpoint (?n ?cE). :result :rowAbsErrBoundMidpoint (?n ?rE). :result :rowNormSqBounds (?n ?rnL ?rnU). :result :rowNormSqWidth (?n ?rnW). :result :rowNormSqContains1 (?n ?okNorm). :result :midpointRowsOrthogonal (?n ?okDot). }.
42
- { :HGate :entry (?n ?r ?c ?reL ?reU ?imL ?imU). } log:query { :result :HEntry (?n ?r ?c ?reL ?reU ?imL ?imU). }.
43
- { :HGate :midpointEntry (?n ?r ?c ?re ?im). } log:query { :result :HMidpointEntry (?n ?r ?c ?re ?im). }.
@@ -1,16 +0,0 @@
1
- # =========================================================================
2
- # Towers of Hanoi
3
- # =========================================================================
4
- @prefix math: <http://www.w3.org/2000/10/swap/math#>.
5
- @prefix list: <http://www.w3.org/2000/10/swap/list#>.
6
- @prefix : <https://eyereasoner.github.io/eye/reasoning#>.
7
-
8
- { (?N ?X ?Y ?Z) :moves ?M } <= {
9
- ?N math:greaterThan 1.
10
- (?N 1) math:difference ?N1.
11
- (?N1 ?X ?Z ?Y) :moves ?M1.
12
- (?N1 ?Z ?Y ?X) :moves ?M2.
13
- (?M1 ((?X ?Y)) ?M2) list:append ?M.
14
- }.
15
- { (1 ?X ?Y ?Z) :moves ((?X ?Y)) } <= true.
16
- { (3 :left :right :center) :moves ?M } => { 3 :answer ?M }.
@@ -1,460 +0,0 @@
1
- # ===========================================================================================
2
- # ODRL + DPV risk assessment with ranked, explainable output.
3
- #
4
- # What this file does
5
- # - Models an agreement as an ODRL policy (odrl:Policy) containing permissions,
6
- # prohibitions, duties, and constraints. ODRL is expressive enough to encode the
7
- # normative “may/must/must-not” structure of TOS clauses as RDF.
8
- # - Links each ODRL rule to a clause resource (:Clause) to keep human-readable text
9
- # while preserving machine-readable structure for reasoning.
10
- # - Uses N3 rules with log:includes / log:notIncludes to detect missing safeguards
11
- # (e.g., missing notice constraints, missing inform duties, missing consent constraints).
12
- # - Generates DPV risks (dpv:Risk) and classifies them using DPV-RISK concepts:
13
- # risk:hasRiskSource, dpv:hasConsequence, dpv:hasImpact, dpv:hasSeverity, dpv:hasRiskLevel.
14
- # - Produces mitigations as dpv:RiskMitigationMeasure resources and attaches them
15
- # to risks with dpv:isMitigatedByMeasure.
16
- # - Computes a numeric score for each risk and prints a ranked, explainable report.
17
- #
18
- # Ranking / output
19
- # - Output strings are emitted as log:outputString triples.
20
- # - When running with Eyeling “strings” mode (-r), strings are printed in deterministic
21
- # order based on their subject key. The program encodes ranking via an “inverse score”
22
- # key (e.g., 1000 - score) so higher-risk items appear first.
23
- #
24
- # References
25
- # - N3 spec: https://w3c.github.io/N3/spec/
26
- # - Eyeling builtins: https://eyereasoner.github.io/eyeling/HANDBOOK#ch11
27
- # - ODRL vocab: https://www.w3.org/TR/odrl-vocab/
28
- # - DPV risk module: https://dev.dpvcg.org/dpv/modules/risk
29
- # - DPV-RISK: https://w3id.org/dpv/risk
30
- # ===========================================================================================
31
-
32
- @prefix : <https://example.org/odrl-dpv-risk-ranked#> .
33
- @prefix odrl: <http://www.w3.org/ns/odrl/2/> .
34
- @prefix dpv: <https://w3id.org/dpv#> .
35
- @prefix risk: <https://w3id.org/dpv/risk#> .
36
- @prefix dct: <http://purl.org/dc/terms/> .
37
- @prefix log: <http://www.w3.org/2000/10/swap/log#> .
38
- @prefix math: <http://www.w3.org/2000/10/swap/math#> .
39
- @prefix string:<http://www.w3.org/2000/10/swap/string#> .
40
- @prefix tosl: <https://example.org/tosl-profile#> .
41
-
42
- # ---------------------------
43
- # 1) Consumer profile (needs)
44
- # ---------------------------
45
-
46
- :ConsumerExample a :ConsumerProfile, odrl:Party ;
47
- dct:title "Example consumer profile" ;
48
- :hasNeed :Need_DataCannotBeRemoved,
49
- :Need_ChangeOnlyWithPriorNotice,
50
- :Need_NoSharingWithoutConsent,
51
- :Need_DataPortability .
52
-
53
- :Need_DataCannotBeRemoved a :Need ;
54
- :importance 20 ;
55
- dct:description "Provider must not remove the consumer account/data." .
56
-
57
- :Need_ChangeOnlyWithPriorNotice a :Need ;
58
- :importance 15 ;
59
- :minNoticeDays 14 ;
60
- dct:description "Agreement may change only with prior notice (>= 14 days)." .
61
-
62
- :Need_NoSharingWithoutConsent a :Need ;
63
- :importance 12 ;
64
- dct:description "No data sharing without explicit consent." .
65
-
66
- :Need_DataPortability a :Need ;
67
- :importance 10 ;
68
- dct:description "Consumer must be able to export their data." .
69
-
70
- # ------------------------------------------
71
- # 2) Agreement (ODRL policy graph + clauses)
72
- # ------------------------------------------
73
-
74
- :Agreement1 a :Agreement ;
75
- dct:title "Example Agreement" ;
76
- :policyGraph {
77
- :Policy1 a odrl:Policy ;
78
- odrl:permission :PermDeleteAccount,
79
- :PermChangeTerms,
80
- :PermShareData ;
81
- odrl:prohibition :ProhibitExportData .
82
-
83
- # Clause C1: remove account/data without safeguards
84
- :PermDeleteAccount a odrl:Permission ;
85
- odrl:assigner :Provider ;
86
- odrl:assignee :ConsumerExample ;
87
- odrl:action tosl:removeAccount ;
88
- odrl:target :UserAccount ;
89
- :clause :ClauseC1 .
90
-
91
- # Clause C2: change terms with noticeDays >= 3 (may be too short for the consumer)
92
- :PermChangeTerms a odrl:Permission ;
93
- odrl:assigner :Provider ;
94
- odrl:assignee :ConsumerExample ;
95
- odrl:action tosl:changeTerms ;
96
- odrl:target :AgreementText ;
97
- odrl:duty [
98
- a odrl:Duty ;
99
- odrl:action odrl:inform ;
100
- odrl:constraint [
101
- a odrl:Constraint ;
102
- odrl:leftOperand tosl:noticeDays ;
103
- odrl:operator odrl:gteq ;
104
- odrl:rightOperand 3
105
- ]
106
- ] ;
107
- :clause :ClauseC2 .
108
-
109
- # Clause C3: share data without explicit consent safeguard
110
- :PermShareData a odrl:Permission ;
111
- odrl:assigner :Provider ;
112
- odrl:assignee :ConsumerExample ;
113
- odrl:action tosl:shareData ;
114
- odrl:target :UserData ;
115
- :clause :ClauseC3 .
116
-
117
- # Clause C4: prohibit export (hurts portability)
118
- :ProhibitExportData a odrl:Prohibition ;
119
- odrl:assigner :Provider ;
120
- odrl:assignee :ConsumerExample ;
121
- odrl:action tosl:exportData ;
122
- odrl:target :UserData ;
123
- :clause :ClauseC4 .
124
- } .
125
-
126
- :ClauseC1 a :Clause ; :clauseId "C1" ; :text "Provider may remove the user account (and associated data) at its discretion." .
127
- :ClauseC2 a :Clause ; :clauseId "C2" ; :text "Provider may change terms by informing users at least 3 days in advance." .
128
- :ClauseC3 a :Clause ; :clauseId "C3" ; :text "Provider may share user data with partners for business purposes." .
129
- :ClauseC4 a :Clause ; :clauseId "C4" ; :text "Users are not permitted to export their data." .
130
-
131
- :ProcessContext1 a dpv:Process ;
132
- dct:source :Agreement1 ;
133
- dct:title "Service operation under Agreement1" .
134
-
135
- # ------------------------------------------------------------------------------------
136
- # 3) Risk rules (ODRL -> DPV/DPV-RISK) + mitigations
137
- # IMPORTANT: only match ODRL structure inside log:includes; clause text is outside.
138
- # ------------------------------------------------------------------------------------
139
-
140
- # R1: remove account/data WITHOUT notice constraint AND WITHOUT inform duty
141
- {
142
- :Agreement1 :policyGraph ?G .
143
- :ConsumerExample :hasNeed :Need_DataCannotBeRemoved .
144
- :Need_DataCannotBeRemoved :importance ?w .
145
-
146
- ?G log:includes {
147
- :PermDeleteAccount a odrl:Permission ;
148
- odrl:action tosl:removeAccount ;
149
- :clause ?clause .
150
- }.
151
-
152
- ?G log:notIncludes {
153
- :PermDeleteAccount odrl:constraint [
154
- odrl:leftOperand tosl:noticeDays
155
- ] .
156
- }.
157
-
158
- ?G log:notIncludes {
159
- :PermDeleteAccount odrl:duty [
160
- odrl:action odrl:inform
161
- ] .
162
- }.
163
-
164
- ?clause :clauseId ?cid ; :text ?txt .
165
-
166
- (90 ?w) math:sum ?raw .
167
- ( "Risk: account/data removal is permitted without notice safeguards (no notice constraint and no duty to inform). Clause %s: %s"
168
- ?cid ?txt ) string:format ?why .
169
- }
170
- =>
171
- {
172
- _:src1 a risk:RiskSource, risk:LegalComplianceRisk ;
173
- dct:source :PermDeleteAccount ;
174
- dct:description "Account removal permitted without notice safeguards." .
175
-
176
- _:risk1 a dpv:Risk, risk:UnwantedDataDeletion, risk:DataUnavailable, risk:DataErasureError, risk:DataLoss ;
177
- dct:source :PermDeleteAccount ;
178
- risk:hasRiskSource _:src1 ;
179
- dpv:hasConsequence risk:DataLoss, risk:DataUnavailable, risk:CustomerConfidenceLoss ;
180
- dpv:hasImpact risk:FinancialLoss, risk:NonMaterialDamage ;
181
- :aboutClause ?clause ;
182
- :scoreRaw ?raw ;
183
- :violatesNeed :Need_DataCannotBeRemoved ;
184
- dct:description ?why .
185
-
186
- :ProcessContext1 dpv:hasRisk _:risk1 .
187
-
188
-
189
- _:m11 a dpv:RiskMitigationMeasure ;
190
- dct:description "Add a notice constraint (minimum noticeDays) before account removal." ;
191
- dpv:mitigatesRisk _:risk1 ;
192
- :suggestAdd {
193
- :PermDeleteAccount odrl:constraint [
194
- a odrl:Constraint ;
195
- odrl:leftOperand tosl:noticeDays ;
196
- odrl:operator odrl:gteq ;
197
- odrl:rightOperand 14
198
- ] .
199
- } .
200
-
201
- _:m21 a dpv:RiskMitigationMeasure ;
202
- dct:description "Add a duty to inform the consumer prior to account removal." ;
203
- dpv:mitigatesRisk _:risk1 ;
204
- :suggestAdd {
205
- :PermDeleteAccount odrl:duty [
206
- a odrl:Duty ;
207
- odrl:action odrl:inform
208
- ] .
209
- } .
210
-
211
- _:risk1 dpv:isMitigatedByMeasure _:m11, _:m21 .
212
- } .
213
-
214
- # R2: change terms noticeDays is below consumer requirement
215
- {
216
- :Agreement1 :policyGraph ?G .
217
- :ConsumerExample :hasNeed :Need_ChangeOnlyWithPriorNotice .
218
- :Need_ChangeOnlyWithPriorNotice :importance ?w ; :minNoticeDays ?req .
219
-
220
- ?G log:includes {
221
- :PermChangeTerms a odrl:Permission ;
222
- odrl:action tosl:changeTerms ;
223
- :clause ?clause ;
224
- odrl:duty [
225
- odrl:action odrl:inform ;
226
- odrl:constraint [
227
- odrl:leftOperand tosl:noticeDays ;
228
- odrl:rightOperand ?days
229
- ]
230
- ] .
231
- }.
232
-
233
- ?days math:lessThan ?req .
234
- ?clause :clauseId ?cid ; :text ?txt .
235
-
236
- (70 ?w) math:sum ?raw .
237
- ( "Risk: terms may change with notice (%s days) below consumer requirement (%s days). Clause %s: %s"
238
- ?days ?req ?cid ?txt ) string:format ?why .
239
- }
240
- =>
241
- {
242
- _:src2 a risk:RiskSource, risk:PolicyRisk ;
243
- dct:source :PermChangeTerms ;
244
- dct:description "Notice for changing terms is shorter than consumer requirement." .
245
-
246
- _:risk2 a dpv:Risk, risk:PolicyRisk, risk:CustomerConfidenceLoss ;
247
- dct:source :PermChangeTerms ;
248
- risk:hasRiskSource _:src2 ;
249
- dpv:hasConsequence risk:CustomerConfidenceLoss ;
250
- dpv:hasImpact risk:NonMaterialDamage ;
251
- :aboutClause ?clause ;
252
- :scoreRaw ?raw ;
253
- :violatesNeed :Need_ChangeOnlyWithPriorNotice ;
254
- dct:description ?why .
255
-
256
- :ProcessContext1 dpv:hasRisk _:risk2 .
257
-
258
- _:m12 a dpv:RiskMitigationMeasure ;
259
- dct:description "Increase minimum noticeDays in the inform duty to meet the consumer requirement." ;
260
- dpv:mitigatesRisk _:risk2 ;
261
- :suggestAdd {
262
- :PermChangeTerms odrl:duty [
263
- a odrl:Duty ;
264
- odrl:action odrl:inform ;
265
- odrl:constraint [
266
- a odrl:Constraint ;
267
- odrl:leftOperand tosl:noticeDays ;
268
- odrl:operator odrl:gteq ;
269
- odrl:rightOperand 14
270
- ]
271
- ] .
272
- } .
273
-
274
- _:risk2 dpv:isMitigatedByMeasure _:m12 .
275
- } .
276
-
277
- # R3: share data WITHOUT explicit consent constraint
278
- {
279
- :Agreement1 :policyGraph ?G .
280
- :ConsumerExample :hasNeed :Need_NoSharingWithoutConsent .
281
- :Need_NoSharingWithoutConsent :importance ?w .
282
-
283
- ?G log:includes {
284
- :PermShareData a odrl:Permission ;
285
- odrl:action tosl:shareData ;
286
- :clause ?clause .
287
- }.
288
-
289
- ?G log:notIncludes {
290
- :PermShareData odrl:constraint [
291
- odrl:leftOperand tosl:consent ;
292
- odrl:operator odrl:eq ;
293
- odrl:rightOperand true
294
- ] .
295
- }.
296
-
297
- ?clause :clauseId ?cid ; :text ?txt .
298
-
299
- (85 ?w) math:sum ?raw .
300
- ( "Risk: user data sharing is permitted without an explicit consent constraint. Clause %s: %s"
301
- ?cid ?txt ) string:format ?why .
302
- }
303
- =>
304
- {
305
- _:src3 a risk:RiskSource, risk:PolicyRisk ;
306
- dct:source :PermShareData ;
307
- dct:description "Data sharing permitted without explicit consent constraint." .
308
-
309
- _:risk3 a dpv:Risk, risk:UnwantedDisclosureData, risk:CustomerConfidenceLoss ;
310
- dct:source :PermShareData ;
311
- risk:hasRiskSource _:src3 ;
312
- dpv:hasConsequence risk:CustomerConfidenceLoss ;
313
- dpv:hasImpact risk:NonMaterialDamage, risk:FinancialLoss ;
314
- :aboutClause ?clause ;
315
- :scoreRaw ?raw ;
316
- :violatesNeed :Need_NoSharingWithoutConsent ;
317
- dct:description ?why .
318
-
319
- :ProcessContext1 dpv:hasRisk _:risk3 .
320
-
321
- _:m13 a dpv:RiskMitigationMeasure ;
322
- dct:description "Add an explicit consent constraint before data sharing." ;
323
- dpv:mitigatesRisk _:risk3 ;
324
- :suggestAdd {
325
- :PermShareData odrl:constraint [
326
- a odrl:Constraint ;
327
- odrl:leftOperand tosl:consent ;
328
- odrl:operator odrl:eq ;
329
- odrl:rightOperand true
330
- ] .
331
- } .
332
-
333
- _:risk3 dpv:isMitigatedByMeasure _:m13 .
334
- } .
335
-
336
- # R4: prohibit export (no portability)
337
- {
338
- :Agreement1 :policyGraph ?G .
339
- :ConsumerExample :hasNeed :Need_DataPortability .
340
- :Need_DataPortability :importance ?w .
341
-
342
- ?G log:includes {
343
- :ProhibitExportData a odrl:Prohibition ;
344
- odrl:action tosl:exportData ;
345
- :clause ?clause .
346
- }.
347
-
348
- ?clause :clauseId ?cid ; :text ?txt .
349
-
350
- (60 ?w) math:sum ?raw .
351
- ( "Risk: portability is restricted because exporting user data is prohibited. Clause %s: %s"
352
- ?cid ?txt ) string:format ?why .
353
- }
354
- =>
355
- {
356
- _:src4 a risk:RiskSource, risk:PolicyRisk ;
357
- dct:source :ProhibitExportData ;
358
- dct:description "Data export is prohibited, reducing portability." .
359
-
360
- _:risk4 a dpv:Risk, risk:PolicyRisk, risk:CustomerConfidenceLoss ;
361
- dct:source :ProhibitExportData ;
362
- risk:hasRiskSource _:src4 ;
363
- dpv:hasConsequence risk:CustomerConfidenceLoss ;
364
- dpv:hasImpact risk:NonMaterialDamage ;
365
- :aboutClause ?clause ;
366
- :scoreRaw ?raw ;
367
- :violatesNeed :Need_DataPortability ;
368
- dct:description ?why .
369
-
370
- :ProcessContext1 dpv:hasRisk _:risk4 .
371
-
372
- _:m14 a dpv:RiskMitigationMeasure ;
373
- dct:description "Add a permission allowing data export (or remove the prohibition) to support portability." ;
374
- dpv:mitigatesRisk _:risk4 ;
375
- :suggestAdd {
376
- :Policy1 odrl:permission [
377
- a odrl:Permission ;
378
- odrl:assigner :Provider ;
379
- odrl:assignee :ConsumerExample ;
380
- odrl:action tosl:exportData ;
381
- odrl:target :UserData
382
- ] .
383
- } .
384
-
385
- _:risk4 dpv:isMitigatedByMeasure _:m14 .
386
- } .
387
-
388
- # ------------------------------------------------
389
- # 4) Score normalization + DPV-RISK severity/level
390
- # ------------------------------------------------
391
-
392
- { ?r a dpv:Risk ; :scoreRaw ?raw . ?raw math:greaterThan 100 . }
393
- => { ?r :score 100 . } .
394
-
395
- { ?r a dpv:Risk ; :scoreRaw ?raw . 100 math:notLessThan ?raw . }
396
- => { ?r :score ?raw . } .
397
-
398
- { ?r a dpv:Risk ; :score ?s . ?s math:greaterThan 79 . }
399
- => { ?r dpv:hasSeverity risk:HighSeverity ; dpv:hasRiskLevel risk:HighRisk . } .
400
-
401
- { ?r a dpv:Risk ; :score ?s . ?s math:lessThan 80 . ?s math:greaterThan 49 . }
402
- => { ?r dpv:hasSeverity risk:ModerateSeverity ; dpv:hasRiskLevel risk:ModerateRisk . } .
403
-
404
- { ?r a dpv:Risk ; :score ?s . ?s math:lessThan 50 . }
405
- => { ?r dpv:hasSeverity risk:LowSeverity ; dpv:hasRiskLevel risk:LowRisk . } .
406
-
407
- # ------------------------------------------------------------------------------
408
- # 5) Ranked explainable output via log:query (Eyeling -r prints these in key order)
409
- # ------------------------------------------------------------------------------
410
-
411
- # Header
412
- {
413
- :Agreement1 dct:title ?alabel .
414
- :ConsumerExample dct:title ?plabel .
415
- ( "\n=== Ranked DPV Risk Report ===\nAgreement: %s\nProfile: %s\n\n"
416
- ?alabel ?plabel ) string:format ?hdr .
417
- }
418
- log:query
419
- {
420
- ( :Agreement1 :ConsumerExample 0 ) log:outputString ?hdr .
421
- }.
422
-
423
- # Risk lines (key includes inverse score = 1000 - score)
424
- {
425
- ?r a dpv:Risk ;
426
- :score ?score ;
427
- dpv:hasRiskLevel ?lvl ;
428
- dpv:hasSeverity ?sev ;
429
- :aboutClause ?clause ;
430
- dct:description ?why .
431
- ?clause :clauseId ?cid .
432
-
433
- ( 1000 ?score ) math:difference ?inv .
434
-
435
- ( "score=%s (%s, %s) clause %s\n %s\n\n"
436
- ?score ?lvl ?sev ?cid ?why ) string:format ?line .
437
- }
438
- log:query
439
- {
440
- ( :Agreement1 :ConsumerExample 1 ?inv ?cid 0 ?r ) log:outputString ?line .
441
- }.
442
-
443
- # Mitigation lines (same ordering as their risk)
444
- {
445
- ?r a dpv:Risk ;
446
- :score ?score ;
447
- dpv:isMitigatedByMeasure ?m ;
448
- :aboutClause ?clause .
449
- ?clause :clauseId ?cid .
450
- ?m dct:description ?md .
451
-
452
- ( 1000 ?score ) math:difference ?inv .
453
-
454
- ( " - mitigation for clause %s: %s\n"
455
- ?cid ?md ) string:format ?mline .
456
- }
457
- log:query
458
- {
459
- ( :Agreement1 :ConsumerExample 1 ?inv ?cid 1 ?r ?m ) log:outputString ?mline .
460
- }.