Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
why3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
119
Issues
119
List
Boards
Labels
Service Desk
Milestones
Merge Requests
16
Merge Requests
16
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Why3
why3
Commits
e8a6fe0f
Commit
e8a6fe0f
authored
Oct 12, 2018
by
Sylvain Dailler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ce-bench: Add new tests
parent
99f12932
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
143 additions
and
0 deletions
+143
-0
bench/ce/array_mono.mlw
bench/ce/array_mono.mlw
+65
-0
bench/ce/records.mlw
bench/ce/records.mlw
+21
-0
bench/ce/ref_mono.mlw
bench/ce/ref_mono.mlw
+57
-0
No files found.
bench/ce/array_mono.mlw
0 → 100644
View file @
e8a6fe0f
module Array
use int.Int
use map.Map
type array = private {
mutable ghost elts : int -> int;
length : int
} invariant { 0 <= length }
function ([]) (a: array) (i: int) : int = a.elts i
val ([]) (a: array) (i: int) : int
requires { [@expl:index in array bounds] 0 <= i < length a }
ensures { result = a[i] }
val ghost function ([<-]) (a: array) (i: int) (v: int): array
ensures { result.length = a.length }
ensures { result.elts = Map.set a.elts i v }
val ([]<-) (a: array) (i: int) (v: int) : unit writes {a}
requires { [@expl:index in array bounds] 0 <= i < length a }
ensures { a.elts = Map.set (old a).elts i v }
ensures { a = (old a)[i <- v] }
end
module A
use int.Int
use Array
let f1 (a:array) : int
= a[0]
let f2 (a:array) : unit
requires { a.length >= 2 }
ensures { a[0] <> a[1] }
= a[0] <- 42
end
(*
module B
use int.Int
use array.Array
clone array.Sorted with
type elt=int,
predicate le=(<=)
let f1 (a:array int) : unit
ensures { sorted a }
= ()
let f2 (a:array int) : array int
ensures { sorted result }
= a
end
*)
\ No newline at end of file
bench/ce/records.mlw
View file @
e8a6fe0f
...
...
@@ -34,6 +34,13 @@ module M
=
x := { !x with f = 6 };
!x
let record_match_eval_test44 (x : ref r) : r
ensures { result.g }
= [@vc:sp]
x := { !x with f = 6 };
assert { !x.f = 12};
!x
val re : ref r
...
...
@@ -78,4 +85,18 @@ module Mutable
x.f <- 6;
x
let record_old_test1 (x : r) : unit
ensures { old x.f = x.f}
=
x.f <- 6
let record_at_test2 (x : r) : unit
=
label L in
x.f <- 6;
label M in
x.f <- 12;
assert { x at L = x at M}
end
bench/ce/ref_mono.mlw
0 → 100644
View file @
e8a6fe0f
module Ref
type ref = { mutable contents [@model_trace:] : int }
function (!) (x: ref) : int = x.contents
let ref (v: int) ensures { result = { contents = v } } = { contents = v }
let (!) (r:ref) ensures { result = !r } = r.contents
let (:=) (r:ref) (v:int) ensures { !r = v } = r.contents <- v
end
module M
use list.List
use int.Int
use Ref
let test_post (x: int) (y: ref): unit
ensures { old !y >= x }
=
y := x - 1 + !y
let test_post2 (x: int) (y: ref): unit
requires { x > 42 }
ensures { old !y > !y + x }
=
y := x - 1 + !y
(**********************************************************
** Getting counterexamples for terms of primitive types **
**********************************************************)
val y :ref
let incr (x23: ref): unit
ensures { !x23 = old !x23 + 2 + !y }
=
(*#"random_path.random" 62 27 32#*)
y := !y + 1;
x23 := !x23 + 1;
x23 := !x23 + 1
let test_loop (x: ref): unit
ensures { !x < old !x }
=
label L in
incr x;
label M in
while !x > 0 do
invariant { !x > !x at L + !x at M }
variant { !x }
x := !x - 1
done
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment