eyeling 1.5.19 → 1.5.21
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/examples/expression-eval.n3 +70 -0
- package/examples/family-cousins.n3 +63 -0
- package/examples/gps.n3 +68 -0
- package/examples/light-eaters.n3 +109 -0
- package/examples/odrl-trust.n3 +146 -0
- package/examples/output/expression-eval.n3 +23 -0
- package/examples/output/family-cousins.n3 +663 -0
- package/examples/output/gps.n3 +53 -0
- package/examples/output/light-eaters.n3 +326 -0
- package/examples/output/odrl-trust.n3 +51 -0
- package/examples/output/spectral-week.n3 +366 -0
- package/examples/spectral-week.n3 +104 -0
- package/package.json +1 -1
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# ---------------------------------
|
|
2
|
+
# A tiny expression evaluator in N3
|
|
3
|
+
# ---------------------------------
|
|
4
|
+
#
|
|
5
|
+
# - numbers are nodes with :n
|
|
6
|
+
# - expressions are nodes with :op, :left, :right
|
|
7
|
+
# - :value is defined as a backward “builtin-like” predicate (<=) with recursion
|
|
8
|
+
# - one forward rule emits the final result
|
|
9
|
+
|
|
10
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
11
|
+
@prefix : <http://example.org/expression-eval#>.
|
|
12
|
+
|
|
13
|
+
# -----------------------------
|
|
14
|
+
# Data: (2 * 3) + (10 - 4) = 12
|
|
15
|
+
# -----------------------------
|
|
16
|
+
|
|
17
|
+
:n2 :n 2.
|
|
18
|
+
:n3 :n 3.
|
|
19
|
+
:n10 :n 10.
|
|
20
|
+
:n4 :n 4.
|
|
21
|
+
|
|
22
|
+
:eMul a :Expr; :op :mul; :left :n2; :right :n3.
|
|
23
|
+
:eSub a :Expr; :op :sub; :left :n10; :right :n4.
|
|
24
|
+
:eAdd a :Expr; :op :add; :left :eMul; :right :eSub.
|
|
25
|
+
|
|
26
|
+
:Root :expr :eAdd.
|
|
27
|
+
|
|
28
|
+
# ----------------------
|
|
29
|
+
# Backward rules: :value
|
|
30
|
+
# ----------------------
|
|
31
|
+
|
|
32
|
+
# Base case: numeric node
|
|
33
|
+
{ ?N :value ?V. } <= { ?N :n ?V. }.
|
|
34
|
+
|
|
35
|
+
# Addition
|
|
36
|
+
{ ?E :value ?V. } <= {
|
|
37
|
+
?E :op :add.
|
|
38
|
+
?E :left ?L.
|
|
39
|
+
?E :right ?R.
|
|
40
|
+
?L :value ?LV.
|
|
41
|
+
?R :value ?RV.
|
|
42
|
+
(?LV ?RV) math:sum ?V.
|
|
43
|
+
}.
|
|
44
|
+
|
|
45
|
+
# Subtraction
|
|
46
|
+
{ ?E :value ?V. } <= {
|
|
47
|
+
?E :op :sub.
|
|
48
|
+
?E :left ?L.
|
|
49
|
+
?E :right ?R.
|
|
50
|
+
?L :value ?LV.
|
|
51
|
+
?R :value ?RV.
|
|
52
|
+
(?LV ?RV) math:difference ?V.
|
|
53
|
+
}.
|
|
54
|
+
|
|
55
|
+
# Multiplication
|
|
56
|
+
{ ?E :value ?V. } <= {
|
|
57
|
+
?E :op :mul.
|
|
58
|
+
?E :left ?L.
|
|
59
|
+
?E :right ?R.
|
|
60
|
+
?L :value ?LV.
|
|
61
|
+
?R :value ?RV.
|
|
62
|
+
(?LV ?RV) math:product ?V.
|
|
63
|
+
}.
|
|
64
|
+
|
|
65
|
+
# ------------------------------
|
|
66
|
+
# Forward rule: emit final value
|
|
67
|
+
# ------------------------------
|
|
68
|
+
|
|
69
|
+
{ :Root :expr ?E. ?E :value ?V. } => { :Root :result ?V. }.
|
|
70
|
+
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# --------------
|
|
2
|
+
# Family cousins
|
|
3
|
+
# --------------
|
|
4
|
+
|
|
5
|
+
@prefix : <http://example.org/family#>.
|
|
6
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
7
|
+
|
|
8
|
+
# --------------------------
|
|
9
|
+
# Data (a small family tree)
|
|
10
|
+
# --------------------------
|
|
11
|
+
|
|
12
|
+
:Adam :parentOf :Bob, :Carol .
|
|
13
|
+
:Bob :parentOf :Dave, :Eve .
|
|
14
|
+
:Carol :parentOf :Frank, :Grace .
|
|
15
|
+
:Dave :parentOf :Heidi .
|
|
16
|
+
:Eve :parentOf :Ivan .
|
|
17
|
+
:Frank :parentOf :Judy .
|
|
18
|
+
|
|
19
|
+
# Seed "branch" labels at generation 2 (so gen-1 siblings won't become cousins)
|
|
20
|
+
:Dave :branch :b .
|
|
21
|
+
:Eve :branch :b .
|
|
22
|
+
:Frank :branch :c .
|
|
23
|
+
:Grace :branch :c .
|
|
24
|
+
|
|
25
|
+
# Declare branch difference (so we can avoid any inequality built-in)
|
|
26
|
+
:b :differentFrom :c .
|
|
27
|
+
:c :differentFrom :b .
|
|
28
|
+
|
|
29
|
+
# -----------------------------------
|
|
30
|
+
# Rules (generation, branch, cousins)
|
|
31
|
+
# -----------------------------------
|
|
32
|
+
|
|
33
|
+
# Root generation
|
|
34
|
+
{ } => { :Adam :generation 0 } .
|
|
35
|
+
|
|
36
|
+
# Generation propagation: child.gen = parent.gen + 1
|
|
37
|
+
{
|
|
38
|
+
?P :parentOf ?C .
|
|
39
|
+
?P :generation ?G .
|
|
40
|
+
(?G 1) math:sum ?G1 .
|
|
41
|
+
} => {
|
|
42
|
+
?C :generation ?G1 .
|
|
43
|
+
} .
|
|
44
|
+
|
|
45
|
+
# Branch propagation: child.branch = parent.branch
|
|
46
|
+
{
|
|
47
|
+
?P :parentOf ?C .
|
|
48
|
+
?P :branch ?B .
|
|
49
|
+
} => {
|
|
50
|
+
?C :branch ?B .
|
|
51
|
+
} .
|
|
52
|
+
|
|
53
|
+
# Cousins: same generation, different branch
|
|
54
|
+
{
|
|
55
|
+
?X :generation ?G .
|
|
56
|
+
?Y :generation ?G .
|
|
57
|
+
?X :branch ?BX .
|
|
58
|
+
?Y :branch ?BY .
|
|
59
|
+
?BX :differentFrom ?BY .
|
|
60
|
+
} => {
|
|
61
|
+
?X :cousin ?Y .
|
|
62
|
+
} .
|
|
63
|
+
|
package/examples/gps.n3
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# ------------------------------
|
|
2
|
+
# Goal driven Parallel Sequences
|
|
3
|
+
# ------------------------------
|
|
4
|
+
#
|
|
5
|
+
# See https://www.sciencedirect.com/science/article/pii/S1532046421000794
|
|
6
|
+
# and https://github.com/hongsun502/wstLogic/tree/master
|
|
7
|
+
|
|
8
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
9
|
+
@prefix list: <http://www.w3.org/2000/10/swap/list#>.
|
|
10
|
+
@prefix gps: <https://eyereasoner.github.io/eye/reasoning/gps/gps-schema#>.
|
|
11
|
+
@prefix : <https://eyereasoner.github.io/eye/reasoning#>.
|
|
12
|
+
|
|
13
|
+
# ---------------------
|
|
14
|
+
# Data (a small sample)
|
|
15
|
+
# ---------------------
|
|
16
|
+
|
|
17
|
+
# current state
|
|
18
|
+
:i1 :location :Gent.
|
|
19
|
+
|
|
20
|
+
# map of Belgium
|
|
21
|
+
(:Gent :Brugge :drive_gent_brugge 1500.0 0.006 0.96 0.99) :edge true .
|
|
22
|
+
(:Gent :Kortrijk :drive_gent_kortrijk 1600.0 0.007 0.96 0.99) :edge true .
|
|
23
|
+
(:Kortrijk :Brugge :drive_kortrijk_brugge 1600.0 0.007 0.96 0.99) :edge true .
|
|
24
|
+
(:Brugge :Oostende :drive_brugge_oostende 900.0 0.004 0.98 1.0) :edge true .
|
|
25
|
+
|
|
26
|
+
# ----------------
|
|
27
|
+
# Path computation
|
|
28
|
+
# ----------------
|
|
29
|
+
|
|
30
|
+
# Base: one edge is a path
|
|
31
|
+
{
|
|
32
|
+
(?From ?To (?Act) ?Dur ?Cost ?Belief ?Comfort) :path true.
|
|
33
|
+
}
|
|
34
|
+
<=
|
|
35
|
+
{
|
|
36
|
+
(?From ?To ?Act ?Dur ?Cost ?Belief ?Comfort) :edge true.
|
|
37
|
+
}.
|
|
38
|
+
|
|
39
|
+
# Recursive: edge + path => path, aggregate weights, concatenate action list
|
|
40
|
+
{
|
|
41
|
+
(?From ?To ?Acts ?Dur ?Cost ?Belief ?Comfort) :path true.
|
|
42
|
+
}
|
|
43
|
+
<=
|
|
44
|
+
{
|
|
45
|
+
(?From ?Mid ?Act ?Dur1 ?Cost1 ?Bel1 ?Comf1) :edge true.
|
|
46
|
+
(?Mid ?To ?RestActs ?Dur2 ?Cost2 ?Bel2 ?Comf2) :path true.
|
|
47
|
+
|
|
48
|
+
((?Act) ?RestActs) list:append ?Acts.
|
|
49
|
+
|
|
50
|
+
(?Dur1 ?Dur2) math:sum ?Dur.
|
|
51
|
+
(?Cost1 ?Cost2) math:sum ?Cost.
|
|
52
|
+
(?Bel1 ?Bel2) math:product ?Belief.
|
|
53
|
+
(?Comf1 ?Comf2) math:product ?Comfort.
|
|
54
|
+
}.
|
|
55
|
+
|
|
56
|
+
# -------------------------
|
|
57
|
+
# Query: only paths to goal
|
|
58
|
+
# -------------------------
|
|
59
|
+
|
|
60
|
+
{
|
|
61
|
+
:i1 :location ?Start.
|
|
62
|
+
(?Start :Oostende ?Acts ?Dur ?Cost ?Bel ?Comf) :path true.
|
|
63
|
+
}
|
|
64
|
+
=>
|
|
65
|
+
{
|
|
66
|
+
:i1 gps:path (?Acts ?Dur ?Cost ?Bel ?Comf).
|
|
67
|
+
}.
|
|
68
|
+
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# ------------
|
|
2
|
+
# Light eaters
|
|
3
|
+
# ------------
|
|
4
|
+
|
|
5
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
6
|
+
@prefix : <http://example.org/light-eaters#>.
|
|
7
|
+
|
|
8
|
+
# ------------------------------------------------------------
|
|
9
|
+
# Plants as "light eaters":
|
|
10
|
+
# convert daily light exposure into stored energy (photosynthesis),
|
|
11
|
+
# then decide whether they thrive or go hungry under their conditions.
|
|
12
|
+
# ------------------------------------------------------------
|
|
13
|
+
|
|
14
|
+
# One day with a fixed amount of usable light (hours)
|
|
15
|
+
:Today :lightHours 10.0.
|
|
16
|
+
|
|
17
|
+
# Two habitats with different light intensities (arbitrary units/hour)
|
|
18
|
+
:Meadow :lightIntensity 100.0.
|
|
19
|
+
:Forest :lightIntensity 20.0.
|
|
20
|
+
|
|
21
|
+
# Organisms
|
|
22
|
+
:Sunflower a :Plant; :location :Meadow; :chlorophyll true; :efficiency 0.25; :maintenance 150.0.
|
|
23
|
+
:Fern a :Plant; :location :Forest; :chlorophyll true; :efficiency 0.25; :maintenance 150.0.
|
|
24
|
+
:Mushroom a :Fungus; :location :Forest; :chlorophyll false; :maintenance 150.0.
|
|
25
|
+
|
|
26
|
+
# ------------------------------------------------------------
|
|
27
|
+
# Rules
|
|
28
|
+
# ------------------------------------------------------------
|
|
29
|
+
|
|
30
|
+
# (1) Daily light energy available at each place:
|
|
31
|
+
# E_place = lightIntensity * lightHours
|
|
32
|
+
{
|
|
33
|
+
:Today :lightHours ?H.
|
|
34
|
+
?Place :lightIntensity ?I.
|
|
35
|
+
(?I ?H) math:product ?E.
|
|
36
|
+
}
|
|
37
|
+
=>
|
|
38
|
+
{
|
|
39
|
+
?Place :dailyLightEnergy ?E.
|
|
40
|
+
}.
|
|
41
|
+
|
|
42
|
+
# (2) Stored energy for each plant:
|
|
43
|
+
# stored = E_place * efficiency
|
|
44
|
+
{
|
|
45
|
+
?Plant a :Plant.
|
|
46
|
+
?Plant :location ?Place.
|
|
47
|
+
?Place :dailyLightEnergy ?E.
|
|
48
|
+
?Plant :efficiency ?Eff.
|
|
49
|
+
(?E ?Eff) math:product ?Stored.
|
|
50
|
+
}
|
|
51
|
+
=>
|
|
52
|
+
{
|
|
53
|
+
?Plant :storedEnergy ?Stored.
|
|
54
|
+
}.
|
|
55
|
+
|
|
56
|
+
# (3) Net energy after maintenance:
|
|
57
|
+
# net = stored - maintenance
|
|
58
|
+
{
|
|
59
|
+
?Org :storedEnergy ?Stored.
|
|
60
|
+
?Org :maintenance ?Maint.
|
|
61
|
+
(?Stored ?Maint) math:difference ?Net.
|
|
62
|
+
}
|
|
63
|
+
=>
|
|
64
|
+
{
|
|
65
|
+
?Org :netEnergy ?Net.
|
|
66
|
+
}.
|
|
67
|
+
|
|
68
|
+
# (4) "Light eater" (photosynthesizer) classification:
|
|
69
|
+
# must be a Plant, must have chlorophyll, and must have positive stored energy
|
|
70
|
+
{
|
|
71
|
+
?Plant a :Plant.
|
|
72
|
+
?Plant :chlorophyll true.
|
|
73
|
+
?Plant :storedEnergy ?Stored.
|
|
74
|
+
(?Stored 0.0) math:greaterThan true.
|
|
75
|
+
}
|
|
76
|
+
=>
|
|
77
|
+
{
|
|
78
|
+
?Plant :canPhotosynthesize true.
|
|
79
|
+
?Plant :lightEater true.
|
|
80
|
+
}.
|
|
81
|
+
|
|
82
|
+
# Non-photosynthesizers (example: fungi)
|
|
83
|
+
{
|
|
84
|
+
?X a :Fungus.
|
|
85
|
+
}
|
|
86
|
+
=>
|
|
87
|
+
{
|
|
88
|
+
?X :lightEater false.
|
|
89
|
+
}.
|
|
90
|
+
|
|
91
|
+
# (5) Outcome: thriving vs hungry, based on netEnergy
|
|
92
|
+
{
|
|
93
|
+
?Org :netEnergy ?Net.
|
|
94
|
+
(?Net 0.0) math:greaterThan true.
|
|
95
|
+
}
|
|
96
|
+
=>
|
|
97
|
+
{
|
|
98
|
+
?Org :thriving true.
|
|
99
|
+
}.
|
|
100
|
+
|
|
101
|
+
{
|
|
102
|
+
?Org :netEnergy ?Net.
|
|
103
|
+
(?Net 0.0) math:notGreaterThan true.
|
|
104
|
+
}
|
|
105
|
+
=>
|
|
106
|
+
{
|
|
107
|
+
?Org :hungry true.
|
|
108
|
+
}.
|
|
109
|
+
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# ----------
|
|
2
|
+
# ODRL trust
|
|
3
|
+
# ----------
|
|
4
|
+
|
|
5
|
+
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
6
|
+
@prefix odrl: <http://www.w3.org/ns/odrl/2/>.
|
|
7
|
+
@prefix dct: <http://purl.org/dc/terms/>.
|
|
8
|
+
@prefix : <http://example.org/odrl-trust#>.
|
|
9
|
+
|
|
10
|
+
# ------------------
|
|
11
|
+
# Trust model (0..1)
|
|
12
|
+
# ------------------
|
|
13
|
+
|
|
14
|
+
:Gov :trust 0.95.
|
|
15
|
+
:Partner :trust 0.70.
|
|
16
|
+
:RandomBlog :trust 0.30.
|
|
17
|
+
|
|
18
|
+
# ---------------------------
|
|
19
|
+
# A request we want to decide
|
|
20
|
+
# ---------------------------
|
|
21
|
+
|
|
22
|
+
:req1 a :Request;
|
|
23
|
+
odrl:assignee :Alice;
|
|
24
|
+
odrl:target :Doc1;
|
|
25
|
+
odrl:action odrl:read.
|
|
26
|
+
|
|
27
|
+
# -------------
|
|
28
|
+
# ODRL Policies
|
|
29
|
+
# -------------
|
|
30
|
+
|
|
31
|
+
# High-trust permission from Gov (trusted enough)
|
|
32
|
+
:PolGov a odrl:Policy;
|
|
33
|
+
dct:creator :Gov;
|
|
34
|
+
odrl:permission :PermGov.
|
|
35
|
+
|
|
36
|
+
:PermGov a odrl:Permission;
|
|
37
|
+
odrl:assignee :Alice;
|
|
38
|
+
odrl:target :Doc1;
|
|
39
|
+
odrl:action odrl:read;
|
|
40
|
+
odrl:constraint :CMinGov.
|
|
41
|
+
|
|
42
|
+
:CMinGov
|
|
43
|
+
odrl:leftOperand :issuerTrust;
|
|
44
|
+
odrl:operator odrl:gteq;
|
|
45
|
+
odrl:rightOperand 0.80.
|
|
46
|
+
|
|
47
|
+
# Medium-trust prohibition from Partner (also applies, but lower trust)
|
|
48
|
+
:PolPartner a odrl:Policy;
|
|
49
|
+
dct:creator :Partner;
|
|
50
|
+
odrl:prohibition :ProhPartner.
|
|
51
|
+
|
|
52
|
+
:ProhPartner a odrl:Prohibition;
|
|
53
|
+
odrl:assignee :Alice;
|
|
54
|
+
odrl:target :Doc1;
|
|
55
|
+
odrl:action odrl:read;
|
|
56
|
+
odrl:constraint :CMinPartner.
|
|
57
|
+
|
|
58
|
+
:CMinPartner
|
|
59
|
+
odrl:leftOperand :issuerTrust;
|
|
60
|
+
odrl:operator odrl:gteq;
|
|
61
|
+
odrl:rightOperand 0.60.
|
|
62
|
+
|
|
63
|
+
# Low-trust prohibition from RandomBlog (does NOT apply due to min trust)
|
|
64
|
+
:PolBlog a odrl:Policy;
|
|
65
|
+
dct:creator :RandomBlog;
|
|
66
|
+
odrl:prohibition :ProhBlog.
|
|
67
|
+
|
|
68
|
+
:ProhBlog a odrl:Prohibition;
|
|
69
|
+
odrl:assignee :Alice;
|
|
70
|
+
odrl:target :Doc1;
|
|
71
|
+
odrl:action odrl:read;
|
|
72
|
+
odrl:constraint :CMinBlog.
|
|
73
|
+
|
|
74
|
+
:CMinBlog
|
|
75
|
+
odrl:leftOperand :issuerTrust;
|
|
76
|
+
odrl:operator odrl:gteq;
|
|
77
|
+
odrl:rightOperand 0.50.
|
|
78
|
+
|
|
79
|
+
# --------------------------------
|
|
80
|
+
# Minimal "ODRL + trust" evaluator
|
|
81
|
+
# --------------------------------
|
|
82
|
+
|
|
83
|
+
# Candidate PERMIT for a request, scored by issuer trust, only if trust >= minTrust
|
|
84
|
+
{
|
|
85
|
+
(?Req odrl:permit ?Score) :cand true.
|
|
86
|
+
}
|
|
87
|
+
<=
|
|
88
|
+
{
|
|
89
|
+
?Req odrl:assignee ?A; odrl:target ?T; odrl:action ?Act.
|
|
90
|
+
|
|
91
|
+
?Pol a odrl:Policy; dct:creator ?Iss; odrl:permission ?Perm.
|
|
92
|
+
?Perm odrl:assignee ?A; odrl:target ?T; odrl:action ?Act.
|
|
93
|
+
|
|
94
|
+
?Perm odrl:constraint ?C.
|
|
95
|
+
?C odrl:leftOperand :issuerTrust;
|
|
96
|
+
odrl:operator odrl:gteq;
|
|
97
|
+
odrl:rightOperand ?Min.
|
|
98
|
+
|
|
99
|
+
?Iss :trust ?Score.
|
|
100
|
+
(?Score ?Min) math:notLessThan true.
|
|
101
|
+
}.
|
|
102
|
+
|
|
103
|
+
# Candidate PROHIBIT for a request, scored by issuer trust, only if trust >= minTrust
|
|
104
|
+
{
|
|
105
|
+
(?Req odrl:prohibit ?Score) :cand true.
|
|
106
|
+
}
|
|
107
|
+
<=
|
|
108
|
+
{
|
|
109
|
+
?Req odrl:assignee ?A; odrl:target ?T; odrl:action ?Act.
|
|
110
|
+
|
|
111
|
+
?Pol a odrl:Policy; dct:creator ?Iss; odrl:prohibition ?Proh.
|
|
112
|
+
?Proh odrl:assignee ?A; odrl:target ?T; odrl:action ?Act.
|
|
113
|
+
|
|
114
|
+
?Proh odrl:constraint ?C.
|
|
115
|
+
?C odrl:leftOperand :issuerTrust;
|
|
116
|
+
odrl:operator odrl:gteq;
|
|
117
|
+
odrl:rightOperand ?Min.
|
|
118
|
+
|
|
119
|
+
?Iss :trust ?Score.
|
|
120
|
+
(?Score ?Min) math:notLessThan true.
|
|
121
|
+
}.
|
|
122
|
+
|
|
123
|
+
# Decide: permit wins if its score is greater than prohibit score
|
|
124
|
+
{
|
|
125
|
+
(:req1 odrl:permit ?Sp) :cand true.
|
|
126
|
+
(:req1 odrl:prohibit ?Sd) :cand true.
|
|
127
|
+
(?Sp ?Sd) math:greaterThan true.
|
|
128
|
+
}
|
|
129
|
+
=>
|
|
130
|
+
{
|
|
131
|
+
:req1 :decision odrl:permit.
|
|
132
|
+
:req1 :confidence ?Sp.
|
|
133
|
+
}.
|
|
134
|
+
|
|
135
|
+
# Decide: otherwise (tie or prohibit higher), prohibit wins
|
|
136
|
+
{
|
|
137
|
+
(:req1 odrl:permit ?Sp) :cand true.
|
|
138
|
+
(:req1 odrl:prohibit ?Sd) :cand true.
|
|
139
|
+
(?Sd ?Sp) math:notLessThan true.
|
|
140
|
+
}
|
|
141
|
+
=>
|
|
142
|
+
{
|
|
143
|
+
:req1 :decision odrl:prohibit.
|
|
144
|
+
:req1 :confidence ?Sd.
|
|
145
|
+
}.
|
|
146
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
@prefix : <http://example.org/expression-eval#> .
|
|
2
|
+
|
|
3
|
+
# ----------------------------------------------------------------------
|
|
4
|
+
# Proof for derived triple:
|
|
5
|
+
# :Root :result 12 .
|
|
6
|
+
# It holds because the following instance of the rule body is provable:
|
|
7
|
+
# :Root :expr :eAdd .
|
|
8
|
+
# :eAdd :value 12 .
|
|
9
|
+
# via the schematic forward rule:
|
|
10
|
+
# {
|
|
11
|
+
# :Root :expr ?E .
|
|
12
|
+
# ?E :value ?V .
|
|
13
|
+
# } => {
|
|
14
|
+
# :Root :result ?V .
|
|
15
|
+
# } .
|
|
16
|
+
# with substitution (on rule variables):
|
|
17
|
+
# ?E = :eAdd
|
|
18
|
+
# ?V = 12
|
|
19
|
+
# Therefore the derived triple above is entailed by the rules and facts.
|
|
20
|
+
# ----------------------------------------------------------------------
|
|
21
|
+
|
|
22
|
+
:Root :result 12 .
|
|
23
|
+
|