eyeling 1.5.12 → 1.5.14
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.
- package/README.md +1 -2
- package/examples/age.n3 +29 -0
- package/examples/backward.n3 +24 -0
- package/examples/basic-monadic.n3 +10032 -0
- package/examples/cat-koko.n3 +29 -0
- package/examples/collect-all-in.n3 +32 -0
- package/examples/complex.n3 +142 -0
- package/examples/control-system.n3 +77 -0
- package/examples/crypto-builtins-tests.n3 +60 -0
- package/examples/deep-taxonomy-10.n3 +21 -0
- package/examples/deep-taxonomy-100.n3 +111 -0
- package/examples/deep-taxonomy-1000.n3 +1011 -0
- package/examples/deep-taxonomy-10000.n3 +10011 -0
- package/examples/derived-backward-rule-2.n3 +28 -0
- package/examples/derived-backward-rule.n3 +32 -0
- package/examples/derived-rule.n3 +19 -0
- package/examples/dijkstra.n3 +64 -0
- package/examples/dog.n3 +21 -0
- package/examples/equals.n3 +12 -0
- package/examples/existential-rule.n3 +18 -0
- package/examples/fibonacci.n3 +34 -0
- package/examples/for-all-in.n3 +21 -0
- package/examples/french-cities.n3 +32 -0
- package/examples/fuse.n3 +13 -0
- package/examples/good-cobbler.n3 +18 -0
- package/examples/gray-code-counter.n3 +64 -0
- package/examples/hanoi.n3 +21 -0
- package/examples/liar.n3 +6 -0
- package/examples/list-builtins-tests.n3 +84 -0
- package/examples/lldm.n3 +133 -0
- package/examples/math-builtins-tests.n3 +612 -0
- package/examples/monkey.n3 +11 -0
- package/examples/output/age.n3 +20 -0
- package/examples/output/backward.n3 +18 -0
- package/examples/output/basic-monadic.n3 +122 -0
- package/examples/output/cat-koko.n3 +125 -0
- package/examples/output/collect-all-in.n3 +122 -0
- package/examples/output/complex.n3 +57 -0
- package/examples/output/control-system.n3 +79 -0
- package/examples/output/crypto-builtins-tests.n3 +66 -0
- package/examples/output/deep-taxonomy-10.n3 +636 -0
- package/examples/output/deep-taxonomy-100.n3 +6036 -0
- package/examples/output/deep-taxonomy-1000.n3 +60036 -0
- package/examples/output/deep-taxonomy-10000.n3 +600036 -0
- package/examples/output/derived-backward-rule-2.n3 +71 -0
- package/examples/output/derived-backward-rule.n3 +53 -0
- package/examples/output/derived-rule.n3 +52 -0
- package/examples/output/dijkstra.n3 +315 -0
- package/examples/output/dog.n3 +33 -0
- package/examples/output/equals.n3 +18 -0
- package/examples/output/existential-rule.n3 +38 -0
- package/examples/output/fibonacci.n3 +44 -0
- package/examples/output/for-all-in.n3 +30 -0
- package/examples/output/french-cities.n3 +507 -0
- package/examples/output/fuse.n3 +1 -0
- package/examples/output/good-cobbler.n3 +27 -0
- package/examples/output/gray-code-counter.n3 +20 -0
- package/examples/output/hanoi.n3 +20 -0
- package/examples/output/liar.n3 +1 -0
- package/examples/output/list-builtins-tests.n3 +148 -0
- package/examples/output/lldm.n3 +1000 -0
- package/examples/output/math-builtins-tests.n3 +4479 -0
- package/examples/output/monkey.n3 +40 -0
- package/examples/output/peano.n3 +26 -0
- package/examples/output/pi.n3 +20 -0
- package/examples/output/polygon.n3 +20 -0
- package/examples/output/reordering.n3 +29 -0
- package/examples/output/rule-matching.n3 +29 -0
- package/examples/output/self-referential.n3 +88 -0
- package/examples/output/similar.n3 +18 -0
- package/examples/output/skolem.n3 +20 -0
- package/examples/output/snaf.n3 +26 -0
- package/examples/output/socrates.n3 +24 -0
- package/examples/output/string-builtins-tests.n3 +258 -0
- package/examples/output/turing.n3 +44 -0
- package/examples/output/uri.n3 +46 -0
- package/examples/output/witch.n3 +115 -0
- package/examples/output/zebra.n3 +114 -0
- package/examples/peano.n3 +45 -0
- package/examples/pi.n3 +32 -0
- package/examples/polygon.n3 +26 -0
- package/examples/reordering.n3 +23 -0
- package/examples/rule-matching.n3 +15 -0
- package/examples/self-referential.n3 +32 -0
- package/examples/similar.n3 +28 -0
- package/examples/skolem.n3 +15 -0
- package/examples/snaf.n3 +18 -0
- package/examples/socrates.n3 +19 -0
- package/examples/string-builtins-tests.n3 +210 -0
- package/examples/test +154 -0
- package/examples/turing.n3 +93 -0
- package/examples/uri.n3 +17 -0
- package/examples/witch.n3 +33 -0
- package/examples/zebra.n3 +47 -0
- package/package.json +7 -2
- package/test/api.test.js +22 -0
|
@@ -0,0 +1,612 @@
|
|
|
1
|
+
# -------------------
|
|
2
|
+
# math builtins tests
|
|
3
|
+
# -------------------
|
|
4
|
+
|
|
5
|
+
@prefix : <http://example.org/math-tests#> .
|
|
6
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#> .
|
|
7
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
|
|
8
|
+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
|
9
|
+
|
|
10
|
+
# -----------------------------------------------------------------------------
|
|
11
|
+
# Simple test vocabulary
|
|
12
|
+
# -----------------------------------------------------------------------------
|
|
13
|
+
|
|
14
|
+
:MathBuiltinTest a :TestCaseClass .
|
|
15
|
+
|
|
16
|
+
:builtin a :TestProperty .
|
|
17
|
+
:input a :TestProperty .
|
|
18
|
+
:other a :TestProperty .
|
|
19
|
+
:expected a :TestProperty .
|
|
20
|
+
:actual a :TestProperty .
|
|
21
|
+
:status a :TestProperty .
|
|
22
|
+
|
|
23
|
+
:pass a :TestStatus .
|
|
24
|
+
|
|
25
|
+
# -----------------------------------------------------------------------------
|
|
26
|
+
# NOTE ABOUT NUMERIC LITERALS
|
|
27
|
+
# -----------------------------------------------------------------------------
|
|
28
|
+
# eyeling.js' math: builtins:
|
|
29
|
+
# - accept both typed and untyped numeric literals as INPUT (via parseNum)
|
|
30
|
+
# - RETURN untyped numeric literals (via formatNum)
|
|
31
|
+
#
|
|
32
|
+
# So in these tests:
|
|
33
|
+
# - Inputs may be typed or untyped (to exercise casting).
|
|
34
|
+
# - Expected results are written as UNTYPED numerics so that math:equalTo
|
|
35
|
+
# can unify directly with the reasoner's untyped numeric results.
|
|
36
|
+
# -----------------------------------------------------------------------------
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
# =============================================================================
|
|
40
|
+
# 4.2.1 math:absoluteValue
|
|
41
|
+
# =============================================================================
|
|
42
|
+
|
|
43
|
+
{
|
|
44
|
+
-2 math:absoluteValue ?abs .
|
|
45
|
+
?abs math:equalTo 2 .
|
|
46
|
+
}
|
|
47
|
+
=>
|
|
48
|
+
{
|
|
49
|
+
:test-absoluteValue-1 a :MathBuiltinTest;
|
|
50
|
+
:builtin math:absoluteValue;
|
|
51
|
+
:input -2;
|
|
52
|
+
:expected 2;
|
|
53
|
+
:actual ?abs;
|
|
54
|
+
:status :pass .
|
|
55
|
+
} .
|
|
56
|
+
|
|
57
|
+
{
|
|
58
|
+
3 math:absoluteValue ?abs .
|
|
59
|
+
?abs math:equalTo 3 .
|
|
60
|
+
}
|
|
61
|
+
=>
|
|
62
|
+
{
|
|
63
|
+
:test-absoluteValue-2 a :MathBuiltinTest;
|
|
64
|
+
:builtin math:absoluteValue;
|
|
65
|
+
:input 3;
|
|
66
|
+
:expected 3;
|
|
67
|
+
:actual ?abs;
|
|
68
|
+
:status :pass .
|
|
69
|
+
} .
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
# =============================================================================
|
|
73
|
+
# 4.2.2 math:acos
|
|
74
|
+
# =============================================================================
|
|
75
|
+
|
|
76
|
+
{
|
|
77
|
+
1 math:acos ?r .
|
|
78
|
+
?r math:equalTo 0 .
|
|
79
|
+
}
|
|
80
|
+
=>
|
|
81
|
+
{
|
|
82
|
+
:test-acos-1 a :MathBuiltinTest;
|
|
83
|
+
:builtin math:acos;
|
|
84
|
+
:input 1;
|
|
85
|
+
:expected 0;
|
|
86
|
+
:actual ?r;
|
|
87
|
+
:status :pass .
|
|
88
|
+
} .
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
# =============================================================================
|
|
92
|
+
# 4.2.3 math:asin
|
|
93
|
+
# =============================================================================
|
|
94
|
+
|
|
95
|
+
{
|
|
96
|
+
0 math:asin ?r .
|
|
97
|
+
?r math:equalTo 0 .
|
|
98
|
+
}
|
|
99
|
+
=>
|
|
100
|
+
{
|
|
101
|
+
:test-asin-1 a :MathBuiltinTest;
|
|
102
|
+
:builtin math:asin;
|
|
103
|
+
:input 0;
|
|
104
|
+
:expected 0;
|
|
105
|
+
:actual ?r;
|
|
106
|
+
:status :pass .
|
|
107
|
+
} .
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
# =============================================================================
|
|
111
|
+
# 4.2.4 math:atan
|
|
112
|
+
# =============================================================================
|
|
113
|
+
|
|
114
|
+
# atan(1) = pi/4
|
|
115
|
+
{
|
|
116
|
+
1 math:atan ?r .
|
|
117
|
+
?r math:equalTo 0.7853981633974483 .
|
|
118
|
+
}
|
|
119
|
+
=>
|
|
120
|
+
{
|
|
121
|
+
:test-atan-1 a :MathBuiltinTest;
|
|
122
|
+
:builtin math:atan;
|
|
123
|
+
:input 1;
|
|
124
|
+
:expected 0.7853981633974483;
|
|
125
|
+
:actual ?r;
|
|
126
|
+
:status :pass .
|
|
127
|
+
} .
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
# =============================================================================
|
|
131
|
+
# 4.2.5 math:cos
|
|
132
|
+
# =============================================================================
|
|
133
|
+
|
|
134
|
+
# cos(0) = 1
|
|
135
|
+
{
|
|
136
|
+
0 math:cos ?r .
|
|
137
|
+
?r math:equalTo 1 .
|
|
138
|
+
}
|
|
139
|
+
=>
|
|
140
|
+
{
|
|
141
|
+
:test-cos-1 a :MathBuiltinTest;
|
|
142
|
+
:builtin math:cos;
|
|
143
|
+
:input 0;
|
|
144
|
+
:expected 1;
|
|
145
|
+
:actual ?r;
|
|
146
|
+
:status :pass .
|
|
147
|
+
} .
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
# =============================================================================
|
|
151
|
+
# 4.2.6 math:cosh
|
|
152
|
+
# =============================================================================
|
|
153
|
+
|
|
154
|
+
# cosh(0) = 1
|
|
155
|
+
{
|
|
156
|
+
0 math:cosh ?r .
|
|
157
|
+
?r math:equalTo 1 .
|
|
158
|
+
}
|
|
159
|
+
=>
|
|
160
|
+
{
|
|
161
|
+
:test-cosh-1 a :MathBuiltinTest;
|
|
162
|
+
:builtin math:cosh;
|
|
163
|
+
:input 0;
|
|
164
|
+
:expected 1;
|
|
165
|
+
:actual ?r;
|
|
166
|
+
:status :pass .
|
|
167
|
+
} .
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
# =============================================================================
|
|
171
|
+
# 4.2.7 math:degrees
|
|
172
|
+
# =============================================================================
|
|
173
|
+
|
|
174
|
+
# degrees(pi) = 180
|
|
175
|
+
{
|
|
176
|
+
3.141592653589793 math:degrees ?deg .
|
|
177
|
+
?deg math:equalTo 180 .
|
|
178
|
+
}
|
|
179
|
+
=>
|
|
180
|
+
{
|
|
181
|
+
:test-degrees-1 a :MathBuiltinTest;
|
|
182
|
+
:builtin math:degrees;
|
|
183
|
+
:input 3.141592653589793;
|
|
184
|
+
:expected 180;
|
|
185
|
+
:actual ?deg;
|
|
186
|
+
:status :pass .
|
|
187
|
+
} .
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
# =============================================================================
|
|
191
|
+
# 4.2.8 math:difference
|
|
192
|
+
# =============================================================================
|
|
193
|
+
|
|
194
|
+
{
|
|
195
|
+
(7 2) math:difference ?d .
|
|
196
|
+
?d math:equalTo 5 .
|
|
197
|
+
}
|
|
198
|
+
=>
|
|
199
|
+
{
|
|
200
|
+
:test-difference-1 a :MathBuiltinTest;
|
|
201
|
+
:builtin math:difference;
|
|
202
|
+
:input (7 2);
|
|
203
|
+
:expected 5;
|
|
204
|
+
:actual ?d;
|
|
205
|
+
:status :pass .
|
|
206
|
+
} .
|
|
207
|
+
|
|
208
|
+
{
|
|
209
|
+
(2 7) math:difference ?d .
|
|
210
|
+
?d math:equalTo -5 .
|
|
211
|
+
}
|
|
212
|
+
=>
|
|
213
|
+
{
|
|
214
|
+
:test-difference-2 a :MathBuiltinTest;
|
|
215
|
+
:builtin math:difference;
|
|
216
|
+
:input (2 7);
|
|
217
|
+
:expected -5;
|
|
218
|
+
:actual ?d;
|
|
219
|
+
:status :pass .
|
|
220
|
+
} .
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
# =============================================================================
|
|
224
|
+
# 4.2.9 math:equalTo
|
|
225
|
+
# =============================================================================
|
|
226
|
+
|
|
227
|
+
# Positive equality test
|
|
228
|
+
{
|
|
229
|
+
42 math:equalTo 42 .
|
|
230
|
+
}
|
|
231
|
+
=>
|
|
232
|
+
{
|
|
233
|
+
:test-equalTo-1 a :MathBuiltinTest;
|
|
234
|
+
:builtin math:equalTo;
|
|
235
|
+
:input 42;
|
|
236
|
+
:other 42;
|
|
237
|
+
:status :pass .
|
|
238
|
+
} .
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
# =============================================================================
|
|
242
|
+
# 4.2.10 math:exponentiation
|
|
243
|
+
# =============================================================================
|
|
244
|
+
|
|
245
|
+
# Forward mode: (7 2) -> 49
|
|
246
|
+
{
|
|
247
|
+
(7 2) math:exponentiation ?r .
|
|
248
|
+
?r math:equalTo 49 .
|
|
249
|
+
}
|
|
250
|
+
=>
|
|
251
|
+
{
|
|
252
|
+
:test-exponentiation-1 a :MathBuiltinTest;
|
|
253
|
+
:builtin math:exponentiation;
|
|
254
|
+
:input (7 2);
|
|
255
|
+
:expected 49;
|
|
256
|
+
:actual ?r;
|
|
257
|
+
:status :pass .
|
|
258
|
+
} .
|
|
259
|
+
|
|
260
|
+
# Inverse mode: (7 ?exp) math:exponentiation 49 => ?exp = 2
|
|
261
|
+
{
|
|
262
|
+
(7 ?exp) math:exponentiation 49 .
|
|
263
|
+
}
|
|
264
|
+
=>
|
|
265
|
+
{
|
|
266
|
+
:test-exponentiation-2 a :MathBuiltinTest;
|
|
267
|
+
:builtin math:exponentiation;
|
|
268
|
+
:input (7 ?exp);
|
|
269
|
+
:expected 2;
|
|
270
|
+
:actual ?exp;
|
|
271
|
+
:status :pass .
|
|
272
|
+
} .
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
# =============================================================================
|
|
276
|
+
# 4.2.11 math:greaterThan
|
|
277
|
+
# =============================================================================
|
|
278
|
+
|
|
279
|
+
{
|
|
280
|
+
42 math:greaterThan 41 .
|
|
281
|
+
}
|
|
282
|
+
=>
|
|
283
|
+
{
|
|
284
|
+
:test-greaterThan-1 a :MathBuiltinTest;
|
|
285
|
+
:builtin math:greaterThan;
|
|
286
|
+
:input 42;
|
|
287
|
+
:other 41;
|
|
288
|
+
:status :pass .
|
|
289
|
+
} .
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
# =============================================================================
|
|
293
|
+
# 4.2.12 math:lessThan
|
|
294
|
+
# =============================================================================
|
|
295
|
+
|
|
296
|
+
{
|
|
297
|
+
41 math:lessThan 42 .
|
|
298
|
+
}
|
|
299
|
+
=>
|
|
300
|
+
{
|
|
301
|
+
:test-lessThan-1 a :MathBuiltinTest;
|
|
302
|
+
:builtin math:lessThan;
|
|
303
|
+
:input 41;
|
|
304
|
+
:other 42;
|
|
305
|
+
:status :pass .
|
|
306
|
+
} .
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
# =============================================================================
|
|
310
|
+
# 4.2.13 math:negation
|
|
311
|
+
# =============================================================================
|
|
312
|
+
|
|
313
|
+
# Forward mode
|
|
314
|
+
{
|
|
315
|
+
42 math:negation ?neg .
|
|
316
|
+
?neg math:equalTo -42 .
|
|
317
|
+
}
|
|
318
|
+
=>
|
|
319
|
+
{
|
|
320
|
+
:test-negation-1 a :MathBuiltinTest;
|
|
321
|
+
:builtin math:negation;
|
|
322
|
+
:input 42;
|
|
323
|
+
:expected -42;
|
|
324
|
+
:actual ?neg;
|
|
325
|
+
:status :pass .
|
|
326
|
+
} .
|
|
327
|
+
|
|
328
|
+
# Inverse mode: ?x math:negation 1 => ?x = -1
|
|
329
|
+
{
|
|
330
|
+
?x math:negation 1 .
|
|
331
|
+
}
|
|
332
|
+
=>
|
|
333
|
+
{
|
|
334
|
+
:test-negation-2 a :MathBuiltinTest;
|
|
335
|
+
:builtin math:negation;
|
|
336
|
+
:input ?x;
|
|
337
|
+
:expected -1;
|
|
338
|
+
:actual ?x;
|
|
339
|
+
:status :pass .
|
|
340
|
+
} .
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
# =============================================================================
|
|
344
|
+
# 4.2.14 math:notEqualTo
|
|
345
|
+
# =============================================================================
|
|
346
|
+
|
|
347
|
+
{
|
|
348
|
+
41 math:notEqualTo 42 .
|
|
349
|
+
}
|
|
350
|
+
=>
|
|
351
|
+
{
|
|
352
|
+
:test-notEqualTo-1 a :MathBuiltinTest;
|
|
353
|
+
:builtin math:notEqualTo;
|
|
354
|
+
:input 41;
|
|
355
|
+
:other 42;
|
|
356
|
+
:status :pass .
|
|
357
|
+
} .
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
# =============================================================================
|
|
361
|
+
# 4.2.15 math:notGreaterThan
|
|
362
|
+
# =============================================================================
|
|
363
|
+
|
|
364
|
+
{
|
|
365
|
+
41 math:notGreaterThan 42 .
|
|
366
|
+
}
|
|
367
|
+
=>
|
|
368
|
+
{
|
|
369
|
+
:test-notGreaterThan-1 a :MathBuiltinTest;
|
|
370
|
+
:builtin math:notGreaterThan;
|
|
371
|
+
:input 41;
|
|
372
|
+
:other 42;
|
|
373
|
+
:status :pass .
|
|
374
|
+
} .
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
# =============================================================================
|
|
378
|
+
# 4.2.16 math:notLessThan
|
|
379
|
+
# =============================================================================
|
|
380
|
+
|
|
381
|
+
{
|
|
382
|
+
42 math:notLessThan 41 .
|
|
383
|
+
}
|
|
384
|
+
=>
|
|
385
|
+
{
|
|
386
|
+
:test-notLessThan-1 a :MathBuiltinTest;
|
|
387
|
+
:builtin math:notLessThan;
|
|
388
|
+
:input 42;
|
|
389
|
+
:other 41;
|
|
390
|
+
:status :pass .
|
|
391
|
+
} .
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
# =============================================================================
|
|
395
|
+
# 4.2.17 math:product
|
|
396
|
+
# =============================================================================
|
|
397
|
+
|
|
398
|
+
{
|
|
399
|
+
(2 21) math:product ?p .
|
|
400
|
+
?p math:equalTo 42 .
|
|
401
|
+
}
|
|
402
|
+
=>
|
|
403
|
+
{
|
|
404
|
+
:test-product-1 a :MathBuiltinTest;
|
|
405
|
+
:builtin math:product;
|
|
406
|
+
:input (2 21);
|
|
407
|
+
:expected 42;
|
|
408
|
+
:actual ?p;
|
|
409
|
+
:status :pass .
|
|
410
|
+
} .
|
|
411
|
+
|
|
412
|
+
{
|
|
413
|
+
(2 4 6 8) math:product ?p .
|
|
414
|
+
?p math:equalTo 384 .
|
|
415
|
+
}
|
|
416
|
+
=>
|
|
417
|
+
{
|
|
418
|
+
:test-product-2 a :MathBuiltinTest;
|
|
419
|
+
:builtin math:product;
|
|
420
|
+
:input (2 4 6 8);
|
|
421
|
+
:expected 384;
|
|
422
|
+
:actual ?p;
|
|
423
|
+
:status :pass .
|
|
424
|
+
} .
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
# =============================================================================
|
|
428
|
+
# 4.2.18 math:quotient
|
|
429
|
+
# =============================================================================
|
|
430
|
+
|
|
431
|
+
{
|
|
432
|
+
(42 2) math:quotient ?q .
|
|
433
|
+
?q math:equalTo 21 .
|
|
434
|
+
}
|
|
435
|
+
=>
|
|
436
|
+
{
|
|
437
|
+
:test-quotient-1 a :MathBuiltinTest;
|
|
438
|
+
:builtin math:quotient;
|
|
439
|
+
:input (42 2);
|
|
440
|
+
:expected 21;
|
|
441
|
+
:actual ?q;
|
|
442
|
+
:status :pass .
|
|
443
|
+
} .
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
# =============================================================================
|
|
447
|
+
# 4.2.19 math:remainder
|
|
448
|
+
# =============================================================================
|
|
449
|
+
|
|
450
|
+
{
|
|
451
|
+
(10 3) math:remainder ?r .
|
|
452
|
+
?r math:equalTo 1 .
|
|
453
|
+
}
|
|
454
|
+
=>
|
|
455
|
+
{
|
|
456
|
+
:test-remainder-1 a :MathBuiltinTest;
|
|
457
|
+
:builtin math:remainder;
|
|
458
|
+
:input (10 3);
|
|
459
|
+
:expected 1;
|
|
460
|
+
:actual ?r;
|
|
461
|
+
:status :pass .
|
|
462
|
+
} .
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
# =============================================================================
|
|
466
|
+
# 4.2.20 math:rounded
|
|
467
|
+
# =============================================================================
|
|
468
|
+
|
|
469
|
+
# Typed input, untyped integer output
|
|
470
|
+
{
|
|
471
|
+
"3.3"^^xsd:double math:rounded ?r .
|
|
472
|
+
?r math:equalTo 3 .
|
|
473
|
+
}
|
|
474
|
+
=>
|
|
475
|
+
{
|
|
476
|
+
:test-rounded-1 a :MathBuiltinTest;
|
|
477
|
+
:builtin math:rounded;
|
|
478
|
+
:input "3.3"^^xsd:double;
|
|
479
|
+
:expected 3;
|
|
480
|
+
:actual ?r;
|
|
481
|
+
:status :pass .
|
|
482
|
+
} .
|
|
483
|
+
|
|
484
|
+
# Tie-breaking towards +infinity: 3.5 -> 4
|
|
485
|
+
{
|
|
486
|
+
3.5 math:rounded ?r .
|
|
487
|
+
?r math:equalTo 4 .
|
|
488
|
+
}
|
|
489
|
+
=>
|
|
490
|
+
{
|
|
491
|
+
:test-rounded-2 a :MathBuiltinTest;
|
|
492
|
+
:builtin math:rounded;
|
|
493
|
+
:input 3.5;
|
|
494
|
+
:expected 4;
|
|
495
|
+
:actual ?r;
|
|
496
|
+
:status :pass .
|
|
497
|
+
} .
|
|
498
|
+
|
|
499
|
+
# Negative tie-breaking towards +infinity: -1.5 -> -1
|
|
500
|
+
{
|
|
501
|
+
-1.5 math:rounded ?r .
|
|
502
|
+
?r math:equalTo -1 .
|
|
503
|
+
}
|
|
504
|
+
=>
|
|
505
|
+
{
|
|
506
|
+
:test-rounded-3 a :MathBuiltinTest;
|
|
507
|
+
:builtin math:rounded;
|
|
508
|
+
:input -1.5;
|
|
509
|
+
:expected -1;
|
|
510
|
+
:actual ?r;
|
|
511
|
+
:status :pass .
|
|
512
|
+
} .
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
# =============================================================================
|
|
516
|
+
# 4.2.21 math:sin
|
|
517
|
+
# =============================================================================
|
|
518
|
+
|
|
519
|
+
# sin(0) = 0
|
|
520
|
+
{
|
|
521
|
+
0 math:sin ?r .
|
|
522
|
+
?r math:equalTo 0 .
|
|
523
|
+
}
|
|
524
|
+
=>
|
|
525
|
+
{
|
|
526
|
+
:test-sin-1 a :MathBuiltinTest;
|
|
527
|
+
:builtin math:sin;
|
|
528
|
+
:input 0;
|
|
529
|
+
:expected 0;
|
|
530
|
+
:actual ?r;
|
|
531
|
+
:status :pass .
|
|
532
|
+
} .
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
# =============================================================================
|
|
536
|
+
# 4.2.22 math:sinh
|
|
537
|
+
# =============================================================================
|
|
538
|
+
|
|
539
|
+
# sinh(0) = 0
|
|
540
|
+
{
|
|
541
|
+
0 math:sinh ?r .
|
|
542
|
+
?r math:equalTo 0 .
|
|
543
|
+
}
|
|
544
|
+
=>
|
|
545
|
+
{
|
|
546
|
+
:test-sinh-1 a :MathBuiltinTest;
|
|
547
|
+
:builtin math:sinh;
|
|
548
|
+
:input 0;
|
|
549
|
+
:expected 0;
|
|
550
|
+
:actual ?r;
|
|
551
|
+
:status :pass .
|
|
552
|
+
} .
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
# =============================================================================
|
|
556
|
+
# 4.2.23 math:sum
|
|
557
|
+
# =============================================================================
|
|
558
|
+
|
|
559
|
+
{
|
|
560
|
+
(1 2 3 4 5 6 7 8 9 10) math:sum ?s .
|
|
561
|
+
?s math:equalTo 55 .
|
|
562
|
+
}
|
|
563
|
+
=>
|
|
564
|
+
{
|
|
565
|
+
:test-sum-1 a :MathBuiltinTest;
|
|
566
|
+
:builtin math:sum;
|
|
567
|
+
:input (1 2 3 4 5 6 7 8 9 10);
|
|
568
|
+
:expected 55;
|
|
569
|
+
:actual ?s;
|
|
570
|
+
:status :pass .
|
|
571
|
+
} .
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
# =============================================================================
|
|
575
|
+
# 4.2.24 math:tan
|
|
576
|
+
# =============================================================================
|
|
577
|
+
|
|
578
|
+
# tan(0) = 0
|
|
579
|
+
{
|
|
580
|
+
0 math:tan ?r .
|
|
581
|
+
?r math:equalTo 0 .
|
|
582
|
+
}
|
|
583
|
+
=>
|
|
584
|
+
{
|
|
585
|
+
:test-tan-1 a :MathBuiltinTest;
|
|
586
|
+
:builtin math:tan;
|
|
587
|
+
:input 0;
|
|
588
|
+
:expected 0;
|
|
589
|
+
:actual ?r;
|
|
590
|
+
:status :pass .
|
|
591
|
+
} .
|
|
592
|
+
|
|
593
|
+
|
|
594
|
+
# =============================================================================
|
|
595
|
+
# 4.2.25 math:tanh
|
|
596
|
+
# =============================================================================
|
|
597
|
+
|
|
598
|
+
# tanh(0) = 0
|
|
599
|
+
{
|
|
600
|
+
0 math:tanh ?r .
|
|
601
|
+
?r math:equalTo 0 .
|
|
602
|
+
}
|
|
603
|
+
=>
|
|
604
|
+
{
|
|
605
|
+
:test-tanh-1 a :MathBuiltinTest;
|
|
606
|
+
:builtin math:tanh;
|
|
607
|
+
:input 0;
|
|
608
|
+
:expected 0;
|
|
609
|
+
:actual ?r;
|
|
610
|
+
:status :pass .
|
|
611
|
+
} .
|
|
612
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# --------------
|
|
2
|
+
# Monkey example
|
|
3
|
+
# --------------
|
|
4
|
+
#
|
|
5
|
+
# Example from Patrick Hochstenbach
|
|
6
|
+
|
|
7
|
+
@prefix : <https://eyereasoner.github.io/ns#>.
|
|
8
|
+
|
|
9
|
+
:Bobo a [ a :Monkey ].
|
|
10
|
+
{ ?X a :Monkey } => { ?X a :Animal }.
|
|
11
|
+
{ ?X a :Monkey . ?X a :Animal } => { :test :is true }.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
@prefix : <https://example.org/#> .
|
|
2
|
+
|
|
3
|
+
# ----------------------------------------------------------------------
|
|
4
|
+
# Proof for derived triple:
|
|
5
|
+
# :test :is true .
|
|
6
|
+
# It holds because the following instance of the rule body is provable:
|
|
7
|
+
# :patH :ageAbove "P80Y"^^<http://www.w3.org/2001/XMLSchema#duration> .
|
|
8
|
+
# via the schematic forward rule:
|
|
9
|
+
# {
|
|
10
|
+
# ?S :ageAbove "P80Y"^^<http://www.w3.org/2001/XMLSchema#duration> .
|
|
11
|
+
# } => {
|
|
12
|
+
# :test :is true .
|
|
13
|
+
# } .
|
|
14
|
+
# with substitution (on rule variables):
|
|
15
|
+
# ?S = :patH
|
|
16
|
+
# Therefore the derived triple above is entailed by the rules and facts.
|
|
17
|
+
# ----------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
:test :is true .
|
|
20
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
@prefix : <http://example.org/#> .
|
|
2
|
+
|
|
3
|
+
# ----------------------------------------------------------------------
|
|
4
|
+
# Proof for derived triple:
|
|
5
|
+
# 5 :isIndeedMoreInterestingThan 3 .
|
|
6
|
+
# It holds because the following instance of the rule body is provable:
|
|
7
|
+
# 5 :moreInterestingThan 3 .
|
|
8
|
+
# via the schematic forward rule:
|
|
9
|
+
# {
|
|
10
|
+
# 5 :moreInterestingThan 3 .
|
|
11
|
+
# } => {
|
|
12
|
+
# 5 :isIndeedMoreInterestingThan 3 .
|
|
13
|
+
# } .
|
|
14
|
+
# Therefore the derived triple above is entailed by the rules and facts.
|
|
15
|
+
# ----------------------------------------------------------------------
|
|
16
|
+
|
|
17
|
+
5 :isIndeedMoreInterestingThan 3 .
|
|
18
|
+
|