Commit 03d1c7b2 authored by Andrei Paskevich's avatar Andrei Paskevich
Browse files

whyml: new specification syntax

parent 65af15a2
module M
use import module ref.Ref
use import ref.Ref
let foo (x : ref int) (y : ref int) =
x := 1;
......
module M
use import module ref.Ref
use import ref.Ref
let foo (x : ref int) (y : ref int) =
x := 1;
......
module M
use import module ref.Ref
use import ref.Ref
let foo (x : ref int) (y : ref int) =
x := 1;
......
module M
use import module ref.Ref
use import ref.Ref
val r : ref int
......
module M
use import module ref.Ref
use import ref.Ref
let foo (x : ref int) (y: ref int) =
x := 1;
......
module M
use import int.Int
use import module ref.Ref
use import ref.Ref
let test (a: (ref int, int)) =
{}
let (r,_) = a in r := !r + 1
{ let (x, _) = a in !x = (old !x) + 1 }
let test (a: (ref int, int))
ensures { let (x, _) = a in !x = (old !x) + 1 }
= let (r,_) = a in r := !r + 1
end
......
module M
use import int.Int
use import module ref.Ref
use import ref.Ref
let test (a: (ref int, int)) =
'L:
......
module M
use import module ref.Ref
use import ref.Ref
val f : x:int -> {} unit writes a.contents {}
val f (x:int) : unit writes {a.contents}
end
module M
use import module ref.Ref
use import ref.Ref
val f : x:int -> {} unit writes x.contents {}
val f (x:int) : unit writes { x.contents }
end
module M
use import module ref.Ref
use import ref.Ref
val a : int
val f : x:int -> {} unit writes a.contents {}
val f (x:int) : unit writes { a.contents }
end
module M
use import module ref.Ref
use import ref.Ref
val foo : int -> int
val foo (_x : int) : int
val f : x:int -> {} unit writes foo.contents {}
val f (x:int) : unit writes { foo.contents }
end
module M
val f : x:int -> {} unit writes 1 {}
val f (x:int) : unit writes { 1 }
end
module M
val f : x:int -> {} unit writes x {}
val f (x:int) : unit writes {x}
end
......@@ -3,10 +3,10 @@ module Bad
use import int.Int
use import ref.Ref
let f (x y : ref int) : unit =
{ !x = !y }
x := !x + 1
{ !x = !y + 1 }
let f (x y : ref int) : unit
requires { !x = !y }
ensures { !x = !y + 1 }
= x := !x + 1
let g () : unit =
let r = ref 0 in
......
module M
use import module ref.Ref
use import ref.Ref
(* reference would escape its scope *)
let test () =
let x = ref 0 in
fun y -> { } x := y; !x { result = !x }
fun y -> ensures { result = !x } x := y; !x
end
module M
use import int.Int
use import module ref.Ref
let test1 (x: ref int) =
{ !x >= 0}
while !x > 0 do
use import ref.Ref
let test1 (x: ref int)
requires { !x >= 0 }
ensures { !x >= old !x }
= while !x > 0 do
invariant { !x >= old !x }
x := !x - 1
done
{ !x >= old !x }
end
(*
......
module M
use import int.Int
use import module ref.Ref
let test1 (x: ref int) =
{ !x >= 0}
x := !x - 1;
use import ref.Ref
let test1 (x: ref int)
ensures { !x >= old !x }
requires { !x >= 0}
= x := !x - 1;
assert { !x >= old !x }
{ !x >= old !x }
end
(*
......
......@@ -2,7 +2,7 @@
module Test
use import module ref.Refint
use import ref.Refint
let test (x: ref int) =
if !x = old !x then 1 else 2
......
module M
use import module ref.Ref
use import ref.Ref
val r : ref 'a
......
module M
use import module ref.Ref
use import ref.Ref
use import list.List
val r : ref (list 'a)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment