29 datatype type_enc = |
29 datatype type_enc = |
30 Simple_Types of order * type_level | |
30 Simple_Types of order * type_level | |
31 Guards of polymorphism * type_level * type_heaviness | |
31 Guards of polymorphism * type_level * type_heaviness | |
32 Tags of polymorphism * type_level * type_heaviness |
32 Tags of polymorphism * type_level * type_heaviness |
33 |
33 |
|
34 val no_lambdasN : string |
|
35 val concealedN : string |
|
36 val liftingN : string |
|
37 val combinatorsN : string |
|
38 val hybridN : string |
|
39 val lambdasN : string |
|
40 val smartN : string |
34 val bound_var_prefix : string |
41 val bound_var_prefix : string |
35 val schematic_var_prefix : string |
42 val schematic_var_prefix : string |
36 val fixed_var_prefix : string |
43 val fixed_var_prefix : string |
37 val tvar_prefix : string |
44 val tvar_prefix : string |
38 val tfree_prefix : string |
45 val tfree_prefix : string |
86 connective -> ('a, 'b, 'c) formula list -> ('a, 'b, 'c) formula |
93 connective -> ('a, 'b, 'c) formula list -> ('a, 'b, 'c) formula |
87 val unmangled_const : string -> string * (string, 'b) ho_term list |
94 val unmangled_const : string -> string * (string, 'b) ho_term list |
88 val unmangled_const_name : string -> string |
95 val unmangled_const_name : string -> string |
89 val helper_table : ((string * bool) * thm list) list |
96 val helper_table : ((string * bool) * thm list) list |
90 val factsN : string |
97 val factsN : string |
91 val introduce_combinators : Proof.context -> term -> term |
|
92 val prepare_atp_problem : |
98 val prepare_atp_problem : |
93 Proof.context -> format -> formula_kind -> formula_kind -> type_enc -> bool |
99 Proof.context -> format -> formula_kind -> formula_kind -> type_enc -> bool |
94 -> bool -> (term list -> term list * term list) -> bool -> bool -> term list |
100 -> bool -> string -> bool -> bool -> term list -> term |
95 -> term -> ((string * locality) * term) list |
101 -> ((string * locality) * term) list |
96 -> string problem * string Symtab.table * int * int |
102 -> string problem * string Symtab.table * int * int |
97 * (string * locality) list vector * int list * int Symtab.table |
103 * (string * locality) list vector * int list * int Symtab.table |
98 val atp_problem_weights : string problem -> (string * real) list |
104 val atp_problem_weights : string problem -> (string * real) list |
99 end; |
105 end; |
100 |
106 |
103 |
109 |
104 open ATP_Util |
110 open ATP_Util |
105 open ATP_Problem |
111 open ATP_Problem |
106 |
112 |
107 type name = string * string |
113 type name = string * string |
|
114 |
|
115 val no_lambdasN = "no_lambdas" |
|
116 val concealedN = "concealed" |
|
117 val liftingN = "lifting" |
|
118 val combinatorsN = "combinators" |
|
119 val hybridN = "hybrid" |
|
120 val lambdasN = "lambdas" |
|
121 val smartN = "smart" |
108 |
122 |
109 val generate_info = false (* experimental *) |
123 val generate_info = false (* experimental *) |
110 |
124 |
111 fun isabelle_info s = |
125 fun isabelle_info s = |
112 if generate_info then SOME (ATerm ("[]", [ATerm ("isabelle_" ^ s, [])])) |
126 if generate_info then SOME (ATerm ("[]", [ATerm ("isabelle_" ^ s, [])])) |
603 Guards stuff => |
617 Guards stuff => |
604 (if is_type_enc_fairly_sound type_enc then Tags else Guards) |
618 (if is_type_enc_fairly_sound type_enc then Tags else Guards) |
605 stuff |
619 stuff |
606 | _ => type_enc) |
620 | _ => type_enc) |
607 | format => (format, type_enc)) |
621 | format => (format, type_enc)) |
|
622 |
|
623 fun lift_lambdas ctxt type_enc = |
|
624 map (close_form o Envir.eta_contract) #> rpair ctxt |
|
625 #-> Lambda_Lifting.lift_lambdas |
|
626 (if polymorphism_of_type_enc type_enc = Polymorphic then |
|
627 SOME polymorphic_free_prefix |
|
628 else |
|
629 NONE) |
|
630 Lambda_Lifting.is_quantifier |
|
631 #> fst |
|
632 |
|
633 fun intentionalize_def (Const (@{const_name All}, _) $ Abs (_, _, t)) = |
|
634 intentionalize_def t |
|
635 | intentionalize_def (Const (@{const_name HOL.eq}, _) $ t $ u) = |
|
636 let |
|
637 fun lam T t = Abs (Name.uu, T, t) |
|
638 val (head, args) = strip_comb t ||> rev |
|
639 val head_T = fastype_of head |
|
640 val n = length args |
|
641 val arg_Ts = head_T |> binder_types |> take n |> rev |
|
642 val u = u |> subst_atomic (args ~~ map Bound (0 upto n - 1)) |
|
643 in HOLogic.eq_const head_T $ head $ fold lam arg_Ts u end |
|
644 | intentionalize_def t = t |
608 |
645 |
609 type translated_formula = |
646 type translated_formula = |
610 {name : string, |
647 {name : string, |
611 locality : locality, |
648 locality : locality, |
612 kind : formula_kind, |
649 kind : formula_kind, |
1916 val free_typesN = "Type variables" |
1953 val free_typesN = "Type variables" |
1917 |
1954 |
1918 val explicit_apply = NONE (* for experiments *) |
1955 val explicit_apply = NONE (* for experiments *) |
1919 |
1956 |
1920 fun prepare_atp_problem ctxt format conj_sym_kind prem_kind type_enc sound |
1957 fun prepare_atp_problem ctxt format conj_sym_kind prem_kind type_enc sound |
1921 exporter trans_lambdas readable_names preproc hyp_ts concl_t facts = |
1958 exporter lambda_trans readable_names preproc hyp_ts concl_t facts = |
1922 let |
1959 let |
1923 val (format, type_enc) = choose_format [format] type_enc |
1960 val (format, type_enc) = choose_format [format] type_enc |
|
1961 val lambda_trans = |
|
1962 if lambda_trans = smartN then |
|
1963 if is_type_enc_higher_order type_enc then lambdasN else combinatorsN |
|
1964 else if lambda_trans = lambdasN andalso |
|
1965 not (is_type_enc_higher_order type_enc) then |
|
1966 error ("Lambda translation method incompatible with first-order \ |
|
1967 \encoding.") |
|
1968 else |
|
1969 lambda_trans |
|
1970 val trans_lambdas = |
|
1971 if lambda_trans = no_lambdasN then |
|
1972 rpair [] |
|
1973 else if lambda_trans = concealedN then |
|
1974 lift_lambdas ctxt type_enc ##> K [] |
|
1975 else if lambda_trans = liftingN then |
|
1976 lift_lambdas ctxt type_enc |
|
1977 else if lambda_trans = combinatorsN then |
|
1978 map (introduce_combinators ctxt) #> rpair [] |
|
1979 else if lambda_trans = hybridN then |
|
1980 lift_lambdas ctxt type_enc |
|
1981 ##> maps (fn t => [t, introduce_combinators ctxt |
|
1982 (intentionalize_def t)]) |
|
1983 else if lambda_trans = lambdasN then |
|
1984 map (Envir.eta_contract) #> rpair [] |
|
1985 else |
|
1986 error ("Unknown lambda translation method: " ^ |
|
1987 quote lambda_trans ^ ".") |
1924 val (fact_names, (conjs, facts, class_rel_clauses, arity_clauses)) = |
1988 val (fact_names, (conjs, facts, class_rel_clauses, arity_clauses)) = |
1925 translate_formulas ctxt format prem_kind type_enc trans_lambdas preproc |
1989 translate_formulas ctxt format prem_kind type_enc trans_lambdas preproc |
1926 hyp_ts concl_t facts |
1990 hyp_ts concl_t facts |
1927 val sym_tab = conjs @ facts |> sym_table_for_facts ctxt explicit_apply |
1991 val sym_tab = conjs @ facts |> sym_table_for_facts ctxt explicit_apply |
1928 val nonmono_Ts = |
1992 val nonmono_Ts = |