blob: 3bd527fb8ec8051772f67ed785696f00af9f227e (
plain)
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
|
interface IntList {
var list: seq[int]
constructor Empty()
ensures list = []
constructor SingletonTwo()
ensures list = [2]
constructor OneTwo()
ensures list = [1 2]
constructor Singleton(p: int)
ensures list = [p]
constructor TwoConsecutive(p: int)
ensures list = [p] + [p+1]
constructor Double(p: int, q: int)
ensures list = [p] + [q]
constructor Sum(p: int, q: int)
ensures list = [p + q]
}
datamodel IntList {
var root: IntNode
frame
root
invariant
root = null <==> |list| = 0
root != null ==> list = root.list
}
interface IntNode {
var list: seq[int]
invariant
|list| > 0
constructor SingletonZero()
ensures list = [0]
constructor Init(x: int)
ensures list = [x]
constructor Double(x: int, y: int)
ensures list = [x y]
method Max() returns (ret: int)
ensures ret in list
ensures forall t :: t in list ==> ret >= t
}
datamodel IntNode {
var data: int
var next: IntNode
frame
next
invariant
next = null ==> list = [data]
next != null ==> list = [data] + next.list
}
|