diff options
author | Rustan Leino <leino@microsoft.com> | 2012-02-29 21:36:03 -0800 |
---|---|---|
committer | Rustan Leino <leino@microsoft.com> | 2012-02-29 21:36:03 -0800 |
commit | 8bcdbb318c0c61b1148705accccb294906cdffb1 (patch) | |
tree | 3753794e9788e5e9dfb1257d5751dc0b5fb7efa8 /Test/dafny0/LetExpr.dfy | |
parent | ba75a2d0b67ce5c330abd1903a6942a9b385d361 (diff) |
Dafny: fixed well-formedness checking of LET expressions to allow the RHS to be used
Diffstat (limited to 'Test/dafny0/LetExpr.dfy')
-rw-r--r-- | Test/dafny0/LetExpr.dfy | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/Test/dafny0/LetExpr.dfy b/Test/dafny0/LetExpr.dfy index 48e4810b..11bf4fbe 100644 --- a/Test/dafny0/LetExpr.dfy +++ b/Test/dafny0/LetExpr.dfy @@ -107,3 +107,43 @@ method PMain(a: array<int>) assert index == old(index) ==> a[index] == 21 && old(a[index]) == 19;
}
}
+
+// ---------- lemmas ----------
+
+method Theorem0(n: int)
+ requires 1 <= n;
+ ensures 1 <= Fib(n);
+{
+ if (n < 3) {
+ } else {
+ Theorem0(n-2);
+ Theorem0(n-1);
+ }
+}
+
+ghost method Theorem1(n: int)
+ requires 1 <= n;
+ ensures 1 <= Fib(n);
+{
+ // in a ghost method, the induction tactic takes care of it
+}
+
+function Theorem2(n: int): int
+ requires 1 <= n;
+ ensures 1 <= Fib(n);
+{
+ if n < 3 then 5 else
+ var x := Theorem2(n-2);
+ var y := Theorem2(n-1);
+ x + y
+}
+
+function Theorem3(n: int): int
+ requires 1 <= n;
+ ensures 1 <= Fib(n);
+{
+ if n < 3 then 5 else
+ var x := Theorem3(n-2);
+ var y := Theorem3(n-1);
+ 5
+}
|