let rec domain xs d = function
    | [] -> List.rev xs,List.rev d
    | h::hs ->
        match h with
          | Fresh x -> domain (x::xs) d hs
          | Update(x,_) ->
              let d' = if List.exists (F.eq_var x) d then d else (x::d) in
              domain xs d' hs