src/HOL/Tools/Ctr_Sugar/ctr_sugar_util.ML
changeset 60788 5e2df6bd906c
parent 60777 ee811a49c8f6
child 63170 eae6549dbea2
equal deleted inserted replaced
60787:12cd198f07af 60788:5e2df6bd906c
    61   val list_all_free: term list -> term -> term
    61   val list_all_free: term list -> term -> term
    62   val list_exists_free: term list -> term -> term
    62   val list_exists_free: term list -> term -> term
    63 
    63 
    64   val fo_match: Proof.context -> term -> term -> Type.tyenv * Envir.tenv
    64   val fo_match: Proof.context -> term -> term -> Type.tyenv * Envir.tenv
    65 
    65 
    66   val cterm_instantiate_pos: cterm option list -> thm -> thm
       
    67   val unfold_thms: Proof.context -> thm list -> thm -> thm
    66   val unfold_thms: Proof.context -> thm list -> thm -> thm
    68 
    67 
    69   val name_noted_thms: string -> string -> (string * thm list) list -> (string * thm list) list
    68   val name_noted_thms: string -> string -> (string * thm list) list -> (string * thm list) list
    70   val substitute_noted_thm: (string * thm list) list -> morphism
    69   val substitute_noted_thm: (string * thm list) list -> morphism
    71 
    70 
   210 
   209 
   211 val list_all_free = list_quant_free HOLogic.all_const;
   210 val list_all_free = list_quant_free HOLogic.all_const;
   212 val list_exists_free = list_quant_free HOLogic.exists_const;
   211 val list_exists_free = list_quant_free HOLogic.exists_const;
   213 
   212 
   214 fun fo_match ctxt t pat =
   213 fun fo_match ctxt t pat =
   215   let val thy = Proof_Context.theory_of ctxt in
   214   let val thy = Proof_Context.theory_of ctxt
   216     Pattern.first_order_match thy (pat, t) (Vartab.empty, Vartab.empty)
   215   in Pattern.first_order_match thy (pat, t) (Vartab.empty, Vartab.empty) end;
   217   end;
       
   218 
       
   219 fun cterm_instantiate_pos cts thm =
       
   220   let
       
   221     val thy = Thm.theory_of_thm thm;
       
   222     val vars = Term.add_vars (Thm.prop_of thm) [];
       
   223     val vars' = rev (drop (length vars - length cts) vars);
       
   224     val ps =
       
   225       map_filter
       
   226         (fn (_, NONE) => NONE
       
   227           | (var, SOME ct) => SOME (Thm.global_cterm_of thy (Var var), ct)) (vars' ~~ cts);
       
   228   in
       
   229     Drule.cterm_instantiate ps thm
       
   230   end;
       
   231 
   216 
   232 fun unfold_thms ctxt thms = Local_Defs.unfold ctxt (distinct Thm.eq_thm_prop thms);
   217 fun unfold_thms ctxt thms = Local_Defs.unfold ctxt (distinct Thm.eq_thm_prop thms);
   233 
   218 
   234 fun name_noted_thms _ _ [] = []
   219 fun name_noted_thms _ _ [] = []
   235   | name_noted_thms qualifier base ((local_name, thms) :: noted) =
   220   | name_noted_thms qualifier base ((local_name, thms) :: noted) =