Optimized unfold_attr.
authorberghofe
Tue, 27 Sep 2005 12:13:17 +0200
changeset 17666 4708ab4626a5
parent 17665 64e5aecbf7fd
child 17667 2beb71c0f92e
Optimized unfold_attr.
src/Pure/codegen.ML
--- a/src/Pure/codegen.ML	Tue Sep 27 11:39:27 2005 +0200
+++ b/src/Pure/codegen.ML	Tue Sep 27 12:13:17 2005 +0200
@@ -346,12 +346,15 @@
     
 fun unfold_attr (thy, eqn) =
   let
-    val (name, _) = dest_Const (head_of
-      (fst (Logic.dest_equals (prop_of eqn))));
+    val names = term_consts
+      (fst (Logic.dest_equals (prop_of eqn)));
     fun prep thy = map (fn th =>
-      if name mem term_consts (prop_of th) then
-        rewrite_rule [eqn] (Thm.transfer thy th)
-      else th)
+      let val prop = prop_of th
+      in
+        if forall (fn name => exists_Const (equal name o fst) prop) names
+        then rewrite_rule [eqn] (Thm.transfer thy th)
+        else th
+      end)
   in (add_preprocessor prep thy, eqn) end;
 
 val _ = Context.add_setup [add_attribute "unfold" (Scan.succeed unfold_attr)];