Skip to content

Commit

Permalink
using explicit rule:vars in rdfreasoning
Browse files Browse the repository at this point in the history
  • Loading branch information
josd committed Nov 24, 2023
1 parent 4eb5eed commit 3951064
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 0 deletions.
119 changes: 119 additions & 0 deletions rdfreasoning/gps/gps.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@

# find paths in the state space from initial state to goal state within limits
[] a rule:BackwardRule;
rule:vars (
_:SCOPE
_:Goal
_:Path
_:Duration
_:Cost
_:Belief
_:Comfort
_:MaxDuration
_:MaxCost
_:MinBelief
_:MinComfort
);
rule:conclusion (
(_:SCOPE gps:findpath (_:Goal _:Path _:Duration _:Cost _:Belief _:Comfort
(_:MaxDuration _:MaxCost _:MinBelief _:MinComfort)))
Expand All @@ -17,6 +30,20 @@
).

[] a rule:BackwardRule;
rule:vars (
_:SCOPE
_:Goal
_:Path
_:Duration
_:Cost
_:Belief
_:Comfort
_:MaxDuration
_:MaxCost
_:MinBelief
_:MinComfort
_:MaxStagecount
);
rule:conclusion (
(_:SCOPE gps:findpath (_:Goal _:Path _:Duration _:Cost _:Belief _:Comfort
(_:MaxDuration _:MaxCost _:MinBelief _:MinComfort _:MaxStagecount)))
Expand All @@ -27,6 +54,21 @@
).

[] a rule:BackwardRule;
rule:vars (
_:SCOPE
_:Maps
_:Goal
_:Path
_:Duration
_:Cost
_:Belief
_:Comfort
_:MaxDuration
_:MaxCost
_:MinBelief
_:MinComfort
_:MaxStagecount
);
rule:conclusion (
(_:SCOPE gps:findpaths (_:Maps _:Goal _:Path _:Duration _:Cost _:Belief _:Comfort _:Path _:Duration _:Cost _:Belief _:Comfort
(_:MaxDuration _:MaxCost _:MinBelief _:MinComfort _:MaxStagecount)))
Expand All @@ -36,6 +78,42 @@
).

[] a rule:BackwardRule;
rule:vars (
_:SCOPE
_:Maps_s
_:Goal
_:Path_s
_:Duration_s
_:Cost_s
_:Belief_s
_:Comfort_s
_:Path
_:Duration
_:Cost
_:Belief
_:Comfort
_:MaxDuration
_:MaxCost
_:MinBelief
_:MinComfort
_:MaxStagecount
_:Map
_:From
_:Transition
_:To
_:Action
_:Duration_n
_:Cost_n
_:Belief_n
_:Comfort_n
_:Maps_t
_:Stagecount
_:Duration_t
_:Cost_t
_:Belief_t
_:Comfort_t
_:Path_t
);
rule:conclusion (
(_:SCOPE gps:findpaths (_:Maps_s _:Goal _:Path_s _:Duration_s _:Cost_s _:Belief_s _:Comfort_s _:Path _:Duration _:Cost _:Belief _:Comfort
(_:MaxDuration _:MaxCost _:MinBelief _:MinComfort _:MaxStagecount)))
Expand All @@ -61,12 +139,22 @@

# counting the number of stages (a stage is a sequence of steps in the same map)
[] a rule:BackwardRule;
rule:vars ();
rule:conclusion (
(() gps:stagecount 1)
);
rule:premise ().

[] a rule:BackwardRule;
rule:vars (
_:A
_:B
_:C
_:D
_:E
_:F
_:G
);
rule:conclusion (
(_:A gps:stagecount _:B)
);
Expand All @@ -79,6 +167,12 @@
).

[] a rule:BackwardRule;
rule:vars (
_:A
_:B
_:C
_:D
);
rule:conclusion (
(_:A gps:stagecount _:B)
);
Expand All @@ -92,6 +186,10 @@

# map of Belgium
[] a rule:BackwardRule;
rule:vars (
_:S
_:L
);
rule:conclusion (
(:map-BE gps:description (((_:S :location :Gent)) () ((_:S :location :Brugge)) :drive_gent_brugge 1500.0 0.006 0.96 0.99))
);
Expand All @@ -100,6 +198,10 @@
).

