Added "del" attribute for deleting equations.
authorberghofe
Mon, 22 Sep 2003 16:14:58 +0200
changeset 14196 be5e838f37bd
parent 14195 e7c9206dd2ef
child 14197 3d7c6fc7c66e
Added "del" attribute for deleting equations.
src/HOL/Tools/recfun_codegen.ML
--- a/src/HOL/Tools/recfun_codegen.ML	Mon Sep 22 16:06:05 2003 +0200
+++ b/src/HOL/Tools/recfun_codegen.ML	Mon Sep 22 16:14:58 2003 +0200
@@ -51,6 +51,15 @@
       tab)) thy, thm)
   end handle TERM _ => (warn thm; p) | Pattern.Pattern => (warn thm; p);
 
+fun del (p as (thy, thm)) =
+  let
+    val tab = CodegenData.get thy;
+    val (s, _) = const_of (prop_of thm);
+  in (CodegenData.put (Symtab.update ((s,
+    gen_rem eq_thm (if_none (Symtab.lookup (tab, s)) [], thm)),
+      tab)) thy, thm)
+  end handle TERM _ => (warn thm; p);
+
 fun get_equations thy (s, T) =
   (case Symtab.lookup (CodegenData.get thy, s) of
      None => []
@@ -139,6 +148,6 @@
 val setup =
   [CodegenData.init,
    add_codegen "recfun" recfun_codegen,
-   add_attribute "" add];
+   add_attribute "" (Args.del |-- Scan.succeed del || Scan.succeed add)];
 
 end;