summaryrefslogtreecommitdiff
path: root/Test/dafny0/DiscoverBounds.dfy
diff options
context:
space:
mode:
authorGravatar leino <unknown>2014-08-28 11:59:20 -0700
committerGravatar leino <unknown>2014-08-28 11:59:20 -0700
commitdb4d9e34aa774f3167a4842aaf75221bc24d50bc (patch)
treebf5a5a8727d245e0171f8095204eff9aad927e93 /Test/dafny0/DiscoverBounds.dfy
parent565b411b3dafa597232f99c018a11163dcda5175 (diff)
Bounds discovery now takes newtype constraints into consideration.
Diffstat (limited to 'Test/dafny0/DiscoverBounds.dfy')
-rw-r--r--Test/dafny0/DiscoverBounds.dfy51
1 files changed, 51 insertions, 0 deletions
diff --git a/Test/dafny0/DiscoverBounds.dfy b/Test/dafny0/DiscoverBounds.dfy
new file mode 100644
index 00000000..ea3f8cff
--- /dev/null
+++ b/Test/dafny0/DiscoverBounds.dfy
@@ -0,0 +1,51 @@
+// RUN: %dafny /print:"%t.print" /compile:3 "%s" > "%t"
+// RUN: %diff "%s.expect" "%t"
+
+newtype NT = x | 0 <= x < 100
+newtype UT = NT
+
+newtype Lower = x | 10 <= x
+newtype Upper = x: Lower | x < 100
+
+newtype Int = int
+
+newtype NR = r | -2.0 <= r <= 5.4
+
+method Main()
+{
+ var n: NT :| true;
+ var t: UT :| true;
+
+ var u: Upper :| true;
+ var l: Lower :| l < 20;
+ var o: Lower :| true;
+
+ var j: Int :| true;
+
+ print n, "\n";
+ print t, "\n";
+ print u, "\n";
+ print l, "\n";
+ print o, "\n";
+
+ var b: bool;
+ b := forall n': NT :: true ==> P(int(n'));
+ b := forall t': UT :: true ==> P(int(t'));
+ b := forall u': Upper :: true ==> P(int(u'));
+ b := forall l': Lower :: l' < 20 ==> P(int(l'));
+ b := forall o': Lower :: true ==> P(int(o')); // error: cannot find finite range
+ b := forall j': Int :: -3 <= j' < 7 ==> P(int(j'));
+
+ b := forall r: real :: 0.0 <= r <= 100.0 ==> Q(r); // error: cannot find finite range
+ b := forall r': NR :: true ==> Q(real(r')); // error: cannot find finite range
+}
+
+predicate method P(x: int)
+{
+ x == 157
+}
+
+predicate method Q(r: real)
+{
+ r / 2.0 <= r
+}