src/Pure/drule.ML
changeset 19730 8abecd308e60
parent 19523 0531e5abf680
child 19753 b345d4e70ca9
equal deleted inserted replaced
19729:cb9e2f0c7658 19730:8abecd308e60
   346     if null xshyps then ()
   346     if null xshyps then ()
   347     else warning ("Pending sort hypotheses: " ^ commas (map str_of_sort xshyps));
   347     else warning ("Pending sort hypotheses: " ^ commas (map str_of_sort xshyps));
   348     thm'
   348     thm'
   349   end;
   349   end;
   350 
   350 
   351 (*Generalization over a list of variables, IGNORING bad ones*)
   351 (*Generalization over a list of variables*)
   352 fun forall_intr_list [] th = th
   352 val forall_intr_list = fold_rev forall_intr;
   353   | forall_intr_list (y::ys) th =
       
   354         let val gth = forall_intr_list ys th
       
   355         in  forall_intr y gth   handle THM _ =>  gth  end;
       
   356 
   353 
   357 (*Generalization over all suitable Free variables*)
   354 (*Generalization over all suitable Free variables*)
   358 fun forall_intr_frees th =
   355 fun forall_intr_frees th =
   359     let val {prop,thy,...} = rep_thm th
   356     let
   360     in  forall_intr_list
   357       val {prop, hyps, tpairs, thy,...} = rep_thm th;
   361          (map (cterm_of thy) (sort Term.term_ord (term_frees prop)))
   358       val fixed = fold Term.add_frees (Thm.terms_of_tpairs tpairs @ hyps) [];
   362          th
   359       val frees = Term.fold_aterms (fn Free v =>
   363     end;
   360         if member (op =) fixed v then I else insert (op =) v | _ => I) prop [];
       
   361     in fold (forall_intr o cterm_of thy o Free) frees th end;
   364 
   362 
   365 (*Generalization over Vars -- canonical order*)
   363 (*Generalization over Vars -- canonical order*)
   366 fun forall_intr_vars th =
   364 fun forall_intr_vars th =
   367   let val cert = Thm.cterm_of (Thm.theory_of_thm th)
   365   let val cert = Thm.cterm_of (Thm.theory_of_thm th)
   368   in forall_intr_list (map (cert o Var) (vars_of th)) th end;
   366   in forall_intr_list (map (cert o Var) (vars_of th)) th end;