type t = Atom of string | And of t * t | Or of t * t | Not of t let rec string_of_formula = function |And(f1,f2) -> Printf.sprintf "(%s And %s)" (string_of_formula f1) (string_of_formula f2) |Or(f1,f2) -> Printf.sprintf "(%s Or %s)" (string_of_formula f1) (string_of_formula f2) |Not(f) -> Printf.sprintf "(Not %s)" (string_of_formula f) |Atom(s) -> s ;; let print s = print_endline (string_of_formula s)