eyeling 1.5.23 → 1.5.25

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 (60) hide show
  1. package/examples/age.n3 +2 -3
  2. package/examples/backward.n3 +2 -3
  3. package/examples/basic-monadic.n3 +2 -3
  4. package/examples/cat-koko.n3 +5 -6
  5. package/examples/collect-all-in.n3 +6 -6
  6. package/examples/complex.n3 +2 -3
  7. package/examples/control-system.n3 +2 -2
  8. package/examples/crypto-builtins-tests.n3 +2 -2
  9. package/examples/deep-taxonomy-10.n3 +5 -0
  10. package/examples/deep-taxonomy-100.n3 +5 -0
  11. package/examples/deep-taxonomy-1000.n3 +5 -0
  12. package/examples/deep-taxonomy-10000.n3 +5 -0
  13. package/examples/derived-backward-rule-2.n3 +2 -3
  14. package/examples/derived-backward-rule.n3 +2 -2
  15. package/examples/derived-rule.n3 +2 -2
  16. package/examples/dijkstra.n3 +2 -3
  17. package/examples/dog.n3 +2 -3
  18. package/examples/drone-corridor-planner-v2.n3 +237 -0
  19. package/examples/drone-corridor-planner.n3 +131 -0
  20. package/examples/equals.n3 +3 -4
  21. package/examples/existential-rule.n3 +2 -2
  22. package/examples/expression-eval.n3 +2 -3
  23. package/examples/family-cousins.n3 +2 -2
  24. package/examples/fibonacci.n3 +2 -3
  25. package/examples/for-all-in.n3 +2 -2
  26. package/examples/french-cities.n3 +2 -3
  27. package/examples/fuse.n3 +2 -2
  28. package/examples/good-cobbler.n3 +2 -3
  29. package/examples/gps.n3 +2 -3
  30. package/examples/gray-code-counter.n3 +2 -5
  31. package/examples/hanoi.n3 +2 -3
  32. package/examples/liar.n3 +5 -0
  33. package/examples/light-eaters.n3 +2 -2
  34. package/examples/list-builtins-tests.n3 +2 -6
  35. package/examples/lldm.n3 +3 -4
  36. package/examples/math-builtins-tests.n3 +32 -134
  37. package/examples/monkey.n3 +2 -3
  38. package/examples/odrl-trust.n3 +2 -2
  39. package/examples/output/drone-corridor-planner-v2.n3 +819 -0
  40. package/examples/output/drone-corridor-planner.n3 +153 -0
  41. package/examples/output/pillar.n3 +36 -0
  42. package/examples/peano.n3 +2 -3
  43. package/examples/pi.n3 +2 -3
  44. package/examples/pillar.n3 +23 -0
  45. package/examples/polygon.n3 +2 -3
  46. package/examples/reordering.n3 +2 -3
  47. package/examples/rule-matching.n3 +2 -3
  48. package/examples/self-referential.n3 +3 -4
  49. package/examples/similar.n3 +3 -4
  50. package/examples/skolem.n3 +2 -2
  51. package/examples/snaf.n3 +2 -2
  52. package/examples/socrates.n3 +2 -2
  53. package/examples/spectral-week.n3 +2 -2
  54. package/examples/string-builtins-tests.n3 +19 -51
  55. package/examples/turing.n3 +2 -3
  56. package/examples/uri.n3 +2 -2
  57. package/examples/witch.n3 +2 -2
  58. package/examples/zebra.n3 +2 -2
  59. package/package.json +1 -1
  60. package/test/api.test.js +241 -165
package/examples/age.n3 CHANGED
@@ -1,8 +1,7 @@
1
- # -----------
1
+ # ===========================================
2
2
  # Age checker
3
- # -----------
4
- #
5
3
  # Is the age of a person above some duration?
4
+ # ===========================================
6
5
 
7
6
  @prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
8
7
  @prefix time: <http://www.w3.org/2000/10/swap/time#>.
@@ -1,8 +1,7 @@
1
- # ---------------------
1
+ # ==============================================================
2
2
  # Backward rule example
3
- # ---------------------
4
- #
5
3
  # See https://www.w3.org/2000/10/swap/doc/tutorial-1.pdf page 17
4
+ # ==============================================================
6
5
 
