123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161(* This file is free software, part of Logtk. See file "license" for more details. *)(** {1 TPTP Ast} *)openLogtkmodulePT=STermmoduleLoc=ParseLocationtypename=|NameIntofint|NameStringofstring(** name of a formula *)androle=|R_axiom(* true *)|R_hypothesis(* true *)|R_definition(* symbol definition *)|R_assumption(* true, but must be proved before *)|R_lemma(* must be proved before use *)|R_theorem(* must be proved before use *)|R_conjecture(* to be proven *)|R_negated_conjecture(* negation of conjecture, must prove 'false' *)|R_plain(* no specific semantics (proof...) *)|R_finiteofstring(* finite interpretation, don't care *)|R_question(* existential question *)|R_type(* type declaration *)|R_unknown(* error *)(** formula role *)andoptional_info=general_datalistandgeneral_data=|GStringofstring|GVarofstring(* variable *)|GIntofint|GColumnofgeneral_data*general_data|GNodeofstring*general_datalist|GListofgeneral_datalistletrole_of_string=function|"axiom"->R_axiom|"hypothesis"->R_hypothesis|"definition"->R_definition|"assumption"->R_assumption|"lemma"->R_axiom(* R_lemma makes problems harder *)|"theorem"->R_theorem|"conjecture"->R_conjecture|"negated_conjecture"->R_negated_conjecture|"plain"->R_plain|"fi_domain"->R_finite"domain"|"fi_functors"->R_finite"functors"|"fi_predicates"->R_finite"predicates"|"question"->R_question|"type"->R_type|"unknown"->R_unknown|s->failwith("not a proper TPTP role: "^s)letstring_of_role=function|R_axiom->"axiom"|R_hypothesis->"hypothesis"|R_definition->"definition"|R_assumption->"assumption"|R_lemma->"lemma"|R_theorem->"theorem"|R_conjecture->"conjecture"|R_negated_conjecture->"negated_conjecture"|R_plain->"plain"|R_finitewhat->"fi_"^what|R_question->"question"|R_type->"type"|R_unknown->"unknown"letpp_roleoutr=CCFormat.stringout(string_of_roler)letstring_of_name=function|NameInti->string_of_inti|NameStrings->sletpp_nameoutn=CCFormat.stringout(string_of_namen)letrecpp_generaloutd=matchdwith|GStrings->CCFormat.stringouts|GInti->CCFormat.intouti|GVars->CCFormat.stringouts|GColumn(a,b)->Format.fprintfout"%a: %a"pp_generalapp_generalb|GNode(f,l)->Format.fprintfout"%s(%a)"f(Util.pp_listpp_general)l|GListl->Format.fprintfout"[%a]"(Util.pp_listpp_general)lletrecpp_general_debugfoutd=matchdwith|GStrings->Format.fprintfout"GSstr %s"s|GInti->Format.fprintfout"GInt %d"i|GVars->Format.fprintfout"GVar %s"s|GColumn(a,b)->Format.fprintfout"%a: %a"pp_general_debugfapp_general_debugfb|GNode(f,l)->Format.fprintfout"GNode(%s[%a])"f(Util.pp_listpp_general_debugf)l|GListl->CCFormat.listpp_general_debugfoutlletpp_generalsoutl=matchlwith|[]->()|_::_->Format.fprintfout",@ ";Util.pp_list~sep:", "pp_generaloutltype'at=|CNFofname*role*'alist*optional_info|FOFofname*role*'a*optional_info|TFFofname*role*'a*optional_info|THFofname*role*'a*optional_info(* XXX not parsed yet *)|TypeDeclofname*string*'a*optional_info(* type declaration for a symbol *)|NewTypeofname*string*'a*optional_info(* declare new type constant... *)|Includeofstring|IncludeOnlyofstring*namelist(* include a subset of names *)(** top level declaration *)type'adeclaration='atletget_name=function|CNF(n,_,_,_)->n|FOF(n,_,_,_)->n|TFF(n,_,_,_)->n|THF(n,_,_,_)->n|TypeDecl(n,_,_,_)->n|NewType(n,_,_,_)->n|IncludeOnly_|Include_->invalid_arg"Ast_tptp.name_of_decl: include directive has no name"(** {2 IO} *)letfpf=Format.fprintfletpp_form_ppout(logic,name,role,f,generals)=Format.fprintfout"@[<2>%s(%a,@ %a,@ (@[%a@])%a@])."logicpp_namenamepp_roleroleppfpp_generalsgeneralsletpppp_tout=function|Includefilename->fpfout"@[<hv2>include(@,'%s'@,).@]"filename|IncludeOnly(filename,names)->fpfout"@[<2>include('%s',@ [@[%a@]]@])."filename(Util.pp_listpp_name)names|TypeDecl(name,s,ty,g)->fpfout"@[<2>tff(%a, type,@ (@[%s : %a@])%a@])."pp_namenamespp_ttypp_generalsg|NewType(name,s,kind,g)->fpfout"@[<2>tff(%a, type,@ (@[%s : %a@])%a@])."pp_namenamespp_tkindpp_generalsg|CNF(name,role,c,generals)->pp_form_(Util.pp_list~sep:" | "pp_t)out("cnf",name,role,c,generals)|FOF(name,role,f,generals)->pp_form_pp_tout("fof",name,role,f,generals)|TFF(name,role,f,generals)->pp_form_pp_tout("tff",name,role,f,generals)|THF(name,role,f,generals)->pp_form_pp_tout("thf",name,role,f,generals)letto_stringppt=CCFormat.to_string(ppppt)