let rec if_term_to_type = function
    If_address(i)
  | If_const(i) ->
      Globals.type_table#get_type i
  | If_cons(_,t2)
  | If_delete(_,t2) ->
      if_term_to_type t2
  | If_set(l) ->
      let rec find_applied = function
          t::lt ->
            (try
              Set([if_term_to_type t])
            with Not_found -> find_applied lt)
        | [] -> raise Not_found
      in
      find_applied l
(*  | If_lst(l) ->
      let rec find_applied = function
          t::lt ->
            (try
              Lst([if_term_to_type t])
            with Not_found -> find_applied lt)
        | [] -> raise Not_found
      in
      find_applied l*)

  | If_pair(t1,t2) ->
      Pair(if_term_to_type t1, if_term_to_type t2)
  | If_scrypt(t1,t2) ->
      Scrypt(if_term_to_type t1, if_term_to_type t2)
  | If_crypt(t1,t2) ->
      Crypt(if_term_to_type t1, if_term_to_type t2)
  | If_inv(t) ->
      Inv(if_term_to_type t)
  | If_function(t1,lt) ->
      Function(if_term_to_type t1, List.map if_term_to_type lt)