module V = struct type t = { id : string ; fr : int } let dump ppf t = Format.fprintf ppf "{%s(%d)}" t.id t.fr let compare x y = Pervasives.compare (x.id,x.fr) (y.id,y.fr) let equal x y = (compare x y) = 0 let hash x = Hashtbl.hash (x.id,x.fr) let check _ = () let id x = x.id let is_fresh x = x.fr > 0 let mk id = { id = id ; fr = 0 } let pp ppf x = (* let pre = if x.fr == 0 then "" else (Printf.sprintf "_fresh_%d" x.fr) in *) Format.fprintf ppf "'%s" x.id let fresh v = { v with fr = v.fr + 1 } end include V type var = t module Set = struct include SortedList.Make(V) let dump ppf s = Utils.pp_list ~sep:";" ~delim:("{","}") V.dump ppf (get s) let pp ppf s = Utils.pp_list ~sep:";" ~delim:("{","}") V.pp ppf (get s) let printf = pp Format.std_formatter let union = cup let inter = cap let cardinal = length let mem t v = mem v t let fold = fold end type 'a pairvar = [ `Atm of 'a | `Var of t ] module Make (X : Custom.T) = struct type t = X.t pairvar let hash = function `Atm t -> X.hash t | `Var x -> V.hash x let check = function `Atm t -> X.check t | `Var _ -> () let compare t1 t2 = match t1,t2 with |`Var x, `Var y -> compare x y |`Atm x, `Atm y -> X.compare x y |`Var _, `Atm _ -> -1 |`Atm _, `Var _ -> 1 let equal t1 t2 = (compare t1 t2) = 0 let dump ppf = function |`Atm x -> X.dump ppf x |`Var x -> V.dump ppf x end