src/HOL/Import/import_rule.ML
changeset 81858 81f3adce1eda
parent 81857 3ba99477b893
child 81859 6cc57bd46179
equal deleted inserted replaced
81857:3ba99477b893 81858:81f3adce1eda
   157     val tyinst =
   157     val tyinst =
   158       TVars.build (Thm.prop_of th |> (fold_types o fold_atyps) (fn TVar v => add v | _ => I))
   158       TVars.build (Thm.prop_of th |> (fold_types o fold_atyps) (fn TVar v => add v | _ => I))
   159   in
   159   in
   160     Thm.instantiate (tyinst, Vars.empty) th
   160     Thm.instantiate (tyinst, Vars.empty) th
   161   end
   161   end
       
   162 
       
   163 fun freeze thy = freezeT thy #> (fn th =>
       
   164   let
       
   165     val vars = Vars.build (th |> Thm.add_vars)
       
   166     val inst = vars |> Vars.map (fn _ => fn v =>
       
   167       let
       
   168         val Var ((x, _), _) = Thm.term_of v
       
   169         val ty = Thm.ctyp_of_cterm v
       
   170       in Thm.free (x, ty) end)
       
   171   in
       
   172     Thm.instantiate (TVars.empty, inst) th
       
   173   end)
   162 
   174 
   163 fun def' c rhs thy =
   175 fun def' c rhs thy =
   164   let
   176   let
   165     val b = Binding.name c
   177     val b = Binding.name c
   166     val ty = type_of rhs
   178     val ty = type_of rhs
   373       | process (#"D", [th1, th2]) = thm th1 ##>> thm th2 #>> uncurry deduct #-> set_thm
   385       | process (#"D", [th1, th2]) = thm th1 ##>> thm th2 #>> uncurry deduct #-> set_thm
   374       | process (#"L", [t, th]) = term t ##>> (fn ti => thm th ti) #>> uncurry abs #-> set_thm
   386       | process (#"L", [t, th]) = term t ##>> (fn ti => thm th ti) #>> uncurry abs #-> set_thm
   375       | process (#"M", [s]) = (fn state =>
   387       | process (#"M", [s]) = (fn state =>
   376           let
   388           let
   377             val thy = get_theory state
   389             val thy = get_theory state
   378             val ctxt = Proof_Context.init_global thy
   390             val th = freeze thy (Global_Theory.get_thm thy s)
   379             val th = freezeT thy (Global_Theory.get_thm thy s)
       
   380             val ((_, [th']), _) = Variable.import true [th] ctxt
       
   381           in
   391           in
   382             set_thm th' state
   392             set_thm th state
   383           end)
   393           end)
   384       | process (#"Q", l) = (fn state =>
   394       | process (#"Q", l) = (fn state =>
   385           let
   395           let
   386             val (tys, th) = list_last l
   396             val (tys, th) = list_last l
   387             val (th, state1) = thm th state
   397             val (th, state1) = thm th state