src/Pure/codegen.ML
changeset 17666 4708ab4626a5
parent 17638 6de497c99e4c
child 18098 227ecb2cfa3d
equal deleted inserted replaced
17665:64e5aecbf7fd 17666:4708ab4626a5
   344     | _ => err ()
   344     | _ => err ()
   345   end;
   345   end;
   346     
   346     
   347 fun unfold_attr (thy, eqn) =
   347 fun unfold_attr (thy, eqn) =
   348   let
   348   let
   349     val (name, _) = dest_Const (head_of
   349     val names = term_consts
   350       (fst (Logic.dest_equals (prop_of eqn))));
   350       (fst (Logic.dest_equals (prop_of eqn)));
   351     fun prep thy = map (fn th =>
   351     fun prep thy = map (fn th =>
   352       if name mem term_consts (prop_of th) then
   352       let val prop = prop_of th
   353         rewrite_rule [eqn] (Thm.transfer thy th)
   353       in
   354       else th)
   354         if forall (fn name => exists_Const (equal name o fst) prop) names
       
   355         then rewrite_rule [eqn] (Thm.transfer thy th)
       
   356         else th
       
   357       end)
   355   in (add_preprocessor prep thy, eqn) end;
   358   in (add_preprocessor prep thy, eqn) end;
   356 
   359 
   357 val _ = Context.add_setup [add_attribute "unfold" (Scan.succeed unfold_attr)];
   360 val _ = Context.add_setup [add_attribute "unfold" (Scan.succeed unfold_attr)];
   358 
   361 
   359 
   362