7
6
  @prefix math: <http://www.w3.org/2000/10/swap/math#>.
8
7
  @prefix log: <http://www.w3.org/2000/10/swap/log#>.
@@ -1,8 +1,7 @@
1
- # -----------------------
1
+ # ======================================================================================
2
2
  # Basic Monadic Benchmark
3
- # -----------------------
4
- #
5
3
  # tested with input of 10^n triples generated with http://josd.github.io/bmb/graphgen.n3
4
+ # ======================================================================================
6
5
 
7
6
  @prefix : <http://eulersharp.sourceforge.net/2007/07test/graph#>.
8
7
 
@@ -1,8 +1,7 @@
1
- # --------
1
+ # =================================
2
2
  # Cat Koko
3
- #---------
4
- #
5
3
  # Example from Patrick Hochstenbach
4
+ # =================================
6
5
 
7
6
  @prefix : <https://eyereasoner.github.io/ns#>.
8
7
  @prefix log: <http://www.w3.org/2000/10/swap/log#>.
@@ -10,9 +9,9 @@
10
9
  :Koko a :Animal.
11
10
 
12
11
  {
13
- :Koko a :Animal
14
- }
15
- =>
12
+ :Koko a :Animal
13
+ }
14
+ =>
16
15
  {
17
16
  { :Koko a :Animal } => { _:x a :Cat } .
18
17
  { :Koko a :Animal } => { _:x a :BritishShortHair } .
@@ -1,6 +1,6 @@
1
- # ------------------------
1
+ # ========================
2
2
  # log:collectAllIn example
3
- # ------------------------
3
+ # ========================
4
4
 
5
5
  @prefix : <http://example.org/>.
6
6
  @prefix log: <http://www.w3.org/2000/10/swap/log#> .
@@ -18,14 +18,14 @@
18
18
 
19
19
  # Add some extra criteria on variable values to be collected
20
20
  ( ?param
21
- {
21
+ {
22
22
  :Let :param ?param .
23
23
  ?param string:lessThan "Louie" .
24
- }
24
+ }
25
25
  ?filteredParams ) log:collectAllIn _:x .
26
26
  }
