let rec if_term_to_string (func : string) : Types.if_term -> string =

  let type_to_string = function
      Base(Var(i))
    | Base(Const(i)) ->
        term_type_to_string (Globals.type_table#get_type i)
    | Set(_) ->
        "set"
    | _ ->
        "message";
  in function

      State(name,session_id,l) ->
              if (func = "print_term_type"then
          if not(List.mem name !roles_printed) then
            (roles_printed := !roles_printed @ [name];
             ("state_"^name^" : "^(list_to_string type_to_string " * " l)^" -> fact\n"))
          else ""
              else 
          (
           (if func = "print_term_value" then 
             list_to_string (term_value_to_string session_id) "," l
           else
             list_to_string term_to_string "," l)
           )

    | Iknows t -> 
              if not (func = "print_term_type"then
          ((term_to_string t))
        else ""

    | Ifcontains (t1,t2) -> 
              if not (func = "print_term_type"then
          ("contains("^(term_to_string t1)
           ^","^(term_to_string t2)^")")
        else ""

    | Ifdelete (t1,t2) -> 
              if not (func = "print_term_type"then
          ("contains("^(term_to_string t1)
           ^","^(term_to_string t2)^")")
        else ""

    | Ifequal (t1,t2) -> 
              if not (func = "print_term_type"then
          ("equal("^(term_to_string t1)
           ^","^(term_to_string t2)^")")
        else ""

    | Ifleq (t1,t2) -> 
              if not (func = "print_term_type"then
          ("leq("^(term_to_string t1)
           ^","^(term_to_string t2)^")")
        else ""

    | Ifnot t ->
         "not("^(if_term_to_string func t)^")"

(*    | Secret(t1,t2) -> 
             if not (func = ") then
          ("^(term_to_string t1)^"
           ^(term_to_string t2)^")
        else "*)


(*    | Witness(authenticator, authenticated, const_term, var_term) ->
             if not (func = ") then
          let pl_authenticator = find_player_in_role authenticator in
          let pl_authenticated = find_player_in_role authenticated in
          ("
           ^(Globals.string_id#get_name pl_authenticator)^"
           ^(Globals.string_id#get_name pl_authenticated)^"
           ^(term_to_string const_term)^"
           ^(term_to_string var_term)
           ^")
        else "*)

(*Event: *)
    | Unknown(t,lt) ->
              (match t with
          Base(Const(id)) ->
            let nid = Globals.string_id#get_name id in
            if (nid = "request"or (nid = "wrequest"then
              ""(*(nid^"^(list_to_string term_to_string " lt)^")*)
            else
              (nid^"("^(list_to_string term_to_string "," lt)^")")
        | _ ->
            (term_to_string t)^"("
             ^(list_to_string term_to_string "," lt)^")")

    | _ ->
         Error_handler.displayWarning 5 "print_if_term"""