src/HOL/Tools/ATP/atp_translate.ML
changeset 43189 0ab7265f659f
parent 43188 0c36ae874fcc
child 43192 9c29a00f2970
equal deleted inserted replaced
43188:0c36ae874fcc 43189:0ab7265f659f
   129     -> translated_formula option * ((string * locality) * thm)
   129     -> translated_formula option * ((string * locality) * thm)
   130   val helper_table : (string * (bool * thm list)) list
   130   val helper_table : (string * (bool * thm list)) list
   131   val should_specialize_helper : type_sys -> term -> bool
   131   val should_specialize_helper : type_sys -> term -> bool
   132   val tfree_classes_of_terms : term list -> string list
   132   val tfree_classes_of_terms : term list -> string list
   133   val tvar_classes_of_terms : term list -> string list
   133   val tvar_classes_of_terms : term list -> string list
   134   val type_consts_of_terms : theory -> term list -> string list
   134   val type_constrs_of_terms : theory -> term list -> string list
   135   val prepare_atp_problem :
   135   val prepare_atp_problem :
   136     Proof.context -> format -> formula_kind -> formula_kind -> type_sys
   136     Proof.context -> format -> formula_kind -> formula_kind -> type_sys
   137     -> bool option -> bool -> bool -> term list -> term
   137     -> bool option -> bool -> bool -> term list -> term
   138     -> (translated_formula option * ((string * 'a) * thm)) list
   138     -> (translated_formula option * ((string * 'a) * thm)) list
   139     -> string problem * string Symtab.table * int * int
   139     -> string problem * string Symtab.table * int * int
  1366 
  1366 
  1367 val tfree_classes_of_terms = classes_of_terms OldTerm.term_tfrees
  1367 val tfree_classes_of_terms = classes_of_terms OldTerm.term_tfrees
  1368 val tvar_classes_of_terms = classes_of_terms OldTerm.term_tvars
  1368 val tvar_classes_of_terms = classes_of_terms OldTerm.term_tvars
  1369 
  1369 
  1370 (*fold type constructors*)
  1370 (*fold type constructors*)
  1371 fun fold_type_consts f (Type (a, Ts)) x = fold (fold_type_consts f) Ts (f (a,x))
  1371 fun fold_type_constrs f (Type (a, Ts)) x =
  1372   | fold_type_consts _ _ x = x
  1372     fold (fold_type_constrs f) Ts (f (a,x))
       
  1373   | fold_type_constrs _ _ x = x
  1373 
  1374 
  1374 (*Type constructors used to instantiate overloaded constants are the only ones needed.*)
  1375 (*Type constructors used to instantiate overloaded constants are the only ones needed.*)
  1375 fun add_type_consts_in_term thy =
  1376 fun add_type_constrs_in_term thy =
  1376   let
  1377   let
  1377     fun add (Const (@{const_name Meson.skolem}, _) $ _) = I
  1378     fun add (Const (@{const_name Meson.skolem}, _) $ _) = I
  1378       | add (t $ u) = add t #> add u
  1379       | add (t $ u) = add t #> add u
  1379       | add (Const (x as (s, _))) =
  1380       | add (Const (x as (s, _))) =
  1380         if String.isPrefix skolem_const_prefix s then I
  1381         if String.isPrefix skolem_const_prefix s then I
  1381         else x |> Sign.const_typargs thy |> fold (fold_type_consts set_insert)
  1382         else x |> Sign.const_typargs thy |> fold (fold_type_constrs set_insert)
  1382       | add (Abs (_, _, u)) = add u
  1383       | add (Abs (_, _, u)) = add u
  1383       | add _ = I
  1384       | add _ = I
  1384   in add end
  1385   in add end
  1385 
  1386 
  1386 fun type_consts_of_terms thy ts =
  1387 fun type_constrs_of_terms thy ts =
  1387   Symtab.keys (fold (add_type_consts_in_term thy) ts Symtab.empty)
  1388   Symtab.keys (fold (add_type_constrs_in_term thy) ts Symtab.empty)
  1388 
  1389 
  1389 fun translate_formulas ctxt format prem_kind type_sys preproc hyp_ts concl_t
  1390 fun translate_formulas ctxt format prem_kind type_sys preproc hyp_ts concl_t
  1390                        rich_facts =
  1391                        rich_facts =
  1391   let
  1392   let
  1392     val thy = Proof_Context.theory_of ctxt
  1393     val thy = Proof_Context.theory_of ctxt
  1401     val hyp_ts = hyp_ts |> filter_out (member (op aconv) fact_ts)
  1402     val hyp_ts = hyp_ts |> filter_out (member (op aconv) fact_ts)
  1402     val goal_t = Logic.list_implies (hyp_ts, concl_t)
  1403     val goal_t = Logic.list_implies (hyp_ts, concl_t)
  1403     val all_ts = goal_t :: fact_ts
  1404     val all_ts = goal_t :: fact_ts
  1404     val subs = tfree_classes_of_terms all_ts
  1405     val subs = tfree_classes_of_terms all_ts
  1405     val supers = tvar_classes_of_terms all_ts
  1406     val supers = tvar_classes_of_terms all_ts
  1406     val tycons = type_consts_of_terms thy all_ts
  1407     val tycons = type_constrs_of_terms thy all_ts
  1407     val conjs =
  1408     val conjs =
  1408       hyp_ts @ [concl_t]
  1409       hyp_ts @ [concl_t]
  1409       |> make_conjecture ctxt format prem_kind type_sys preproc
  1410       |> make_conjecture ctxt format prem_kind type_sys preproc
  1410     val (supers', arity_clauses) =
  1411     val (supers', arity_clauses) =
  1411       if level_of_type_sys type_sys = No_Types then ([], [])
  1412       if level_of_type_sys type_sys = No_Types then ([], [])