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
120
Issues
120
List
Boards
Labels
Service Desk
Milestones
Merge Requests
18
Merge Requests
18
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
4c99984c
Commit
4c99984c
authored
Feb 10, 2017
by
Leon Gondelman
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'coercions' into new_system
parents
d4c766eb
db0d6501
Changes
25
Show whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
492 additions
and
224 deletions
+492
-224
Makefile.in
Makefile.in
+2
-2
bench/typing/bad/coercion_already.mlw
bench/typing/bad/coercion_already.mlw
+10
-0
bench/typing/bad/coercion_already1.mlw
bench/typing/bad/coercion_already1.mlw
+9
-0
bench/typing/bad/coercion_already3.mlw
bench/typing/bad/coercion_already3.mlw
+11
-0
bench/typing/bad/coercion_cycle1.mlw
bench/typing/bad/coercion_cycle1.mlw
+9
-0
bench/typing/bad/coercion_cycle2.mlw
bench/typing/bad/coercion_cycle2.mlw
+13
-0
bench/typing/bad/coercion_cycle3.mlw
bench/typing/bad/coercion_cycle3.mlw
+13
-0
bench/typing/good/coercions.mlw
bench/typing/good/coercions.mlw
+23
-0
examples/leftist_heap.mlw
examples/leftist_heap.mlw
+7
-14
examples/vstte10_queens.mlw
examples/vstte10_queens.mlw
+15
-15
examples/vstte10_queens/why3session.xml
examples/vstte10_queens/why3session.xml
+61
-111
examples/vstte10_queens/why3shapes.gz
examples/vstte10_queens/why3shapes.gz
+0
-0
modules/mach/int.mlw
modules/mach/int.mlw
+1
-0
src/core/coercion.ml
src/core/coercion.ml
+103
-0
src/core/coercion.mli
src/core/coercion.mli
+29
-0
src/core/dterm.ml
src/core/dterm.ml
+101
-44
src/core/dterm.mli
src/core/dterm.mli
+1
-1
src/core/pretty.ml
src/core/pretty.ml
+8
-0
src/core/pretty.mli
src/core/pretty.mli
+2
-0
src/core/theory.ml
src/core/theory.ml
+21
-11
src/core/theory.mli
src/core/theory.mli
+10
-8
src/core/ty.ml
src/core/ty.ml
+0
-1
src/ide/gconfig.ml
src/ide/gconfig.ml
+25
-0
src/ide/gconfig.mli
src/ide/gconfig.mli
+1
-0
src/parser/typing.ml
src/parser/typing.ml
+17
-17
No files found.
Makefile.in
View file @
4c99984c
...
...
@@ -169,7 +169,7 @@ LIB_UTIL = config bigInt util opt lists strings \
hashcons stdlib exn_printer pp json debug loc lexlib print_tree
\
cmdline warning sysutil rc plugin bigInt number pqueue
LIB_CORE
=
ident ty term pattern decl theory
\
LIB_CORE
=
ident ty term pattern decl
coercion
theory
\
task pretty dterm
env
trans printer model_parser
LIB_DRIVER
=
prove_client call_provers driver_ast driver_parser driver_lexer driver
\
...
...
@@ -1748,7 +1748,7 @@ MODULESTODOC = \
util/util util/opt util/lists util/strings
\
util/extmap util/extset util/exthtbl
\
util/weakhtbl util/stdlib util/rc util/debug
\
core/ident core/ty core/term core/decl core/theory
\
core/ident core/ty core/term core/decl core/
coercion core/
theory
\
core/env core/task
\
driver/whyconf driver/call_provers driver/driver
\
session/session session/session_tools session/session_scheduler
...
...
bench/typing/bad/coercion_already.mlw
0 → 100644
View file @
4c99984c
type a
type b
type c
function b_to_c b : c
meta coercion function b_to_c
function a_to_b a : b
meta coercion function a_to_b
function a_to_c a : c
meta coercion function a_to_c
bench/typing/bad/coercion_already1.mlw
0 → 100644
View file @
4c99984c
type a
type b
function f a : b
meta coercion function f
function g a : b
meta coercion function g
bench/typing/bad/coercion_already3.mlw
0 → 100644
View file @
4c99984c
type a
type b
type c
function f a : c
meta coercion function f
function g b : c
meta coercion function g
function h a : b
meta coercion function h
bench/typing/bad/coercion_cycle1.mlw
0 → 100644
View file @
4c99984c
type a
type b
function f a : b
meta coercion function f
function g b : a
meta coercion function g
bench/typing/bad/coercion_cycle2.mlw
0 → 100644
View file @
4c99984c
type a
type b
type c
function f a : b
meta coercion function f
function g b : c
meta coercion function g
function h c : a
meta coercion function h
bench/typing/bad/coercion_cycle3.mlw
0 → 100644
View file @
4c99984c
type a
type b
type c
function g b : c
meta coercion function g
function f a : b
meta coercion function f
function h c : a
meta coercion function h
bench/typing/good/coercions.mlw
0 → 100644
View file @
4c99984c
type t
function f t : int
meta coercion function f
goal G: forall x: t. 42 = x
type a
type b
type c
function b_to_c b : c
meta coercion function b_to_c
function a_to_b a : b
meta coercion function a_to_b
predicate is_c c
goal G2: forall x: a. is_c x
function is_zero int : bool
meta coercion function is_zero
goal G3: if 42 then 1=2 else 3=4
examples/leftist_heap.mlw
View file @
4c99984c
...
...
@@ -18,7 +18,7 @@ module Heap
type heap
function size heap : int
val
function size heap : int
function occ elt heap : int
...
...
@@ -39,9 +39,6 @@ module Heap
val is_empty (h: heap) : bool
ensures { result <-> size h = 0 }
val size (h: heap) : int
ensures { result = size h }
val merge (h1 h2: heap) : heap
ensures { forall x. occ x result = occ x h1 + occ x h2 }
ensures { size result = size h1 + size h2 }
...
...
@@ -74,7 +71,7 @@ module Size
use import TreeRank
use import int.Int
function size (t: tree 'a) : int = match t with
let rec
function size (t: tree 'a) : int = match t with
| E -> 0
| N _ l _ r -> 1 + size l + size r
end
...
...
@@ -105,7 +102,7 @@ end
module LeftistHeap
type elt
predicate le elt elt
val
predicate le elt elt
clone relations.TotalPreOrder with type t = elt, predicate rel = le
use import TreeRank
...
...
@@ -117,7 +114,7 @@ module LeftistHeap
type t = tree elt
(* [e] is no greater than the root of [h], if any *)
predicate le_root (e: elt) (h: t) = match h with
let
predicate le_root (e: elt) (h: t) = match h with
| E -> true
| N _ _ x _ -> le e x
end
...
...
@@ -144,8 +141,8 @@ module LeftistHeap
= match h with
| E -> absurd
| N _ l _ r ->
if l <> E then root_is_miminum l
;
if r <> E then root_is_miminum r
match l with E -> root_is_miminum l | _ -> () end
;
match r with E -> root_is_miminum r | _ -> () end
end
function rank (h: t) : int = match h with
...
...
@@ -172,11 +169,7 @@ module LeftistHeap
let is_empty (h: t) : bool
ensures { result <-> size h = 0 }
= h = E
let size (h: t) : int
ensures { result = size h }
= size h
= match h with E -> true | N _ _ _ _ -> false end
let rank (h: t) : int
requires { leftist_heap h }
...
...
examples/vstte10_queens.mlw
View file @
4c99984c
...
...
@@ -155,19 +155,19 @@ module NQueens63
predicate is_board (board: array int63) (pos: int) =
forall q: int. 0 <= q < pos ->
0 <=
to_int board[q] < to_int
(length board)
0 <=
board[q] <
(length board)
exception MInconsistent
let check_is_consistent (board: array int63) (pos: int63)
requires { 0 <=
to_int pos < to_int
(length board) }
requires { is_board board (
to_int
pos + 1) }
requires { 0 <=
pos <
(length board) }
requires { is_board board (pos + 1) }
= try
let q = ref (of_int 0) in
while !q < pos do
invariant { 0 <=
to_int !q <= to_int
pos }
invariant { is_board board (
to_int
pos + 1) }
variant {
to_int pos - to_int
!q }
invariant { 0 <=
!q <=
pos }
invariant { is_board board (pos + 1) }
variant {
pos -
!q }
let bq = board[!q] in
let bpos = board[pos] in
if bq = bpos then raise MInconsistent;
...
...
@@ -184,20 +184,20 @@ module NQueens63
let rec count_bt_queens
(solutions: ref P.t) (board: array int63) (n: int63) (pos: int63)
requires {
to_int (length board) = to_int
n }
requires { 0 <=
to_int pos <= to_int
n }
requires { is_board board (
to_int
pos) }
variant {
to_int n - to_int
pos }
ensures { is_board board (
to_int
pos) }
requires {
(length board) =
n }
requires { 0 <=
pos <=
n }
requires { is_board board (pos) }
variant {
n -
pos }
ensures { is_board board (pos) }
=
if eq pos n then
solutions := P.succ !solutions
else
let i = ref (of_int 0) in
while !i < n do
invariant { 0 <=
to_int !i <= to_int
n }
invariant { is_board board (
to_int
pos) }
variant {
to_int n - to_int
!i }
invariant { 0 <=
!i <=
n }
invariant { is_board board (pos) }
variant {
n -
!i }
board[pos] <- !i;
if check_is_consistent board pos then
count_bt_queens solutions board n (pos + of_int 1);
...
...
@@ -205,7 +205,7 @@ module NQueens63
done
let count_queens (n: int63) : P.t
requires {
to_int
n >= 0 }
requires { n >= 0 }
ensures { true }
=
let solutions = ref (P.zero ()) in
...
...
examples/vstte10_queens/why3session.xml
View file @
4c99984c
...
...
@@ -2,147 +2,97 @@
<!DOCTYPE why3session PUBLIC "-//Why3//proof session v5//EN"
"http://why3.lri.fr/why3session.dtd">
<why3session
shape_version=
"4"
>
<prover
id=
"0"
name=
"CVC4"
version=
"1.4"
timelimit=
"6"
steplimit=
"0"
memlimit=
"1000"
/>
<prover
id=
"1"
name=
"CVC3"
version=
"2.4.1"
timelimit=
"20"
steplimit=
"0"
memlimit=
"0"
/>
<prover
id=
"2"
name=
"Z3"
version=
"4.3.2"
timelimit=
"6"
steplimit=
"0"
memlimit=
"1000"
/>
<prover
id=
"0"
name=
"CVC4"
version=
"1.4"
timelimit=
"5"
steplimit=
"0"
memlimit=
"1000"
/>
<prover
id=
"3"
name=
"Z3"
version=
"3.2"
timelimit=
"8"
steplimit=
"0"
memlimit=
"1000"
/>
<prover
id=
"
6"
name=
"Alt-Ergo"
version=
"0.99.1"
timelimit=
"6
"
steplimit=
"0"
memlimit=
"1000"
/>
<prover
id=
"
4"
name=
"Alt-Ergo"
version=
"1.30"
timelimit=
"5
"
steplimit=
"0"
memlimit=
"1000"
/>
<file
name=
"../vstte10_queens.mlw"
expanded=
"true"
>
<theory
name=
"NQueens"
sum=
"
bd54a466f42b418faffacb9470dabda3
"
expanded=
"true"
>
<theory
name=
"NQueens"
sum=
"
409b3951ae957384bbb25de0839f6b15
"
expanded=
"true"
>
<goal
name=
"eq_board_set"
>
<proof
prover=
"
6"
timelimit=
"5"
><result
status=
"valid"
time=
"0.00"
steps=
"7
"
/></proof>
<proof
prover=
"
4"
><result
status=
"valid"
time=
"0.00"
steps=
"12
"
/></proof>
</goal>
<goal
name=
"eq_board_sym"
>
<proof
prover=
"
6"
timelimit=
"20"
memlimit=
"0"
><result
status=
"valid"
time=
"0.01"
steps=
"7
"
/></proof>
<proof
prover=
"
4"
timelimit=
"20"
memlimit=
"0"
><result
status=
"valid"
time=
"0.01"
steps=
"3
"
/></proof>
</goal>
<goal
name=
"eq_board_trans"
>
<proof
prover=
"
6"
timelimit=
"20"
memlimit=
"0"
><result
status=
"valid"
time=
"0.01"
steps=
"10
"
/></proof>
<proof
prover=
"
4"
timelimit=
"20"
memlimit=
"0"
><result
status=
"valid"
time=
"0.01"
steps=
"9
"
/></proof>
</goal>
<goal
name=
"eq_board_extension"
>
<proof
prover=
"
6
"
timelimit=
"20"
memlimit=
"0"
><result
status=
"valid"
time=
"0.01"
steps=
"10"
/></proof>
<proof
prover=
"
4
"
timelimit=
"20"
memlimit=
"0"
><result
status=
"valid"
time=
"0.01"
steps=
"10"
/></proof>
</goal>
<goal
name=
"consistent_row_eq"
>
<proof
prover=
"
6"
timelimit=
"20"
memlimit=
"0"
><result
status=
"valid"
time=
"0.06"
steps=
"37
"
/></proof>
<proof
prover=
"
4"
timelimit=
"20"
memlimit=
"0"
><result
status=
"valid"
time=
"0.06"
steps=
"32
"
/></proof>
</goal>
<goal
name=
"
WP_parameter check_is_consistent"
expl=
"VC for check_is_consistent
"
>
<proof
prover=
"
1"
><result
status=
"valid"
time=
"0.0
2"
/></proof>
<goal
name=
"
VC check_is_consistent"
expl=
"VC for check_is_consistent"
expanded=
"true
"
>
<proof
prover=
"
4"
><result
status=
"valid"
time=
"0.02"
steps=
"6
2"
/></proof>
</goal>
<goal
name=
"solution_eq_board"
>
<proof
prover=
"3"
><result
status=
"valid"
time=
"0.06"
/></proof>
</goal>
<goal
name=
"WP_parameter bt_queens"
expl=
"VC for bt_queens"
>
<proof
prover=
"1"
><result
status=
"valid"
time=
"1.42"
/></proof>
<goal
name=
"VC bt_queens"
expl=
"VC for bt_queens"
expanded=
"true"
>
<transf
name=
"split_goal_wp"
expanded=
"true"
>
<goal
name=
"VC bt_queens.1"
expl=
"1. exceptional postcondition"
>
<proof
prover=
"4"
><result
status=
"valid"
time=
"0.01"
steps=
"6"
/></proof>
</goal>
<goal
name=
"WP_parameter queens"
expl=
"VC for queen
s"
>
<proof
prover=
"6"
timelimit=
"20"
memlimit=
"0"
><result
status=
"valid"
time=
"0.02"
steps=
"25
"
/></proof>
<goal
name=
"VC bt_queens.2"
expl=
"2. loop bound
s"
>
<proof
prover=
"4"
><result
status=
"valid"
time=
"0.01"
steps=
"6
"
/></proof>
</goal>
<goal
name=
"WP_parameter test8"
expl=
"VC for test8
"
>
<proof
prover=
"6"
timelimit=
"5"
><result
status=
"valid"
time=
"0.01"
steps=
"2
"
/></proof>
<goal
name=
"VC bt_queens.3"
expl=
"3. loop invariant init
"
>
<proof
prover=
"4"
><result
status=
"valid"
time=
"0.01"
steps=
"7
"
/></proof>
</goal>
<goal
name=
"WP_parameter count_bt_queens"
expl=
"VC for count_bt_queen
s"
>
<proof
prover=
"0"
timelimit=
"5"
memlimit=
"4000"
><result
status=
"valid"
time=
"0.27
"
/></proof>
<goal
name=
"VC bt_queens.4"
expl=
"4. index in array bound
s"
>
<proof
prover=
"4"
><result
status=
"valid"
time=
"0.01"
steps=
"10
"
/></proof>
</goal>
<goal
name=
"WP_parameter count_queens"
expl=
"VC for count_queens
"
>
<proof
prover=
"6"
><result
status=
"valid"
time=
"0.01"
steps=
"7
"
/></proof>
<goal
name=
"VC bt_queens.5"
expl=
"5. precondition
"
>
<proof
prover=
"4"
><result
status=
"valid"
time=
"0.01"
steps=
"12
"
/></proof>
</goal>
<goal
name=
"WP_parameter test_count_8"
expl=
"VC for test_count_8
"
>
<proof
prover=
"6"
><result
status=
"valid"
time=
"0.01"
steps=
"2
"
/></proof>
<goal
name=
"VC bt_queens.6"
expl=
"6. variant decrease
"
>
<proof
prover=
"4"
><result
status=
"valid"
time=
"0.01"
steps=
"13
"
/></proof>
</goal>
</theory>
<theory
name=
"NQueens63"
sum=
"f2313c3331066814cd7f4f7313021e3c"
expanded=
"true"
>
<goal
name=
"WP_parameter check_is_consistent"
expl=
"VC for check_is_consistent"
>
<proof
prover=
"0"
><result
status=
"valid"
time=
"0.09"
/></proof>
</goal>
<goal
name=
"WP_parameter count_bt_queens"
expl=
"VC for count_bt_queens"
>
<transf
name=
"split_goal_wp"
>
<goal
name=
"WP_parameter count_bt_queens.1"
expl=
"1. postcondition"
>
<proof
prover=
"6"
><result
status=
"valid"
time=
"0.02"
steps=
"9"
/></proof>
</goal>
<goal
name=
"WP_parameter count_bt_queens.2"
expl=
"2. integer overflow"
>
<proof
prover=
"6"
><result
status=
"valid"
time=
"0.02"
steps=
"8"
/></proof>
</goal>
<goal
name=
"WP_parameter count_bt_queens.3"
expl=
"3. loop invariant init"
>
<proof
prover=
"6"
><result
status=
"valid"
time=
"0.02"
steps=
"9"
/></proof>
</goal>
<goal
name=
"WP_parameter count_bt_queens.4"
expl=
"4. loop invariant init"
>
<proof
prover=
"6"
><result
status=
"valid"
time=
"0.02"
steps=
"9"
/></proof>
</goal>
<goal
name=
"WP_parameter count_bt_queens.5"
expl=
"5. type invariant"
>
<proof
prover=
"6"
><result
status=
"valid"
time=
"0.02"
steps=
"14"
/></proof>
</goal>
<goal
name=
"WP_parameter count_bt_queens.6"
expl=
"6. index in array63 bounds"
>
<proof
prover=
"6"
><result
status=
"valid"
time=
"0.02"
steps=
"14"
/></proof>
</goal>
<goal
name=
"WP_parameter count_bt_queens.7"
expl=
"7. precondition"
>
<proof
prover=
"6"
><result
status=
"valid"
time=
"0.02"
steps=
"16"
/></proof>
</goal>
<goal
name=
"WP_parameter count_bt_queens.8"
expl=
"8. precondition"
>
<proof
prover=
"6"
><result
status=
"valid"
time=
"0.17"
steps=
"115"
/></proof>
</goal>
<goal
name=
"WP_parameter count_bt_queens.9"
expl=
"9. integer overflow"
>
<proof
prover=
"6"
><result
status=
"valid"
time=
"0.02"
steps=
"21"
/></proof>
<goal
name=
"VC bt_queens.7"
expl=
"7. precondition"
>
<proof
prover=
"0"
><result
status=
"valid"
time=
"0.16"
/></proof>
</goal>
<goal
name=
"
WP_parameter count_bt_queens.10"
expl=
"10. integer overflow
"
>
<proof
prover=
"
6"
><result
status=
"valid"
time=
"0.04"
steps=
"48
"
/></proof>
<goal
name=
"
VC bt_queens.8"
expl=
"8. loop invariant preservation
"
>
<proof
prover=
"
4"
><result
status=
"valid"
time=
"0.06"
steps=
"236
"
/></proof>
</goal>
<goal
name=
"
WP_parameter count_bt_queens.11"
expl=
"11. variant decrease
"
>
<proof
prover=
"
6"
><result
status=
"valid"
time=
"0.02"
steps=
"22
"
/></proof>
<goal
name=
"
VC bt_queens.9"
expl=
"9. exceptional postcondition
"
>
<proof
prover=
"
4"
><result
status=
"valid"
time=
"0.01"
steps=
"15
"
/></proof>
</goal>
<goal
name=
"
WP_parameter count_bt_queens.12"
expl=
"12. precondi
tion"
>
<proof
prover=
"
6"
><result
status=
"valid"
time=
"0.02"
steps=
"22
"
/></proof>
<goal
name=
"
VC bt_queens.10"
expl=
"10. loop invariant preserva
tion"
>
<proof
prover=
"
4"
><result
status=
"valid"
time=
"0.51"
steps=
"895
"
/></proof>
</goal>
<goal
name=
"
WP_parameter count_bt_queens.13"
expl=
"13. pre
condition"
>
<proof
prover=
"
6"
><result
status=
"valid"
time=
"0.02"
steps=
"2
2"
/></proof>
<goal
name=
"
VC bt_queens.11"
expl=
"11. post
condition"
>
<proof
prover=
"
4"
><result
status=
"valid"
time=
"0.01"
steps=
"3
2"
/></proof>
</goal>
<goal
name=
"WP_parameter count_bt_queens.14"
expl=
"14. precondition"
>
<proof
prover=
"0"
><result
status=
"valid"
time=
"0.05"
/></proof>
<proof
prover=
"6"
><result
status=
"valid"
time=
"0.00"
steps=
"22"
/></proof>
</goal>
<goal
name=
"WP_parameter count_bt_queens.15"
expl=
"15. integer overflow"
>
<proof
prover=
"6"
><result
status=
"valid"
time=
"0.02"
steps=
"26"
/></proof>
</goal>
<goal
name=
"WP_parameter count_bt_queens.16"
expl=
"16. integer overflow"
>
<proof
prover=
"6"
><result
status=
"valid"
time=
"0.13"
steps=
"62"
/></proof>
</goal>
<goal
name=
"WP_parameter count_bt_queens.17"
expl=
"17. loop invariant preservation"
>
<proof
prover=
"6"
><result
status=
"valid"
time=
"0.02"
steps=
"30"
/></proof>
</goal>
<goal
name=
"WP_parameter count_bt_queens.18"
expl=
"18. loop invariant preservation"
>
<proof
prover=
"6"
><result
status=
"valid"
time=
"0.02"
steps=
"58"
/></proof>
</goal>
<goal
name=
"WP_parameter count_bt_queens.19"
expl=
"19. loop variant decrease"
>
<proof
prover=
"6"
><result
status=
"valid"
time=
"0.02"
steps=
"30"
/></proof>
</goal>
<goal
name=
"WP_parameter count_bt_queens.20"
expl=
"20. integer overflow"
>
<proof
prover=
"6"
><result
status=
"valid"
time=
"0.01"
steps=
"21"
/></proof>
</transf>
</goal>
<goal
name=
"WP_parameter count_bt_queens.21"
expl=
"21. integer overflow
"
>
<proof
prover=
"6"
><result
status=
"valid"
time=
"0.02"
steps=
"48
"
/></proof>
<goal
name=
"VC queens"
expl=
"VC for queens"
expanded=
"true
"
>
<proof
prover=
"4"
><result
status=
"valid"
time=
"0.00"
steps=
"24
"
/></proof>
</goal>
<goal
name=
"WP_parameter count_bt_queens.22"
expl=
"22. loop invariant preservation
"
>
<proof
prover=
"6"
><result
status=
"valid"
time=
"0.02"
steps=
"23
"
/></proof>
<goal
name=
"VC test8"
expl=
"VC for test8"
expanded=
"true
"
>
<proof
prover=
"4"
><result
status=
"valid"
time=
"0.00"
steps=
"1
"
/></proof>
</goal>
<goal
name=
"WP_parameter count_bt_queens.23"
expl=
"23. loop invariant preservation
"
>
<proof
prover=
"6"
><result
status=
"valid"
time=
"0.11"
steps=
"46
"
/></proof>
<goal
name=
"VC count_bt_queens"
expl=
"VC for count_bt_queens"
expanded=
"true
"
>
<proof
prover=
"4"
><result
status=
"valid"
time=
"1.26"
steps=
"438
"
/></proof>
</goal>
<goal
name=
"WP_parameter count_bt_queens.24"
expl=
"24. loop variant decreas
e"
>
<proof
prover=
"6"
><result
status=
"valid"
time=
"0.02"
steps=
"23
"
/></proof>
<goal
name=
"VC count_queens"
expl=
"VC for count_queens"
expanded=
"tru
e"
>
<proof
prover=
"4"
><result
status=
"valid"
time=
"0.00"
steps=
"7
"
/></proof>
</goal>
<goal
name=
"WP_parameter count_bt_queens.25"
expl=
"25. type invariant"
>
<proof
prover=
"0"
><result
status=
"valid"
time=
"0.05"
/></proof>
<proof
prover=
"6"
><result
status=
"valid"
time=
"0.02"
steps=
"14"
/></proof>
<goal
name=
"VC test_count_8"
expl=
"VC for test_count_8"
expanded=
"true"
>
<proof
prover=
"4"
><result
status=
"valid"
time=
"0.00"
steps=
"1"
/></proof>
</goal>
<goal
name=
"WP_parameter count_bt_queens.26"
expl=
"26. postcondition"
>
<proof
prover=
"6"
><result
status=
"valid"
time=
"0.01"
steps=
"14"
/></proof>
</theory>
<theory
name=
"NQueens63"
sum=
"8c5fcf08811dad3a40f6c343ffc3660e"
expanded=
"true"
>
<goal
name=
"VC check_is_consistent"
expl=
"VC for check_is_consistent"
expanded=
"true"
>
<proof
prover=
"4"
><result
status=
"valid"
time=
"0.09"
steps=
"287"
/></proof>
</goal>
</transf>
<goal
name=
"VC count_bt_queens"
expl=
"VC for count_bt_queens"
expanded=
"true"
>
<proof
prover=
"4"
><result
status=
"valid"
time=
"0.32"
steps=
"1264"
/></proof>
</goal>
<goal
name=
"
WP_parameter count_queens"
expl=
"VC for count_queens
"
>
<proof
prover=
"
6"
><result
status=
"valid"
time=
"0.01"
steps=
"12
"
/></proof>
<goal
name=
"
VC count_queens"
expl=
"VC for count_queens"
expanded=
"true
"
>
<proof
prover=
"
4"
><result
status=
"valid"
time=
"0.01"
steps=
"11
"
/></proof>
</goal>
<goal
name=
"WP_parameter test_count_8"
expl=
"VC for test_count_8"
>
<proof
prover=
"2"
><result
status=
"valid"
time=
"0.01"
/></proof>
<proof
prover=
"6"
><result
status=
"valid"
time=
"0.00"
steps=
"2"
/></proof>
<goal
name=
"VC test_count_8"
expl=
"VC for test_count_8"
expanded=
"true"
>
<proof
prover=
"4"
><result
status=
"valid"
time=
"0.01"
steps=
"2"
/></proof>
</goal>
</theory>
</file>
...
...
examples/vstte10_queens/why3shapes.gz
View file @
4c99984c
No preview for this file type
modules/mach/int.mlw
View file @
4c99984c
...
...
@@ -45,6 +45,7 @@ module Bounded_int
constant max : int
val function to_int (n:t) : int
meta coercion function to_int
predicate in_bounds (n:int) = min <= n <= max
...
...
src/core/coercion.ml
0 → 100644
View file @
4c99984c
open
Ident
open
Ty
open
Term
type
coercion_kind
=
|
CRCleaf
of
lsymbol
|
CRCcomp
of
coercion_kind
*
coercion_kind
type
coercion
=
{
crc_kind
:
coercion_kind
;
crc_src
:
Ty
.
tysymbol
;
crc_tar
:
Ty
.
tysymbol
;
crc_len
:
int
;
}
type
t
=
(
coercion
Mts
.
t
)
Mts
.
t
(** invariant: transitively closed *)
let
empty
=
Mts
.
empty
exception
NotACoercion
of
lsymbol
exception
CoercionCycle
of
coercion
exception
CoercionAlreadyDefined
of
coercion
let
create_crc
ls
=
match
ls
.
ls_args
,
ls
.
ls_value
with
|
[{
ty_node
=
Tyapp
(
ty1
,_
)}]
,
Some
{
ty_node
=
Tyapp
(
ty2
,_
)}
->
if
ts_equal
ty1
ty2
then
raise
(
NotACoercion
ls
);
{
crc_kind
=
CRCleaf
ls
;
crc_src
=
ty1
;
crc_tar
=
ty2
;
crc_len
=
1
}
|
_
->
raise
(
NotACoercion
ls
)
let
mem
crcmap
ts1
ts2
=
try
let
m
=
Mts
.
find
ts1
crcmap
in
Mts
.
mem
ts2
m
with
Not_found
->
false
let
find
crcmap
ts1
ts2
=
Mts
.
find
ts2
(
Mts
.
find
ts1
crcmap
)
(* replace an old coercion by a new one, or fail *)
let
replace
c_old
c_new
_m1
m
=
match
c_old
.
crc_kind
,
c_new
.
crc_kind
with
|
CRCleaf
ls_old
,
CRCleaf
ls_new
when
ls_equal
ls_old
ls_new
->
m
|
_
->
raise
(
CoercionAlreadyDefined
c_old
)
(* add a new coercion c, without making the transitive closure *)
let
insert
crc
m
=
let
put
crc
m1
m2
=
Mts
.
add
crc
.
crc_src
(
Mts
.
add
crc
.
crc_tar
crc
m1
)
m2
in
if
mem
m
crc
.
crc_tar
crc
.
crc_src
then
raise
(
CoercionCycle
(
find
m
crc
.
crc_tar
crc
.
crc_src
));
let
m1
=
Mts
.
find_def
Mts
.
empty
crc
.
crc_src
m
in
if
Mts
.
mem
crc
.
crc_tar
m1
then
replace
(
Mts
.
find
crc
.
crc_tar
m1
)
crc
m1
m
else
put
crc
m1
m
let
compose
crc1
crc2
=
{
crc_kind
=
CRCcomp
(
crc1
.
crc_kind
,
crc2
.
crc_kind
);
crc_src
=
crc1
.
crc_src
;
crc_tar
=
crc2
.
crc_tar
;
crc_len
=
crc1
.
crc_len
+
crc2
.
crc_len
}
(* add a new coercion crc, and make the transitive closure *)
let
add_crc
crcmap
crc
=
let
close_right
c1
_ty
c2
macc
=
insert
(
compose
c1
c2
)
macc
in
let
close_left_right
_ty1
m1
macc
=
if
Mts
.
mem
crc
.
crc_src
m1
then
let
c1
=
Mts
.
find
crc
.
crc_src
m1
in
let
m2
=
Mts
.
find_def
Mts
.
empty
crc
.
crc_tar
macc
in
Mts
.
fold
(
close_right
c1
)
(
Mts
.
add
crc
.
crc_tar
crc
m2
)
macc
else
macc
in
let
crcmap_uc1
=
insert
crc
crcmap
in
let
crcmap_uc2
=
let
m1
=
Mts
.
find_def
Mts
.
empty
crc
.
crc_tar
crcmap_uc1
in
Mts
.
fold
(
close_right
crc
)
m1
crcmap_uc1
in
Mts
.
fold
(
close_left_right
)
crcmap_uc2
crcmap_uc2
let
add
crcmap
ls
=
add_crc
crcmap
(
create_crc
ls
)
let
union
s1
s2
=
Mts
.
fold
(
fun
_
m1
s
->
Mts
.
fold
(
fun
_
c
s
->
add_crc
s
c
)
m1
s
)
s2
s1
let
rec
print_kind
fmt
=
function
|
CRCleaf
ls
->
Format
.
fprintf
fmt
"%s"
ls
.
ls_name
.
id_string
|
CRCcomp
(
k1
,
k2
)
->
Format
.
fprintf
fmt
"%a o %a"
print_kind
k2
print_kind
k1
let
already_a_coercion
fmt
crc
=
Format
.
fprintf
fmt
"already a coercion from type %s to type %s@ (%a)"
crc
.
crc_src
.
ts_name
.
id_string
crc
.
crc_tar
.
ts_name
.
id_string
print_kind
crc
.
crc_kind
let
()
=
Exn_printer
.
register
begin
fun
fmt
exn
->
match
exn
with
|
NotACoercion
ls
->
Format
.
fprintf
fmt
"Function %s cannot be used as a coercion"
ls
.
ls_name
.
id_string
|
CoercionCycle
crc
->
Format
.
fprintf
fmt
"This coercion introduces a cycle;@ "
;
already_a_coercion
fmt
crc
|
CoercionAlreadyDefined
crc
->
already_a_coercion
fmt
crc
|
_
->
raise
exn
end
src/core/coercion.mli
0 → 100644
View file @
4c99984c
type
coercion_kind
=
|
CRCleaf
of
Term
.
lsymbol
|
CRCcomp
of
coercion_kind
*
coercion_kind
type
coercion
=
private
{
crc_kind
:
coercion_kind
;
crc_src
:
Ty
.
tysymbol
;
crc_tar
:
Ty
.
tysymbol
;
crc_len
:
int
;
}
type
t
(** a set of coercions *)
val
empty
:
t
val
add
:
t
->
Term
.
lsymbol
->
t
(** adds a new coercion
raises an error if this introduces a cycle *)
val
find
:
t
->
Ty
.
tysymbol
->
Ty
.
tysymbol
->
coercion
(** returns the coercion, or raises [Not_found] *)
val
union
:
t
->
t
->
t
(** [union s1 s2] merges the coercions from [s2] into [s1]
(as a new set of coercions)