src/HOL/TPTP/atp_theory_export.ML
changeset 59058 a78612c67ec0
parent 58922 1f500b18c4c6
child 59577 012c6165bbd2
equal deleted inserted replaced
59057:5b649fb2f2e1 59058:a78612c67ec0
   125   | ident_of_problem_line (Type_Decl (ident, _, _)) = ident
   125   | ident_of_problem_line (Type_Decl (ident, _, _)) = ident
   126   | ident_of_problem_line (Sym_Decl (ident, _, _)) = ident
   126   | ident_of_problem_line (Sym_Decl (ident, _, _)) = ident
   127   | ident_of_problem_line (Class_Memb (ident, _, _, _)) = ident
   127   | ident_of_problem_line (Class_Memb (ident, _, _, _)) = ident
   128   | ident_of_problem_line (Formula ((ident, _), _, _, _, _)) = ident
   128   | ident_of_problem_line (Formula ((ident, _), _, _, _, _)) = ident
   129 
   129 
   130 fun order_facts ord = sort (ord o pairself ident_of_problem_line)
   130 fun order_facts ord = sort (ord o apply2 ident_of_problem_line)
   131 
   131 
   132 fun order_problem_facts _ [] = []
   132 fun order_problem_facts _ [] = []
   133   | order_problem_facts ord ((heading, lines) :: problem) =
   133   | order_problem_facts ord ((heading, lines) :: problem) =
   134     if heading = factsN then (heading, order_facts ord lines) :: problem
   134     if heading = factsN then (heading, order_facts ord lines) :: problem
   135     else (heading, lines) :: order_problem_facts ord problem
   135     else (heading, lines) :: order_problem_facts ord problem
   164                |> adjust_type_enc format
   164                |> adjust_type_enc format
   165     val mono = not (is_type_enc_polymorphic type_enc)
   165     val mono = not (is_type_enc_polymorphic type_enc)
   166     val facts =
   166     val facts =
   167       Sledgehammer_Fact.all_facts (Proof_Context.init_global thy) true false
   167       Sledgehammer_Fact.all_facts (Proof_Context.init_global thy) true false
   168                                   Keyword.empty_keywords [] [] css_table
   168                                   Keyword.empty_keywords [] [] css_table
   169       |> sort (Sledgehammer_MaSh.crude_thm_ord o pairself snd)
   169       |> sort (Sledgehammer_MaSh.crude_thm_ord o apply2 snd)
   170     val problem =
   170     val problem =
   171       facts
   171       facts
   172       |> map (fn ((_, loc), th) =>
   172       |> map (fn ((_, loc), th) =>
   173         ((Thm.get_name_hint th, loc), th |> prop_of |> mono ? monomorphize_term ctxt))
   173         ((Thm.get_name_hint th, loc), th |> prop_of |> mono ? monomorphize_term ctxt))
   174       |> generate_atp_problem ctxt format Axiom type_enc Exporter combsN false false true []
   174       |> generate_atp_problem ctxt format Axiom type_enc Exporter combsN false false true []
   200         (tl all_problem_names ~~ fst (split_last all_problem_names))
   200         (tl all_problem_names ~~ fst (split_last all_problem_names))
   201       |> String_Graph.topological_order
   201       |> String_Graph.topological_order
   202     val order_tab =
   202     val order_tab =
   203       Symtab.empty
   203       Symtab.empty
   204       |> fold (Symtab.insert (op =)) (ordered_names ~~ (1 upto length ordered_names))
   204       |> fold (Symtab.insert (op =)) (ordered_names ~~ (1 upto length ordered_names))
   205     val name_ord = int_ord o pairself (the o Symtab.lookup order_tab)
   205     val name_ord = int_ord o apply2 (the o Symtab.lookup order_tab)
   206   in
   206   in
   207     problem
   207     problem
   208     |> (case format of
   208     |> (case format of
   209           DFG _ => I
   209           DFG _ => I
   210         | _ => add_inferences_to_problem ctxt format
   210         | _ => add_inferences_to_problem ctxt format
   295     val _ = Isabelle_System.mkdir include_dir
   295     val _ = Isabelle_System.mkdir include_dir
   296     val (prelude, groups) =
   296     val (prelude, groups) =
   297       problem_of_theory ctxt thy format infer_policy type_enc
   297       problem_of_theory ctxt thy format infer_policy type_enc
   298       |> split_last
   298       |> split_last
   299       ||> (snd
   299       ||> (snd
   300            #> chop_maximal_groups (op = o pairself theory_name_of_fact)
   300            #> chop_maximal_groups (op = o apply2 theory_name_of_fact)
   301            #> map (`(include_base_name_of_fact o hd)))
   301            #> map (`(include_base_name_of_fact o hd)))
   302     fun write_prelude () =
   302     fun write_prelude () =
   303       let val ss = lines_of_problem ctxt format prelude in
   303       let val ss = lines_of_problem ctxt format prelude in
   304         File.append file_order_path (prelude_base_name ^ "\n");
   304         File.append file_order_path (prelude_base_name ^ "\n");
   305         write_lines (ap include_dir prelude_name) ss
   305         write_lines (ap include_dir prelude_name) ss