src/HOL/Tools/Sledgehammer/sledgehammer_filter_mash.ML
changeset 48325 2ec05ef3e593
parent 48324 3ee5b5589402
child 48326 ef800e91d072
equal deleted inserted replaced
48324:3ee5b5589402 48325:2ec05ef3e593
   153 val thy_feature_name_of = prefix thy_feature_prefix
   153 val thy_feature_name_of = prefix thy_feature_prefix
   154 val const_name_of = prefix const_prefix
   154 val const_name_of = prefix const_prefix
   155 val type_name_of = prefix type_const_prefix
   155 val type_name_of = prefix type_const_prefix
   156 val class_name_of = prefix class_prefix
   156 val class_name_of = prefix class_prefix
   157 
   157 
   158 local
       
   159 
       
   160 fun has_bool @{typ bool} = true
       
   161   | has_bool (Type (_, Ts)) = exists has_bool Ts
       
   162   | has_bool _ = false
       
   163 
       
   164 fun has_fun (Type (@{type_name fun}, _)) = true
       
   165   | has_fun (Type (_, Ts)) = exists has_fun Ts
       
   166   | has_fun _ = false
       
   167 
       
   168 val is_conn = member (op =)
       
   169   [@{const_name Trueprop}, @{const_name HOL.conj}, @{const_name HOL.disj},
       
   170    @{const_name HOL.implies}, @{const_name Not},
       
   171    @{const_name All}, @{const_name Ex}, @{const_name Ball}, @{const_name Bex},
       
   172    @{const_name HOL.eq}]
       
   173 
       
   174 val has_bool_arg_const =
       
   175   exists_Const (fn (c, T) =>
       
   176                    not (is_conn c) andalso exists has_bool (binder_types T))
       
   177 
       
   178 fun higher_inst_const thy (s, T) =
       
   179   case binder_types T of
       
   180     [] => false
       
   181   | Ts => length (binder_types (Sign.the_const_type thy s)) <> length Ts
       
   182   handle TYPE _ => false
       
   183 
       
   184 val binders = [@{const_name All}, @{const_name Ex}]
       
   185 
       
   186 in
       
   187 
       
   188 fun is_fo_term thy t =
       
   189   let
       
   190     val t =
       
   191       t |> Envir.beta_eta_contract
       
   192         |> transform_elim_prop
       
   193         |> Object_Logic.atomize_term thy
       
   194   in
       
   195     Term.is_first_order binders t andalso
       
   196     not (exists_subterm (fn Var (_, T) => has_bool T orelse has_fun T
       
   197                           | _ => false) t orelse
       
   198          has_bool_arg_const t orelse exists_Const (higher_inst_const thy) t)
       
   199   end
       
   200 
       
   201 end
       
   202 
       
   203 fun is_likely_tautology_or_too_meta th =
   158 fun is_likely_tautology_or_too_meta th =
   204   let
   159   let
   205     val is_boring_const = member (op =) atp_widely_irrelevant_consts
   160     val is_boring_const = member (op =) atp_widely_irrelevant_consts
   206     fun is_boring_bool t =
   161     fun is_boring_bool t =
   207       not (exists_Const (not o is_boring_const o fst) t) orelse
   162       not (exists_Const (not o is_boring_const o fst) t) orelse
   283   thy_feature_name_of (Context.theory_name thy) ::
   238   thy_feature_name_of (Context.theory_name thy) ::
   284   interesting_terms_types_and_classes ctxt prover term_max_depth type_max_depth
   239   interesting_terms_types_and_classes ctxt prover term_max_depth type_max_depth
   285                                       ts
   240                                       ts
   286   |> exists (not o is_lambda_free) ts ? cons "lambdas"
   241   |> exists (not o is_lambda_free) ts ? cons "lambdas"
   287   |> exists (exists_Const is_exists) ts ? cons "skolems"
   242   |> exists (exists_Const is_exists) ts ? cons "skolems"
   288   |> exists (not o is_fo_term thy) ts ? cons "ho"
       
   289   |> (case status of
   243   |> (case status of
   290         General => I
   244         General => I
   291       | Induction => cons "induction"
   245       | Induction => cons "induction"
   292       | Intro => cons "intro"
   246       | Intro => cons "intro"
   293       | Inductive => cons "inductive"
   247       | Inductive => cons "inductive"