src/HOL/Tools/Metis/metis_translate.ML
changeset 43090 f6331d785128
parent 43087 b870759ce0f3
child 43091 b0b30df60056
equal deleted inserted replaced
43089:c2ec08b0d217 43090:f6331d785128
    23   val num_type_args: theory -> string -> int
    23   val num_type_args: theory -> string -> int
    24   val new_skolem_var_name_from_const : string -> string
    24   val new_skolem_var_name_from_const : string -> string
    25   val reveal_old_skolem_terms : (string * term) list -> term -> term
    25   val reveal_old_skolem_terms : (string * term) list -> term -> term
    26   val string_of_mode : mode -> string
    26   val string_of_mode : mode -> string
    27   val prepare_metis_problem :
    27   val prepare_metis_problem :
    28     mode -> Proof.context -> bool -> thm list -> thm list list
    28     mode -> Proof.context -> thm list -> thm list list -> mode * metis_problem
    29     -> mode * metis_problem
       
    30 end
    29 end
    31 
    30 
    32 structure Metis_Translate : METIS_TRANSLATE =
    31 structure Metis_Translate : METIS_TRANSLATE =
    33 struct
    32 struct
    34 
    33 
   205     (s = the_default [] (Variable.def_sort ctxt (x, ~1)));
   204     (s = the_default [] (Variable.def_sort ctxt (x, ~1)));
   206 
   205 
   207 fun metis_of_tfree tf =
   206 fun metis_of_tfree tf =
   208   Metis_Thm.axiom (Metis_LiteralSet.singleton (metis_of_type_literals true tf));
   207   Metis_Thm.axiom (Metis_LiteralSet.singleton (metis_of_type_literals true tf));
   209 
   208 
   210 fun hol_thm_to_fol is_conjecture ctxt type_lits mode j old_skolems th =
   209 fun hol_thm_to_fol is_conjecture ctxt mode j old_skolems th =
   211   let
   210   let
   212     val thy = Proof_Context.theory_of ctxt
   211     val thy = Proof_Context.theory_of ctxt
   213     val (old_skolems, (mlits, types_sorts)) =
   212     val (old_skolems, (mlits, types_sorts)) =
   214      th |> prop_of |> Logic.strip_imp_concl
   213      th |> prop_of |> Logic.strip_imp_concl
   215         |> conceal_old_skolem_terms j old_skolems
   214         |> conceal_old_skolem_terms j old_skolems
   220        raw_type_literals_for_types types_sorts, old_skolems)
   219        raw_type_literals_for_types types_sorts, old_skolems)
   221     else
   220     else
   222       let
   221       let
   223         val tylits = types_sorts |> filter_out (has_default_sort ctxt)
   222         val tylits = types_sorts |> filter_out (has_default_sort ctxt)
   224                                  |> raw_type_literals_for_types
   223                                  |> raw_type_literals_for_types
   225         val mtylits =
   224         val mtylits = map (metis_of_type_literals false) tylits
   226           if type_lits then map (metis_of_type_literals false) tylits else []
       
   227       in
   225       in
   228         (Metis_Thm.axiom (Metis_LiteralSet.fromList(mtylits @ mlits)), [],
   226         (Metis_Thm.axiom (Metis_LiteralSet.fromList(mtylits @ mlits)), [],
   229          old_skolems)
   227          old_skolems)
   230       end
   228       end
   231   end;
   229   end;
   293       val class_rel_clauses = make_class_rel_clauses thy subs supers'
   291       val class_rel_clauses = make_class_rel_clauses thy subs supers'
   294   in  map class_rel_cls class_rel_clauses @ map arity_cls arity_clauses
   292   in  map class_rel_cls class_rel_clauses @ map arity_cls arity_clauses
   295   end;
   293   end;
   296 
   294 
   297 (* Function to generate metis clauses, including comb and type clauses *)
   295 (* Function to generate metis clauses, including comb and type clauses *)
   298 fun prepare_metis_problem New ctxt type_lits cls thss =
   296 fun prepare_metis_problem New ctxt cls thss =
   299     error "Not implemented yet"
   297     error "Not implemented yet"
   300   | prepare_metis_problem mode ctxt type_lits cls thss =
   298   | prepare_metis_problem mode ctxt cls thss =
   301     let
   299     let
   302       val thy = Proof_Context.theory_of ctxt
   300       val thy = Proof_Context.theory_of ctxt
   303       (* The modes FO and FT are sticky. HO can be downgraded to FO. *)
   301       (* The modes FO and FT are sticky. HO can be downgraded to FO. *)
   304       val mode =
   302       val mode =
   305         if mode = HO andalso
   303         if mode = HO andalso
   310       (*transform isabelle clause to metis clause *)
   308       (*transform isabelle clause to metis clause *)
   311       fun add_thm is_conjecture (isa_ith, metis_ith)
   309       fun add_thm is_conjecture (isa_ith, metis_ith)
   312                   {axioms, tfrees, old_skolems} : metis_problem =
   310                   {axioms, tfrees, old_skolems} : metis_problem =
   313         let
   311         let
   314           val (mth, tfree_lits, old_skolems) =
   312           val (mth, tfree_lits, old_skolems) =
   315             hol_thm_to_fol is_conjecture ctxt type_lits mode (length axioms)
   313             hol_thm_to_fol is_conjecture ctxt mode (length axioms) old_skolems
   316                            old_skolems metis_ith
   314                            metis_ith
   317         in
   315         in
   318            {axioms = (mth, isa_ith) :: axioms,
   316            {axioms = (mth, isa_ith) :: axioms,
   319             tfrees = union (op =) tfree_lits tfrees, old_skolems = old_skolems}
   317             tfrees = union (op =) tfree_lits tfrees, old_skolems = old_skolems}
   320         end;
   318         end;
   321       val lmap = {axioms = [], tfrees = init_tfrees ctxt, old_skolems = []}
   319       val lmap = {axioms = [], tfrees = init_tfrees ctxt, old_skolems = []}