let rec term_to_string : Types.atoms_type Types.term_structure -> string = function
Pair(term1,term2) ->
"pair("^(term_to_string term1)
^","^(term_to_string term2)^")"
| Scrypt(term1,term2) ->
"scrypt("^(term_to_string term2)
^","^(term_to_string term1)^")"
| Crypt(term1,term2) ->
"crypt("^(term_to_string term2)
^ ","^(term_to_string term1)^")"
| Inv(term) ->
"inv("^(term_to_string term)^")"
| Function(term1,termlist) ->
begin
match term1 with
Base(Const(fun_id)) ->
let fun_string = (string_id#get_name fun_id) in
if (fun_string = "exp") || (fun_string = "xor") then
fun_string^"("
^(list_to_string term_to_string "," termlist)
^")"
else
"apply("^(term_to_string term1)
^","^(list2_to_string term_to_string "," termlist)
^")"
| _ ->
"apply("^(term_to_string term1)
^","^(list2_to_string term_to_string "," termlist)
^")"
end
| Cons(term1,term2) ->
"contains("^(term_to_string term1)
^","^(term_to_string term2)^")"
| Delete(term1,term2) ->
"delete("^(term_to_string term1)
^","^(term_to_string term2)^")"
| Set(termlist) ->
"set("^(list_to_string term_to_string "," termlist)^")"
| Base(Var(id)) | Base(Const(id))
| Prime(Var(id)) | Prime(Const(id)) ->
Globals.string_id#get_name id
| Hash(_) ->
prerr_endline "Interface.term_to_string: Impossible error: invalid hash type/term";
raise Not_found