let rec term_value_to_string (session_id : int) : Types.atoms_type Types.term_structure -> string =
  (* This sub-fonction prints the IF values of atoms.*)
  let atom_value_to_string hlpsl_id = 
    let gid = global_var_id#get_id_of session_id hlpsl_id in
    let map_id = memory_map#get_map gid in
    let if_value = value_table#get_value map_id in
    ground_if_value_to_string if_value
  in function
      Pair(term1,term2) ->
              "pair("^(term_value_to_string session_id term1)^","
              ^(term_value_to_string session_id term2)^")"
    | Scrypt(term1,term2) ->
              "scrypt("^(term_value_to_string session_id term2)^","
              ^(term_value_to_string session_id term1)^")"
    | Crypt(term1,term2) ->
              "crypt("^(term_value_to_string session_id term2)^","
              ^(term_value_to_string session_id term1)^")"
    | Inv(term) ->
              "inv("^(term_value_to_string session_id term)^")"
    | Function(term1,termlist) ->
              (term_value_to_string session_id term1)^"("
              ^(list_to_string (term_value_to_string session_id) "," termlist)^")"
    | Cons(term1,term2) ->
              "cons("^(term_value_to_string session_id term1)^","
              ^(term_value_to_string session_id term2)^")"
    | Delete(term1,term2) ->
              "delete("^(term_value_to_string session_id term1)^","
              ^(term_value_to_string session_id term2)^")"
    | Set(termlist) ->
              "set("
              ^(list_to_string (term_value_to_string session_id) "," termlist)^")"
(*BUG??? 15/03/2005
              list2_to_string (term_value_to_string session_id) " termlist *)

(*    | Lst(termlist) ->
              "
              ^(list_to_string (term_value_to_string session_id) " termlist)^"*)

    | Prime(Var(id))
    | Prime(Const(id)) ->
              (Globals.string_id#get_name id)^"'"
    | Base(Var(id)) ->
              atom_value_to_string id
    | Base(Const(id)) ->
              string_id#get_name id;
    | Hash(_) ->
        prerr_endline "Interface.term_value_to_string: Impossible error: invalid hash type/term"
        raise Not_found