diff options
author | leino <unknown> | 2014-12-12 20:46:48 -0800 |
---|---|---|
committer | leino <unknown> | 2014-12-12 20:46:48 -0800 |
commit | 91c4d57eb84d5d15e011902a1da1b70131e5a222 (patch) | |
tree | 6794bafdc71f6bc31c8d09496c3435658bbfc144 /Test/dafny0/Termination.dfy | |
parent | 62a3e97eb61cbee0d523297ccad1f2d3bcf871c3 (diff) |
Language change: All functions and methods declared lexically outside any class are now
automatically static, and fields are no longer allowed to be declared there. Stated
differently, all heap state must now be declared inside an explicitly declared class,
and functions and methods declared outside any class can be viewed as belonging to
the module. The motivating benefit of this change is to no longer need the 'static'
keyword when declaring a module of functions and methods.
Diffstat (limited to 'Test/dafny0/Termination.dfy')
-rw-r--r-- | Test/dafny0/Termination.dfy | 71 |
1 files changed, 36 insertions, 35 deletions
diff --git a/Test/dafny0/Termination.dfy b/Test/dafny0/Termination.dfy index 70c30aa6..0e51ade2 100644 --- a/Test/dafny0/Termination.dfy +++ b/Test/dafny0/Termination.dfy @@ -201,50 +201,51 @@ method DecreasesYieldsAnInvariant(z: int) { // ----------------------- top elements --------------------------------------
-var count: int;
+class TopElements {
+ var count: int;
-// Here is the old way that this had to be specified:
+ // Here is the old way that this had to be specified:
-method OuterOld(a: int)
- modifies this;
- decreases a, true;
-{
- count := count + 1;
- InnerOld(a, count);
-}
+ method OuterOld(a: int)
+ modifies this;
+ decreases a, true;
+ {
+ count := count + 1;
+ InnerOld(a, count);
+ }
-method InnerOld(a: int, b: int)
- modifies this;
- decreases a, false, b;
-{
- count := count + 1;
- if (b == 0 && 1 <= a) {
- OuterOld(a - 1);
- } else if (1 <= b) {
- InnerOld(a, b - 1);
+ method InnerOld(a: int, b: int)
+ modifies this;
+ decreases a, false, b;
+ {
+ count := count + 1;
+ if (b == 0 && 1 <= a) {
+ OuterOld(a - 1);
+ } else if (1 <= b) {
+ InnerOld(a, b - 1);
+ }
}
-}
-// Now the default specifications ("decreases a;" and "decreases a, b;") suffice:
+ // Now the default specifications ("decreases a;" and "decreases a, b;") suffice:
-method Outer(a: int)
- modifies this;
-{
- count := count + 1;
- Inner(a, count);
-}
+ method Outer(a: int)
+ modifies this;
+ {
+ count := count + 1;
+ Inner(a, count);
+ }
-method Inner(a: int, b: int)
- modifies this;
-{
- count := count + 1;
- if (b == 0 && 1 <= a) {
- Outer(a - 1);
- } else if (1 <= b) {
- Inner(a, b - 1);
+ method Inner(a: int, b: int)
+ modifies this;
+ {
+ count := count + 1;
+ if (b == 0 && 1 <= a) {
+ Outer(a - 1);
+ } else if (1 <= b) {
+ Inner(a, b - 1);
+ }
}
}
-
// -------------------------- decrease either datatype value -----------------
function Zipper0<T>(a: List<T>, b: List<T>): List<T>
|