src/HOL/Tools/Ctr_Sugar/ctr_sugar_util.ML
changeset 59617 b60e65ad13df
parent 59582 0fbed69ff081
child 59621 291934bac95e
equal deleted inserted replaced
59616:eb59c6968219 59617:b60e65ad13df
   211     Pattern.first_order_match thy (pat, t) (Vartab.empty, Vartab.empty)
   211     Pattern.first_order_match thy (pat, t) (Vartab.empty, Vartab.empty)
   212   end;
   212   end;
   213 
   213 
   214 fun cterm_instantiate_pos cts thm =
   214 fun cterm_instantiate_pos cts thm =
   215   let
   215   let
   216     val cert = Thm.cterm_of (Thm.theory_of_thm thm);
   216     val thy = Thm.theory_of_thm thm;
   217     val vars = Term.add_vars (Thm.prop_of thm) [];
   217     val vars = Term.add_vars (Thm.prop_of thm) [];
   218     val vars' = rev (drop (length vars - length cts) vars);
   218     val vars' = rev (drop (length vars - length cts) vars);
   219     val ps = map_filter (fn (_, NONE) => NONE
   219     val ps =
   220       | (var, SOME ct) => SOME (cert (Var var), ct)) (vars' ~~ cts);
   220       map_filter
       
   221         (fn (_, NONE) => NONE
       
   222           | (var, SOME ct) => SOME (Thm.cterm_of thy (Var var), ct)) (vars' ~~ cts);
   221   in
   223   in
   222     Drule.cterm_instantiate ps thm
   224     Drule.cterm_instantiate ps thm
   223   end;
   225   end;
   224 
   226 
   225 fun unfold_thms ctxt thms = Local_Defs.unfold ctxt (distinct Thm.eq_thm_prop thms);
   227 fun unfold_thms ctxt thms = Local_Defs.unfold ctxt (distinct Thm.eq_thm_prop thms);