-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfibonacci.trig
59 lines (46 loc) · 1.15 KB
/
fibonacci.trig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# -----------------
# Fibonacci numbers
# -----------------
#
# See https://en.wikipedia.org/wiki/Fibonacci_number
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix var: <http://www.w3.org/2000/10/swap/var#>.
@prefix : <http://example.org/#>.
# backward rules
_:bng_1 log:isImpliedBy _:bng_2.
_:bng_1 {
var:X :fibonacci var:Y.
}
_:bng_2 {
(var:X 0 1) :fib var:Y.
}
_:bng_3 log:isImpliedBy true.
_:bng_3 {
(0 var:A var:B) :fib var:A.
}
_:bng_4 log:isImpliedBy true.
_:bng_4 {
(1 var:A var:B) :fib var:B.
}
_:bng_5 log:isImpliedBy _:bng_6.
_:bng_5 {
(var:X var:A var:B) :fib var:Y.
}
_:bng_6 {
var:X math:greaterThan 1.
(var:X 1) math:difference var:C.
(var:A var:B) math:sum var:D.
(var:C var:B var:D) :fib var:Y.
}
# query
_:bng_7 log:query _:bng_7.
_:bng_7 {
[] rdf:value 0; :fibonacci var:F1.
[] rdf:value 1; :fibonacci var:F2.
[] rdf:value 6; :fibonacci var:F3.
[] rdf:value 91; :fibonacci var:F4.
[] rdf:value 283; :fibonacci var:F5.
#[] rdf:value 3674; :fibonacci var:F6.
}