src/HOL/Tools/ATP/atp_problem_generate.ML
changeset 52025 9f94930b12e6
parent 52005 a86717e3859f
child 52026 97dd505ee058
equal deleted inserted replaced
52024:eb264c3fa30e 52025:9f94930b12e6
   424                        ? add_schematic_const x
   424                        ? add_schematic_const x
   425                       | _ => I)
   425                       | _ => I)
   426 fun atp_schematic_consts_of t = add_schematic_consts_of t Symtab.empty
   426 fun atp_schematic_consts_of t = add_schematic_consts_of t Symtab.empty
   427 
   427 
   428 val tvar_a_str = "'a"
   428 val tvar_a_str = "'a"
   429 val tvar_a_z = ((tvar_a_str, 100 (* arbitrary *)), HOLogic.typeS)
   429 val tvar_a_z = ((tvar_a_str, 0), HOLogic.typeS)
   430 val tvar_a = TVar tvar_a_z
   430 val tvar_a = TVar tvar_a_z
   431 val tvar_a_name = tvar_name tvar_a_z
   431 val tvar_a_name = tvar_name tvar_a_z
   432 val itself_name = `make_fixed_type_const @{type_name itself}
   432 val itself_name = `make_fixed_type_const @{type_name itself}
   433 val TYPE_name = `(make_fixed_const NONE) @{const_name TYPE}
   433 val TYPE_name = `(make_fixed_const NONE) @{const_name TYPE}
   434 val tvar_a_atype = AType (tvar_a_name, [])
   434 val tvar_a_atype = AType (tvar_a_name, [])
  2537     val syms = sym_decl_tab |> Symtab.dest |> sort_wrt fst
  2537     val syms = sym_decl_tab |> Symtab.dest |> sort_wrt fst
  2538     val mono_lines = lines_of_mono_types ctxt mono type_enc mono_Ts
  2538     val mono_lines = lines_of_mono_types ctxt mono type_enc mono_Ts
  2539     val decl_lines = maps (lines_of_sym_decls ctxt mono type_enc) syms
  2539     val decl_lines = maps (lines_of_sym_decls ctxt mono type_enc) syms
  2540   in mono_lines @ decl_lines end
  2540   in mono_lines @ decl_lines end
  2541 
  2541 
  2542 fun datatypes_of_facts ctxt (DFG Polymorphic) (type_enc as Native _) facts =
  2542 fun datatypes_of_facts ctxt (DFG Polymorphic) (type_enc as Native (_, _, level))
  2543     if is_type_enc_polymorphic type_enc then
  2543                        facts =
  2544       [(@{typ nat}, [@{term "0::nat"}, @{term Suc}], true)]
  2544     let
  2545     else
  2545       val thy = Proof_Context.theory_of ctxt
  2546       []
  2546       val mono = default_mono level false
       
  2547       val ho_term_from_term =
       
  2548         iterm_from_term thy type_enc []
       
  2549         #> fst #> ho_term_from_iterm ctxt mono type_enc NONE
       
  2550     in
       
  2551       if is_type_enc_polymorphic type_enc then
       
  2552         [(native_ho_type_from_typ type_enc false 0 @{typ nat},
       
  2553           map ho_term_from_term [@{term "0::nat"}, @{term Suc}]) (*,
       
  2554          (native_ho_type_from_typ type_enc false 0 (Logic.varifyT_global @{typ "'a list"}),
       
  2555           map (ho_term_from_term o Logic.varify_types_global) [@{term Nil}, @{term Cons}]) *)]
       
  2556       else
       
  2557         []
       
  2558     end
  2547   | datatypes_of_facts _ _ _ _ = []
  2559   | datatypes_of_facts _ _ _ _ = []
  2548 
  2560 
  2549 fun decl_line_of_datatype (_, [], _) = NONE
  2561 fun decl_line_of_datatype (ty as AType ((_, s'), ty_args), ctrs) =
  2550   | decl_line_of_datatype (T as Type (s, _), ctrs, exhaust) =
  2562   let
  2551     SOME (Datatype_Decl (datatype_decl_prefix ^ ascii_of s, [],
  2563     val xs = map (fn AType (name, []) => name) ty_args
  2552              AType (("naT", @{type_name nat}), []), [], exhaust)) (*###*)
  2564   in
       
  2565     Datatype_Decl (datatype_decl_prefix ^ ascii_of s', map (rpair []) xs, ty,
       
  2566                    ctrs)
       
  2567   end
  2553 
  2568 
  2554 fun pair_append (xs1, xs2) (ys1, ys2) = (xs1 @ ys1, xs2 @ ys2)
  2569 fun pair_append (xs1, xs2) (ys1, ys2) = (xs1 @ ys1, xs2 @ ys2)
  2555 
  2570 
  2556 fun do_uncurried_alias_lines_of_sym ctxt constrs mono type_enc sym_tab0 sym_tab
  2571 fun do_uncurried_alias_lines_of_sym ctxt constrs mono type_enc sym_tab0 sym_tab
  2557                                     base_s0 types in_conj =
  2572                                     base_s0 types in_conj =
  2666       | do_formula (AConn (_, phis)) = fold do_formula phis
  2681       | do_formula (AConn (_, phis)) = fold do_formula phis
  2667       | do_formula (AAtom tm) = do_term true tm
  2682       | do_formula (AAtom tm) = do_term true tm
  2668     fun do_line (Class_Decl (_, _, cls)) = fold do_class cls
  2683     fun do_line (Class_Decl (_, _, cls)) = fold do_class cls
  2669       | do_line (Type_Decl _) = I
  2684       | do_line (Type_Decl _) = I
  2670       | do_line (Sym_Decl (_, _, ty)) = do_type ty
  2685       | do_line (Sym_Decl (_, _, ty)) = do_type ty
  2671       | do_line (Datatype_Decl (_, xs, ty, tms, _)) =
  2686       | do_line (Datatype_Decl (_, xs, ty, tms)) =
  2672         fold do_bound_tvars xs #> do_type ty #> fold (do_term false) tms
  2687         fold do_bound_tvars xs #> do_type ty #> fold (do_term false) tms
  2673       | do_line (Class_Memb (_, xs, ty, cl)) =
  2688       | do_line (Class_Memb (_, xs, ty, cl)) =
  2674         fold do_bound_tvars xs #> do_type ty #> do_class cl
  2689         fold do_bound_tvars xs #> do_type ty #> do_class cl
  2675       | do_line (Formula (_, _, phi, _, _)) = do_formula phi
  2690       | do_line (Formula (_, _, phi, _, _)) = do_formula phi
  2676     val ((cls, tys), syms) = declared_in_atp_problem problem
  2691     val ((cls, tys), syms) = declared_in_atp_problem problem
  2770     val class_decl_lines = decl_lines_of_classes type_enc classes
  2785     val class_decl_lines = decl_lines_of_classes type_enc classes
  2771     val sym_decl_lines =
  2786     val sym_decl_lines =
  2772       (conjs, helpers @ facts, uncurried_alias_eq_tms)
  2787       (conjs, helpers @ facts, uncurried_alias_eq_tms)
  2773       |> sym_decl_table_of_facts thy type_enc sym_tab
  2788       |> sym_decl_table_of_facts thy type_enc sym_tab
  2774       |> lines_of_sym_decl_table ctxt mono type_enc mono_Ts
  2789       |> lines_of_sym_decl_table ctxt mono type_enc mono_Ts
  2775     val datatype_decl_lines = map_filter decl_line_of_datatype datatypes
  2790     val datatype_decl_lines = map decl_line_of_datatype datatypes
  2776     val decl_lines = class_decl_lines @ sym_decl_lines @ datatype_decl_lines
  2791     val decl_lines = class_decl_lines @ sym_decl_lines @ datatype_decl_lines
  2777     val num_facts = length facts
  2792     val num_facts = length facts
  2778     val fact_lines =
  2793     val fact_lines =
  2779       map (line_of_fact ctxt fact_prefix ascii_of I (not exporter)
  2794       map (line_of_fact ctxt fact_prefix ascii_of I (not exporter)
  2780                (not exporter) mono type_enc (rank_of_fact_num num_facts))
  2795                (not exporter) mono type_enc (rank_of_fact_num num_facts))