forked from runtimeverification/zero-to-k-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
04_assignment_strict.k.sol
71 lines (55 loc) · 2 KB
/
04_assignment_strict.k.sol
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
module ASSIGNMENT-SYNTAX
imports INT-SYNTAX
imports BOOL-SYNTAX
imports ID
syntax Exp ::= IExp | BExp
syntax IExp ::= Id | Int
syntax KResult ::= Int | Bool
syntax IExp ::= "(" IExp ")" [bracket]
| IExp "+" IExp [strict]
| IExp "-" IExp [strict]
> IExp "*" IExp [strict]
| IExp "/" IExp [strict]
> IExp "^" IExp [strict]
syntax BExp ::= Bool
syntax BExp ::= "(" BExp ")" [bracket]
| IExp "<=" IExp [strict]
| IExp "<" IExp [strict]
| IExp ">=" IExp [strict]
| IExp ">" IExp [strict]
| IExp "==" IExp [strict]
| IExp "!=" IExp [strict]
syntax BExp ::= BExp "&&" BExp [strict]
| BExp "||" BExp [strict]
syntax Stmt ::= Id "=" IExp ";" [strict(2)]
| Stmt Stmt [left]
endmodule
module ASSIGNMENT
imports INT
imports BOOL
imports MAP
imports ASSIGNMENT-SYNTAX
configuration
<k> $PGM:Stmt </k>
<mem> .Map </mem>
// -----------------------------------------------
rule <k> I1 + I2 => I1 +Int I2 ... </k>
rule <k> I1 - I2 => I1 -Int I2 ... </k>
rule <k> I1 * I2 => I1 *Int I2 ... </k>
rule <k> I1 / I2 => I1 /Int I2 ... </k>
rule <k> I1 ^ I2 => I1 ^Int I2 ... </k>
rule <k> I:Id => MEM[I] ... </k>
<mem> MEM </mem>
// ------------------------------------------------
rule <k> I1 <= I2 => I1 <=Int I2 ... </k>
rule <k> I1 < I2 => I1 <Int I2 ... </k>
rule <k> I1 >= I2 => I1 >=Int I2 ... </k>
rule <k> I1 > I2 => I1 >Int I2 ... </k>
rule <k> I1 == I2 => I1 ==Int I2 ... </k>
rule <k> I1 != I2 => I1 =/=Int I2 ... </k>
rule <k> B1 && B2 => B1 andBool B2 ... </k>
rule <k> B1 || B2 => B1 orBool B2 ... </k>
rule <k> S1:Stmt S2:Stmt => S1 ~> S2 ... </k>
rule <k> ID = I:Int ; => . ... </k>
<mem> MEM => MEM [ ID <- I ] </mem>
endmodule