package dolmen
Source file answer.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71(* This file is free software, part of dolmen. See file "LICENSE" for more information. *) (* Type definitions *) type term = Term.t type location = Loc.t type defs = Statement.defs type descr = | Unsat | Sat of defs list option | Error of string type t = { id : Id.t option; descr : descr; attrs : term list; loc : location; } let pp_defs = Statement.print_group Statement.print_def let print_model_opt fmt = function | None -> Format.fprintf fmt "@[<h>no model@]" | Some l -> let pp_sep fmt () = Format.fprintf fmt ",@ " in Format.fprintf fmt "%a" (Format.pp_print_list ~pp_sep pp_defs) l let print_descr fmt = function | Unsat -> Format.fprintf fmt "unsat" | Sat model_opt -> Format.fprintf fmt "@[<hv 2>sat:@ %a@]" print_model_opt model_opt | Error message -> Format.fprintf fmt "@[<hv 2>error:@ @[<hov>%a@]@]" Format.pp_print_text message let print_attrs fmt = function | [] -> () | l -> Format.fprintf fmt "@[<hov>{ %a }@]@ " (Format.pp_print_list Term.print) l let print fmt = function { descr; attrs; _ } -> Format.fprintf fmt "%a%a" print_attrs attrs print_descr descr let mk ?id ?(loc= Loc.no_loc) ?(attrs=[]) descr = { id; descr; loc; attrs; } let fun_def ?loc id vars params ret_ty body : defs = Statement.group ~recursive:false [ Statement.def ?loc id ~vars ~params ret_ty body ] let funs_def_rec ?loc l = let contents = List.map (fun (id, vars, params, ret_ty, body) -> Statement.def ?loc id ~vars ~params ret_ty body ) l in Statement.group ~recursive:true contents let sat ?loc model = mk ?loc (Sat model) let unsat ?loc () = mk ?loc Unsat let error ?loc message = mk ?loc (Error message)