Repository navigation
Expand file tree
/
Copy pathCorrectLoopPostState.java
More file actions
79 lines (67 loc) · 1.94 KB
/
Copy pathCorrectLoopPostState.java
File metadata and controls
79 lines (67 loc) · 1.94 KB
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
package testSuite;
import liquidjava.specification.StateRefinement;
import liquidjava.specification.StateSet;
@StateSet({"open", "marked"})
public class CorrectLoopPostState {
@StateRefinement(to = "open(this)")
CorrectLoopPostState() {}
@StateRefinement(to = "marked(this)")
void mark() {}
@StateRefinement(from = "marked(this)", to = "open(this)")
void reset() {}
@StateRefinement(from = "open(this)")
void use() {}
// A state-preserving call leaves the entry state available after the loop.
static void unchangedState(int n) {
CorrectLoopPostState b = new CorrectLoopPostState();
while (n > 0) {
b.use();
n--;
}
b.use();
}
// An unconditional transition after the loop establishes the required state.
static void establishStateAfterLoop(int n) {
CorrectLoopPostState b = new CorrectLoopPostState();
while (n > 0) {
b.mark();
n--;
}
b.mark();
b.reset();
}
@StateRefinement(from = "open(this)")
void unchangedThisState(int n) {
while (n > 0) {
this.use();
n--;
}
use();
}
@StateRefinement(from = "open(this)")
void establishThisStateAfterLoop(int n) {
while (n > 0) {
mark();
n--;
}
this.mark();
reset();
}
@StateRefinement(from = "open(this)")
void directValidTransitions() {
this.use();
mark();
this.reset();
use();
}
@StateRefinement(from = "open(this)")
@StateRefinement(from = "marked(this)")
void acceptEitherState() {}
// Neither alternative is known individually; the call accepts their union and preserves it.
@StateRefinement(from = "open(this)")
@StateRefinement(from = "marked(this)")
void wrapEitherState() {
acceptEitherState();
this.acceptEitherState();
}
}