let fpp_term term fmt t =
match t with
| Fol.Tconst c -> constant fmt c
| Fol.Tvar v -> pp_var fmt v
| Fol.Tapp (id, []) -> Format.pp_print_string fmt id
| Fol.Tapp ("ite",[c;a;b]) | Fol.Tif (c,a,b) ->
Format.fprintf fmt "(@[<hv>if %a@ then %a@ else %a@])"
term c term a term b
| Fol.Tapp ("neg_int", [t]) ->
Format.fprintf fmt "@[<hov 1>(-%a)@]" term t
| Fol.Tapp ("add_int", ts) ->
let xs = collect_assoc "add_int" [] ts in
pp_flow fmt "0" "+" term xs
| Fol.Tapp ("sub_int", [a;b]) ->
Format.fprintf fmt "@[<hov 1>(%a@,-%a)@]" term a term b
| Fol.Tapp ("mul_int", ts) ->
let xs = collect_assoc "mul_int" [] ts in
pp_flow fmt "1" "*" term xs
| Fol.Tapp ("neg_real", [t]) ->
Format.fprintf fmt "@[<hov 1>(-%a)@]" term t
| Fol.Tapp ("add_real", ts) ->
let xs = collect_assoc "add_real" [] ts in
pp_flow fmt "0.0" "+" term xs
| Fol.Tapp ("sub_real", [a;b]) ->
Format.fprintf fmt "@[<hov 1>(%a@,-%a)@]" term a term b
| Fol.Tapp ("mul_real", ts) ->
let xs = collect_assoc "mul_real" [] ts in
pp_flow fmt "1.0" "*" term xs
| Fol.Tapp ("div_real", [a;b]) ->
Format.fprintf fmt "@[<hov 1>(%a@,/%a)@]" term a term b
| Fol.Tapp (id, t::ts) ->
Format.fprintf fmt "@[<hov 2>%s(@,%a" id term t ;
List.iter (fun t -> Format.fprintf fmt ",@,%a" term t) ts ;
Format.fprintf fmt ")@]"
| Fol.Tlet (x,v,t) ->
Format.fprintf fmt "(@[<hv 0>let %a@ = %a@ in %a@])"
pp_var x term v term t
| Fol.Taccess(a,k) -> Format.fprintf fmt "access(%a,@,%a)" term a term k
| Fol.Tupdate(a,k,b) ->
Format.fprintf fmt "@[<hv 2>update(%a,@,%a,@,%a)@]"
term a term k term b
| Fol.Tgetfield (f,r) ->
Format.fprintf fmt "@[<hv 2>%s(%a)@]" (get_field f) term r
| Fol.Tsetfield (f,r,v) ->
Format.fprintf fmt "@[<hv 2>%s(%a,@,%a)@]" (set_field f)
term r term v