-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNorm01
More file actions
158 lines (121 loc) · 4.56 KB
/
Norm01
File metadata and controls
158 lines (121 loc) · 4.56 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
NORM Norm01
ON ?e1
WHERE RestrictedTrafficAreaAccess(?e1) AND vehicle(?e1,?v) AND
owner(?v,?agent) AND atTime(?e1,?inst1) AND
inXSDDateTimeStamp(?inst1,?t1) AND ?t1.hour>7 a.m. AND ?t1.hour<7p.m
THEN
COMPUTE ?t_end.hour=?t1.hour+24
CREATE DeonticRelation(?dr01_n);TimeEvent(?tev_end_n);
Instant(?inst_end_n);
ASSERT isGenerated(?dr01_n,Norm01);activated(?dr01_n,?e1);
debtor(?dr01_n,?agent);end(?dr01_n,?tev_end_n);
atTime(?tev_end_n,?inst_end_n);
inXSDDateTimeStamp(?inst_end_n,?t_end);
ON ?e2 BEFORE ?tev_end_n
WHERE PayAction(?e2) AND reason(?e2,?e1) AND recipient(?e2,Milan)
AND price(?e2,6) AND priceCurrency(?e2,euro) AND actor(?e2,?agent).
THEN ASSERT fulfills(?agent,?dr01_n); fulfilled(?dr01_n,?e2)
ELSE ASSERT violates(?agent,?dr01_n); violated(?dr01_n,?tev_end_n)
[N01_ProductionRule1_ACTIVATE:
//the priority of the rule is the lowest
isSalience(0)
(?e1 rdf:type event:RestrictedTrafficAreaAccess)
(?e1 event:vehicle ?v)
(?v event:owner ?agent)
(?e1 event:atTime ?inst1)
(?inst1 time:inXSDDateTimeStamp ?t1)
//check that ?t1 is between 7am and 7pm
checkTime(?t1)
//check that ?t1 is elapsed
greaterThanNow(?t1)
addDeadline(?t1,"P1D"^^http://www.w3.org/2001/XMLSchema#duration,?t_end)
getCounter(?counter)
uriConcat(tnorm: dr01_ ?counter ?dr)
uriConcat(event: instCreationDr01_ ?counter ?instCreation)
uriConcat(event: tev_end_ ?counter ?tev_end_n)
uriConcat(event: inst_end_ ?counter ?inst_end_n)
noValue(tnorm:norm01 event:exceptionToNorm ?e1)
->
(?dr rdf:type event:DeonticRelation)
(?dr event:isGenerated event:norm01)
(?dr event:activated ?e1)
(?dr tnorm:debtor ?agent)
(?inst_end_n rdf:type time:Instant)
(?te_end_n rdf:type time:TimeEvent)
(?dr event:end ?tev_end_n)
(?tev_end_n event:atTime ?inst_end_n)
(?inst_end_n time:inXSDDateTimeStamp ?t_end)
//the creation time of the dr can be computed strating from ?e1
(?instCreation rdf:type time:Instant)
(?instCreation time:inXSDDateTimeStamp ?t1)
(?dr event:creationTime ?teCreation)
]
[N01_ProductionRule2_FULFILL:
isSalience(0)
(?dr rdf:type event:DeonticRelation)
(?dr event:creationTime ?teCreation)
(?teCreation time:inXSDDateTimeStamp ?tCreation)
(?dr event:end ?tev_end_n)
(?tev_end_n event:atTime ?inst_end_n)
(?inst_end_n time:inXSDDateTimeStamp ?t_end)
//this condition check that the production rule is applied only to Norm01
(?dr event:isGenerated event:norm01)
(?dr event:activated ?e1)
(?payment rdf:type event:Payment)
(?payment event:reason ?e1)
(?payment event:recipient event:Milan)
(?payment event:price 6)
(?payment event:priceCurrency event:euro)
(?payment event:actor ?agent)
(?dr tnorm:debtor ?agent)
(?payment event:atTime ?instPayment)
(?instPayment time:inXSDDateTimeStamp ?tPayment)
teGreaterThan(?tPayment ?tCreation)
teGreaterThan(?t_end ?tPayment)
greaterThanNow(?tPayment)
noValue(?dr event:exceptionToDR ?payment)
noValue(?dr event:violated)
noValue(?dr event:fulfilled)
->
(?agent event:fulfills ?dr)
(?dr event:fulfilled ?payment)
]
[N01_ProductionRule3_VIOLATE:
isSalience(0)
(?dr rdf:type event:DeonticRelation)
(?dr event:creationTime ?teCreation)
(?teCreation time:inXSDDateTimeStamp ?tCreation)
(?dr event:end ?tev_end_n)
(?tev_end_n event:atTime ?inst_end_n)
(?inst_end_n time:inXSDDateTimeStamp ?t_end)
(?dr event:isGenerated event:norm01)
(?dr event:activated ?e1)
(?dr tnorm:debtor ?agent)
(?payment rdf:type event:Payment)
(?payment event:reason ?e1)
(?payment event:recipient event:Milan)
(?payment event:price 6)
(?payment event:priceCurrency event:euro)
(?payment event:actor ?agent)
//t_end < now it means that t_end is elapsed
greaterThanNow(?t_end)
noValue(?dr event:exceptionToDR ?payment)
noValue(?dr event:violated)
noValue(?dr event:fulfilled)
->
(?agent event:violates ?dr)
(?dr event:violated ?tev_end_n)
]
[N01_ ProductionRule4_EXCEPTION01:
isSalience(1)
(?e1 rdf:type event:RestrictedTrafficAreaAccess)
(?e1 event:atTime ?inst1)
(?inst1 time:inXSDDateTimeStamp ?t1)
checkTime(?t1)
(?e1 event:hasVehicle ?vehicle)
(?vehicle rdf:type event:Ambulance)
noValue(event:norm01 event:exceptionToException ?e1)
greaterThanNow(?t1)
->
(event:norm01 event:exceptionToNorm ?e1)
]