Skip to content

Commit ef2d333

Browse files
author
davidcok
committed
Edits
1 parent 7d485b1 commit ef2d333

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

tutorial/MethodsInSpecifications.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,31 @@ the program.
2525
There is a hierarchy of four kinds of purity, all of which share the
2626
property of no effect on the initial Java program state.
2727

28-
**pure** methods: The basic kind of pure method has no side effects on the external program
28+
**pure** methods: This basic kind of `pure` method has no side effects on the external program
2929
state but may allocate and dispose of objects within the method and may return
3030
a newly allocated object (e.g. a `String`). Because it can return a fresh object,
3131
it is not a deterministic method from the point of view of the Java program heap.
3232

33-
**spec_pure** methods: A spec_pure method is a pure method that does not return any
33+
**spec_pure** methods: A `spec_pure` method is a `pure` method that does not return any
3434
fresh object; it either returns a primitive value or an object reference that was
35-
already allocated in the pre-state. Consequently it is deterministic.
35+
already allocated in the pre-state. Consequently it is deterministic.
36+
A method must be at least `spec_pure` to be used in a specification.
3637

37-
**strictly_pure** methods: A strictly_pure method is a spec_pure method that does not
38+
**strictly_pure** methods: A `strictly_pure` method is a `spec_pure` method that does not
3839
allocate any new objects in the body of the method. Such a method has no effect on the
3940
object heap at all; it may read heap values and perform computations on the method's
40-
local stack. Though a strictly_pure method is generally undistinguishable by a calling method from a
41-
spec_pure method, some tools can benefit by knowing that a method makes no changes,
41+
local stack. Though a `strictly_pure` method is generally indistinguishable by a calling method from a
42+
`spec_pure` method, some tools can benefit by knowing that a method makes no changes,
4243
even internally, to the program heap.
4344

44-
**heap_free** methods: A heap_free method is one that does not depend on the program heap
45+
**heap_free** methods: A `heap_free` method is one that does not depend on the program heap
4546
at all. Hence such a method (if deterministic) returns the same value for the same arguments
4647
no matter in what heap or program state it is invoked. Examples are purely mathematical
4748
library functions.
4849

49-
A method marked with any kind of purity may not have any `assignable` clauses;
50+
A method marked with any kind of purity should not have any `assignable` clauses;
5051
all the method's behaviors are implicitly `assignable \nothing`.
52+
Any `assignable` clause that is present must be `assignable \nothing`.
5153

5254
To be called in a method specification, a method must be at least `spec_pure`.
5355
For historical reasons, a method parked `pure` that returns a primitive value

tutorial/MyBox.out

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ MyBox.java:18: verify: The prover cannot establish an assertion (InvariantExit:
44
MyBox.java:6: verify: Associated declaration: MyBox.java:18:
55
//@ public invariant size >= 0;
66
^
7-
MyBox.java:50: verify: The prover cannot establish an assertion (Assert) in method test3
8-
//@ assert b.sizeH() >= 0; // FAILS -- changeSizeH does not necessarily establish the invariant
7+
MyBox.java:52: verify: The prover cannot establish an assertion (Assert) in method test3
8+
//@ check b.sizeH() >= 0; // FAILS -- changeSizeH does not assume nor is required to establish the invariant
99
^
10-
MyBox.java:55: verify: The prover cannot establish an assertion (InvariantLeaveCaller: MyBox.java:6:) in method test4: (Caller: MyBox.test4(MyBox), Callee: MyBox.size())
10+
MyBox.java:58: verify: The prover cannot establish an assertion (InvariantEntrance: MyBox.java:6:) in method test4: (Caller: MyBox.test4(MyBox), Callee: MyBox.size())
1111
//@ assert b.size() >= 0; // FAILS -- invariants not necessarily true, so size() is not allowed to be called
1212
^
13-
MyBox.java:6: verify: Associated declaration: MyBox.java:55:
13+
MyBox.java:6: verify: Associated declaration: MyBox.java:58:
1414
//@ public invariant size >= 0;
1515
^
1616
5 verification failures

0 commit comments

Comments
 (0)