-
Notifications
You must be signed in to change notification settings - Fork 0
/
alcq-system.maude
351 lines (255 loc) · 12.1 KB
/
alcq-system.maude
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
fmod SYNTAX is
inc NAT .
sorts AConcept Concept ARole Role .
subsort AConcept < Concept .
subsort ARole < Role .
ops ALL EXIST : Role Concept -> Concept .
ops CTRUE CFALSE : -> AConcept .
op _&_ : Concept Concept -> Concept [gather (e E) prec 31] .
op _|_ : Concept Concept -> Concept [gather (e E) prec 32] .
op ~_ : Concept -> Concept [prec 30] .
eq ~ CTRUE = CFALSE .
eq ~ CFALSE = CTRUE .
ops AT-MOST AT-LEAST : Nat Role Concept -> Concept .
op INV : Role -> Role .
var R : Role .
var C : Concept .
--- eq AT-LEAST(1, R, C) = EXIST(R, C) .
endfm
fmod LABEL is
inc SYNTAX .
sorts Label ELabel ALabel QLabel .
subsorts ELabel ALabel QLabel < Label .
ops gt lt : Nat Role -> QLabel .
op ex : Role -> ELabel .
op al : Role -> ALabel .
endfm
view Label from TRIV to LABEL is
sort Elt to Label .
endv
fmod LALC-SYNTAX is
inc LABEL .
inc LIST{Label} .
vars L1 L2 L : List{Label} .
vars R S : Role .
var C : Concept .
var T : Label .
var n : Nat .
sorts Expression LConcept FzConcept .
subsorts LConcept FzConcept < Expression .
op <_|_> : List{Label} Concept -> LConcept [ctor] .
op [_,_] : Nat LConcept -> FzConcept .
ops has-quant has-lt has-gt : List{Label} -> Bool .
ops has-al has-ex : List{Label} -> Bool .
ceq has-quant(T L) = true if (T :: QLabel) .
eq has-quant(T L) = has-quant(L) [owise] .
eq has-quant(nil) = false .
ceq has-lt(T L) = true if (T :: QLabel) /\ lt(n, R) := T .
eq has-lt(T L) = has-lt(L) [owise] .
eq has-lt(nil) = false .
ceq has-gt(T L) = true if (T :: QLabel) /\ gt(n, R) := T .
eq has-gt(T L) = has-gt(L) [owise] .
eq has-gt(nil) = false .
ceq has-ex(T L) = true if (T :: ELabel) .
eq has-ex(T L) = has-ex(L) [owise] .
eq has-ex(nil) = false .
ceq has-al(T L) = true if (T :: ALabel) .
eq has-al(T L) = has-al(L) [owise] .
eq has-al(nil) = false .
op neg : List{Label} -> List{Label} .
op neg-aux : List{Label} List{Label} -> List{Label} .
eq neg(L1) = neg-aux(L1, nil) .
eq neg-aux(L1 al(R), L2) = neg-aux(L1, ex(R) L2) .
eq neg-aux(L1 ex(R), L2) = neg-aux(L1, al(R) L2) .
eq neg-aux(nil, L2) = L2 .
endfm
view Expression from TRIV to LALC-SYNTAX is
sort Elt to Expression .
endv
fmod SEQUENT-CALCULUS is
inc LALC-SYNTAX .
inc SET{Expression} .
inc SET{Label} .
inc SET{Nat} .
inc NAT .
inc QID .
sort Sequent .
sorts Goal State Proof .
subsort Goal State < Proof .
op next : Nat -> State .
op goals : Set{Nat} -> State .
op [_from_by_is_] : Nat Nat Qid Sequent -> Goal [format (n d d d d d d d d d)] .
op nil : -> Proof [ctor] .
op __ : Proof Proof -> Proof [ctor comm assoc] .
op _|-_ : Set{Expression} Set{Expression} -> Sequent [ctor prec 122 gather(e e)] .
op _:_|-_:_ : Set{Expression} Set{Expression} Set{Expression} Set{Expression} -> Sequent [ctor prec 122 gather(e e e e)] .
endfm
mod LALCQ-SYSTEM is
inc SEQUENT-CALCULUS .
inc INT .
vars ALFA GAMMA : Set{Expression} .
vars X Y N M : Nat .
var XS : Set{Nat} .
vars A B C D : Concept .
vars R S : Role .
var E : Expression .
var AT : AConcept .
var Q : Qid .
vars L L1 L2 L3 L4 : List{Label} .
--- como lidar com regras nao deterministicas? m > n sss inc em um, controle de aplicacoes
rl [initial] :
[ X from Y by Q is ALFA, < nil | AT > |- < nil | AT >, GAMMA ] goals((X, XS)) =>
[ X from Y by Q is ALFA, < nil | AT > |- < nil | AT >, GAMMA ] goals((XS)) .
crl [initial] :
[ X from Y by Q is ALFA, < lt(n,R) L | A > |- < lt(m,R) L | A >, GAMMA ] goals((X, XS)) =>
[ X from Y by Q is ALFA, < lt(n,R) L | A > |- < lt(m,R) L | A >, GAMMA ] goals((XS))
if n <= m .
crl [initial] :
[ X from Y by Q is ALFA, < gt(n,R) L | A > |- < gt(m,R) L | A >, GAMMA ] goals((X, XS)) =>
[ X from Y by Q is ALFA, < gt(n,R) L | A > |- < gt(m,R) L | A >, GAMMA ] goals((XS))
if m <= n .
rl [weak-l] :
[ X from Y by Q is ALFA, E |- GAMMA ] next(N) goals((X, XS)) =>
[ X from Y by Q is ALFA, E |- GAMMA ] next(N + 1) goals((XS, N))
[ N from X by 'weak-l is ALFA |- GAMMA ] .
rl [weak-r] :
[ X from Y by Q is ALFA |- GAMMA, E ] next(N) goals((X, XS)) =>
[ X from Y by Q is ALFA |- GAMMA, E ] next(N + 1) goals((XS, N))
[ N from X by 'weak-r is ALFA |- GAMMA ] .
rl [forall-r] :
[ X from Y by Q is ALFA |- GAMMA, < L1 | ALL(R, A) > ] next(N) goals((X, XS)) =>
[ X from Y by Q is ALFA |- GAMMA, < L1 | ALL(R, A) > ] next(N + 1) goals((XS, N))
[ N from X by 'forall-r is ALFA |- GAMMA, < L1 al(R) | A > ] .
rl [forall-l] :
[ X from Y by Q is ALFA, < L1 | ALL(R, A) > |- GAMMA ] next(N) goals((X, XS)) =>
[ X from Y by Q is ALFA, < L1 | ALL(R, A) > |- GAMMA ] next(N + 1) goals((XS, N))
[ N from X by 'forall-l is ALFA, < L1 al(R) | A > |- GAMMA ] .
rl [exist-r] :
[ X from Y by Q is ALFA |- GAMMA, < L1 | EXIST(R, A) > ] next(N) goals((X, XS)) =>
[ X from Y by Q is ALFA |- GAMMA, < L1 | EXIST(R, A) > ] next(N + 1) goals((XS, N))
[ N from X by 'exist-r is ALFA |- GAMMA, < L1 ex(R) | A > ] .
rl [exist-l] :
[ X from Y by Q is ALFA, < L1 | EXIST(R, A) > |- GAMMA ] next(N) goals((X, XS)) =>
[ X from Y by Q is ALFA, < L1 | EXIST(R, A) > |- GAMMA ] next(N + 1) goals((XS, N))
[ N from X by 'exist-l is ALFA, < L1 ex(R) | A > |- GAMMA ] .
rl [least-l] :
[ X from Y by Q is ALFA, < L1 | AT-LEAST(M, R, A) > |- GAMMA ] next(N) goals((X, XS)) =>
[ X from Y by Q is ALFA, < L1 | AT-LEAST(M, R, A) > |- GAMMA ] next(N + 1) goals((XS, N))
[ N from X by 'least-l is ALFA, < L1 gt(M,R) | A > |- GAMMA ] .
rl [least-r] :
[ X from Y by Q is ALFA |- < L1 | AT-LEAST(M, R, A) >, GAMMA ] next(N) goals((X, XS)) =>
[ X from Y by Q is ALFA |- < L1 | AT-LEAST(M, R, A) >, GAMMA ] next(N + 1) goals((XS, N))
[ N from X by 'least-r is ALFA |- < L1 gt(M,R) | A >, GAMMA ] .
rl [most-l] :
[ X from Y by Q is ALFA, < L1 | AT-MOST(M, R, A) > |- GAMMA ] next(N) goals((X, XS)) =>
[ X from Y by Q is ALFA, < L1 | AT-MOST(M, R, A) > |- GAMMA ] next(N + 1) goals((XS, N))
[ N from X by 'most-l is ALFA, < L1 lt(M,R) | A > |- GAMMA ] .
rl [most-r] :
[ X from Y by Q is ALFA |- < L1 | AT-MOST(M, R, A) >, GAMMA ] next(N) goals((X, XS)) =>
[ X from Y by Q is ALFA |- < L1 | AT-MOST(M, R, A) >, GAMMA ] next(N + 1) goals((XS, N))
[ N from X by 'most-r is ALFA |- < L1 lt(M,R) | A >, GAMMA ] .
crl [neg-l] :
[ X from Y by Q is ALFA, < L1 | ~ A > |- GAMMA ] next(N) goals((X, XS)) =>
[ X from Y by Q is ALFA, < L1 | ~ A > |- GAMMA ] next(N + 1) goals((XS, N))
[ N from X by 'neg-l is ALFA |- GAMMA, < neg(L1) | A > ]
if not has-quant(L1) .
crl [neg-r] :
[ X from Y by Q is ALFA |- GAMMA, < L1 | ~ A > ] next(N) goals((X, XS)) =>
[ X from Y by Q is ALFA |- GAMMA, < L1 | ~ A > ] next(N + 1) goals((XS, N))
[ N from X by 'neg-r is ALFA, < neg(L1) | A > |- GAMMA ]
if not has-quant(L1) .
vars m n : Nat .
rl [quant-exist-l] :
[ X from Y by Q is ALFA, < ex(R) L1 | A > |- GAMMA ] next(N) goals((X, XS)) =>
[ X from Y by Q is ALFA, < ex(R) L1 | A > |- GAMMA ] next(N + 1) goals((XS, N))
[ N from X by 'quant-exist-l is ALFA, < gt(1,R) L1 | A > |- GAMMA ] .
--- or gt(n,R) where n >= 1
rl [quant-exist-r] :
[ X from Y by Q is ALFA |- < ex(R) L1 | A >, GAMMA ] next(N) goals((X, XS)) =>
[ X from Y by Q is ALFA |- < ex(R) L1 | A >, GAMMA ] next(N + 1) goals((XS, N))
[ N from X by 'quant-exist-r is ALFA |- < gt(1,R) L1 | A >, GAMMA ] .
crl [exist-quant-l] :
[ X from Y by Q is ALFA, < gt(n,R) L1 | A > |- GAMMA ] next(N) goals((X, XS)) =>
[ X from Y by Q is ALFA, < gt(n,R) L1 | A > |- GAMMA ] next(N + 1) goals((XS, N))
[ N from X by 'exist-quant-l is ALFA, < ex(R) L1 | A > |- GAMMA ]
if n >= 1 .
rl [exist-quant-r] :
[ X from Y by Q is ALFA |- < gt(1,R) L1 | A >, GAMMA ] next(N) goals((X, XS)) =>
[ X from Y by Q is ALFA |- < gt(1,R) L1 | A >, GAMMA ] next(N + 1) goals((XS, N))
[ N from X by 'exist-quant-r is ALFA |- < ex(R) L1 | A >, GAMMA ] .
crl [quant-gt-l] :
[ X from Y by Q is ALFA, < gt(m,R) L1 | A > |- GAMMA ] next(N) goals((X, XS)) =>
[ X from Y by Q is ALFA, < gt(m,R) L1 | A > |- GAMMA ] next(N + 1) goals((XS, N))
[ N from X by 'quant-qt-r is ALFA, < gt((m - 1), R) L1 | A > |- GAMMA ]
if m >= 1 .
rl [quant-gt-r] :
[ X from Y by Q is ALFA |- < gt(m,R) L1 | A >, GAMMA ] next(N) goals((X, XS)) =>
[ X from Y by Q is ALFA |- < gt(m,R) L1 | A >, GAMMA ] next(N + 1) goals((XS, N))
[ N from X by 'quant-qt-r is ALFA |- < gt((m + 1), R) L1 | A >, GAMMA ] .
rl [quant-lt-l] :
[ X from Y by Q is ALFA, < lt(m,R) L1 | A > |- GAMMA ] next(N) goals((X, XS)) =>
[ X from Y by Q is ALFA, < lt(m,R) L1 | A > |- GAMMA ] next(N + 1) goals((XS, N))
[ N from X by 'quant-lt-r is ALFA, < lt((m + 1), R) L1 | A > |- GAMMA ] .
crl [quant-lt-r] :
[ X from Y by Q is ALFA |- < lt(m,R) L1 | A >, GAMMA ] next(N) goals((X, XS)) =>
[ X from Y by Q is ALFA |- < lt(m,R) L1 | A >, GAMMA ] next(N + 1) goals((XS, N))
[ N from X by 'quant-lt-r is ALFA |- < lt((m - 1), R) L1 | A >, GAMMA ]
if m >= 1 .
crl [and-r] :
[ X from Y by Q is ALFA |- GAMMA, < L | A & B > ] next(N) goals((X, XS)) =>
[ X from Y by Q is ALFA |- GAMMA, < L | A & B > ] next(N + 2) goals((XS, N, N + 1))
[ N from X by 'and-r is ALFA |- GAMMA, < L | A > ]
[ N + 1 from X by 'and-r is ALFA |- GAMMA, < L | B > ]
if not has-ex(L) /\ not has-gt(L) .
crl [and-l] :
[ X from Y by Q is ALFA, < L | A & B > |- GAMMA ] next(N) goals((X, XS)) =>
[ X from Y by Q is ALFA, < L | A & B > |- GAMMA ] next(N + 1) goals((XS, N))
[ N from X by 'and-l is ALFA, < L | A >, < L | B > |- GAMMA ]
if not has-ex(L) /\ not has-lt(L) .
crl [or-l] :
[ X from Y by Q is ALFA, < L | (A | B) > |- GAMMA ] next(N) goals((X, XS)) =>
[ X from Y by Q is ALFA, < L | (A | B) > |- GAMMA ] next(N + 2) goals((XS, N, N + 1))
[ N from X by 'or-l is ALFA, < L | A > |- GAMMA ]
[ N + 1 from X by 'or-l is ALFA, < L | B > |- GAMMA ]
if not has-al(L) /\ not has-gt(L) .
crl [or-r] :
[ X from Y by Q is ALFA |- GAMMA, < L | (A | B) > ] next(N) goals((X, XS)) =>
[ X from Y by Q is ALFA |- GAMMA, < L | (A | B) > ] next(N + 1) goals((XS, N))
[ N from X by 'or-r is ALFA |- GAMMA, < L | A >, < L | B > ]
if not has-al(L) /\ not has-lt(L) .
op all-label : Set{Expression} Label -> Bool .
op remove-label : Set{Expression} Label Set{Expression} -> Set{Expression} .
vars ALFA' GAMMA' : Set{Expression} .
var LBL : Label .
eq all-label((< LBL L | A >, GAMMA), LBL) =
all-label(GAMMA, LBL) .
eq all-label(empty, LBL) = true .
eq all-label(GAMMA, LBL) = false [owise] .
eq remove-label((< LBL L | A >, GAMMA), LBL, GAMMA') =
remove-label(GAMMA, LBL, (GAMMA', < L | A >)) .
eq remove-label(empty, LBL, GAMMA) = GAMMA .
crl [prom-exist] :
[ X from Y by Q is < ex(R) L | A > |- GAMMA ] next(N) goals((X, XS)) =>
[ X from Y by Q is < ex(R) L | A > |- GAMMA ] next(N + 1) goals((XS, N))
[ N from X by 'prom-exist is < L | A > |- GAMMA' ]
if all-label(GAMMA, ex(R)) = true /\
GAMMA' := remove-label(GAMMA, ex(R), empty) .
crl [prom-all] :
[ X from Y by Q is ALFA |- < al(R) L | A > ] next(N) goals((X, XS)) =>
[ X from Y by Q is ALFA |- < al(R) L | A > ] next(N + 1) goals((XS, N))
[ N from X by 'prom-all is ALFA' |- < L | A > ]
if all-label(ALFA, al(R)) = true /\
ALFA' := remove-label(ALFA, al(R), empty) .
crl [prom-gt-l] :
[ X from Y by Q is < gt(n,R) L | A > |- GAMMA ] next(N) goals((X, XS)) =>
[ X from Y by Q is < gt(n,R) L | A > |- GAMMA ] next(N + 1) goals((XS, N))
[ N from X by 'prom-gt-l is < L | A > |- GAMMA' ]
if all-label(GAMMA, gt(n,R)) = true /\
GAMMA' := remove-label(GAMMA, gt(n,R), empty) .
crl [prom-gt-r] :
[ X from Y by Q is ALFA |- < gt(n,R) L | A > ] next(N) goals((X, XS)) =>
[ X from Y by Q is ALFA |- < gt(n,R) L | A > ] next(N + 1) goals((XS, N))
[ N from X by 'prom-gt-r is ALFA' |- < L | A > ]
if all-label(ALFA, gt(n,R)) = true /\
ALFA' := remove-label(ALFA, gt(n,R), empty) .
endm