27
- =>
28
- {
27
+ =>
28
+ {
29
29
  :result1 :is ?allParams .
30
30
  :result2 :is ?nestedParams .
31
31
  :result3 :is ?filteredParams .
@@ -1,8 +1,7 @@
1
- # ---------------
1
+ # ================================================
2
2
  # Complex numbers
3
- # ---------------
4
- #
5
3
  # See https://en.wikipedia.org/wiki/Complex_number
4
+ # ================================================
6
5
 
7
6
  @prefix math: <http://www.w3.org/2000/10/swap/math#>.
8
7
  @prefix log: <http://www.w3.org/2000/10/swap/log#>.
@@ -1,6 +1,6 @@
1
- # --------------
1
+ # ==============
2
2
  # Control System
3
- # --------------
3
+ # ==============
4
4
 
5
5
  @prefix math: <http://www.w3.org/2000/10/swap/math#>.
6
6
  @prefix : <https://eyereasoner.github.io/eye/reasoning/cs#>.
@@ -1,6 +1,6 @@
1
- # ---------------------
1
+ # =====================
2
2
  # crypto builtins tests
3
- # ---------------------
3
+ # =====================
4
4
 
5
5
  @prefix : <https://eyereasoner.github.io/ns#> .
6
6
  @prefix crypto: <http://www.w3.org/2000/10/swap/crypto#> .
@@ -1,3 +1,8 @@
1
+ # =============================================================================================================================
2
+ # Deep Taxonomy - depth 10
3
+ # See https://web.archive.org/web/20220119222608/http://responder.ruleml.org/WellnessRules/files/WellnessRulesN3-2009-11-10.pdf
4
+ # =============================================================================================================================
5
+
1
6
  @prefix : <http://eulersharp.sourceforge.net/2009/12dtb/test#>.
2
7
 
3
8
  # fact
@@ -1,3 +1,8 @@
1
+ # =============================================================================================================================
2
+ # Deep Taxonomy - depth 100
3
+ # See https://web.archive.org/web/20220119222608/http://responder.ruleml.org/WellnessRules/files/WellnessRulesN3-2009-11-10.pdf
4
+ # =============================================================================================================================
5
+
1
6
  @prefix : <http://eulersharp.sourceforge.net/2009/12dtb/test#>.
2
7
 
3
8
  # fact
@@ -1,3 +1,8 @@
1
+ # =============================================================================================================================
2
+ # Deep Taxonomy - depth 1000
3
+ # See https://web.archive.org/web/20220119222608/http://responder.ruleml.org/WellnessRules/files/WellnessRulesN3-2009-11-10.pdf
4
+ # =============================================================================================================================
5
+
1
6
  @prefix : <http://eulersharp.sourceforge.net/2009/12dtb/test#>.
2
7
 
3
8
  # fact
@@ -1,3 +1,8 @@
1
+ # =============================================================================================================================
2
+ # Deep Taxonomy - depth 10000
3
+ # See https://web.archive.org/web/20220119222608/http://responder.ruleml.org/WellnessRules/files/WellnessRulesN3-2009-11-10.pdf
4
+ # =============================================================================================================================
5
+
1
6
  @prefix : <http://eulersharp.sourceforge.net/2009/12dtb/test#>.
2
7
 
3
8
  # fact
@@ -1,8 +1,7 @@
1
- # ---------------------
1
+ # =================================
2
2
  # Derived backward rule
3
- # ---------------------
4
- #
5
3
  # Example from Patrick Hochstenbach
4
+ # =================================
6
5
 
7
6
  @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
8
7
  @prefix : <http://example.org/socrates#>.
@@ -1,6 +1,6 @@
1
- # ---------------------
1
+ # =====================
2
2
  # Derived backward rule
3
- # ---------------------
3
+ # =====================
4
4
 
5
5
  @prefix log: <http://www.w3.org/2000/10/swap/log#> .
6
6
  @prefix : <https://eyereasoner.github.io/ns#> .
@@ -1,6 +1,6 @@
1
- # ------------
1
+ # ============
2
2
  # Derived rule
3
- # ------------
3
+ # ============
4
4
 
5
5
  @prefix log: <http://www.w3.org/2000/10/swap/log#>.
6
6
  @prefix : <https://eyereasoner.github.io/ns#>.
@@ -1,8 +1,7 @@
1
- # ----------------------------------------------
1
+ # ===========================================================
2
2
  # Dijkstra's algorithm to find the shortest path
3
- # ----------------------------------------------
4
- #
5
3
  # Original from https://github.com/agx-r/Dijkstra-s-Algorithm
4
+ # ===========================================================
6
5
 
7
6
  @prefix list: <http://www.w3.org/2000/10/swap/list#>.
8
7
  @prefix math: <http://www.w3.org/2000/10/swap/math#>.
package/examples/dog.n3 CHANGED
@@ -1,8 +1,7 @@
1
- # -------------------
1
+ # ===============================================
2
2
  # Dog license example
3
- # -------------------
4
- #
5
3
  # If you have more than 4 dogs you need a license.
4
+ # ===============================================
6
5
 
7
6
  @prefix log: <http://www.w3.org/2000/10/swap/log#>.
8
7
  @prefix math: <http://www.w3.org/2000/10/swap/math#>.
@@ -0,0 +1,237 @@
1
+ # ========================================================================================
2
+ # Drone Corridor Planner v2 (example N3 program)
3
+ #
4
+ # What this file is
5
+ # - A tiny “planner” written in Notation3 (N3): it searches for a sequence of
6
+ # actions that moves a drone from a start state to a goal state.
7
+ # - Intended to run in an N3 reasoner that supports forward rules (`=>`),
8
+ # backward rules (`<=`), and a few built-ins (e.g., `math:*`, `list:*`).
9
+ #
10
+ # How to run (one simple option)
11
+ # - With the JavaScript `eyeling` CLI:
12
+ # npx eyeling examples/drone-corridor-planner-v2.n3
13
+ # The output will be newly derived facts, including one or more `gps:plan`
14
+ # results (see “Output” below).
15
+ #
16
+ # Big idea (in plain terms)
17
+ # - We describe a “world” as a small set of facts: location, battery level,
18
+ # and whether the drone has a permit.
19
+ # - We describe each possible action (fly, train, charge, buy/get permit) as a
20
+ # state transition: FROM-state -> TO-state plus some numeric “weights”.
21
+ # - The rules then *compose* these transitions into multi-step plans while
22
+ # aggregating the weights (e.g., add durations, multiply beliefs).
23
+ #
24
+ # Reading the action descriptions
25
+ # - Each action is encoded as a `gps:description` with this shape:
26
+ # ( FROM true TO :actionName duration cost belief comfort )
27
+ # where:
28
+ # - FROM / TO are little graphs in `{ ... }` describing the state.
29
+ # - `true` is a placeholder “precondition” (kept for symmetry with richer
30
+ # variants where extra conditions may appear).
31
+ # - duration/cost/belief/comfort are example numbers used for scoring/pruning.
32
+ #
33
+ # Bounded search (why it doesn’t loop forever)
34
+ # - The planner is *fuel-bounded*: it carries a list of “fuel tokens” and
35
+ # consumes one token per step. When fuel runs out, expansion stops.
36
+ # - This is important because the map can contain cycles (e.g., going back to a
37
+ # previous city). Fuel-bounding keeps the search safe and finite.
38
+ #
39
+ # How scores are combined across a multi-step plan
40
+ # - Duration and cost are summed.
41
+ # - Belief and comfort are multiplied (so long plans tend to reduce them).
42
+ # - The list of actions is built by appending each step’s action name.
43
+ #
44
+ # Output (what you should expect to see)
45
+ # - The “Query” section asks for plans that take the drone from the initial
46
+ # state to the goal (Oostende), then prunes bad plans using thresholds like:
47
+ # belief > ... and cost < ...
48
+ # - Each surviving plan is reported as a derived fact like:
49
+ # :d1 gps:plan ( ...actions... duration cost belief comfort battery permit fuelLeft ).
50
+ #
51
+ # Customizing this example
52
+ # - Add/edit `gps:description` lines to introduce new routes/actions.
53
+ # - Change the initial state (`:d1 :location ...`, `:battery ...`, `:permit ...`).
54
+ # - Adjust `:fuel7` (more/less steps) and the pruning thresholds in the Query.
55
+ #
56
+ # Notes
57
+ # - This is a *toy* corridor-planning model meant to illustrate rule-based
58
+ # planning patterns. The numeric values and “units” are illustrative.
59
+ # ========================================================================================
60
+
61
+ @prefix math: <http://www.w3.org/2000/10/swap/math#>.
62
+ @prefix list: <http://www.w3.org/2000/10/swap/list#>.
63
+ @prefix gps: <https://eyereasoner.github.io/eye/reasoning/gps/gps-schema#>.
64
+ @prefix : <https://eyereasoner.github.io/eye/reasoning#>.
65
+
66
+ # ----------------
67
+ # current state
68
+ # ----------------
69
+ :d1 :location :Gent.
70
+ :d1 :battery :full.
71
+ :d1 :permit :none.
72
+
73
+ # bounded search horizon (7 steps max)
74
+ :fuel7 :value (:t :t :t :t :t :t :t).
75
+
76
+ # -----------------------------------------------------------------
77
+ # "map" / action descriptions (as backward rules)
78
+ # State = { ?S :location ... . ?S :battery ... . ?S :permit ... . }
79
+ # -----------------------------------------------------------------
80
+ # two ways to reach Brugge (tradeoff: cost/comfort)
81
+ {:map-DRONE gps:description (
82
+ {?S :location :Gent. ?S :battery :full. ?S :permit ?P.} true
83
+ {?S :location :Brugge. ?S :battery :mid. ?S :permit ?P.}
84
+ :fly_gent_brugge
85
+ 1500.0 0.006 0.99 0.99
86
+ )} <= true.
87
+
88
+ {:map-DRONE gps:description (
89
+ {?S :location :Gent. ?S :battery ?B. ?S :permit ?P.} true
90
+ {?S :location :Brugge. ?S :battery ?B. ?S :permit ?P.}
91
+ :train_gent_brugge
92
+ 1700.0 0.012 0.999 0.995
93
+ )} <= true.
94
+
95
+ # via Kortrijk (permit + charging opportunities)
96
+ {:map-DRONE gps:description (
97
+ {?S :location :Gent. ?S :battery :full. ?S :permit ?P.} true
98
+ {?S :location :Kortrijk. ?S :battery :mid. ?S :permit ?P.}
99
+ :fly_gent_kortrijk
100
+ 1600.0 0.007 0.99 0.99
101
+ )} <= true.
102
+
103
+ {:map-DRONE gps:description (
104
+ {?S :location :Kortrijk. ?S :battery :mid. ?S :permit ?P.} true
105
+ {?S :location :Brugge. ?S :battery :low. ?S :permit ?P.}
106
+ :fly_kortrijk_brugge
107
+ 1600.0 0.007 0.99 0.99
108
+ )} <= true.
109
+
110
+ # cycle edge (safe due to fuel bound; typically pruned by belief threshold)
111
+ {:map-DRONE gps:description (
112
+ {?S :location :Brugge. ?S :battery :mid. ?S :permit ?P.} true
113
+ {?S :location :Kortrijk. ?S :battery :low. ?S :permit ?P.}
114
+ :fly_brugge_kortrijk
115
+ 1600.0 0.007 0.985 0.98
116
+ )} <= true.
117
+
118
+ # get permit in Kortrijk (best belief)
119
+ {:map-DRONE gps:description (
120
+ {?S :location :Kortrijk. ?S :battery ?B. ?S :permit :none.} true
121
+ {?S :location :Kortrijk. ?S :battery ?B. ?S :permit :yes.}
122
+ :get_zone_permit_kortrijk
123
+ 300.0 0.001 0.999 1.0
124
+ )} <= true.
125
+
126
+ # get permit in Brugge (faster, but lower belief)
127
+ {:map-DRONE gps:description (
128
+ {?S :location :Brugge. ?S :battery ?B. ?S :permit :none.} true
129
+ {?S :location :Brugge. ?S :battery ?B. ?S :permit :yes.}
130
+ :buy_permit_brugge
131
+ 450.0 0.002 0.98 1.0
132
+ )} <= true.
133
+
134
+ # charging options
135
+ {:map-DRONE gps:description (
136
+ {?S :location :Brugge. ?S :battery :low. ?S :permit ?P.} true
137
+ {?S :location :Brugge. ?S :battery :full. ?S :permit ?P.}
138
+ :quick_charge_brugge
139
+ 600.0 0.004 0.999 0.97
140
+ )} <= true.
141
+
142
+ {:map-DRONE gps:description (
143
+ {?S :location :Brugge. ?S :battery :mid. ?S :permit ?P.} true
144
+ {?S :location :Brugge. ?S :battery :full. ?S :permit ?P.}
145
+ :topup_brugge
146
+ 400.0 0.003 0.999 0.98
147
+ )} <= true.
148
+
149
+ {:map-DRONE gps:description (
150
+ {?S :location :Kortrijk. ?S :battery :mid. ?S :permit ?P.} true
151
+ {?S :location :Kortrijk. ?S :battery :full. ?S :permit ?P.}
152
+ :emergency_charge_kortrijk
153
+ 500.0 0.003 0.999 0.95
154
+ )} <= true.
155
+
156
+ # to Oostende: three alternatives
157
+ # A) restricted corridor: fastest+comfortable, but requires permit=yes and full battery
158
+ {:map-DRONE gps:description (
159
+ {?S :location :Brugge. ?S :battery :full. ?S :permit :yes.} true
160
+ {?S :location :Oostende. ?S :battery :mid. ?S :permit :yes.}
161
+ :cross_corridor_brugge_oostende
162
+ 900.0 0.004 0.98 1.0
163
+ )} <= true.
164
+
165
+ # B) public coastline: no permit required, slower
166
+ {:map-DRONE gps:description (
167
+ {?S :location :Brugge. ?S :battery :mid. ?S :permit ?P.} true
168
+ {?S :location :Oostende. ?S :battery :low. ?S :permit ?P.}
169
+ :public_coastline_brugge_oostende
170
+ 1300.0 0.006 0.97 0.96
171
+ )} <= true.
172
+
173
+ {:map-DRONE gps:description (
174
+ {?S :location :Brugge. ?S :battery :full. ?S :permit ?P.} true
175
+ {?S :location :Oostende. ?S :battery :mid. ?S :permit ?P.}
176
+ :public_coastline_brugge_oostende
177
+ 1200.0 0.006 0.975 0.96
178
+ )} <= true.
179
+
180
+ # C) Kortrijk shortcut: requires permit and full battery; quicker but lower comfort
181
+ {:map-DRONE gps:description (
182
+ {?S :location :Kortrijk. ?S :battery :full. ?S :permit :yes.} true
183
+ {?S :location :Oostende. ?S :battery :mid. ?S :permit :yes.}
184
+ :direct_corridor_kortrijk_oostende
185
+ 1100.0 0.009 0.955 0.92
186
+ )} <= true.
187
+
188
+ # -------------------------------------------------
189
+ # planner: compute all bounded paths
190
+ # -------------------------------------------------
191
+ # Base: one description is a path (consume 1 fuel token)
192
+ {
193
+ (?From ?To (?Act) ?Dur ?Cost ?Bel ?Comf ?FuelIn ?FuelOut) :path true.
194
+ }
195
+ <=
196
+ {
197
+ :map-DRONE gps:description (?From true ?To ?Act ?Dur ?Cost ?Bel ?Comf).
198
+ ?FuelIn list:rest ?FuelOut.
199
+ }.
200
+
201
+ # Recursive: chain one step + rest path, aggregate weights, consume 1 fuel token
202
+ {
203
+ (?From ?To ?Actions ?Dur ?Cost ?Bel ?Comf ?FuelIn ?FuelOut) :path true.
204
+ }
205
+ <=
206
+ {
207
+ :map-DRONE gps:description (?From true ?Mid ?Act ?Dur1 ?Cost1 ?Bel1 ?Comf1).
208
+
209
+ ?FuelIn list:rest ?FuelMid.
210
+ (?Mid ?To ?RestActs ?Dur2 ?Cost2 ?Bel2 ?Comf2 ?FuelMid ?FuelOut) :path true.
211
+
212
+ ((?Act) ?RestActs) list:append ?Actions.
213
+
214
+ (?Dur1 ?Dur2) math:sum ?Dur.
215
+ (?Cost1 ?Cost2) math:sum ?Cost.
216
+ (?Bel1 ?Bel2) math:product ?Bel.
217
+ (?Comf1 ?Comf2) math:product ?Comf.
218
+ }.
219
+
220
+ # -------------------------------------------------
221
+ # Query: plans for d1 to Oostende with pruning thresholds
222
+ # -------------------------------------------------
223
+ {
224
+ :fuel7 :value ?Fuel.
225
+
226
+ ({:d1 :location :Gent. :d1 :battery :full. :d1 :permit :none.}
227
+ {:d1 :location :Oostende. :d1 :battery ?B. :d1 :permit ?P.}
228
+ ?Acts ?Dur ?Cost ?Bel ?Comf ?Fuel ?FuelLeft) :path true.
229
+
230
+ ?Bel math:greaterThan 0.94.
231
+ ?Cost math:lessThan 0.03.
232
+ }
233
+ =>
234
+ {
235
+ :d1 gps:plan (?Acts ?Dur ?Cost ?Bel ?Comf ?B ?P ?FuelLeft).
236
+ }.
237
+
@@ -0,0 +1,131 @@
1
+ # =====================================================================================
2
+ # Drone Corridor Planner
3
+ # Fuel-bounded drone planning in N3: chain quoted-state transitions, aggregate weights,
4
+ # and enforce permit/battery constraints while remaining safe under cycles.
5
+ # =====================================================================================
6
+
7
+ @prefix math: <http://www.w3.org/2000/10/swap/math#>.
8
+ @prefix list: <http://www.w3.org/2000/10/swap/list#>.
9
+ @prefix gps: <https://eyereasoner.github.io/eye/reasoning/gps/gps-schema#>.
10
+ @prefix : <https://eyereasoner.github.io/eye/reasoning#>.
11
+
12
+ # Fuel-bounded drone planning in N3: chain quoted-state transitions, aggregate weights, and enforce permit/battery constraints while remaining safe under cycles.
13
+
14
+ # ----------------
15
+ # current state
16
+ # ----------------
17
+ :d1 :location :Gent.
18
+ :d1 :battery :full.
19
+ :d1 :permit :none.
20
+
21
+ # bounded search horizon (6 steps max)
22
+ :fuel6 :value (:t :t :t :t :t :t).
23
+
24
+ # -------------------------------------------------
25
+ # "map" / action descriptions (as backward rules)
26
+ # -------------------------------------------------
27
+ {:map-DRONE gps:description (
28
+ {?S :location :Gent. ?S :battery :full. ?S :permit ?P.} true
29
+ {?S :location :Brugge. ?S :battery :mid. ?S :permit ?P.}
30
+ :fly_gent_brugge
31
+ 1500.0 0.006 0.99 0.99
32
+ )} <= true.
33
+
34
+ {:map-DRONE gps:description (
35
+ {?S :location :Gent. ?S :battery :full. ?S :permit ?P.} true
36
+ {?S :location :Kortrijk. ?S :battery :mid. ?S :permit ?P.}
37
+ :fly_gent_kortrijk
38
+ 1600.0 0.007 0.99 0.99
39
+ )} <= true.
40
+
41
+ {:map-DRONE gps:description (
42
+ {?S :location :Kortrijk. ?S :battery :mid. ?S :permit ?P.} true
43
+ {?S :location :Brugge. ?S :battery :low. ?S :permit ?P.}
44
+ :fly_kortrijk_brugge
45
+ 1600.0 0.007 0.99 0.99
46
+ )} <= true.
47
+
48
+ # cycle edge (safe due to fuel bound)
49
+ {:map-DRONE gps:description (
50
+ {?S :location :Brugge. ?S :battery :mid. ?S :permit ?P.} true
51
+ {?S :location :Kortrijk. ?S :battery :low. ?S :permit ?P.}
52
+ :fly_brugge_kortrijk
53
+ 1600.0 0.007 0.985 0.98
54
+ )} <= true.
55
+
56
+ # permit acquisition (only in Kortrijk)
57
+ {:map-DRONE gps:description (
58
+ {?S :location :Kortrijk. ?S :battery ?B. ?S :permit :none.} true
59
+ {?S :location :Kortrijk. ?S :battery ?B. ?S :permit :yes.}
60
+ :get_zone_permit
61
+ 300.0 0.001 0.999 1.0
62
+ )} <= true.
63
+
64
+ # charging (low -> full)
65
+ {:map-DRONE gps:description (
66
+ {?S :location :Brugge. ?S :battery :low. ?S :permit ?P.} true
67
+ {?S :location :Brugge. ?S :battery :full. ?S :permit ?P.}
68
+ :quick_charge_brugge
69
+ 600.0 0.004 0.999 0.97
70
+ )} <= true.
71
+
72
+ # restricted corridor to Oostende requires permit=yes
73
+ {:map-DRONE gps:description (
74
+ {?S :location :Brugge. ?S :battery :full. ?S :permit :yes.} true
75
+ {?S :location :Oostende. ?S :battery :mid. ?S :permit :yes.}
76
+ :cross_corridor_brugge_oostende
77
+ 900.0 0.004 0.98 1.0
78
+ )} <= true.
79
+
80
+ # -------------------------------------------------
81
+ # planner: compute all bounded paths
82
+ # -------------------------------------------------
83
+ # Base: one description is a path (consume 1 fuel token)
84
+ {
85
+ (?From ?To (?Act) ?Dur ?Cost ?Bel ?Comf ?FuelIn ?FuelOut) :path true.
86
+ }
87
+ <=
88
+ {
89
+ :map-DRONE gps:description (?From true ?To ?Act ?Dur ?Cost ?Bel ?Comf).
90
+ ?FuelIn list:rest ?FuelOut.
91
+ }.
92
+
93
+ # Recursive: chain one step + rest path, aggregate weights, consume 1 fuel token
94
+ {
95
+ (?From ?To ?Actions ?Dur ?Cost ?Bel ?Comf ?FuelIn ?FuelOut) :path true.
96
+ }
97
+ <=
98
+ {
99
+ :map-DRONE gps:description (?From true ?Mid ?Act ?Dur1 ?Cost1 ?Bel1 ?Comf1).
100
+
101
+ ?FuelIn list:rest ?FuelMid.
102
+ (?Mid ?To ?RestActs ?Dur2 ?Cost2 ?Bel2 ?Comf2 ?FuelMid ?FuelOut) :path true.
103
+
104
+ ((?Act) ?RestActs) list:append ?Actions.
105
+
106
+ (?Dur1 ?Dur2) math:sum ?Dur.
107
+ (?Cost1 ?Cost2) math:sum ?Cost.
108
+ (?Bel1 ?Bel2) math:product ?Bel.
109
+ (?Comf1 ?Comf2) math:product ?Comf.
110
+ }.
111
+
112
+ # -------------------------------------------------
113
+ # Query: plans for d1 to Oostende with thresholds
114
+ # -------------------------------------------------
115
+ {
116
+ :fuel6 :value ?Fuel.
117
+
118
+ ({:d1 :location :Gent. :d1 :battery :full. :d1 :permit :none.}
119
+ {:d1 :location :Oostende. :d1 :battery ?B. :d1 :permit ?P.}
120
+ ?Acts ?Dur ?Cost ?Bel ?Comf ?Fuel ?FuelLeft) :path true.
121
+
122
+ ?Bel math:greaterThan 0.95.
123
+ ?Cost math:lessThan 0.05.
124
+ }
125
+ =>
126
+ {
127
+ :d1 gps:plan (?Acts ?Dur ?Cost ?Bel ?Comf ?FuelLeft).
128
+ :d1 :finalBattery ?B.
129
+ :d1 :finalPermit ?P.
130
+ }.
131
+
@@ -1,12 +1,11 @@
1
- # -----------
1
+ # =================================
2
2
  # Equals test
3
- # -----------
4
- #
5
3
  # Example from Patrick Hochstenbach
4
+ # =================================
6
5
 
7
6
  @prefix owl: <http://www.w3.org/2002/07/owl#> .
8
7
  @prefix : <http://example.org/socrates#>.
9
8
 
10
- :X = :Y .
9
+ :X = :Y .
11
10
 
12
11
  { :X owl:sameAs :Y } => { :test :is true }.
@@ -1,6 +1,6 @@
1
- # ----------------
1
+ # ================
2
2
  # Existential rule
3
- # ----------------
3
+ # ================
4
4
 
5
5
  @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
6
6
  @prefix : <http://example.org/socrates#>.
@@ -1,11 +1,10 @@
1
- # ---------------------------------
1
+ # ==============================================================================
2
2
  # A tiny expression evaluator in N3
3
- # ---------------------------------
4
- #
5
3
  # - numbers are nodes with :n
6
4
  # - expressions are nodes with :op, :left, :right
7
5
  # - :value is defined as a backward “builtin-like” predicate (<=) with recursion
8
6
  # - one forward rule emits the final result
7
+ # ==============================================================================
9
8
 
10
9
  @prefix math: <http://www.w3.org/2000/10/swap/math#>.
11
10
  @prefix : <http://example.org/expression-eval#>.
@@ -1,6 +1,6 @@
1
- # --------------
1
+ # ==============
2
2
  # Family cousins
3
- # --------------
3
+ # ==============
4
4
 
5
5
  @prefix : <http://example.org/family#>.
6
6
  @prefix math: <http://www.w3.org/2000/10/swap/math#>.
@@ -1,8 +1,7 @@
1
- # -----------------
1
+ # ==================================================
2
2
  # Fibonacci numbers
3
- # -----------------
4
- #
5
3
  # See https://en.wikipedia.org/wiki/Fibonacci_number
4
+ # ==================================================
6
5
 
7
6
  @prefix math: <http://www.w3.org/2000/10/swap/math#>.
8
7
  @prefix : <https://eyereasoner.github.io/eye/reasoning#>.
@@ -1,6 +1,6 @@
1
- # --------------------
1
+ # ====================
2
2
  # log:forAllIn example
3
- # --------------------
3
+ # ====================
4
4
 
5
5
  @prefix : <http://example.org/>.
6
6
  @prefix log: <http://www.w3.org/2000/10/swap/log#> .
@@ -1,8 +1,7 @@
1
- # ----------------------
1
+ # ============================================
2
2
  # Traversing Graph Paths
3
- # ----------------------
4
- #
5
3
  # Simple data & rules over a tiny city dataset
4
+ # ============================================
6
5
 
7
6
  @prefix log: <http://www.w3.org/2000/10/swap/log#>.
8
7
  @prefix owl: <http://www.w3.org/2002/07/owl#>.