src/HOL/Tools/ATP/atp_problem.ML
changeset 57255 488046fdda59
parent 56847 3e369d8610c4
child 57256 cf43583f9bb9
equal deleted inserted replaced
57254:d3d91422f408 57255:488046fdda59
    42     THF of polymorphism * thf_choice |
    42     THF of polymorphism * thf_choice |
    43     DFG of polymorphism
    43     DFG of polymorphism
    44 
    44 
    45   datatype atp_formula_role =
    45   datatype atp_formula_role =
    46     Axiom | Definition | Lemma | Hypothesis | Conjecture | Negated_Conjecture |
    46     Axiom | Definition | Lemma | Hypothesis | Conjecture | Negated_Conjecture |
    47     Plain | Unknown
    47     Plain | Type_Role | Unknown
    48 
    48 
    49   datatype 'a atp_problem_line =
    49   datatype 'a atp_problem_line =
    50     Class_Decl of string * 'a * 'a list |
    50     Class_Decl of string * 'a * 'a list |
    51     Type_Decl of string * 'a * int |
    51     Type_Decl of string * 'a * int |
    52     Sym_Decl of string * 'a * 'a atp_type |
    52     Sym_Decl of string * 'a * 'a atp_type |
    73   val tptp_ho_forall : string
    73   val tptp_ho_forall : string
    74   val tptp_pi_binder : string
    74   val tptp_pi_binder : string
    75   val tptp_exists : string
    75   val tptp_exists : string
    76   val tptp_ho_exists : string
    76   val tptp_ho_exists : string
    77   val tptp_choice : string
    77   val tptp_choice : string
       
    78   val tptp_ho_choice : string
    78   val tptp_not : string
    79   val tptp_not : string
    79   val tptp_and : string
    80   val tptp_and : string
       
    81   val tptp_not_and : string
    80   val tptp_or : string
    82   val tptp_or : string
       
    83   val tptp_not_or : string
    81   val tptp_implies : string
    84   val tptp_implies : string
    82   val tptp_if : string
    85   val tptp_if : string
    83   val tptp_iff : string
    86   val tptp_iff : string
    84   val tptp_not_iff : string
    87   val tptp_not_iff : string
    85   val tptp_app : string
    88   val tptp_app : string
    86   val tptp_not_infix : string
    89   val tptp_not_infix : string
    87   val tptp_equal : string
    90   val tptp_equal : string
       
    91   val tptp_not_equal : string
    88   val tptp_old_equal : string
    92   val tptp_old_equal : string
    89   val tptp_false : string
    93   val tptp_false : string
    90   val tptp_true : string
    94   val tptp_true : string
       
    95   val tptp_lambda : string
    91   val tptp_empty_list : string
    96   val tptp_empty_list : string
       
    97   val tptp_binary_op_list : string list
    92   val isabelle_info_prefix : string
    98   val isabelle_info_prefix : string
    93   val isabelle_info : string -> int -> (string, 'a) atp_term list
    99   val isabelle_info : string -> int -> (string, 'a) atp_term list
    94   val extract_isabelle_status : (string, 'a) atp_term list -> string option
   100   val extract_isabelle_status : (string, 'a) atp_term list -> string option
    95   val extract_isabelle_rank : (string, 'a) atp_term list -> int
   101   val extract_isabelle_rank : (string, 'a) atp_term list -> int
    96   val inductionN : string
   102   val inductionN : string
   112   val individual_atype : (string * string) atp_type
   118   val individual_atype : (string * string) atp_type
   113   val mk_anot : ('a, 'b, 'c, 'd) atp_formula -> ('a, 'b, 'c, 'd) atp_formula
   119   val mk_anot : ('a, 'b, 'c, 'd) atp_formula -> ('a, 'b, 'c, 'd) atp_formula
   114   val mk_aconn :
   120   val mk_aconn :
   115     atp_connective -> ('a, 'b, 'c, 'd) atp_formula
   121     atp_connective -> ('a, 'b, 'c, 'd) atp_formula
   116     -> ('a, 'b, 'c, 'd) atp_formula -> ('a, 'b, 'c, 'd) atp_formula
   122     -> ('a, 'b, 'c, 'd) atp_formula -> ('a, 'b, 'c, 'd) atp_formula
       
   123   val mk_app : (string, 'a) atp_term -> (string, 'a) atp_term -> (string, 'a) atp_term
       
   124   val mk_apps :  (string, 'a) atp_term -> (string, 'a) atp_term list -> (string, 'a) atp_term
       
   125   val mk_simple_aterm:  'a -> ('a, 'b) atp_term
   117   val aconn_fold :
   126   val aconn_fold :
   118     bool option -> (bool option -> 'a -> 'b -> 'b) -> atp_connective * 'a list
   127     bool option -> (bool option -> 'a -> 'b -> 'b) -> atp_connective * 'a list
   119     -> 'b -> 'b
   128     -> 'b -> 'b
   120   val aconn_map :
   129   val aconn_map :
   121     bool option -> (bool option -> 'a -> ('b, 'c, 'd, 'e) atp_formula)
   130     bool option -> (bool option -> 'a -> ('b, 'c, 'd, 'e) atp_formula)
   187   THF of polymorphism * thf_choice |
   196   THF of polymorphism * thf_choice |
   188   DFG of polymorphism
   197   DFG of polymorphism
   189 
   198 
   190 datatype atp_formula_role =
   199 datatype atp_formula_role =
   191   Axiom | Definition | Lemma | Hypothesis | Conjecture | Negated_Conjecture |
   200   Axiom | Definition | Lemma | Hypothesis | Conjecture | Negated_Conjecture |
   192   Plain | Unknown
   201   Plain | Type_Role | Unknown
   193 
   202 
   194 datatype 'a atp_problem_line =
   203 datatype 'a atp_problem_line =
   195   Class_Decl of string * 'a * 'a list |
   204   Class_Decl of string * 'a * 'a list |
   196   Type_Decl of string * 'a * int |
   205   Type_Decl of string * 'a * int |
   197   Sym_Decl of string * 'a * 'a atp_type |
   206   Sym_Decl of string * 'a * 'a atp_type |
   219 val tptp_ho_forall = "!!"
   228 val tptp_ho_forall = "!!"
   220 val tptp_pi_binder = "!>"
   229 val tptp_pi_binder = "!>"
   221 val tptp_exists = "?"
   230 val tptp_exists = "?"
   222 val tptp_ho_exists = "??"
   231 val tptp_ho_exists = "??"
   223 val tptp_choice = "@+"
   232 val tptp_choice = "@+"
       
   233 val tptp_ho_choice = "@@+"
   224 val tptp_not = "~"
   234 val tptp_not = "~"
   225 val tptp_and = "&"
   235 val tptp_and = "&"
       
   236 val tptp_not_and = "~&"
   226 val tptp_or = "|"
   237 val tptp_or = "|"
       
   238 val tptp_not_or = "~|"
   227 val tptp_implies = "=>"
   239 val tptp_implies = "=>"
   228 val tptp_if = "<="
   240 val tptp_if = "<="
   229 val tptp_iff = "<=>"
   241 val tptp_iff = "<=>"
   230 val tptp_not_iff = "<~>"
   242 val tptp_not_iff = "<~>"
   231 val tptp_app = "@"
   243 val tptp_app = "@"
   232 val tptp_not_infix = "!"
   244 val tptp_not_infix = "!"
   233 val tptp_equal = "="
   245 val tptp_equal = "="
       
   246 val tptp_not_equal = "!="
   234 val tptp_old_equal = "equal"
   247 val tptp_old_equal = "equal"
   235 val tptp_false = "$false"
   248 val tptp_false = "$false"
   236 val tptp_true = "$true"
   249 val tptp_true = "$true"
       
   250 val tptp_lambda = "^"
   237 val tptp_empty_list = "[]"
   251 val tptp_empty_list = "[]"
   238 
   252 val tptp_binary_op_list = [tptp_and, tptp_not_and, tptp_or, tptp_not_or, tptp_implies, tptp_if,
       
   253                              tptp_iff, tptp_not_iff, tptp_equal, tptp_app]
   239 val isabelle_info_prefix = "isabelle_"
   254 val isabelle_info_prefix = "isabelle_"
   240 
   255 
   241 val inductionN = "induction"
   256 val inductionN = "induction"
   242 val introN = "intro"
   257 val introN = "intro"
   243 val inductiveN = "inductive"
   258 val inductiveN = "inductive"
   289 
   304 
   290 fun mk_anot (AConn (ANot, [phi])) = phi
   305 fun mk_anot (AConn (ANot, [phi])) = phi
   291   | mk_anot phi = AConn (ANot, [phi])
   306   | mk_anot phi = AConn (ANot, [phi])
   292 fun mk_aconn c phi1 phi2 = AConn (c, [phi1, phi2])
   307 fun mk_aconn c phi1 phi2 = AConn (c, [phi1, phi2])
   293 
   308 
       
   309 fun mk_app t u = ATerm ((tptp_app, []), [t, u])
       
   310 fun mk_apps f xs = fold (fn x => fn f => mk_app f x) xs f
       
   311 
       
   312 fun mk_simple_aterm p = ATerm ((p, []), [])
       
   313 
   294 fun aconn_fold pos f (ANot, [phi]) = f (Option.map not pos) phi
   314 fun aconn_fold pos f (ANot, [phi]) = f (Option.map not pos) phi
   295   | aconn_fold pos f (AImplies, [phi1, phi2]) =
   315   | aconn_fold pos f (AImplies, [phi1, phi2]) =
   296     f (Option.map not pos) phi1 #> f pos phi2
   316     f (Option.map not pos) phi1 #> f pos phi2
   297   | aconn_fold pos f (AAnd, phis) = fold (f pos) phis
   317   | aconn_fold pos f (AAnd, phis) = fold (f pos) phis
   298   | aconn_fold pos f (AOr, phis) = fold (f pos) phis
   318   | aconn_fold pos f (AOr, phis) = fold (f pos) phis
   343   | tptp_string_of_role Lemma = "lemma"
   363   | tptp_string_of_role Lemma = "lemma"
   344   | tptp_string_of_role Hypothesis = "hypothesis"
   364   | tptp_string_of_role Hypothesis = "hypothesis"
   345   | tptp_string_of_role Conjecture = "conjecture"
   365   | tptp_string_of_role Conjecture = "conjecture"
   346   | tptp_string_of_role Negated_Conjecture = "negated_conjecture"
   366   | tptp_string_of_role Negated_Conjecture = "negated_conjecture"
   347   | tptp_string_of_role Plain = "plain"
   367   | tptp_string_of_role Plain = "plain"
       
   368   | tptp_string_of_role Type_Role = "type"
   348   | tptp_string_of_role Unknown = "unknown"
   369   | tptp_string_of_role Unknown = "unknown"
   349 
   370 
   350 fun tptp_string_of_app _ func [] = func
   371 fun tptp_string_of_app _ func [] = func
   351   | tptp_string_of_app format func args =
   372   | tptp_string_of_app format func args =
   352     if is_format_higher_order format then
   373     if is_format_higher_order format then