You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorial/FrameConditions.md
+5-6Lines changed: 5 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,9 +37,9 @@ ensures clause that states that `counter2 == \old(counter2)`. This specification
37
37
verifies as correct.
38
38
39
39
But this is not a practical solution. We can't add to `increment1()`'s specification a clause stating that every visible variable is unchanged.
40
-
Instead we use a *frame condition* whose purpose is to state what memory
40
+
Instead we use a *frame condition* whose purpose is to state which memory
41
41
locations a method might have modified. There are a variety of names for
42
-
the frame clause: traditionally it is `assignable`, but `assigns`is also permitted.
42
+
the frame clause: traditionally it is `assignable`, but `assigns`and `writes` are also permitted.
43
43
Note that `modifies` is also an
44
44
(implemented) synonym, but in some tools it has a slightly different meaning,
45
45
so its use is not recommended.
@@ -69,8 +69,7 @@ that is written to in the body of `m`.
69
69
*`a[*]` for array expression `a` means all elements of that array
70
70
*`a[i..j]` for expressions `a`, `i`, and `j` means the stated range of array elements, from `i` to `j` inclusive.
71
71
72
-
If there is no frame condition at all, then a default is used, namely `assigns \everything;`--- which means exactly that: after a call of this method, any memory location in the state might have been written to and might be changed. It is very difficult to prove anything about a program that includes a call to a method with such a frame condition. Thus
73
-
*you must include a frame condition for any method that is called within a program*.
72
+
If there is no frame condition at all, then a default is used, namely `assigns \everything;`--- which means exactly that: after a call of this method, any memory location in the state might have been written to and might be changed. It is very difficult to prove anything about a program that includes a call to a method with such a frame condition. Thus *you must include a frame condition for any method that is called within a program*.
74
73
75
74
A shorthand way to say that a method `assigns \nothing;` is to designate it `pure`, as in
76
75
```
@@ -84,7 +83,7 @@ though there are a few other details to purity --- see the [lesson on pure](Meth
84
83
There are two other points to know about frame conditions. First, where a frame condition clause includes expressions, such as the indices of array expressions, those expressions are evaluated in the pre-state, not the post-state.
85
84
86
85
Second, a frame condition is a method specification clause like `requires` and `ensures`. A method specification may contain more than one such clause.
87
-
However, note that each cluase is considered individually. That is, each clause
86
+
However, note that each clause is considered individually. That is, each clause
88
87
by itself lists the memory locations that may be written to by the method.
89
88
As each frame condition clause must be valid on its own, the effect of multiple clauses is the same as one clause with the _intersection_ of the sets of locations given by the separate clauses.
90
89
For example,
@@ -110,7 +109,7 @@ result of mutiple assigns clauses was the *union* of their contents, but that is
110
109
not the case, for historical reasons. The advice is then to
111
110
*have only one frame condition clause per specification (case)*, even if that
112
111
means the clause has a long list. (All the method specifications in the
113
-
tutorial lessons so far have just one specification case; an advanced lesson
112
+
tutorial lessons so far have just one specification case; a subsequent lesson
Copy file name to clipboardExpand all lines: tutorial/MethodCalls.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ The callee, on the right, is a simple standalone method. When the method is
20
20
verified, the logical engine
21
21
* assumes its preconditions are true
22
22
* symbolically represents the actions of the method body
23
-
* asserts the postconditions---that is, proves the the postconditions logically follow from the preconditions and method body in every initial state allowed by the preconditions
23
+
* asserts the postconditions---that is, proves that the postconditions logically follow from the preconditions and method body in every initial state allowed by the preconditions
24
24
25
25
As for the caller, it also follows the same three steps. But how do we represent the call to `callee()`? We could inline the whole callee method, but that would
26
26
become unwieldy, would not work for recursion, and is not modular.
@@ -42,7 +42,7 @@ The following code is a simple example of a two-method verification.
42
42
```
43
43
44
44
The output on verifying is given next. Note that the openjml command includes
45
-
the `-progress` option, so we receive quite a bit more output.
45
+
the `--progress` option, so we receive quite a bit more output.
46
46
47
47
```
48
48
{% include_relative T_CallerCallee.out %}
@@ -70,8 +70,8 @@ is reported as not verified.
70
70
71
71
A few additional points might be helpful.
72
72
73
-
Often one is working on the specifications for just one method and so one does not want to try to verify everything. You can specify the one method to run like this:
Often one is working on the specifications for just one method and so one does not want to try to verify everything.
74
+
You can specify the one method to run like this: `openjml --esc --method=caller2 T_CallerCallee.java`
75
75
76
76
Secondly, the `--progress` option is useful to see the detail about what verified and what did not; it also puts out information as work is accomplished, so you can see what progress is being made in a long-running job. But you can also reduce the amount of output. For example, the default `--normal` option
77
77
```
@@ -85,7 +85,7 @@ which just shows any error messages.
85
85
86
86
If you want you can hide all the output text and just observe the exit code:
Copy file name to clipboardExpand all lines: tutorial/MultipleBehaviors.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,7 @@ There are a few points to note:
21
21
* There is no order to the behaviors; they can be written in any order that is understandable.
22
22
* Every behavior applies on its own and must hold by itself --- there is no if-then-else among them. If a behavior's preconditions hold,
23
23
then its postconditions must hold, independent of what any other behavior says.
24
+
* The effective precondition for each behavior is the conjunction (with `&&`) of the preconditions for that behavior. The effective precondition for the combination of multiple behaviors is the disjunction (with `||`) of the effective preconditions of the individual behaviors. Consequently, at the point where such a method is called, at least one, but by no means necessarily all, of the behaviors must have an effective precondition that is true.
24
25
25
26
In our example, if `a`, `b`, and `c` are all equal, then the precondiition (`requires` clause) of each of the three behaviors is true.
26
27
So the postconditions of each of the behaviors must also be true. Fortunately they all agree.
@@ -66,7 +67,7 @@ The normal and exceptional behaviors illustrated in the previous section are ver
66
67
The `normal_behavior` heading implies that no exception is allowed (`signals false`); the `exceptional_behavior` heading says that normal termination is not allowed (`ensures false`).
67
68
A behavior that is neither of these is a simple `behavior`, which is the default when there is no heading.
68
69
69
-
One other point: any one of the behavior keywords needs a visibility keyword; almost always, as in the example above, the visibility is the same as the method. The absence of a visibility modifier means `package` visibility, just as the absence of a visibility modifier on the method declaration.
70
+
One other point: any one of the behavior keywords needs a visibility keyword; almost always, as in the example above, the visibility is the same as the method. The absence of a visibility modifier means `package` visibility, just as the absence of a visibility modifier on the method declaration. However, if there is no specialized behavior keyword, then there is no place for the visibility keyword; in that cae, the visibility is the same as the visibility of the method.
@@ -28,15 +29,15 @@ Some of these have been already discussed; others are discussed in later lessons
28
29
There is no pre-defined order to the clauses within a single specification case (cf. a later lesson on [multiple specification cases](MultipleBehaviors)].
29
30
However, a specification is much more readable if the clauses generally follow the order above, with preconditions first, then frame conditions, followed by postconditions.
30
31
31
-
There is some meaning to the ordering within the precondition group and within the postcondition group: earlier clauses can set conditions that are needed for later clause to be well-defined. For example,
32
+
There is some meaning to the ordering within the precondition group and within the postcondition group: earlier clauses can set conditions that are needed for later clause to be well-defined; but ordering only matters within the kinds of precondition clauses and separately for any `ensures` clauses. For example,
32
33
```
33
34
{% include_relative T_order1.java %}
34
35
```
35
36
yields
36
37
```
37
-
T_order1.old
38
+
{% include_relative T_order1.out %}
38
39
```
39
-
The first requires clause might not be well-defined because `a` might be null. If we reverse the order of the clauses, then JML is content:
40
+
The first requires clause might not be well-defined because `a` might be null. If we reverse the order of the clauses, then OpenJML is content:
0 commit comments