Debian Codegraph @

reasoning/blogic/input/gps.n3

raw
1 # Goal driven Parallel Sequences -- Jos De Roo
2
3 # Inspired by https://www.cs.cmu.edu/~fp/courses/15816-s12/lectures/01-inference.pdf
4
5 # "In linear logic we are instead concerned with the change of truth with a
6 # change of state. We model this in a very simple way: when an inference rule
7 # is applied we consume the propositions used as premises and produce the
8 # propositions in the conclusions, thereby effecting an overall change in state."
9
10 @prefix math: <http://www.w3.org/2000/10/swap/math#>.
11 @prefix list: <http://www.w3.org/2000/10/swap/list#>.
12 @prefix log: <http://www.w3.org/2000/10/swap/log#>.
13 @prefix gps: <http://eyereasoner.github.io/eye/reasoning/gps/gps-schema#>.
14 @prefix : <urn:example:>.
15
16 # declare components
17 gps:findpath a log:Component.
18 gps:findpaths a log:Component.
19 gps:stagecount a log:Component.
20
21 # find paths in the state space from initial state to goal state within limits
22 (_:SCOPE _:Goal _:Path _:Duration _:Cost _:Belief _:Comfort _:MaxDuration _:MaxCost _:MinBelief _:MinComfort) log:onNegativeSurface {
23 () log:onNegativeSurface {
24 _:SCOPE gps:findpath (_:Goal _:Path _:Duration _:Cost _:Belief _:Comfort (_:MaxDuration _:MaxCost _:MinBelief _:MinComfort)).
25 }.
26 _:SCOPE gps:findpaths (() _:Goal () 0.0 0.0 1.0 1.0 _:Path _:Duration _:Cost _:Belief _:Comfort
27 (_:MaxDuration _:MaxCost _:MinBelief _:MinComfort 1)).
28 }.
29
30 (_:SCOPE _:Goal _:Path _:Duration _:Cost _:Belief _:Comfort _:MaxDuration _:MaxCost _:MinBelief _:MinComfort _:MaxStagecount) log:onNegativeSurface {
31 () log:onNegativeSurface {
32 _:SCOPE gps:findpath (_:Goal _:Path _:Duration _:Cost _:Belief _:Comfort (_:MaxDuration _:MaxCost _:MinBelief _:MinComfort _:MaxStagecount)).
33 }.
34 _:SCOPE gps:findpaths (() _:Goal () 0.0 0.0 1.0 1.0 _:Path _:Duration _:Cost _:Belief _:Comfort
35 (_:MaxDuration _:MaxCost _:MinBelief _:MinComfort _:MaxStagecount)).
36 }.
37
38 (_:SCOPE _:Maps _:Goal _:Path _:Duration _:Cost _:Belief _:Comfort _:MaxDuration _:MaxCost _:MinBelief _:MinComfort _:MaxStagecount) log:onNegativeSurface {
39 () log:onNegativeSurface {
40 _:SCOPE gps:findpaths (_:Maps _:Goal _:Path _:Duration _:Cost _:Belief _:Comfort _:Path _:Duration _:Cost _:Belief _:Comfort
41 (_:MaxDuration _:MaxCost _:MinBelief _:MinComfort _:MaxStagecount)).
42 }.
43 _:Goal log:callWithCleanup true.
44 }.
45
46 (_:SCOPE _:Maps_s _:Goal _:Path_s _:Duration_s _:Cost_s _:Belief_s _:Comfort_s _:Path
47 _:Duration _:Cost _:Belief _:Comfort _:MaxDuration _:MaxCost _:MinBelief _:MinComfort _:MaxStagecount
48 _:From _:Transition _:To _:Action _:Duration_n _:Cost_n _:Belief_n _:Comfort_n _:Map _:Maps_t _:Stagecount
49 _:Duration_t _:Cost_t _:Belief_t _:Comfort_t _:Path_t) log:onNegativeSurface {
50 () log:onNegativeSurface {
51 _:SCOPE gps:findpaths (_:Maps_s _:Goal _:Path_s _:Duration_s _:Cost_s _:Belief_s _:Comfort_s _:Path _:Duration _:Cost _:Belief _:Comfort
52 (_:MaxDuration _:MaxCost _:MinBelief _:MinComfort _:MaxStagecount)).
53 }.
54 _:Map gps:description (_:From _:Transition _:To _:Action _:Duration_n _:Cost_n _:Belief_n _:Comfort_n).
55 (_:Maps_s (_:Map)) list:append _:Maps_t.
56 _:Maps_t gps:stagecount _:Stagecount.
57 _:Stagecount math:notGreaterThan _:MaxStagecount.
58 (_:Duration_s _:Duration_n) math:sum _:Duration_t.
59 _:Duration_t math:notGreaterThan _:MaxDuration.
60 (_:Cost_s _:Cost_n) math:sum _:Cost_t.
61 _:Cost_t math:notGreaterThan _:MaxCost.
62 (_:Belief_s _:Belief_n) math:product _:Belief_t.
63 _:Belief_t math:notLessThan _:MinBelief.
64 (_:Comfort_s _:Comfort_n) math:product _:Comfort_t.
65 _:Comfort_t math:notLessThan _:MinComfort.
66 (_:Path_s (_:Action)) list:append _:Path_t.
67 _:From log:becomes _:To.
68 {_:SCOPE gps:findpaths (_:Maps_t _:Goal _:Path_t _:Duration_t _:Cost_t _:Belief_t _:Comfort_t _:Path _:Duration _:Cost _:Belief _:Comfort
69 (_:MaxDuration _:MaxCost _:MinBelief _:MinComfort _:MaxStagecount))} log:callWithCleanup {_:To log:becomes _:From}.
70 }.
71
72 # counting the number of stages (a stage is a sequence of steps in the same map)
73 () log:onNegativeSurface {
74 () log:onNegativeSurface {
75 () gps:stagecount 1.
76 }.
77 }.
78
79 (_:A _:B _:C _:D _:E _:F _:G) log:onNegativeSurface {
80 () log:onNegativeSurface {
81 _:A gps:stagecount _:B.
82 }.
83 _:A list:firstRest (_:C _:D).
84 _:D list:firstRest (_:E _:F).
85 _:C log:notEqualTo _:E.
86 _:D gps:stagecount _:G.
87 (_:G 1) math:sum _:B.
88 }.
89
90 (_:A _:B _:C _:D) log:onNegativeSurface {
91 () log:onNegativeSurface {
92 _:A gps:stagecount _:B.
93 }.
94 _:A list:firstRest (_:C _:D).
95 _:D gps:stagecount _:B.
96 }.
97
98 # current state
99 :i1 :location :Gent.
100
101 # map of Belgium
102 (_:S _:L) log:onNegativeSurface {
103 () log:onNegativeSurface {
104 :map-BE gps:description ({_:S :location :Gent} true {_:S :location :Brugge} :drive_gent_brugge 1500.0 0.006 0.96 0.99).
105 }.
106 _:S :location _:L.
107 }.
108
109 (_:S _:L) log:onNegativeSurface {
110 () log:onNegativeSurface {
111 :map-BE gps:description ({_:S :location :Gent} true {_:S :location :Kortrijk} :drive_gent_kortrijk 1600.0 0.007 0.96 0.99).
112 }.
113 _:S :location _:L.
114 }.
115
116 (_:S _:L) log:onNegativeSurface {
117 () log:onNegativeSurface {
118 :map-BE gps:description ({_:S :location :Kortrijk} true {_:S :location :Brugge} :drive_kortrijk_brugge 1600.0 0.007 0.96 0.99).
119 }.
120 _:S :location _:L.
121 }.
122
123 (_:S _:L) log:onNegativeSurface {
124 () log:onNegativeSurface {
125 :map-BE gps:description ({_:S :location :Brugge} true {_:S :location :Oostende} :drive_brugge_oostende 900.0 0.004 0.98 1.0).
126 }.
127 _:S :location _:L.
128 }.
129
130 # query
131 (_:SCOPE _:SUBJECT _:PATH _:DURATION _:COST _:BELIEF _:COMFORT) log:onNegativeSurface {
132 _:SCOPE gps:findpath ({_:SUBJECT :location :Oostende} _:PATH _:DURATION _:COST _:BELIEF _:COMFORT (5000.0 5.0 0.2 0.4 1)).
133 () log:onNegativeAnswerSurface {
134 _:SUBJECT gps:path (_:PATH _:DURATION _:COST _:BELIEF _:COMFORT).
135 }.
136 }.