summaryrefslogtreecommitdiff
path: root/Chalice
diff options
context:
space:
mode:
authorGravatar kyessenov <unknown>2010-08-11 01:18:42 +0000
committerGravatar kyessenov <unknown>2010-08-11 01:18:42 +0000
commit78ee8223d2bab10b38f3e42c450126d6171e4536 (patch)
tree277c6e54efe127b3b34a7b7f49072d6976fb3fc1 /Chalice
parent7c0ae7d3fcf53750937bdc56ba2192dfcbcfb5f9 (diff)
Chalice: fix "assume false" in the example (intended a spec statement)
Diffstat (limited to 'Chalice')
-rw-r--r--Chalice/examples/refinement/FiniteDiff.chalice18
1 files changed, 11 insertions, 7 deletions
diff --git a/Chalice/examples/refinement/FiniteDiff.chalice b/Chalice/examples/refinement/FiniteDiff.chalice
index 725d5961..ba9dfeb3 100644
--- a/Chalice/examples/refinement/FiniteDiff.chalice
+++ b/Chalice/examples/refinement/FiniteDiff.chalice
@@ -1,3 +1,7 @@
+// Example of a program computing cube using only addition.
+// Step-wise refinement using specification statement.
+// Chalice does not have termination metric for recursive methods.
+
class Cube0 {
method compute(n:int) returns (v: int)
requires n >= 0;
@@ -17,8 +21,8 @@ class Cube1 {
v := 0;
w := 1;
} else {
- call v,w := compute(n-1); // rely on stronger post-condition
- v := v + w;
+ call v1,w1 := compute(n-1); // rely on stronger post-condition
+ v := v1 + w1;
assume w == 3*n*n + 3*n + 1; // simplify and guess next step
}
}
@@ -29,17 +33,17 @@ class Cube2 {
requires n >= 0;
ensures v == n*n*n;
ensures w == (n+1)*(n+1)*(n+1)-n*n*n;
- ensures x == (n+1)*(n+1);
+ ensures x == (n+1)*(n+1); // stop it here; \delta w is messy
{
if (n == 0) {
v := 0;
w := 1;
x := 1;
} else {
- call v,w,x := compute(n-1);
- v := v + w;
- w := 3*x + 3*n + 1;
- x := x + 2*n + 1;
+ call v1,w1,x1 := compute(n-1);
+ v := v1 + w1;
+ w := 3*x1 + 3*n + 1;
+ x := x1 + 2*n + 1;
}
}
}