This document gives the essential changes to perform when migrating from Why2 to Why3.
Of course, this does not replace the Why3 manual.
theory T use import bool.Bool use import int.Int ... endThe first two imports correspond to the inclusion of the Why2 prelude. Generally speaking, the Why2 inclusion of other files does not exist anymore, and proper importation clauses must be used instead, e.g
include "division.why"must be replaced by
use import int.Computer_divisionThis declaration imports the theory called Computer_division from the file int.why of the Why3 standard library.
The following table provides a quick reference to syntax changes in the logic language
| Why 2.xx | Why3 0.70 |
|---|---|
| type 'a t | type t 'a |
| logic f: int, bool -> int | function f int bool : int |
| logic p: int, bool -> prop | predicate p int bool |
| function f (x: int, y:bool) = e | function f (x: int) (y:bool) = e |
| predicate p (x: int, y:bool) = e | predicate p (x: int) (y:bool) = e |
| inductive p : int, bool -> prop = ... | inductive p int bool = ... |
| f(t1,t2,t3) | (f t1 t2 t3) |
| f1 and f2 | f1 /\ f2 |
| f1 or f2 | f1 \/ f2 |
| (label : f) | "label" f |
| true (of type bool) | True |
| false (of type bool) | False |
| void | () |
| unit | () |
module M use import bool.Bool use import int.Int use import module ref.Ref use import module array.Array ... end
| Why 2.xx | Why3 0.70 |
|---|---|
| int ref | ref int |
| { ... x ... } | { ... !x ... } |
| { ... x@ ... } | { ... (old !x) ... } |
| { ... x@L ... } | { ... (at !x 'L) ... } |
| L: e | 'L : e |
| exception Exc of t | exception Exc t |
| parameter f: x:int -> y:int -> { ... } t writes a,b { ... } | val f (x:int) (y:int) : { ... } t writes a b { ... } |
| parameter f: int -> unit -> { ... } t writes a,b { ... } | val f : int -> unit -> { ... } t writes a b { ... } |
| while c do { invariant f variant t} e done | while c do invariant { f } variant { t } e done |
| while c do { invariant f variant t for R } e done | while c do invariant { f } variant { t } with R e done |
Examples of Why3 programs are available in
ProVal's gallery.
Why3 homepage