forall_intr_list: do not ignore errors;
authorwenzelm
Fri, 26 May 2006 22:20:05 +0200
changeset 19730 8abecd308e60
parent 19729 cb9e2f0c7658
child 19731 581cdbdbba9a
forall_intr_list: do not ignore errors;
src/Pure/drule.ML
--- a/src/Pure/drule.ML	Fri May 26 22:20:03 2006 +0200
+++ b/src/Pure/drule.ML	Fri May 26 22:20:05 2006 +0200
@@ -348,19 +348,17 @@
     thm'
   end;
 
-(*Generalization over a list of variables, IGNORING bad ones*)
-fun forall_intr_list [] th = th
-  | forall_intr_list (y::ys) th =
-        let val gth = forall_intr_list ys th
-        in  forall_intr y gth   handle THM _ =>  gth  end;
+(*Generalization over a list of variables*)
+val forall_intr_list = fold_rev forall_intr;
 
 (*Generalization over all suitable Free variables*)
 fun forall_intr_frees th =
-    let val {prop,thy,...} = rep_thm th
-    in  forall_intr_list
-         (map (cterm_of thy) (sort Term.term_ord (term_frees prop)))
-         th
-    end;
+    let
+      val {prop, hyps, tpairs, thy,...} = rep_thm th;
+      val fixed = fold Term.add_frees (Thm.terms_of_tpairs tpairs @ hyps) [];
+      val frees = Term.fold_aterms (fn Free v =>
+        if member (op =) fixed v then I else insert (op =) v | _ => I) prop [];
+    in fold (forall_intr o cterm_of thy o Free) frees th end;
 
 (*Generalization over Vars -- canonical order*)
 fun forall_intr_vars th =