[] a rule:BackwardRule;
rule:vars (
_:S
_:L
);
rule:conclusion (
(:map-BE gps:description (((_:S :location :Gent)) () ((_:S :location :Kortrijk)) :drive_gent_kortrijk 1600.0 0.007 0.96 0.99))
);
Expand All @@ -108,6 +210,10 @@
).

[] a rule:BackwardRule;
rule:vars (
_:S
_:L
);
rule:conclusion (
(:map-BE gps:description (((_:S :location :Kortrijk)) () ((_:S :location :Brugge)) :drive_kortrijk_brugge 1600.0 0.007 0.96 0.99))
);
Expand All @@ -116,6 +222,10 @@
).

[] a rule:BackwardRule;
rule:vars (
_:S
_:L
);
rule:conclusion (
(:map-BE gps:description (((_:S :location :Brugge)) () ((_:S :location :Oostende)) :drive_brugge_oostende 900.0 0.004 0.98 1.0))
);
Expand All @@ -125,6 +235,15 @@

# query
[] a rule:QueryRule;
rule:vars (
_:SCOPE
_:SUBJECT
_:PATH
_:DURATION
_:COST
_:BELIEF
_:COMFORT
);
rule:premise (
(_:SCOPE gps:findpath (((_:SUBJECT :location :Oostende)) _:PATH _:DURATION _:COST _:BELIEF _:COMFORT (5000.0 5.0 0.2 0.4 1)))
);
Expand Down
5 changes: 5 additions & 0 deletions rdfreasoning/gps/out/gps.ttl.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@prefix : <http://example.org/ns#>.
@prefix gps: <http://eyereasoner.github.io/eye/reasoning/gps/gps-schema#>.

:i1 gps:path ((:drive_gent_brugge :drive_brugge_oostende) 2400.0 0.01 0.9408 0.99).
:i1 gps:path ((:drive_gent_kortrijk :drive_kortrijk_brugge :drive_brugge_oostende) 4100.0 0.018000000000000002 0.903168 0.9801).
4 changes: 4 additions & 0 deletions rdfreasoning/unpack/out/unpack.ttl.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@prefix : <http://example.org/ns#>.

:a :b _:e_c_1
:u :v _:e_w_1.
40 changes: 40 additions & 0 deletions rdfreasoning/unpack/unpack.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,21 @@ _:b1 :data (

# the logic for unpack using backward rules
[] a rule:BackwardRule;
rule:vars ();
rule:conclusion (
(() :unpackLott ())
);
rule:premise ().

[] a rule:BackwardRule;
rule:vars (
_:g
_:h
_:f
_:r
_:a
_:b
);
rule:conclusion (
(_:g :unpackLott _:h)
);
Expand All @@ -48,6 +57,14 @@ _:b1 :data (
).

[] a rule:BackwardRule;
rule:vars (
_:b
_:p
_:f
_:a
_:c
_:t
);
rule:conclusion (
((_:b :package _:p) :unpack _:f)
);
Expand All @@ -59,6 +76,13 @@ _:b1 :data (
).

[] a rule:BackwardRule;
rule:vars (
_:b
_:p
_:a
_:c
_:t
);
rule:conclusion (
((_:b :package _:p) :unpack ())
);
Expand All @@ -69,12 +93,23 @@ _:b1 :data (
).

[] a rule:BackwardRule;
rule:vars (
_:b
_:p
);
rule:conclusion (
((_:b :tag _:p) :unpack ())
);
rule:premise ().

[] a rule:BackwardRule;
rule:vars (
_:g
_:a
_:p
_:b
_:q
);
rule:conclusion (
(_:g :unpack (_:g))
);
Expand All @@ -85,6 +120,11 @@ _:b1 :data (

# unpack the triples that are usable in the future
[] a rule:QueryRule;
rule:vars (
_:b
_:g
_:m
);
rule:premise (
(_:b :data _:g)
(_:g :unpackLott _:m)
Expand Down

0 comments on commit 3951064

Please sign in to comment.