eyeling 1.5.11 → 1.5.13
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 +4 -6
- 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 +6 -5
- package/test/api.test.js +22 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# ---------------------
|
|
2
|
+
# Derived backward rule
|
|
3
|
+
# ---------------------
|
|
4
|
+
#
|
|
5
|
+
# Example from Patrick Hochstenbach
|
|
6
|
+
|
|
7
|
+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
|
|
8
|
+
@prefix : <http://example.org/socrates#>.
|
|
9
|
+
|
|
10
|
+
true => {
|
|
11
|
+
{ :Socrates a :Human. } <= true .
|
|
12
|
+
{ :Human rdfs:subClassOf :Mortal } <= true.
|
|
13
|
+
}.
|
|
14
|
+
|
|
15
|
+
{
|
|
16
|
+
?S a ?A.
|
|
17
|
+
?A rdfs:subClassOf ?B.
|
|
18
|
+
} => {
|
|
19
|
+
?S a ?B.
|
|
20
|
+
}.
|
|
21
|
+
|
|
22
|
+
{
|
|
23
|
+
:Socrates a :Mortal .
|
|
24
|
+
}
|
|
25
|
+
=>
|
|
26
|
+
{
|
|
27
|
+
:test :is true .
|
|
28
|
+
} .
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# ---------------------
|
|
2
|
+
# Derived backward rule
|
|
3
|
+
# ---------------------
|
|
4
|
+
|
|
5
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
|
|
6
|
+
@prefix : <https://eyereasoner.github.io/ns#> .
|
|
7
|
+
|
|
8
|
+
:parentOf :invOf :childOf .
|
|
9
|
+
|
|
10
|
+
:alice :parentOf :bob .
|
|
11
|
+
|
|
12
|
+
# Meta-rule:
|
|
13
|
+
# For every inverse pair (?p :invOf ?q),
|
|
14
|
+
# create a backward rule:
|
|
15
|
+
# { ?x ?q ?y } <= { ?y ?p ?x } .
|
|
16
|
+
{
|
|
17
|
+
?p :invOf ?q .
|
|
18
|
+
} => {
|
|
19
|
+
{
|
|
20
|
+
?x ?q ?y .
|
|
21
|
+
} <= {
|
|
22
|
+
?y ?p ?x .
|
|
23
|
+
} .
|
|
24
|
+
} .
|
|
25
|
+
|
|
26
|
+
# Ordinary forward rule that uses :childOf in its premise.
|
|
27
|
+
{
|
|
28
|
+
?x :childOf ?y .
|
|
29
|
+
} => {
|
|
30
|
+
?x :hasParent ?y .
|
|
31
|
+
} .
|
|
32
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# ------------
|
|
2
|
+
# Derived rule
|
|
3
|
+
# ------------
|
|
4
|
+
|
|
5
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
|
|
6
|
+
@prefix : <https://eyereasoner.github.io/ns#>.
|
|
7
|
+
|
|
8
|
+
:Minka a :Cat.
|
|
9
|
+
:Charly a :Dog.
|
|
10
|
+
|
|
11
|
+
{
|
|
12
|
+
?x a :Cat.
|
|
13
|
+
} => {
|
|
14
|
+
{
|
|
15
|
+
?y a :Dog.
|
|
16
|
+
} => {
|
|
17
|
+
:test :is true.
|
|
18
|
+
}.
|
|
19
|
+
}.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# ----------------------------------------------
|
|
2
|
+
# Dijkstra's algorithm to find the shortest path
|
|
3
|
+
# ----------------------------------------------
|
|
4
|
+
#
|
|
5
|
+
# Original from https://github.com/agx-r/Dijkstra-s-Algorithm
|
|
6
|
+
|
|
7
|
+
@prefix list: <http://www.w3.org/2000/10/swap/list#>.
|
|
8
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
9
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
|
|
10
|
+
@prefix : <https://eyereasoner.github.io/ns#>.
|
|
11
|
+
|
|
12
|
+
# edges
|
|
13
|
+
(:a :b) :edge 4 .
|
|
14
|
+
(:a :c) :edge 2 .
|
|
15
|
+
(:b :c) :edge 1 .
|
|
16
|
+
(:b :d) :edge 5 .
|
|
17
|
+
(:c :d) :edge 8 .
|
|
18
|
+
(:c :e) :edge 10 .
|
|
19
|
+
(:d :e) :edge 2 .
|
|
20
|
+
(:d :f) :edge 6 .
|
|
21
|
+
(:e :f) :edge 3 .
|
|
22
|
+
|
|
23
|
+
{
|
|
24
|
+
(?A ?B) :edge ?C.
|
|
25
|
+
} => {
|
|
26
|
+
(?B ?A) :edge ?C.
|
|
27
|
+
}.
|
|
28
|
+
|
|
29
|
+
# Dijkstra's algorithm
|
|
30
|
+
{ (?Start ?Goal) :dijkstra (?Path ?Cost) } <= {
|
|
31
|
+
(((0 ?Start)) ?Goal ()) :dijkstra2 (?RevPath ?Cost).
|
|
32
|
+
?RevPath list:reverse ?Path.
|
|
33
|
+
}.
|
|
34
|
+
|
|
35
|
+
{ (?L1 ?Goal ?L2) :dijkstra2 (?L3 ?Cost) } <= {
|
|
36
|
+
?L1 list:firstRest (?L4 ?L5).
|
|
37
|
+
?L4 list:firstRest (?Cost ?L3).
|
|
38
|
+
?L3 list:firstRest (?Goal ?Path).
|
|
39
|
+
}.
|
|
40
|
+
|
|
41
|
+
{ (?L1 ?Goal ?Visited) :dijkstra2 (?ResultPath ?ResultCost) } <= {
|
|
42
|
+
?L1 list:firstRest (?L2 ?Queue).
|
|
43
|
+
?L2 list:firstRest (?Cost ?L3).
|
|
44
|
+
?L3 list:firstRest (?Node ?Path).
|
|
45
|
+
(?L4 {
|
|
46
|
+
?L4 list:firstRest (?NewCost ?L5).
|
|
47
|
+
?L5 list:firstRest (?Neighbor ?L6).
|
|
48
|
+
?L6 list:firstRest (?Node ?Path).
|
|
49
|
+
(?Node ?Neighbor) :edge ?Weight.
|
|
50
|
+
?Visited list:notMember ?Neighbor.
|
|
51
|
+
(?Cost ?Weight) math:sum ?NewCost.
|
|
52
|
+
} ?Neighbors) log:collectAllIn ?SCOPE.
|
|
53
|
+
(?Queue ?Neighbors) list:append ?NewQueue.
|
|
54
|
+
?NewQueue list:sort ?SortedQueue.
|
|
55
|
+
?L7 list:firstRest (?Node ?Visited).
|
|
56
|
+
(?SortedQueue ?Goal ?L7) :dijkstra2 (?ResultPath ?ResultCost).
|
|
57
|
+
}.
|
|
58
|
+
|
|
59
|
+
# find the paths
|
|
60
|
+
{
|
|
61
|
+
(:a :f) :dijkstra (?Path ?Cost).
|
|
62
|
+
} => {
|
|
63
|
+
(:a :f) :path (?Path ?Cost).
|
|
64
|
+
}.
|
package/examples/dog.n3
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# -------------------
|
|
2
|
+
# Dog license example
|
|
3
|
+
# -------------------
|
|
4
|
+
#
|
|
5
|
+
# If you have more than 4 dogs you need a license.
|
|
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 : <https://eyereasoner.github.io/ns#>.
|
|
10
|
+
|
|
11
|
+
:alice :hasDog :dog1, :dog2, :dog3, :dog4, :dog5.
|
|
12
|
+
:bob :hasDog :dog6, :dog7.
|
|
13
|
+
|
|
14
|
+
{
|
|
15
|
+
?Subject :hasDog ?Any.
|
|
16
|
+
(1 { ?Subject :hasDog ?Dog } ?List) log:collectAllIn ?Scope.
|
|
17
|
+
?List math:sum ?Count.
|
|
18
|
+
?Count math:greaterThan 4.
|
|
19
|
+
} => {
|
|
20
|
+
?Subject :mustHave :dogLicense.
|
|
21
|
+
}.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# ----------------
|
|
2
|
+
# Existential rule
|
|
3
|
+
# ----------------
|
|
4
|
+
|
|
5
|
+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
|
|
6
|
+
@prefix : <http://example.org/socrates#>.
|
|
7
|
+
|
|
8
|
+
# facts
|
|
9
|
+
:Socrates a :Human.
|
|
10
|
+
:Plato a :Human.
|
|
11
|
+
|
|
12
|
+
# subclass rule
|
|
13
|
+
{
|
|
14
|
+
?S a :Human.
|
|
15
|
+
} => {
|
|
16
|
+
?S :is _:B.
|
|
17
|
+
}.
|
|
18
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# -----------------
|
|
2
|
+
# Fibonacci numbers
|
|
3
|
+
# -----------------
|
|
4
|
+
#
|
|
5
|
+
# See https://en.wikipedia.org/wiki/Fibonacci_number
|
|
6
|
+
|
|
7
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
8
|
+
@prefix : <https://eyereasoner.github.io/eye/reasoning#>.
|
|
9
|
+
|
|
10
|
+
{?X :fibonacci ?Y} <= {(?X 0 1) :fib ?Y}.
|
|
11
|
+
|
|
12
|
+
{(0 ?A ?B) :fib ?A} <= true.
|
|
13
|
+
{(1 ?A ?B) :fib ?B} <= true.
|
|
14
|
+
{(?X ?A ?B) :fib ?Y} <= {
|
|
15
|
+
?X math:greaterThan 1.
|
|
16
|
+
(?X 1) math:difference ?D.
|
|
17
|
+
(?A ?B) math:sum ?S.
|
|
18
|
+
(?D ?B ?S) :fib ?Y.
|
|
19
|
+
}.
|
|
20
|
+
|
|
21
|
+
{
|
|
22
|
+
0 :fibonacci ?F0.
|
|
23
|
+
1 :fibonacci ?F1.
|
|
24
|
+
10 :fibonacci ?F10.
|
|
25
|
+
100 :fibonacci ?F100.
|
|
26
|
+
} => {
|
|
27
|
+
:test :is {
|
|
28
|
+
0 :fibonacci ?F0.
|
|
29
|
+
1 :fibonacci ?F1.
|
|
30
|
+
10 :fibonacci ?F10.
|
|
31
|
+
100 :fibonacci ?F100.
|
|
32
|
+
}.
|
|
33
|
+
}.
|
|
34
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# --------------------
|
|
2
|
+
# log:forAllIn example
|
|
3
|
+
# --------------------
|
|
4
|
+
|
|
5
|
+
@prefix : <http://example.org/>.
|
|
6
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
|
|
7
|
+
|
|
8
|
+
:c a :CompositeTask ;
|
|
9
|
+
:subTask :s1 , :s2 , :s3 .
|
|
10
|
+
:s1 :state :Completed .
|
|
11
|
+
:s2 :state :Completed .
|
|
12
|
+
:s3 :state :Completed .
|
|
13
|
+
|
|
14
|
+
{
|
|
15
|
+
?c a :CompositeTask .
|
|
16
|
+
( { ?c :subTask ?s } { ?s :state :Completed } ) log:forAllIn _:t .
|
|
17
|
+
}
|
|
18
|
+
=>
|
|
19
|
+
{
|
|
20
|
+
:result :is true .
|
|
21
|
+
} .
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# ----------------------
|
|
2
|
+
# Traversing Graph Paths
|
|
3
|
+
# ----------------------
|
|
4
|
+
#
|
|
5
|
+
# Simple data & rules over a tiny city dataset
|
|
6
|
+
|
|
7
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
|
|
8
|
+
@prefix owl: <http://www.w3.org/2002/07/owl#>.
|
|
9
|
+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
|
|
10
|
+
@prefix : <http://www.agfa.com/w3c/euler/graph.axiom#>.
|
|
11
|
+
|
|
12
|
+
:paris :oneway :orleans.
|
|
13
|
+
:paris :oneway :chartres.
|
|
14
|
+
:paris :oneway :amiens.
|
|
15
|
+
:orleans :oneway :blois.
|
|
16
|
+
:orleans :oneway :bourges.
|
|
17
|
+
:blois :oneway :tours.
|
|
18
|
+
:chartres :oneway :lemans.
|
|
19
|
+
:lemans :oneway :angers.
|
|
20
|
+
:lemans :oneway :tours.
|
|
21
|
+
:angers :oneway :nantes.
|
|
22
|
+
|
|
23
|
+
:oneway rdfs:subPropertyOf :path.
|
|
24
|
+
:path a owl:TransitiveProperty.
|
|
25
|
+
|
|
26
|
+
# RDFS rules
|
|
27
|
+
{?P rdfs:subPropertyOf ?Q. ?S ?P ?O} => {?S ?Q ?O}.
|
|
28
|
+
{?P rdfs:subPropertyOf ?Q. ?Q rdfs:subPropertyOf ?R} => {?P rdfs:subPropertyOf ?R}.
|
|
29
|
+
|
|
30
|
+
# OWL rules
|
|
31
|
+
{?P a owl:TransitiveProperty. ?S ?P ?X. ?X ?P ?O.} => {?S ?P ?O}.
|
|
32
|
+
|
package/examples/fuse.n3
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# ------------
|
|
2
|
+
# Good cobbler
|
|
3
|
+
# ------------
|
|
4
|
+
#
|
|
5
|
+
# Example from https://shs.hal.science/halshs-04148373/document
|
|
6
|
+
# Using term logic http://intrologic.stanford.edu/chapters/chapter_11.html
|
|
7
|
+
|
|
8
|
+
@prefix : <https://eyereasoner.github.io/ns#>.
|
|
9
|
+
|
|
10
|
+
# joe is a good cobbler
|
|
11
|
+
:joe :is (:good :Cobbler).
|
|
12
|
+
|
|
13
|
+
# is there some x which is good at some y
|
|
14
|
+
{
|
|
15
|
+
?X :is (:good ?Y).
|
|
16
|
+
} => {
|
|
17
|
+
:test :is { ?X :is (:good ?Y) }.
|
|
18
|
+
}.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# -----------------
|
|
2
|
+
# Gray code counter
|
|
3
|
+
# -----------------
|
|
4
|
+
#
|
|
5
|
+
# Taken from the book "Clause and Effect" Chapter 8
|
|
6
|
+
|
|
7
|
+
@prefix list: <http://www.w3.org/2000/10/swap/list#>.
|
|
8
|
+
@prefix : <https://eyereasoner.github.io/eye/reasoning#>.
|
|
9
|
+
|
|
10
|
+
(0 0) :and 0.
|
|
11
|
+
(0 1) :and 0.
|
|
12
|
+
(1 0) :and 0.
|
|
13
|
+
(1 1) :and 1.
|
|
14
|
+
|
|
15
|
+
(0 0) :or 0.
|
|
16
|
+
(0 1) :or 1.
|
|
17
|
+
(1 0) :or 1.
|
|
18
|
+
(1 1) :or 1.
|
|
19
|
+
|
|
20
|
+
0 :inv 1.
|
|
21
|
+
1 :inv 0.
|
|
22
|
+
|
|
23
|
+
{(?D 0 ?Q) :dff ?Q} <= true.
|
|
24
|
+
{(?D 1 ?Q) :dff ?D} <= true.
|
|
25
|
+
|
|
26
|
+
{(?A ?B) :neta ?Q} <= {
|
|
27
|
+
(?A ?B) :and ?T1.
|
|
28
|
+
?A :inv ?NA.
|
|
29
|
+
?B :inv ?NB.
|
|
30
|
+
(?NA ?NB) :and ?T2.
|
|
31
|
+
(?T1 ?T2) :or ?Q.
|
|
32
|
+
}.
|
|
33
|
+
|
|
34
|
+
{(?A ?B ?C) :netb (?Q1 ?Q2)} <= {
|
|
35
|
+
(?A ?C) :and ?T1.
|
|
36
|
+
?C :inv ?NC.
|
|
37
|
+
(?B ?NC) :and ?T2.
|
|
38
|
+
?A :inv ?NA.
|
|
39
|
+
(?NA ?C) :and ?T3.
|
|
40
|
+
(?T1 ?T2) :or ?Q1.
|
|
41
|
+
(?T2 ?T3) :or ?Q2.
|
|
42
|
+
}.
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
{(?C (?Qa ?Qb ?Qc)) :gcc (?Za ?Zb ?Zc)} <= {
|
|
46
|
+
(?Qa ?Qb ?Qc) :netb (?D1 ?D2).
|
|
47
|
+
(?Qa ?Qb) :neta ?D3.
|
|
48
|
+
(?D1 ?C ?Qa) :dff ?Za.
|
|
49
|
+
(?D2 ?C ?Qb) :dff ?Zb.
|
|
50
|
+
(?D3 ?C ?Qc) :dff ?Zc.
|
|
51
|
+
}.
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
{(() ?S) :testgcc ()} <= true.
|
|
55
|
+
{(?Cc ?S) :testgcc ?Nc} <= {
|
|
56
|
+
?Cc list:firstRest (?C ?Cs).
|
|
57
|
+
?Nc list:firstRest (?N ?Ns).
|
|
58
|
+
(?C ?S) :gcc ?N.
|
|
59
|
+
(?Cs ?N) :testgcc ?Ns.
|
|
60
|
+
}.
|
|
61
|
+
|
|
62
|
+
# test
|
|
63
|
+
{((1 1 1 1 1 1 1 1 1) (0 0 0)) :testgcc ?Q} => {((1 1 1 1 1 1 1 1 1) (0 0 0)) :isgcc ?Q}.
|
|
64
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# ---------------
|
|
2
|
+
# Towers of Hanoi
|
|
3
|
+
# ---------------
|
|
4
|
+
#
|
|
5
|
+
# Taken from the book "The Art of Prolog" by Leon Sterling and Ehud Shapiro
|
|
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 : <https://eyereasoner.github.io/eye/reasoning#>.
|
|
10
|
+
|
|
11
|
+
# ?M is the sequence of moves to move ?N disks from ?X to ?Y using ?Z as intermediary
|
|
12
|
+
{(?N ?X ?Y ?Z) :moves ?M} <=
|
|
13
|
+
{ ?N math:greaterThan 1.
|
|
14
|
+
(?N 1) math:difference ?N1.
|
|
15
|
+
(?N1 ?X ?Z ?Y) :moves ?M1.
|
|
16
|
+
(?N1 ?Z ?Y ?X) :moves ?M2.
|
|
17
|
+
(?M1 ((?X ?Y)) ?M2) list:append ?M.
|
|
18
|
+
}.
|
|
19
|
+
{(1 ?X ?Y ?Z) :moves ((?X ?Y))} <= true.
|
|
20
|
+
|
|
21
|
+
{(3 :left :right :center) :moves ?M} => {3 :answer ?M}.
|
package/examples/liar.n3
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# -------------------
|
|
2
|
+
# list builtins tests
|
|
3
|
+
# -------------------
|
|
4
|
+
|
|
5
|
+
@prefix : <https://eyereasoner.github.io/ns#> .
|
|
6
|
+
@prefix list: <http://www.w3.org/2000/10/swap/list#> .
|
|
7
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
|
|
8
|
+
|
|
9
|
+
# ============================================================
|
|
10
|
+
# 4.4 list: builtins
|
|
11
|
+
# ============================================================
|
|
12
|
+
|
|
13
|
+
# 4.4.1 list:append
|
|
14
|
+
# ( (1 2) (3 4) ) list:append (1 2 3 4) .
|
|
15
|
+
{
|
|
16
|
+
( (1 2) (3 4) ) list:append (1 2 3 4) .
|
|
17
|
+
} => {
|
|
18
|
+
:ok_list_append_1 a :Pass .
|
|
19
|
+
} .
|
|
20
|
+
|
|
21
|
+
# 4.4.2 list:first
|
|
22
|
+
# (1 2 3 4) list:first 1 .
|
|
23
|
+
{
|
|
24
|
+
(1 2 3 4) list:first 1 .
|
|
25
|
+
} => {
|
|
26
|
+
:ok_list_first_1 a :Pass .
|
|
27
|
+
} .
|
|
28
|
+
|
|
29
|
+
# 4.4.3 list:in
|
|
30
|
+
# "cat" list:in ( "dog" "penguin" "cat" ) .
|
|
31
|
+
{
|
|
32
|
+
"cat" list:in ( "dog" "penguin" "cat" ) .
|
|
33
|
+
} => {
|
|
34
|
+
:ok_list_in_1 a :Pass .
|
|
35
|
+
} .
|
|
36
|
+
|
|
37
|
+
# 4.4.4 list:iterate
|
|
38
|
+
# ("dog" "penguin" "cat") list:iterate (?index "cat") .
|
|
39
|
+
{
|
|
40
|
+
("dog" "penguin" "cat") list:iterate (?index "cat") .
|
|
41
|
+
} => {
|
|
42
|
+
:ok_list_iterate_1 a :Pass .
|
|
43
|
+
} .
|
|
44
|
+
|
|
45
|
+
# 4.4.5 list:last
|
|
46
|
+
# (1 2 3 4) list:last 4 .
|
|
47
|
+
{
|
|
48
|
+
(1 2 3 4) list:last 4 .
|
|
49
|
+
} => {
|
|
50
|
+
:ok_list_last_1 a :Pass .
|
|
51
|
+
} .
|
|
52
|
+
|
|
53
|
+
# 4.4.6 list:length
|
|
54
|
+
# (1 2 3 4) list:length 4 .
|
|
55
|
+
{
|
|
56
|
+
(1 2 3 4) list:length 4 .
|
|
57
|
+
} => {
|
|
58
|
+
:ok_list_length_1 a :Pass .
|
|
59
|
+
} .
|
|
60
|
+
|
|
61
|
+
# 4.4.7 list:member
|
|
62
|
+
# ("dog" "penguin" "cat") list:member "cat" .
|
|
63
|
+
{
|
|
64
|
+
("dog" "penguin" "cat") list:member "cat" .
|
|
65
|
+
} => {
|
|
66
|
+
:ok_list_member_1 a :Pass .
|
|
67
|
+
} .
|
|
68
|
+
|
|
69
|
+
# 4.4.8 list:memberAt
|
|
70
|
+
# (("dog" "penguin" "cat") 2) list:memberAt "cat" .
|
|
71
|
+
{
|
|
72
|
+
(("dog" "penguin" "cat") 2) list:memberAt "cat" .
|
|
73
|
+
} => {
|
|
74
|
+
:ok_list_memberAt_1 a :Pass .
|
|
75
|
+
} .
|
|
76
|
+
|
|
77
|
+
# 4.4.9 list:remove
|
|
78
|
+
# (("dog" "penguin" "cat" "penguin") "penguin") list:remove ("dog" "cat") .
|
|
79
|
+
{
|
|
80
|
+
(("dog" "penguin" "cat" "penguin") "penguin") list:remove ("dog" "cat") .
|
|
81
|
+
} => {
|
|
82
|
+
:ok_list_remove_1 a :Pass .
|
|
83
|
+
} .
|
|
84
|
+
|
package/examples/lldm.n3
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# ----------------------------------
|
|
2
|
+
# Leg Length Discrepancy Measurement
|
|
3
|
+
# ----------------------------------
|
|
4
|
+
#
|
|
5
|
+
# See https://web.archive.org/web/20220524062310/http://www.agfa.com/w3c/2002/10/medicad/op/
|
|
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 owl: <http://www.w3.org/2002/07/owl#>.
|
|
10
|
+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
|
|
11
|
+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
|
|
12
|
+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
|
|
13
|
+
@prefix : <http://www.agfa.com/w3c/2002/10/medicad/op/lldmP#>.
|
|
14
|
+
|
|
15
|
+
## measurement data
|
|
16
|
+
|
|
17
|
+
:meas47 a :Measurement;
|
|
18
|
+
:p1xCm 10.1; :p1yCm 7.8;
|
|
19
|
+
:p2xCm 45.1; :p2yCm 5.6;
|
|
20
|
+
:p3xCm 3.6; :p3yCm 29.8;
|
|
21
|
+
:p4xCm 54.7; :p4yCm 28.5.
|
|
22
|
+
|
|
23
|
+
## measurement axioms
|
|
24
|
+
|
|
25
|
+
:p1 a :Point; :incident :L1.
|
|
26
|
+
:p2 a :Point; :incident :L1.
|
|
27
|
+
:p3 a :Point; :incident :L3.
|
|
28
|
+
:p4 a :Point; :incident :L4.
|
|
29
|
+
:p5 a :Point; :incident :L1, :L3.
|
|
30
|
+
:p6 a :Point; :incident :L1, :L4.
|
|
31
|
+
:L1 a :Line; :perpendicular :L3, :L4.
|
|
32
|
+
:L3 a :Line.
|
|
33
|
+
:L4 a :Line.
|
|
34
|
+
|
|
35
|
+
:incident rdfs:domain :Point; rdfs:range :Line; owl:inverseOf :contains.
|
|
36
|
+
:perpendicular rdfs:domain :Line; rdfs:range :Line; a owl:SymmetricProperty.
|
|
37
|
+
|
|
38
|
+
:p1xCm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
39
|
+
:p1yCm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
40
|
+
:p2xCm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
41
|
+
:p2yCm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
42
|
+
:p3xCm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
43
|
+
:p3yCm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
44
|
+
:p4xCm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
45
|
+
:p4yCm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
46
|
+
:p5xCm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
47
|
+
:p5yCm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
48
|
+
:p6xCm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
49
|
+
:p6yCm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
50
|
+
:dx12Cm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
51
|
+
:dx51Cm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
52
|
+
:dx53Cm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
53
|
+
:dx62Cm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
54
|
+
:dx64Cm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
55
|
+
:dy12Cm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
56
|
+
:dy13Cm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
57
|
+
:dy24Cm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
58
|
+
:dy53Cm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
59
|
+
:dy64Cm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
60
|
+
:cL1 rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
61
|
+
:dL3m rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
62
|
+
:cL3 rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
63
|
+
:pL1x1Cm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
64
|
+
:pL1x2Cm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
65
|
+
:pL3x3Cm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
66
|
+
:pL3x4Cm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
67
|
+
:dd13Cm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
68
|
+
:ddy13Cm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
69
|
+
:dd24Cm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
70
|
+
:ddy24Cm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
71
|
+
:ddL13 rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
72
|
+
:pL1dx51Cm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
73
|
+
:pL1dx62Cm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
74
|
+
:sdx53Cm2 rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
75
|
+
:sdx64Cm2 rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
76
|
+
:sdy53Cm2 rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
77
|
+
:sdy64Cm2 rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
78
|
+
:sdd53Cm2 rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
79
|
+
:sdd64Cm2 rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
80
|
+
:ssd53Cm2 rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
81
|
+
:ssd64Cm2 rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
82
|
+
:d53Cm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
83
|
+
:d64Cm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
84
|
+
:dCm rdfs:domain :Measurement; rdfs:range :Quantity.
|
|
85
|
+
|
|
86
|
+
## measurement implications
|
|
87
|
+
|
|
88
|
+
{?M a :Measurement; :p1xCm ?X; :p2xCm ?Y. (?X ?Y) math:difference ?Z} => {?M :dx12Cm ?Z}.
|
|
89
|
+
{?M a :Measurement; :p5xCm ?X; :p1xCm ?Y. (?X ?Y) math:difference ?Z} => {?M :dx51Cm ?Z}.
|
|
90
|
+
{?M a :Measurement; :p5xCm ?X; :p3xCm ?Y. (?X ?Y) math:difference ?Z} => {?M :dx53Cm ?Z}.
|
|
91
|
+
{?M a :Measurement; :p6xCm ?X; :p2xCm ?Y. (?X ?Y) math:difference ?Z} => {?M :dx62Cm ?Z}.
|
|
92
|
+
{?M a :Measurement; :p6xCm ?X; :p4xCm ?Y. (?X ?Y) math:difference ?Z} => {?M :dx64Cm ?Z}.
|
|
93
|
+
{?M a :Measurement; :p1yCm ?X; :p2yCm ?Y. (?X ?Y) math:difference ?Z} => {?M :dy12Cm ?Z}.
|
|
94
|
+
{?M a :Measurement; :p1yCm ?X; :p3yCm ?Y. (?X ?Y) math:difference ?Z} => {?M :dy13Cm ?Z}.
|
|
95
|
+
{?M a :Measurement; :p2yCm ?X; :p4yCm ?Y. (?X ?Y) math:difference ?Z} => {?M :dy24Cm ?Z}.
|
|
96
|
+
{?M a :Measurement; :p5yCm ?X; :p3yCm ?Y. (?X ?Y) math:difference ?Z} => {?M :dy53Cm ?Z}.
|
|
97
|
+
{?M a :Measurement; :p6yCm ?X; :p4yCm ?Y. (?X ?Y) math:difference ?Z} => {?M :dy64Cm ?Z}.
|
|
98
|
+
|
|
99
|
+
{?M a :Measurement; :dy12Cm ?Y; :dx12Cm ?X. (?Y ?X) math:quotient ?Z} => {?M :cL1 ?Z}.
|
|
100
|
+
{?M a :Measurement; :cL1 ?X. (1 ?X) math:quotient ?Z} => {?M :dL3m ?Z}.
|
|
101
|
+
{?M a :Measurement; :dL3m ?X. (0 ?X) math:difference ?Z} => {?M :cL3 ?Z}.
|
|
102
|
+
|
|
103
|
+
{?M a :Measurement; :cL1 ?X; :p1xCm ?Y. (?X ?Y) math:product ?Z} => {?M :pL1x1Cm ?Z}.
|
|
104
|
+
{?M a :Measurement; :cL1 ?X; :p2xCm ?Y. (?X ?Y) math:product ?Z} => {?M :pL1x2Cm ?Z}.
|
|
105
|
+
{?M a :Measurement; :cL3 ?X; :p3xCm ?Y. (?X ?Y) math:product ?Z} => {?M :pL3x3Cm ?Z}.
|
|
106
|
+
{?M a :Measurement; :cL3 ?X; :p4xCm ?Y. (?X ?Y) math:product ?Z} => {?M :pL3x4Cm ?Z}.
|
|
107
|
+
{?M a :Measurement; :pL1x1Cm ?X; :pL3x3Cm ?Y. (?X ?Y) math:difference ?Z} => {?M :dd13Cm ?Z}.
|
|
108
|
+
{?M a :Measurement; :dd13Cm ?X; :dy13Cm ?Y. (?X ?Y) math:difference ?Z} => {?M :ddy13Cm ?Z}.
|
|
109
|
+
{?M a :Measurement; :pL1x2Cm ?X; :pL3x4Cm ?Y. (?X ?Y) math:difference ?Z} => {?M :dd24Cm ?Z}.
|
|
110
|
+
{?M a :Measurement; :dd24Cm ?X; :dy24Cm ?Y. (?X ?Y) math:difference ?Z} => {?M :ddy24Cm ?Z}.
|
|
111
|
+
{?M a :Measurement; :cL1 ?X; :cL3 ?Y. (?X ?Y) math:difference ?Z} => {?M :ddL13 ?Z}.
|
|
112
|
+
{?M a :Measurement; :cL1 ?X; :dx51Cm ?Y. (?X ?Y) math:product ?Z} => {?M :pL1dx51Cm ?Z}.
|
|
113
|
+
{?M a :Measurement; :cL1 ?X; :dx62Cm ?Y. (?X ?Y) math:product ?Z} => {?M :pL1dx62Cm ?Z}.
|
|
114
|
+
|
|
115
|
+
{?M a :Measurement; :ddy13Cm ?X; :ddL13 ?Y. (?X ?Y) math:quotient ?Z} => {?M :p5xCm ?Z}.
|
|
116
|
+
{?M a :Measurement; :pL1dx51Cm ?X; :p1yCm ?Y. (?X ?Y) math:sum ?Z} => {?M :p5yCm ?Z}.
|
|
117
|
+
{?M a :Measurement; :ddy24Cm ?X; :ddL13 ?Y. (?X ?Y) math:quotient ?Z} => {?M :p6xCm ?Z}.
|
|
118
|
+
{?M a :Measurement; :pL1dx62Cm ?X; :p2yCm ?Y. (?X ?Y) math:sum ?Z} => {?M :p6yCm ?Z}.
|
|
119
|
+
|
|
120
|
+
{?M a :Measurement; :dx53Cm ?X. (?X 2) math:exponentiation ?Z} => {?M :sdx53Cm2 ?Z}.
|
|
121
|
+
{?M a :Measurement; :dx64Cm ?X. (?X 2) math:exponentiation ?Z} => {?M :sdx64Cm2 ?Z}.
|
|
122
|
+
{?M a :Measurement; :dy53Cm ?X. (?X 2) math:exponentiation ?Z} => {?M :sdy53Cm2 ?Z}.
|
|
123
|
+
{?M a :Measurement; :dy64Cm ?X. (?X 2) math:exponentiation ?Z} => {?M :sdy64Cm2 ?Z}.
|
|
124
|
+
{?M a :Measurement; :sdx53Cm2 ?X; :sdy53Cm2 ?Y. (?X ?Y) math:sum ?Z} => {?M :ssd53Cm2 ?Z}.
|
|
125
|
+
{?M a :Measurement; :sdx64Cm2 ?X; :sdy64Cm2 ?Y. (?X ?Y) math:sum ?Z} => {?M :ssd64Cm2 ?Z}.
|
|
126
|
+
|
|
127
|
+
{?M a :Measurement; :ssd53Cm2 ?X. (?X 0.5) math:exponentiation ?Z} => {?M :d53Cm ?Z}.
|
|
128
|
+
{?M a :Measurement; :ssd64Cm2 ?X. (?X 0.5) math:exponentiation ?Z} => {?M :d64Cm ?Z}.
|
|
129
|
+
|
|
130
|
+
{?M a :Measurement; :d53Cm ?X; :d64Cm ?Y. (?X ?Y) math:difference ?Z} => {?M :dCm ?Z}.
|
|
131
|
+
|
|
132
|
+
{?M a :Measurement; :dCm ?X. ?X math:lessThan -1.25} => {?M a :LLDAlarm}.
|
|
133
|
+
{?M a :Measurement; :dCm ?X. ?X math:greaterThan 1.25} => {?M a :LLDAlarm}.
|