summaryrefslogtreecommitdiff
path: root/Test/dafny0/Corecursion.dfy
diff options
context:
space:
mode:
authorGravatar Rustan Leino <unknown>2014-02-24 16:20:55 -0800
committerGravatar Rustan Leino <unknown>2014-02-24 16:20:55 -0800
commitdeac70817db80a3f203859ab9414d1c28205d4e2 (patch)
tree5df5ccbafa6dc443c979dab0f1bbd9c81af23dd7 /Test/dafny0/Corecursion.dfy
parentec90ed7e102dfc76bc3677f0241494bad4c16c6f (diff)
Refactored code for dealing with SCCs in the call graph.
Fixed bug.
Diffstat (limited to 'Test/dafny0/Corecursion.dfy')
-rw-r--r--Test/dafny0/Corecursion.dfy41
1 files changed, 41 insertions, 0 deletions
diff --git a/Test/dafny0/Corecursion.dfy b/Test/dafny0/Corecursion.dfy
index d8eb296d..e22bbf84 100644
--- a/Test/dafny0/Corecursion.dfy
+++ b/Test/dafny0/Corecursion.dfy
@@ -124,3 +124,44 @@ module MixRecursiveAndCorecursive {
X(n-1)
}
}
+
+// --------------------------------------------------
+
+module FunctionSCCsWithMethods {
+ codatatype Stream<T> = Cons(head: T, tail: Stream)
+
+ lemma M(n: nat)
+ decreases n, 0;
+ {
+ if n != 0 {
+ var p := Cons(10, F(n-1));
+ }
+ }
+
+ function F(n: nat): Stream<int>
+ decreases n;
+ {
+ M(n);
+ // the following call to F is not considered co-recursive, because the SCC contains a method
+ Cons(5, F(n)) // error: cannot prove termination
+ }
+
+ function G(): Stream<int>
+ {
+ Lemma();
+ H()
+ }
+
+ function H(): Stream<int>
+ decreases 0;
+ {
+ // the following call to G is not considered co-recursive, because the SCC contains a method
+ Cons(5, G()) // error: cannot prove termination
+ }
+
+ lemma Lemma()
+ decreases 1;
+ {
+ var h := H();
+ }
+}