Newer
Older
(**************************************************************************)
(* *)
(* This file is part of WP plug-in of Frama-C. *)
(* *)
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
(* CEA (Commissariat a l'energie atomique et aux energies *)
(* alternatives) *)
(* *)
(* you can redistribute it and/or modify it under the terms of the GNU *)
(* Lesser General Public License as published by the Free Software *)
(* Foundation, version 2.1. *)
(* *)
(* It is distributed in the hope that it will be useful, *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
(* GNU Lesser General Public License for more details. *)
(* *)
(* See the GNU Lesser General Public License version 2.1 *)
(* for more details (enclosed in the file licenses/LGPLv2.1). *)
(* *)
(**************************************************************************)
(* -------------------------------------------------------------------------- *)
(* --- Passive Forms --- *)
(* -------------------------------------------------------------------------- *)
open Lang
open Lang.F
type binding =
| Bind of var * var (* fresh , bound *)
| Join of var * var (* left, right *)
type t = binding list
let empty = []
let is_empty n = n = []
let union = List.append
let bind ~fresh ~bound bs = Bind(fresh,bound) :: bs
let join x y bs =
if Var.equal x y then bs else Join(x,y) :: bs
let eq x y = F.p_equal (e_var x) (e_var y)
let rec collect phi hs = function
| [] -> hs
| Bind(x,y)::bs -> collect phi (if phi y then eq x y :: hs else hs) bs
| Join(x,y)::bs -> collect phi (if phi x || phi y then eq x y :: hs else hs) bs
let apply bindings p =
let xs = varsp p in
let hs = collect (fun x -> Vars.mem x xs) [] bindings in
p_conj (p::hs)
let conditions bindings phi = collect phi [] bindings
let iter = List.iter
let pretty fmt =
List.iter
begin function
| Bind(x,y) ->
Format.fprintf fmt "@ @[%a:=%a@]"
F.pp_var x F.pp_var y
| Join(x,y) ->
Format.fprintf fmt "@ @[%a==%a@]"
F.pp_var x F.pp_var y
end