389 fun make_tvar (s, i) = tvar_prefix ^ ascii_of_indexname (unquote_tvar s, i) |
389 fun make_tvar (s, i) = tvar_prefix ^ ascii_of_indexname (unquote_tvar s, i) |
390 fun make_tfree s = tfree_prefix ^ ascii_of (unquote_tvar s) |
390 fun make_tfree s = tfree_prefix ^ ascii_of (unquote_tvar s) |
391 fun tvar_name ((x as (s, _)), _) = (make_tvar x, s) |
391 fun tvar_name ((x as (s, _)), _) = (make_tvar x, s) |
392 |
392 |
393 (* "HOL.eq" and choice are mapped to the ATP's equivalents *) |
393 (* "HOL.eq" and choice are mapped to the ATP's equivalents *) |
394 fun make_fixed_const _ \<^const_name>\<open>HOL.eq\<close> = tptp_old_equal |
394 fun make_fixed_const \<^const_name>\<open>HOL.eq\<close> = tptp_old_equal |
395 | make_fixed_const _ c = const_prefix ^ lookup_const c |
395 | make_fixed_const c = const_prefix ^ lookup_const c |
396 |
396 |
397 fun make_fixed_type_const c = type_const_prefix ^ lookup_const c |
397 fun make_fixed_type_const c = type_const_prefix ^ lookup_const c |
398 |
398 |
399 fun make_class clas = class_prefix ^ ascii_of clas |
399 fun make_class clas = class_prefix ^ ascii_of clas |
400 |
400 |
436 val tvar_a_str = "'a" |
436 val tvar_a_str = "'a" |
437 val tvar_a_z = ((tvar_a_str, 0), \<^sort>\<open>type\<close>) |
437 val tvar_a_z = ((tvar_a_str, 0), \<^sort>\<open>type\<close>) |
438 val tvar_a = TVar tvar_a_z |
438 val tvar_a = TVar tvar_a_z |
439 val tvar_a_name = tvar_name tvar_a_z |
439 val tvar_a_name = tvar_name tvar_a_z |
440 val itself_name = `make_fixed_type_const \<^type_name>\<open>itself\<close> |
440 val itself_name = `make_fixed_type_const \<^type_name>\<open>itself\<close> |
441 val TYPE_name = `(make_fixed_const NONE) \<^const_name>\<open>Pure.type\<close> |
441 val TYPE_name = `make_fixed_const \<^const_name>\<open>Pure.type\<close> |
442 val tvar_a_atype = AType ((tvar_a_name, []), []) |
442 val tvar_a_atype = AType ((tvar_a_name, []), []) |
443 val a_itself_atype = AType ((itself_name, []), [tvar_a_atype]) |
443 val a_itself_atype = AType ((itself_name, []), [tvar_a_atype]) |
444 |
444 |
445 (** Definitions and functions for FOL clauses and formulas for TPTP **) |
445 (** Definitions and functions for FOL clauses and formulas for TPTP **) |
446 |
446 |
611 let |
611 let |
612 val (P', P_atomics_Ts) = iot fool bs P |
612 val (P', P_atomics_Ts) = iot fool bs P |
613 val (Q', Q_atomics_Ts) = iot fool bs Q |
613 val (Q', Q_atomics_Ts) = iot fool bs Q |
614 in (IApp (P', Q'), union (op =) P_atomics_Ts Q_atomics_Ts) end |
614 in (IApp (P', Q'), union (op =) P_atomics_Ts Q_atomics_Ts) end |
615 | iot _ _ (Const (c, T)) = |
615 | iot _ _ (Const (c, T)) = |
616 (IConst (`(make_fixed_const (SOME type_enc)) c, T, robust_const_type_args thy (c, T)), |
616 (IConst (`make_fixed_const c, T, robust_const_type_args thy (c, T)), |
617 atomic_types_of T) |
617 atomic_types_of T) |
618 | iot _ _ (Free (s, T)) = (IConst (`make_fixed_var s, T, []), atomic_types_of T) |
618 | iot _ _ (Free (s, T)) = (IConst (`make_fixed_var s, T, []), atomic_types_of T) |
619 | iot _ _ (Var (v as (s, _), T)) = |
619 | iot _ _ (Var (v as (s, _), T)) = |
620 (if String.isPrefix Meson_Clausify.new_skolem_var_prefix s then |
620 (if String.isPrefix Meson_Clausify.new_skolem_var_prefix s then |
621 let |
621 let |
622 val Ts = T |> strip_type |> swap |> op :: |
622 val Ts = T |> strip_type |> swap |> op :: |
623 val s' = new_skolem_const_name s (length Ts) |
623 val s' = new_skolem_const_name s (length Ts) |
624 in IConst (`(make_fixed_const (SOME type_enc)) s', T, Ts) end |
624 in IConst (`make_fixed_const s', T, Ts) end |
625 else |
625 else |
626 IVar ((make_schematic_var v, s), T), atomic_types_of T) |
626 IVar ((make_schematic_var v, s), T), atomic_types_of T) |
627 | iot _ bs (Bound j) = |
627 | iot _ bs (Bound j) = |
628 nth bs j |> (fn (_, (name, T)) => (IConst (name, T, []), atomic_types_of T)) |
628 nth bs j |> (fn (_, (name, T)) => (IConst (name, T, []), atomic_types_of T)) |
629 | iot fool bs (Abs (s, T, t)) = |
629 | iot fool bs (Abs (s, T, t)) = |
1593 fun default_sym_tab_entries type_enc = |
1593 fun default_sym_tab_entries type_enc = |
1594 let |
1594 let |
1595 fun mk_sym_info pred n = |
1595 fun mk_sym_info pred n = |
1596 {pred_sym = pred, min_ary = n, max_ary = n, types = [], in_conj = false} |
1596 {pred_sym = pred, min_ary = n, max_ary = n, types = [], in_conj = false} |
1597 in |
1597 in |
1598 (make_fixed_const NONE \<^const_name>\<open>undefined\<close>, mk_sym_info false 0) :: |
1598 (make_fixed_const \<^const_name>\<open>undefined\<close>, mk_sym_info false 0) :: |
1599 (map (apsnd (fn {arity, is_predicate} => mk_sym_info is_predicate arity)) |
1599 (map (apsnd (fn {arity, is_predicate} => mk_sym_info is_predicate arity)) |
1600 (Symtab.dest tptp_builtins)) |
1600 (Symtab.dest tptp_builtins)) |
1601 |> not (is_type_enc_fool type_enc orelse is_type_enc_full_higher_order type_enc) |
1601 |> not (is_type_enc_fool type_enc orelse is_type_enc_full_higher_order type_enc) |
1602 ? cons (prefixed_predicator_name, mk_sym_info true 1) |
1602 ? cons (prefixed_predicator_name, mk_sym_info true 1) |
1603 end |
1603 end |
1730 (case Symtab.lookup sym_tab s of |
1730 (case Symtab.lookup sym_tab s of |
1731 SOME ({pred_sym, min_ary, max_ary, ...} : sym_info) => pred_sym andalso min_ary = max_ary |
1731 SOME ({pred_sym, min_ary, max_ary, ...} : sym_info) => pred_sym andalso min_ary = max_ary |
1732 | NONE => false) |
1732 | NONE => false) |
1733 |
1733 |
1734 val fTrue_iconst = IConst ((const_prefix ^ "fTrue", \<^const_name>\<open>fTrue\<close>), \<^typ>\<open>bool\<close>, []) |
1734 val fTrue_iconst = IConst ((const_prefix ^ "fTrue", \<^const_name>\<open>fTrue\<close>), \<^typ>\<open>bool\<close>, []) |
1735 val predicator_iconst = IConst (`(make_fixed_const NONE) predicator_name, \<^typ>\<open>bool => bool\<close>, []) |
1735 val predicator_iconst = IConst (`make_fixed_const predicator_name, \<^typ>\<open>bool => bool\<close>, []) |
1736 |
1736 |
1737 fun predicatify completish tm = |
1737 fun predicatify completish tm = |
1738 if completish > 1 then |
1738 if completish > 1 then |
1739 IApp (IApp (IConst (`I tptp_equal, \<^typ>\<open>bool => bool => bool\<close>, []), tm), fTrue_iconst) |
1739 IApp (IApp (IConst (`I tptp_equal, \<^typ>\<open>bool => bool => bool\<close>, []), tm), fTrue_iconst) |
1740 else |
1740 else |
1741 IApp (predicator_iconst, tm) |
1741 IApp (predicator_iconst, tm) |
1742 |
1742 |
1743 val app_op = `(make_fixed_const NONE) app_op_name |
1743 val app_op = `make_fixed_const app_op_name |
1744 |
1744 |
1745 fun list_app head args = fold (curry (IApp o swap)) args head |
1745 fun list_app head args = fold (curry (IApp o swap)) args head |
1746 |
1746 |
1747 fun mk_app_op type_enc head arg = |
1747 fun mk_app_op type_enc head arg = |
1748 let |
1748 let |
1921 val min_rank = 9 * helper_rank div 10 |
1921 val min_rank = 9 * helper_rank div 10 |
1922 val max_rank = 4 * min_rank |
1922 val max_rank = 4 * min_rank |
1923 |
1923 |
1924 fun rank_of_fact_num n j = min_rank + (max_rank - min_rank) * j div n |
1924 fun rank_of_fact_num n j = min_rank + (max_rank - min_rank) * j div n |
1925 |
1925 |
1926 val type_tag = `(make_fixed_const NONE) type_tag_name |
1926 val type_tag = `make_fixed_const type_tag_name |
1927 |
1927 |
1928 fun could_specialize_helpers type_enc = |
1928 fun could_specialize_helpers type_enc = |
1929 not (is_type_enc_polymorphic type_enc) andalso level_of_type_enc type_enc <> No_Types |
1929 not (is_type_enc_polymorphic type_enc) andalso level_of_type_enc type_enc <> No_Types |
1930 |
1930 |
1931 fun should_specialize_helper type_enc t = |
1931 fun should_specialize_helper type_enc t = |
2115 val subclass_pairs = make_subclass_pairs thy subs supers |
2115 val subclass_pairs = make_subclass_pairs thy subs supers |
2116 in |
2116 in |
2117 (union (op =) subs supers, conjs, facts @ lam_facts, subclass_pairs, tcon_clauses, lifted) |
2117 (union (op =) subs supers, conjs, facts @ lam_facts, subclass_pairs, tcon_clauses, lifted) |
2118 end |
2118 end |
2119 |
2119 |
2120 val type_guard = `(make_fixed_const NONE) type_guard_name |
2120 val type_guard = `make_fixed_const type_guard_name |
2121 |
2121 |
2122 fun type_guard_iterm type_enc T tm = |
2122 fun type_guard_iterm type_enc T tm = |
2123 IApp (IConst (type_guard, T --> \<^typ>\<open>bool\<close>, [T]) |
2123 IApp (IConst (type_guard, T --> \<^typ>\<open>bool\<close>, [T]) |
2124 |> mangle_type_args_in_iterm type_enc, tm) |
2124 |> mangle_type_args_in_iterm type_enc, tm) |
2125 |
2125 |
2379 and this declaration causes problems in FOF if undefined_bool occurs without predicator pp. |
2379 and this declaration causes problems in FOF if undefined_bool occurs without predicator pp. |
2380 *) |
2380 *) |
2381 fun add_undefined_const \<^Type>\<open>bool\<close> = I |
2381 fun add_undefined_const \<^Type>\<open>bool\<close> = I |
2382 | add_undefined_const T = |
2382 | add_undefined_const T = |
2383 let |
2383 let |
2384 val name = `(make_fixed_const NONE) \<^const_name>\<open>undefined\<close> |
2384 val name = `make_fixed_const \<^const_name>\<open>undefined\<close> |
2385 val ((s, s'), Ts) = |
2385 val ((s, s'), Ts) = |
2386 if is_type_enc_mangling type_enc then |
2386 if is_type_enc_mangling type_enc then |
2387 (mangled_const_name type_enc [T] name, []) |
2387 (mangled_const_name type_enc [T] name, []) |
2388 else |
2388 else |
2389 (name, [T]) |
2389 (name, [T]) |
2686 let |
2686 let |
2687 fun do_alias ary = |
2687 fun do_alias ary = |
2688 let |
2688 let |
2689 val thy = Proof_Context.theory_of ctxt |
2689 val thy = Proof_Context.theory_of ctxt |
2690 val (role, maybe_negate) = honor_conj_sym_role in_conj |
2690 val (role, maybe_negate) = honor_conj_sym_role in_conj |
2691 val base_name = base_s0 |> `(make_fixed_const (SOME type_enc)) |
2691 val base_name = base_s0 |> `make_fixed_const |
2692 val T = (case types of [T] => T | _ => robust_const_type thy base_s0) |
2692 val T = (case types of [T] => T | _ => robust_const_type thy base_s0) |
2693 val T_args = robust_const_type_args thy (base_s0, T) |
2693 val T_args = robust_const_type_args thy (base_s0, T) |
2694 val (base_name as (base_s, _), T_args) = |
2694 val (base_name as (base_s, _), T_args) = |
2695 mangle_type_args_in_const type_enc base_name T_args |
2695 mangle_type_args_in_const type_enc base_name T_args |
2696 val base_ary = min_ary_of sym_tab0 base_s |
2696 val base_ary = min_ary_of sym_tab0 base_s |