src/Pure/Isar/element.ML
changeset 59616 eb59c6968219
parent 59498 50b60f501b05
child 59621 291934bac95e
equal deleted inserted replaced
59593:304ee0a475d1 59616:eb59c6968219
   199 
   199 
   200 fun standard_elim th =
   200 fun standard_elim th =
   201   (case Object_Logic.elim_concl th of
   201   (case Object_Logic.elim_concl th of
   202     SOME C =>
   202     SOME C =>
   203       let
   203       let
   204         val cert = Thm.cterm_of (Thm.theory_of_thm th);
   204         val thy = Thm.theory_of_thm th;
   205         val thesis = Var ((Auto_Bind.thesisN, Thm.maxidx_of th + 1), fastype_of C);
   205         val thesis = Var ((Auto_Bind.thesisN, Thm.maxidx_of th + 1), fastype_of C);
   206         val th' = Thm.instantiate ([], [(cert C, cert thesis)]) th;
   206         val th' = Thm.instantiate ([], [(Thm.cterm_of thy C, Thm.cterm_of thy thesis)]) th;
   207       in (th', true) end
   207       in (th', true) end
   208   | NONE => (th, false));
   208   | NONE => (th, false));
   209 
   209 
   210 fun thm_name kind th prts =
   210 fun thm_name kind th prts =
   211   let val head =
   211   let val head =
   336 
   336 
   337 (* derived rules *)
   337 (* derived rules *)
   338 
   338 
   339 fun instantiate_tfrees thy subst th =
   339 fun instantiate_tfrees thy subst th =
   340   let
   340   let
   341     val certT = Thm.ctyp_of thy;
       
   342     val idx = Thm.maxidx_of th + 1;
   341     val idx = Thm.maxidx_of th + 1;
   343     fun cert_inst (a, (S, T)) = (certT (TVar ((a, idx), S)), certT T);
   342     fun cert_inst (a, (S, T)) = (Thm.ctyp_of thy (TVar ((a, idx), S)), Thm.ctyp_of thy T);
   344 
   343 
   345     fun add_inst (a, S) insts =
   344     fun add_inst (a, S) insts =
   346       if AList.defined (op =) insts a then insts
   345       if AList.defined (op =) insts a then insts
   347       else (case AList.lookup (op =) subst a of NONE => insts | SOME T => (a, (S, T)) :: insts);
   346       else (case AList.lookup (op =) subst a of NONE => insts | SOME T => (a, (S, T)) :: insts);
   348     val insts =
   347     val insts =
   353     |> Thm.generalize (map fst insts, []) idx
   352     |> Thm.generalize (map fst insts, []) idx
   354     |> Thm.instantiate (map cert_inst insts, [])
   353     |> Thm.instantiate (map cert_inst insts, [])
   355   end;
   354   end;
   356 
   355 
   357 fun instantiate_frees thy subst =
   356 fun instantiate_frees thy subst =
   358   let val cert = Thm.cterm_of thy in
   357   Drule.forall_intr_list (map (Thm.cterm_of thy o Free o fst) subst) #>
   359     Drule.forall_intr_list (map (cert o Free o fst) subst) #>
   358   Drule.forall_elim_list (map (Thm.cterm_of thy o snd) subst);
   360     Drule.forall_elim_list (map (cert o snd) subst)
       
   361   end;
       
   362 
   359 
   363 fun hyps_rule rule th =
   360 fun hyps_rule rule th =
   364   let val {hyps, ...} = Thm.crep_thm th in
   361   let val {hyps, ...} = Thm.crep_thm th in
   365     Drule.implies_elim_list
   362     Drule.implies_elim_list
   366       (rule (Drule.implies_intr_list hyps th))
   363       (rule (Drule.implies_intr_list hyps th))