Commit 7b0929a7 authored by Andrei Paskevich's avatar Andrei Paskevich

WhyML: "use/clone T" imports by default (in absence of "as")

For the previous behaviour (no import), write "use/clone T as T".

This shortens the most used "use/clone import" to simply "use/clone".
parent 585b99a6
...@@ -5,5 +5,5 @@ end ...@@ -5,5 +5,5 @@ end
module M module M
type t = { a: bool } (* bad type for a *) type t = { a: bool } (* bad type for a *)
clone S with type t = t clone import S with type t = t
end end
...@@ -5,5 +5,5 @@ end ...@@ -5,5 +5,5 @@ end
module M module M
type t = { b: int } (* no field a *) type t = { b: int } (* no field a *)
clone S with type t = t clone import S with type t = t
end end
theory A use B end theory A use export B end
theory A end theory A end
theory B use A use A end theory B use import A use import A end
theory A end theory A end
theory B end theory B end
theory C use A use B as A end theory C use A as A use B as A end
...@@ -7,7 +7,7 @@ theory A ...@@ -7,7 +7,7 @@ theory A
end end
theory B theory B
use A use A as A
use A use A as A
end end
...@@ -3,5 +3,5 @@ theory A ...@@ -3,5 +3,5 @@ theory A
end end
theory B theory B
use A use A as A
end end
...@@ -202,7 +202,7 @@ end ...@@ -202,7 +202,7 @@ end
theory TestSemantics theory TestSemantics
use import SemOp use import SemOp
use map.Const use import map.Const
function my_sigma : env = Const.const (Vint 0) function my_sigma : env = Const.const (Vint 0)
constant x : ident constant x : ident
......
...@@ -44,7 +44,7 @@ function eval (f:prop_fmla) (v:idmap bool) : bool = ...@@ -44,7 +44,7 @@ function eval (f:prop_fmla) (v:idmap bool) : bool =
end end
use map.Const use import map.Const
goal Test1 : goal Test1 :
let x = mk_ident 0 in let x = mk_ident 0 in
......
...@@ -56,7 +56,7 @@ function eval_expr (s:state) (e:expr) : int = ...@@ -56,7 +56,7 @@ function eval_expr (s:state) (e:expr) : int =
eval_bin (eval_expr s e1) op (eval_expr s e2) eval_bin (eval_expr s e1) op (eval_expr s e2)
end end
use map.Const use import map.Const
goal Test13 : goal Test13 :
let s = Const.const 0 in let s = Const.const 0 in
......
...@@ -262,7 +262,7 @@ end ...@@ -262,7 +262,7 @@ end
theory TestSemantics theory TestSemantics
use import Imp use import Imp
use map.Const use import map.Const
function my_sigma : env = Const.const (Vint 0) function my_sigma : env = Const.const (Vint 0)
function my_pi : env = Const.const (Vint 42) function my_pi : env = Const.const (Vint 42)
...@@ -425,7 +425,7 @@ predicate stmt_writes (i:stmt) (w:Set.set ident) = ...@@ -425,7 +425,7 @@ predicate stmt_writes (i:stmt) (w:Set.set ident) =
eval_fmla sigma' pi' result eval_fmla sigma' pi' result
} }
use HoareLogic use import HoareLogic
let rec wp (i:stmt) (q:fmla) let rec wp (i:stmt) (q:fmla)
ensures { valid_triple result i q } ensures { valid_triple result i q }
......
...@@ -49,7 +49,7 @@ module ResizableArraySpec ...@@ -49,7 +49,7 @@ module ResizableArraySpec
use import int.Int use import int.Int
use import map.Map use import map.Map
use map.Const use import map.Const
type rarray 'a = private { type rarray 'a = private {
ghost mutable len: int; ghost mutable len: int;
...@@ -93,9 +93,9 @@ module BagImpl ...@@ -93,9 +93,9 @@ module BagImpl
use import int.Int use import int.Int
use import Bag use import Bag
use import ResizableArraySpec as R use import ResizableArraySpec as R
use map.Map use map.Map as Map
use int.NumOf use int.NumOf as NumOf
use null.Null use null.Null as Null
function numof (r: rarray (Null.t 'a)) (x: 'a) (l u: int) : int = function numof (r: rarray (Null.t 'a)) (x: 'a) (l u: int) : int =
NumOf.numof (fun i -> (Map.get r.R.data i).Null.v = Null.Value x) l u NumOf.numof (fun i -> (Map.get r.R.data i).Null.v = Null.Value x) l u
...@@ -164,7 +164,7 @@ module BagImpl ...@@ -164,7 +164,7 @@ module BagImpl
resize t.data n; resize t.data n;
t.size <- n t.size <- n
clone BagSpec with clone import BagSpec with
type t = t, type t = t,
val create = create, val create = create,
val clear = clear, val clear = clear,
......
...@@ -9,7 +9,6 @@ theory Graph ...@@ -9,7 +9,6 @@ theory Graph
use export list.List use export list.List
use export list.Append use export list.Append
use export list.Length use export list.Length
use list.Mem
use export int.Int use export int.Int
use export set.Fset use export set.Fset
...@@ -61,7 +60,7 @@ theory Graph ...@@ -61,7 +60,7 @@ theory Graph
Two cases depending on l3=[] (and thus u=v) conclude the proof. Qed. Two cases depending on l3=[] (and thus u=v) conclude the proof. Qed.
*) *)
clone pigeon.ListAndSet with type t = vertex clone import pigeon.ListAndSet with type t = vertex
predicate cyc_decomp (v: vertex) (l: list vertex) predicate cyc_decomp (v: vertex) (l: list vertex)
(vi: vertex) (l1 l2 l3: list vertex) = (vi: vertex) (l1 l2 l3: list vertex) =
......
...@@ -8,10 +8,10 @@ ...@@ -8,10 +8,10 @@
module BinarySqrt module BinarySqrt
use import real.Real use import real.Real
use int.Int use int.Int as Int
use real.MinMax use real.MinMax as MinMax
use real.FromInt use real.FromInt as FromInt
use real.Truncate use real.Truncate as Truncate
let rec sqrt (r: real) (eps: real) (ghost n:int) (ghost eps0:real) : real let rec sqrt (r: real) (eps: real) (ghost n:int) (ghost eps0:real) : real
requires { 0.0 <= r } requires { 0.0 <= r }
......
...@@ -20,7 +20,7 @@ module BinomialHeap ...@@ -20,7 +20,7 @@ module BinomialHeap
type elt type elt
val predicate le elt elt val predicate le elt elt
clone relations.TotalPreOrder with type t = elt, predicate rel = le, axiom . clone import relations.TotalPreOrder with type t = elt, predicate rel = le, axiom .
(** Trees. (** Trees.
......
...@@ -390,7 +390,7 @@ module AsciiCode ...@@ -390,7 +390,7 @@ module AsciiCode
odd number of changes on a valid ascii character, the result odd number of changes on a valid ascii character, the result
will be invalid, hence the validity of the encoding. *) will be invalid, hence the validity of the encoding. *)
use Hamming use import Hamming
let rec lemma tmp (a b : t) (i j : int) let rec lemma tmp (a b : t) (i j : int)
requires { i < j } requires { i < j }
......
...@@ -22,8 +22,8 @@ module Test_proofinuse ...@@ -22,8 +22,8 @@ module Test_proofinuse
(* Mask example --------------------- *) (* Mask example --------------------- *)
use bv.BV8 use bv.BV8 as BV8
use bv.BV64 use bv.BV64 as BV64
use bv.BVConverter_32_64 as C32_46 use bv.BVConverter_32_64 as C32_46
use bv.BVConverter_8_32 as C8_32 use bv.BVConverter_8_32 as C8_32
......
...@@ -375,8 +375,8 @@ theory BV32_64 ...@@ -375,8 +375,8 @@ theory BV32_64
use import int.Int use import int.Int
use BV32 use BV32 as BV32
use BV64 use BV64 as BV64
function concat BV32.bv BV32.bv : BV64.bv function concat BV32.bv BV32.bv : BV64.bv
......
...@@ -7,11 +7,11 @@ theory DoubleOfInt ...@@ -7,11 +7,11 @@ theory DoubleOfInt
use import real.RealInfix use import real.RealInfix
use import real.FromInt use import real.FromInt
use power2.Pow2int use power2.Pow2int as Pow2int
use power2.Pow2real use power2.Pow2real as Pow2real
use bitvector.BV32 use bitvector.BV32 as BV32
use bitvector.BV64 use bitvector.BV64 as BV64
use bitvector.BV32_64 use bitvector.BV32_64 as BV32_64
use import double.BV_double use import double.BV_double
(*********************************************************************) (*********************************************************************)
......
...@@ -143,16 +143,10 @@ theory Pow2real ...@@ -143,16 +143,10 @@ theory Pow2real
lemma Power_sum : forall n m: int. pow2 (n+m) = pow2 n *. pow2 m lemma Power_sum : forall n m: int. pow2 (n+m) = pow2 n *. pow2 m
use Pow2int use Pow2int as P2I
use import real.FromInt use import real.FromInt
lemma Pow2_int_real: lemma Pow2_int_real:
forall x:int. x >= 0 -> pow2 x = from_int (Pow2int.pow2 x) forall x:int. x >= 0 -> pow2 x = from_int (P2I.pow2 x)
end end
(*
Local Variables:
compile-command: "why3 ide power2.why"
End:
*)
...@@ -26,7 +26,7 @@ module BraunHeaps ...@@ -26,7 +26,7 @@ module BraunHeaps
val predicate le elt elt val predicate le elt elt
clone relations.TotalPreOrder with type t = elt, predicate rel = le, axiom . clone import relations.TotalPreOrder with type t = elt, predicate rel = le, axiom .
(* [e] is no greater than the root of [t], if any *) (* [e] is no greater than the root of [t], if any *)
let predicate le_root (e: elt) (t: tree elt) = match t with let predicate le_root (e: elt) (t: tree elt) = match t with
......
theory T theory T
use real.Real use import real.Real
goal toto: true goal toto: true
end end
...@@ -21,7 +21,7 @@ module B ...@@ -21,7 +21,7 @@ module B
type t = { ghost a : unit } type t = { ghost a : unit }
clone A with type t = t clone export A with type t = t
(* FIXME ! (* FIXME !
let sub (x:t) : unit = A.add x let sub (x:t) : unit = A.add x
......
...@@ -5,5 +5,5 @@ end ...@@ -5,5 +5,5 @@ end
module B module B
goal G : false goal G : false
clone A with goal G clone A as A with goal G
end end
module Soundness module Soundness
use import int.Int use import int.Int
use HighOrd
function f0 (x y z:int) : int = x * y + z function f0 (x y z:int) : int = x * y + z
predicate p (f:int -> int) = predicate p (f:int -> int) =
......
theory Test theory Test
type t type t
function f t t : t function f t t : t
clone algebra.AC with type t = t, function op = f, axiom . clone import algebra.AC with type t = t, function op = f, axiom .
goal G1 : forall x y : t. f x y = f y x goal G1 : forall x y : t. f x y = f y x
goal G2 : forall x y z : t. f (f x y) z = f x (f y z) goal G2 : forall x y z : t. f (f x y) z = f x (f y z)
end end
...@@ -5,7 +5,7 @@ theory TestGappa ...@@ -5,7 +5,7 @@ theory TestGappa
use import real.Abs use import real.Abs
use import real.Square use import real.Square
use import floating_point.Rounding use import floating_point.Rounding
use floating_point.Single use floating_point.Single as Single
use import floating_point.Double use import floating_point.Double
goal Round_single_01: goal Round_single_01:
......
...@@ -85,7 +85,7 @@ module ListCursorImpl (* : ListCursor *) ...@@ -85,7 +85,7 @@ module ListCursorImpl (* : ListCursor *)
ensures { result.to_visit = t } ensures { result.to_visit = t }
= { visited = empty; collection = t; to_visit = t } = { visited = empty; collection = t; to_visit = t }
clone cursor.ListCursor with clone import cursor.ListCursor with
type cursor = cursor, type cursor = cursor,
val create = create, val create = create,
val C.has_next = has_next, val C.has_next = has_next,
...@@ -187,7 +187,7 @@ module ArrayCursorImpl (* : ArrayCursor *) ...@@ -187,7 +187,7 @@ module ArrayCursorImpl (* : ArrayCursor *)
c.index <- c.index + 1; c.index <- c.index + 1;
x end x end
clone cursor.ArrayCursor with clone import cursor.ArrayCursor with
type cursor = cursor, type cursor = cursor,
val C.next = next, val C.next = next,
val C.has_next = has_next, val C.has_next = has_next,
......
...@@ -675,12 +675,12 @@ function size_e (e:expr) : int = ...@@ -675,12 +675,12 @@ function size_e (e:expr) : int =
lemma size_e_pos: forall e: expr. size_e e >= 1 lemma size_e_pos: forall e: expr. size_e e >= 1
use Defunctionalization use Defunctionalization as D
function size_c (c:cont) : int = function size_c (c:cont) : int =
match c with match c with
| I -> 0 | I -> 0
| A e2 k -> 2 + Defunctionalization.size_e e2 + size_c k | A e2 k -> 2 + D.size_e e2 + size_c k
| B _ k -> 1 + size_c k | B _ k -> 1 + size_c k
end end
...@@ -698,7 +698,7 @@ let rec continue_4 (c:cont) (v:int) : value ...@@ -698,7 +698,7 @@ let rec continue_4 (c:cont) (v:int) : value
end end
with eval_4 (e:expr) (c:cont) : value with eval_4 (e:expr) (c:cont) : value
variant { size_c c + Defunctionalization.size_e e } variant { size_c c + D.size_e e }
ensures { eval_cont c (eval_0 e) result } ensures { eval_cont c (eval_0 e) result }
= =
match e with match e with
...@@ -886,9 +886,9 @@ predicate is_empty_context (c:context) = ...@@ -886,9 +886,9 @@ predicate is_empty_context (c:context) =
end end
use Defunctionalization (* for size_e *) use Defunctionalization as D (* for size_e *)
function size_e (e:expr) : int = Defunctionalization.size_e e function size_e (e:expr) : int = D.size_e e
function size_c (c:context) : int = function size_c (c:context) : int =
match c with match c with
...@@ -1099,9 +1099,9 @@ use import SemWithError ...@@ -1099,9 +1099,9 @@ use import SemWithError
type context = Empty | Left context expr | Right int context type context = Empty | Left context expr | Right int context
use Defunctionalization (* for size_e *) use Defunctionalization as D (* for size_e *)
function size_e (e:expr) : int = Defunctionalization.size_e e function size_e (e:expr) : int = D.size_e e
function size_c (c:context) : int = function size_c (c:context) : int =
match c with match c with
......
...@@ -60,7 +60,7 @@ theory TriangularNumbers ...@@ -60,7 +60,7 @@ theory TriangularNumbers
use import int.Int use import int.Int
use import int.ComputerDivision use import int.ComputerDivision
use import int.Div2 use import int.Div2
use DivModHints use DivModHints as DMH
lemma tr_mod_2: lemma tr_mod_2:
forall n:int. n >= 0 -> mod (n*(n+1)) 2 = 0 forall n:int. n >= 0 -> mod (n*(n+1)) 2 = 0
...@@ -105,8 +105,7 @@ theory SumMultiple ...@@ -105,8 +105,7 @@ theory SumMultiple
predicate p (n:int) = sum_multiple_3_5_lt (n+1) = closed_formula_aux n predicate p (n:int) = sum_multiple_3_5_lt (n+1) = closed_formula_aux n
use DivModHints use DivModHints as DMH
use TriangularNumbers
lemma mod_15: lemma mod_15:
forall n:int. forall n:int.
......
...@@ -52,7 +52,7 @@ end ...@@ -52,7 +52,7 @@ end
module TreeMax module TreeMax
use import int.Int use import int.Int
use int.MinMax use import int.MinMax
use import BinTree use import BinTree
let rec max_aux (t:tree) (acc:int) variant {t} let rec max_aux (t:tree) (acc:int) variant {t}
......
...@@ -52,7 +52,7 @@ module BinaryGcd ...@@ -52,7 +52,7 @@ module BinaryGcd
lemma odd1: forall n: int. 0 <= n -> not (even n) <-> n = 2 * div n 2 + 1 lemma odd1: forall n: int. 0 <= n -> not (even n) <-> n = 2 * div n 2 + 1
lemma div_nonneg: forall n: int. 0 <= n -> 0 <= div n 2 lemma div_nonneg: forall n: int. 0 <= n -> 0 <= div n 2
use number.Coprime use import number.Coprime
lemma gcd_even_even: forall u v: int. 0 <= v -> 0 <= u -> lemma gcd_even_even: forall u v: int. 0 <= v -> 0 <= u ->
gcd (2 * u) (2 * v) = 2 * gcd u v gcd (2 * u) (2 * v) = 2 * gcd u v
......
...@@ -52,7 +52,7 @@ module BinaryGcd ...@@ -52,7 +52,7 @@ module BinaryGcd
lemma odd1: forall n: int. 0 <= n -> not (even n) <-> n = 2 * div n 2 + 1 lemma odd1: forall n: int. 0 <= n -> not (even n) <-> n = 2 * div n 2 + 1
lemma div_nonneg: forall n: int. 0 <= n -> 0 <= div n 2 lemma div_nonneg: forall n: int. 0 <= n -> 0 <= div n 2
use number.Coprime use import number.Coprime
lemma gcd_even_even: forall u v: int. 0 <= v -> 0 <= u -> lemma gcd_even_even: forall u v: int. 0 <= v -> 0 <= u ->
gcd (2 * u) (2 * v) = 2 * gcd u v gcd (2 * u) (2 * v) = 2 * gcd u v
......
...@@ -12,7 +12,7 @@ module HashtblImpl ...@@ -12,7 +12,7 @@ module HashtblImpl
use import list.List use import list.List
use import list.Mem use import list.Mem
use import map.Map use import map.Map
use map.Const use import map.Const
use import array.Array use import array.Array
type key type key
......