forked from runtimeverification/zero-to-k-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlooping-spec.k
37 lines (30 loc) · 826 Bytes
/
looping-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
requires "../../control-flow.k"
requires "domains.md"
module LOOPING-SPEC-SYNTAX
imports CONTROL-FLOW-SYNTAX
syntax Id ::= "$a" [token]
| "$b" [token]
| "$c" [token]
| "$x" [token]
| "$y" [token]
| "$z" [token]
| "$s" [token]
| "$n" [token]
endmodule
module VERIFICATION
imports LOOPING-SPEC-SYNTAX
imports CONTROL-FLOW
endmodule
module LOOPING-SPEC
imports VERIFICATION
claim <k> while ( 0 < $n ) {
$s = $s + $n ;
$n = $n - 1 ;
}
=> . ... </k>
<mem> $s |-> (S:Int => S +Int ((N +Int 1) *Int N /Int 2))
$n |-> (N:Int => 0)
</mem>
requires N >=Int 0
andBool S >=Int 0
endmodule