diff options
author | Dan Rosén <danr@chalmers.se> | 2014-08-11 14:57:27 -0700 |
---|---|---|
committer | Dan Rosén <danr@chalmers.se> | 2014-08-11 14:57:27 -0700 |
commit | 4cbe4583b329a39dee2b4b456758cafbe7e2fa79 (patch) | |
tree | 6bb2377f06036fd41d939d168365d4e47cc7a327 /Test/hofs/Apply.dfy | |
parent | c377658acba5472b6d0c1e1452ce4c4c8f1fc28e (diff) |
Add higher-order-functions and some other goodies
* The reads clause now needs to be self framing.
* The requires clause now needs to be framed by the reads clause.
* There are one-shot lambdas, with a single arrow, but they will probably be
removed.
* There is a {:heapQuantifier} attribute to quantifiers, but they will
probably be removed.
* Add smart handling of type variables
* Add < and > for datatype & type parameter
Diffstat (limited to 'Test/hofs/Apply.dfy')
-rw-r--r-- | Test/hofs/Apply.dfy | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Test/hofs/Apply.dfy b/Test/hofs/Apply.dfy new file mode 100644 index 00000000..bdd102c2 --- /dev/null +++ b/Test/hofs/Apply.dfy @@ -0,0 +1,29 @@ +// RUN: %dafny /compile:0 /print:"%t.print" /dprint:"%t.dprint" "%s" > "%t" +// RUN: %diff "%s.expect" "%t" + + +method Apply(x : int) returns (i : int) + ensures i == x; +{ + i := (x => x)(x); +} + +function method Const<A,B>(a : A) : B -> A { + b => a +} + +method Test(m : map<int, int -> int -> int>) +{ + assume forall i :: i in m; + assume forall i, x :: m[i].requires(x); + assume forall i, x, y :: m[i](x).requires(y); + assume m[1](2)(3) > 5; + assert ((m[1])(2))(3) > 4; +} + +method Main() { + assert forall x : int, y : int :: Const(x)(y) == (Const(x))(y); + assert (a => b => a) == (u : int) => (v : int) => u; + assert Const == (u : int) => (v : int) => u; +} + |