74 val tptp_false : string |
74 val tptp_false : string |
75 val tptp_true : string |
75 val tptp_true : string |
76 val tptp_empty_list : string |
76 val tptp_empty_list : string |
77 val isabelle_info_prefix : string |
77 val isabelle_info_prefix : string |
78 val isabelle_info : atp_format -> string -> int -> (string, 'a) ho_term list |
78 val isabelle_info : atp_format -> string -> int -> (string, 'a) ho_term list |
|
79 val extract_isabelle_status : (string, 'a) ho_term list -> string option |
|
80 val extract_isabelle_rank : (string, 'a) ho_term list -> int |
79 val introN : string |
81 val introN : string |
80 val elimN : string |
82 val elimN : string |
81 val simpN : string |
83 val simpN : string |
82 val spec_eqN : string |
84 val spec_eqN : string |
83 val rankN : string |
85 val rankN : string |
84 val minimum_rank : int |
86 val minimum_rank : int |
85 val default_rank : int |
87 val default_rank : int |
|
88 val default_kbo_weight : int |
86 val is_tptp_equal : string -> bool |
89 val is_tptp_equal : string -> bool |
87 val is_built_in_tptp_symbol : string -> bool |
90 val is_built_in_tptp_symbol : string -> bool |
88 val is_tptp_variable : string -> bool |
91 val is_tptp_variable : string -> bool |
89 val is_tptp_user_symbol : string -> bool |
92 val is_tptp_user_symbol : string -> bool |
90 val atype_of_types : (string * string) ho_type |
93 val atype_of_types : (string * string) ho_type |
102 -> connective * 'a list -> ('b, 'c, 'd) formula |
105 -> connective * 'a list -> ('b, 'c, 'd) formula |
103 val formula_fold : |
106 val formula_fold : |
104 bool option -> (bool option -> 'c -> 'd -> 'd) -> ('a, 'b, 'c) formula |
107 bool option -> (bool option -> 'c -> 'd -> 'd) -> ('a, 'b, 'c) formula |
105 -> 'd -> 'd |
108 -> 'd -> 'd |
106 val formula_map : ('c -> 'd) -> ('a, 'b, 'c) formula -> ('a, 'b, 'd) formula |
109 val formula_map : ('c -> 'd) -> ('a, 'b, 'c) formula -> ('a, 'b, 'd) formula |
|
110 val is_function_type : string ho_type -> bool |
|
111 val is_predicate_type : string ho_type -> bool |
107 val is_format_higher_order : atp_format -> bool |
112 val is_format_higher_order : atp_format -> bool |
108 val is_format_typed : atp_format -> bool |
113 val is_format_typed : atp_format -> bool |
109 val lines_for_atp_problem : atp_format -> string problem -> string list |
114 val lines_for_atp_problem : |
|
115 atp_format -> (unit -> (string * int) list) -> string problem -> string list |
110 val ensure_cnf_problem : |
116 val ensure_cnf_problem : |
111 (string * string) problem -> (string * string) problem |
117 (string * string) problem -> (string * string) problem |
112 val filter_cnf_ueq_problem : |
118 val filter_cnf_ueq_problem : |
113 (string * string) problem -> (string * string) problem |
119 (string * string) problem -> (string * string) problem |
114 val declared_syms_in_problem : (string * ''a) problem -> (string * ''a) list |
120 val declared_syms_in_problem : (string * ''a) problem -> (string * ''a) list |
203 val spec_eqN = "spec_eq" |
209 val spec_eqN = "spec_eq" |
204 val rankN = "rank" |
210 val rankN = "rank" |
205 |
211 |
206 val minimum_rank = 0 |
212 val minimum_rank = 0 |
207 val default_rank = 1000 |
213 val default_rank = 1000 |
|
214 val default_kbo_weight = 1 |
208 |
215 |
209 (* Currently, only newer versions of SPASS, with sorted DFG format support, can |
216 (* Currently, only newer versions of SPASS, with sorted DFG format support, can |
210 process Isabelle metainformation. *) |
217 process Isabelle metainformation. *) |
211 fun isabelle_info (DFG DFG_Sorted) status rank = |
218 fun isabelle_info (DFG DFG_Sorted) status rank = |
212 [] |> rank <> default_rank |
219 [] |> rank <> default_rank |
270 in fld pos end |
277 in fld pos end |
271 |
278 |
272 fun formula_map f (AQuant (q, xs, phi)) = AQuant (q, xs, formula_map f phi) |
279 fun formula_map f (AQuant (q, xs, phi)) = AQuant (q, xs, formula_map f phi) |
273 | formula_map f (AConn (c, phis)) = AConn (c, map (formula_map f) phis) |
280 | formula_map f (AConn (c, phis)) = AConn (c, map (formula_map f) phis) |
274 | formula_map f (AAtom tm) = AAtom (f tm) |
281 | formula_map f (AAtom tm) = AAtom (f tm) |
|
282 |
|
283 fun is_function_type (AFun (_, ty)) = is_function_type ty |
|
284 | is_function_type (AType (s, _)) = |
|
285 s <> tptp_type_of_types andalso s <> tptp_bool_type |
|
286 | is_function_type _ = false |
|
287 fun is_predicate_type (AFun (_, ty)) = is_predicate_type ty |
|
288 | is_predicate_type (AType (s, _)) = (s = tptp_bool_type) |
|
289 | is_predicate_type _ = false |
|
290 fun is_nontrivial_predicate_type (AFun (_, ty)) = is_predicate_type ty |
|
291 | is_nontrivial_predicate_type _ = false |
275 |
292 |
276 fun is_format_higher_order (THF _) = true |
293 fun is_format_higher_order (THF _) = true |
277 | is_format_higher_order _ = false |
294 | is_format_higher_order _ = false |
278 fun is_format_typed (TFF _) = true |
295 fun is_format_typed (TFF _) = true |
279 | is_format_typed (THF _) = true |
296 | is_format_typed (THF _) = true |
441 | arity_of_type _ = 0 |
458 | arity_of_type _ = 0 |
442 |
459 |
443 fun binder_atypes (AFun (ty1, ty2)) = ty1 :: binder_atypes ty2 |
460 fun binder_atypes (AFun (ty1, ty2)) = ty1 :: binder_atypes ty2 |
444 | binder_atypes _ = [] |
461 | binder_atypes _ = [] |
445 |
462 |
446 fun is_function_type (AFun (_, ty)) = is_function_type ty |
|
447 | is_function_type (AType (s, _)) = |
|
448 s <> tptp_type_of_types andalso s <> tptp_bool_type |
|
449 | is_function_type _ = false |
|
450 |
|
451 fun is_predicate_type (AFun (_, ty)) = is_predicate_type ty |
|
452 | is_predicate_type (AType (s, _)) = (s = tptp_bool_type) |
|
453 | is_predicate_type _ = false |
|
454 fun is_nontrivial_predicate_type (AFun (_, ty)) = is_predicate_type ty |
|
455 | is_nontrivial_predicate_type _ = false |
|
456 |
|
457 fun dfg_string_for_formula flavor info = |
463 fun dfg_string_for_formula flavor info = |
458 let |
464 let |
459 fun suffix_tag top_level s = |
465 fun suffix_tag top_level s = |
460 if top_level then |
466 if top_level then |
461 case extract_isabelle_status info of |
467 case extract_isabelle_status info of |
488 str_for_conn top_level c ^ "(" ^ |
494 str_for_conn top_level c ^ "(" ^ |
489 commas (map (str_for_formula false) phis) ^ ")" |
495 commas (map (str_for_formula false) phis) ^ ")" |
490 | str_for_formula top_level (AAtom tm) = str_for_term top_level tm |
496 | str_for_formula top_level (AAtom tm) = str_for_term top_level tm |
491 in str_for_formula true end |
497 in str_for_formula true end |
492 |
498 |
493 fun dfg_lines flavor problem = |
499 fun dfg_lines flavor kbo_weights problem = |
494 let |
500 let |
495 val sorted = (flavor = DFG_Sorted) |
501 val sorted = (flavor = DFG_Sorted) |
496 val format = DFG flavor |
502 val format = DFG flavor |
497 fun ary sym ty = |
503 fun spair (sym, k) = "(" ^ sym ^ ", " ^ string_of_int k ^ ")" |
498 "(" ^ sym ^ ", " ^ string_of_int (arity_of_type ty) ^ ")" |
504 fun ary sym = curry spair sym o arity_of_type |
499 fun fun_typ sym ty = |
505 fun fun_typ sym ty = |
500 "function(" ^ sym ^ ", " ^ string_for_type format ty ^ ")." |
506 "function(" ^ sym ^ ", " ^ string_for_type format ty ^ ")." |
501 fun pred_typ sym ty = |
507 fun pred_typ sym ty = |
502 "predicate(" ^ |
508 "predicate(" ^ |
503 commas (sym :: map (string_for_type format) (binder_atypes ty)) ^ ")." |
509 commas (sym :: map (string_for_type format) (binder_atypes ty)) ^ ")." |
525 fun sorts () = |
531 fun sorts () = |
526 filt (fn Decl (_, sym, AType (s, [])) => |
532 filt (fn Decl (_, sym, AType (s, [])) => |
527 if s = tptp_type_of_types then SOME sym else NONE |
533 if s = tptp_type_of_types then SOME sym else NONE |
528 | _ => NONE) @ [[dfg_individual_type]] |
534 | _ => NONE) @ [[dfg_individual_type]] |
529 |> flat |> commas |> enclose "sorts [" "]." |
535 |> flat |> commas |> enclose "sorts [" "]." |
530 val syms = [func_aries, pred_aries] @ (if sorted then [sorts ()] else []) |
536 fun do_kbo_weights () = |
|
537 kbo_weights () |> map spair |> commas |> enclose "weights [" "]." |
|
538 val syms = |
|
539 [func_aries] @ (if sorted then [do_kbo_weights ()] else []) @ |
|
540 [pred_aries] @ (if sorted then [sorts ()] else []) |
531 fun func_sigs () = |
541 fun func_sigs () = |
532 filt (fn Decl (_, sym, ty) => |
542 filt (fn Decl (_, sym, ty) => |
533 if is_function_type ty then SOME (fun_typ sym ty) else NONE |
543 if is_function_type ty then SOME (fun_typ sym ty) else NONE |
534 | _ => NONE) |
544 | _ => NONE) |
535 |> flat |
545 |> flat |
558 list_of "formulae(axioms)" axioms @ |
568 list_of "formulae(axioms)" axioms @ |
559 list_of "formulae(conjectures)" conjs @ |
569 list_of "formulae(conjectures)" conjs @ |
560 ["end_problem.\n"] |
570 ["end_problem.\n"] |
561 end |
571 end |
562 |
572 |
563 fun lines_for_atp_problem format problem = |
573 fun lines_for_atp_problem format kbo_weights problem = |
564 "% This file was generated by Isabelle (most likely Sledgehammer)\n\ |
574 "% This file was generated by Isabelle (most likely Sledgehammer)\n\ |
565 \% " ^ timestamp () ^ "\n" :: |
575 \% " ^ timestamp () ^ "\n" :: |
566 (case format of |
576 (case format of |
567 DFG flavor => dfg_lines flavor |
577 DFG flavor => dfg_lines flavor kbo_weights |
568 | _ => tptp_lines format) problem |
578 | _ => tptp_lines format) problem |
569 |
579 |
570 |
580 |
571 (** CNF (Metis) and CNF UEQ (Waldmeister) **) |
581 (** CNF (Metis) and CNF UEQ (Waldmeister) **) |
572 |
582 |