forked from runtimeverification/zero-to-k-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimple-spec.k
56 lines (46 loc) · 1.36 KB
/
simple-spec.k
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
requires "../../control-flow.k"
requires "domains.md"
module SIMPLE-SPEC-SYNTAX
imports CONTROL-FLOW-SYNTAX
syntax Id ::= "$a" [token]
| "$b" [token]
| "$c" [token]
| "$x" [token]
| "$y" [token]
| "$z" [token]
endmodule
module VERIFICATION
imports SIMPLE-SPEC-SYNTAX
imports CONTROL-FLOW
rule maxInt(X, Y) => Y requires X <Int Y [simplification]
rule maxInt(X, Y) => X requires notBool X <Int Y [simplification]
endmodule
module SIMPLE-SPEC
imports VERIFICATION
claim <k> 3 + 4 => 7 ... </k>
claim <k> if ( 3 < 4 ) {
$c = 1 ;
} else {
$c = 2 ;
}
=> . ... </k>
<mem> MEM => MEM [ $c <- 1 ] </mem>
claim <k> $a = A:Int ; $b = B:Int ;
if (A < B) {
$c = B ;
} else {
$c = A ;
}
=> . ... </k>
<mem> MEM => MEM [ $a <- A ] [ $b <- B ] [ $c <- ?C:Int ] </mem>
requires A <=Int ?C
andBool B <=Int ?C
claim <k> $a = A:Int ; $b = B:Int ;
if (A < B) {
$c = B ;
} else {
$c = A ;
}
=> . ... </k>
<mem> MEM => MEM [ $a <- A ] [ $b <- B ] [ $c <- maxInt(A, B) ] </mem>
endmodule