-
Notifications
You must be signed in to change notification settings - Fork 1
/
imp.kore
174 lines (158 loc) · 10.9 KB
/
imp.kore
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
in kore
in imp-tokens
mod IMP is
including IMP-TOKENS .
endm
parse
[]
module ID
syntax Id []
endmodule []
module BOOL
syntax Bool []
syntax Bool ::= true() []
axiom \equal(true(), bool("true")) []
syntax Bool ::= false() []
axiom \equal(false(), bool("false")) []
syntax Bool ::= not@BOOL(Bool) []
endmodule []
module INT
import BOOL []
syntax Int []
syntax Int ::= plus@INT(Int,Int) []
syntax Int ::= div@INT(Int,Int) []
syntax Bool ::= leq@INT(Int,Int) []
syntax Int ::= 0() []
axiom \equal(0(), int("0")) []
endmodule []
module SET
syntax Set [set()]
syntax Set ::= .Set() [set()]
syntax Set ::= kAsSet(K) [set()]
syntax Set ::= comma@SET(Set,Set) [set()]
syntax Bool ::= in(K,Set) [set()]
axiom \equal(comma@SET(.Set(), S : InferredSort), S : InferredSort) [set()]
axiom \equal(comma@SET(S1 : InferredSort, S2 : InferredSort), comma@SET(S2 : InferredSort, S1 : InferredSort)) [set()]
axiom \equal(comma@SET(comma@SET(S1 : InferredSort, S2 : InferredSort), S3 : InferredSort), comma@SET(S1 : InferredSort, comma@SET(S2 : InferredSort, S3 : InferredSort))) [set()]
axiom \equal(comma@SET(S : InferredSort, S : InferredSort), S : InferredSort) [set()]
axiom \equal(in(K1 : InferredSort, comma@SET(kAsSet(K1 : InferredSort), S : InferredSort)), true()) [set()]
axiom \implies(\not(\equal(K1 : InferredSort, K2 : InferredSort)), \equal(in(K1 : InferredSort, comma@SET(kAsSet(K2 : InferredSort), S : InferredSort)), in(K1 : InferredSort, S : InferredSort))) [set()]
axiom \equal(in(K1 : InferredSort, .Set()), false()) [set()]
endmodule []
module MAP
import SET []
syntax Map [map()]
syntax Map ::= bind(K,K) [map()]
syntax Map ::= .Map() [map()]
syntax Map ::= comma@MAP(Map,Map) [map()]
syntax Set ::= keys(Map) [map()]
axiom \equal(comma@MAP(.Map(), M : InferredSort), M : InferredSort) [map()]
axiom \equal(comma@MAP(M : InferredSort, .Map()), M : InferredSort) [map()]
axiom \equal(comma@MAP(comma@MAP(M1 : InferredSort, M2 : InferredSort), M3 : InferredSort), comma@MAP(M1 : InferredSort, comma@MAP(M2 : InferredSort, M3 : InferredSort))) [map()]
axiom \equal(comma@MAP(M1 : InferredSort, M2 : InferredSort), comma@MAP(M2 : InferredSort, M1 : InferredSort)) [map()]
endmodule []
module DOMAINS
import ID []
import BOOL []
import INT []
import SET []
import MAP []
endmodule []
module K
syntax KResult []
syntax K []
syntax K ::= kResultAsK(KResult) []
endmodule []
module CONTEXTS
import K []
syntax K ::= #context(K,K) []
syntax K ::= #context2(K,K,K) []
syntax K ::= #context3(K,K,K,K) []
axiom \equal(#context2(C : InferredSort, K1 : InferredSort, K2 : InferredSort), #context(#context(C : InferredSort, K1 : InferredSort), K2 : InferredSort)) []
axiom \equal(#context3(C : InferredSort, K1 : InferredSort, K2 : InferredSort, K3 : InferredSort), #context(#context2(C : InferredSort, K1 : InferredSort, K2 : InferredSort), K3 : InferredSort)) []
syntax K ::= #...(K) []
syntax K ::= #...2(K,K) []
syntax K ::= #...3(K,K) []
axiom \equal(#...(K1 : InferredSort), \exists(C : InferredSort, #context(C : InferredSort, K1 : InferredSort))) []
axiom \equal(#...2(K1 : InferredSort, K2 : InferredSort), \exists(C : InferredSort, #context2(C : InferredSort, K1 : InferredSort, K2 : InferredSort))) []
axiom \equal(#...3(K1 : InferredSort, K2 : InferredSort, K3 : InferredSort), \exists(C : InferredSort, #context3(C : InferredSort, K1 : InferredSort, K2 : InferredSort, K3 : InferredSort))) []
syntax K ::= #gamma(K) []
axiom \equal(#context(\exists(HOLE : InferredSort, #gamma(HOLE : InferredSort)), K1 : InferredSort), K1 : InferredSort) []
endmodule []
module IMP-SYNTAX
import DOMAINS []
import CONTEXTS []
syntax AExp []
syntax AExp ::= intAsAExp(Int) []
syntax AExp ::= idAsAExp(Id) []
syntax AExp ::= div(AExp,AExp) [strict()]
axiom \equal(#context(\exists(HOLE : InferredSort, #gamma(div(#context(C : InferredSort, HOLE : InferredSort), A2 : InferredSort))), A1 : InferredSort), div(#context(C : InferredSort, A1 : InferredSort), A2 : InferredSort)) [strict(div(), 1())]
axiom \equal(#context(\exists(HOLE : InferredSort, #gamma(div(A1 : InferredSort, #context(C : InferredSort, HOLE : InferredSort)))), A2 : InferredSort), div(A1 : InferredSort, #context(C : InferredSort, A2 : InferredSort))) [strict(div(), 2())]
syntax AExp ::= plus(AExp,AExp) [strict()]
axiom \equal(#context(\exists(HOLE : InferredSort, #gamma(plus(#context(C : InferredSort, HOLE : InferredSort), A2 : InferredSort))), A1 : InferredSort), plus(#context(C : InferredSort, A1 : InferredSort), A2 : InferredSort)) [strict(plus(), 1())]
axiom \equal(#context(\exists(HOLE : InferredSort, #gamma(plus(A1 : InferredSort, #context(C : InferredSort, HOLE : InferredSort)))), A2 : InferredSort), plus(A1 : InferredSort, #context(C : InferredSort, A2 : InferredSort))) [strict(plus(), 2())]
syntax BExp []
syntax BExp ::= boolAsBExp(Bool) []
syntax BExp ::= leq(AExp,AExp) [seqstrict()]
axiom \equal(#context(\exists(HOLE : InferredSort, #gamma(leq(#context(C : InferredSort, HOLE : InferredSort), A2 : InferredSort))), A1 : InferredSort), leq(#context(C : InferredSort, A1 : InferredSort), A2 : InferredSort)) [seqstrict(leq(), 1())]
axiom \implies(\equal(isKResult(A1 : InferredSort), \top), \equal(#context(\exists(HOLE : InferredSort, #gamma(leq(A1 : InferredSort, #context(C : InferredSort, HOLE : InferredSort)))), A2 : InferredSort), leq(A1 : InferredSort, #context(C : InferredSort, A2 : InferredSort)))) [seqstrict(leq(), 2())]
syntax BExp ::= not(BExp) [strict()]
axiom \equal(#context(\exists(HOLE : InferredSort, #gamma(not(#context(C : InferredSort, HOLE : InferredSort)))), B : InferredSort), not(#context(C : InferredSort, B : InferredSort))) [strict(not(), 1())]
syntax BExp ::= and(BExp,BExp) [strict(1())]
axiom \equal(#context(\exists(HOLE : InferredSort, #gamma(and(#context(C : InferredSort, HOLE : InferredSort), B2 : InferredSort))), B1 : InferredSort), and(#context(C : InferredSort, B1 : InferredSort), B2 : InferredSort)) [strict(and(), 1())]
syntax Block []
syntax Block ::= emptyBlock() []
syntax Block ::= block(Stmt) []
syntax Stmt []
syntax Stmt ::= blockAsStmt(Block) []
syntax Stmt ::= asgn(Id,AExp) [strict(2())]
axiom \equal(#context(\exists(HOLE : InferredSort, #gamma(asgn(X : InferredSort, #context(C : InferredSort, HOLE : InferredSort)))), A : InferredSort), asgn(X : InferredSort, #context(C : InferredSort, A : InferredSort))) [strict(asgn(), 2())]
syntax Stmt ::= if(BExp,Block,Block) [strict(1())]
axiom \equal(#context(\exists(HOLE : InferredSort, #gamma(if(#context(C : InferredSort, HOLE : InferredSort), S1 : InferredSort, S2 : InferredSort))), B : InferredSort), if(#context(C : InferredSort, B : InferredSort), S1 : InferredSort, S2 : InferredSort)) [strict(if(), 1())]
syntax Stmt ::= while(BExp,Block) []
syntax Stmt ::= seq(Stmt,Stmt) [strict(1())]
axiom \equal(#context(\exists(HOLE : InferredSort, #gamma(seq(#context(C : InferredSort, HOLE : InferredSort), S2 : InferredSort))), S1 : InferredSort), seq(#context(C : InferredSort, S1 : InferredSort), S2 : InferredSort)) [strict(seq(), 1())]
syntax Pgm []
syntax Pgm ::= pgm(Ids,Stmt) []
syntax Ids []
syntax Ids ::= idAsIds(Id) [list()]
syntax Ids ::= .Ids() [list()]
syntax Ids ::= comma(Ids,Ids) [list()]
axiom \equal(comma(.Ids(), Ids1 : InferredSort), Ids1 : InferredSort) [list()]
axiom \equal(comma(Ids1 : InferredSort, .Ids()), Ids1 : InferredSort) [list()]
axiom \equal(comma(comma(Ids1 : InferredSort, Ids2 : InferredSort), Ids3 : InferredSort), comma(Ids1 : InferredSort, comma(Ids2 : InferredSort, Ids3 : InferredSort))) [list()]
endmodule []
module IMP
import IMP-SYNTAX []
syntax KResult ::= intAsKResult(Int) []
syntax KResult ::= boolAsKResult(Bool) []
syntax TopCell [cfg()]
syntax TopCell ::= top(KCell,StateCell) [cfg()]
axiom \equal(#context(\exists(HOLE : InferredSort, #gamma(top(#context(C : InferredSort, HOLE : InferredSort), Sc : InferredSort))), Kc : InferredSort), top(#context(C : InferredSort, Kc : InferredSort), Sc : InferredSort)) [cfg(top(), 1())]
axiom \equal(#context(\exists(HOLE : InferredSort, #gamma(top(Kc : InferredSort, #context(C : InferredSort, HOLE : InferredSort)))), Sc : InferredSort), top(Kc : InferredSort, #context(C : InferredSort, Sc : InferredSort))) [cfg(top(), 2())]
syntax KCell [cfg()]
syntax KCell ::= k(K) [cfg()]
axiom \equal(#context(\exists(HOLE : InferredSort, #gamma(k(#context(C : InferredSort, HOLE : InferredSort)))), K1 : InferredSort), k(#context(C : InferredSort, K1 : InferredSort))) [cfg(k(), 1())]
syntax StateCell [cfg()]
syntax StateCell ::= state(Map) [cfg()]
axiom \equal(#context(\exists(HOLE : InferredSort, #gamma(state(#context(C : InferredSort, HOLE : InferredSort)))), M : InferredSort), state(#context(C : InferredSort, M : InferredSort))) [cfg(state(), 1())]
syntax TopCell ::= #krun(Pgm) []
axiom \equal(#krun(P : InferredSort), top(k(P : InferredSort), state(.Map()))) []
rule #...2(\rewrite(idAsAExp(X : InferredSort), intAsAExp(I : InferredSort)), bind(X : InferredSort, I : InferredSort)) []
rule \implies(\not(\equal(I2 : InferredSort, 0())), #...(\rewrite(div(intAsAExp(I1 : InferredSort), intAsAExp(I2 : InferredSort)), intAsAExp(div@INT(I1 : InferredSort, I2 : InferredSort))))) []
rule #...(\rewrite(plus(intAsAExp(I1 : InferredSort), intAsAExp(I2 : InferredSort)), intAsAExp(plus@INT(I1 : InferredSort, I2 : InferredSort)))) []
rule #...(\rewrite(leq(intAsAExp(I1 : InferredSort), intAsAExp(I2 : InferredSort)), boolAsBExp(leq@INT(I1 : InferredSort, I2 : InferredSort)))) []
rule #...(\rewrite(not(boolAsBExp(T : InferredSort)), boolAsBExp(not@BOOL(T : InferredSort)))) []
rule #...(\rewrite(and(boolAsBExp(true()), B : InferredSort), B : InferredSort)) []
rule #...(\rewrite(and(boolAsBExp(false()), _ : InferredSort), boolAsBExp(false()))) []
rule #...(\rewrite(blockAsStmt(block(S : InferredSort)), S : InferredSort)) []
rule #...2(\rewrite(asgn(X : InferredSort, intAsAExp(I : InferredSort)), blockAsStmt(emptyBlock())), bind(X : InferredSort, \rewrite(_ : InferredSort, I : InferredSort))) []
rule #...(\rewrite(seq(blockAsStmt(emptyBlock()), S : InferredSort), S : InferredSort)) []
rule #...(\rewrite(if(boolAsBExp(true()), S : InferredSort, _ : InferredSort), blockAsStmt(S : InferredSort))) []
rule #...(\rewrite(if(boolAsBExp(false()), _ : InferredSort, S : InferredSort), blockAsStmt(S : InferredSort))) []
rule #...(\rewrite(while(B : InferredSort, S : InferredSort), if(B : InferredSort, block(seq(blockAsStmt(S : InferredSort), while(B : InferredSort, S : InferredSort))), emptyBlock()))) []
rule #...(pgm(\rewrite(comma(idAsIds(X : InferredSort), Xs : InferredSort), Xs : InferredSort), _ : InferredSort), state(comma@MAP(\equal(\and(M : InferredSort, in(X : InferredSort, keys(M : InferredSort))), false()), \rewrite(.Map(), bind(X : InferredSort, 0()))))) []
rule #...(\rewrite(pgmAsK(pgm(.Ids(), S : Stmt)), stmtAsK(S : InferredSort))) []
endmodule []
.
q