src/HOL/Tools/recfun_codegen.ML
changeset 14196 be5e838f37bd
parent 13105 3d1e7a199bdc
child 14981 e73f8140af78
equal deleted inserted replaced
14195:e7c9206dd2ef 14196:be5e838f37bd
    48 
    48 
    49   in (CodegenData.put (Symtab.update ((s,
    49   in (CodegenData.put (Symtab.update ((s,
    50     filter_out (matches thm) (if_none (Symtab.lookup (tab, s)) []) @ [thm]),
    50     filter_out (matches thm) (if_none (Symtab.lookup (tab, s)) []) @ [thm]),
    51       tab)) thy, thm)
    51       tab)) thy, thm)
    52   end handle TERM _ => (warn thm; p) | Pattern.Pattern => (warn thm; p);
    52   end handle TERM _ => (warn thm; p) | Pattern.Pattern => (warn thm; p);
       
    53 
       
    54 fun del (p as (thy, thm)) =
       
    55   let
       
    56     val tab = CodegenData.get thy;
       
    57     val (s, _) = const_of (prop_of thm);
       
    58   in (CodegenData.put (Symtab.update ((s,
       
    59     gen_rem eq_thm (if_none (Symtab.lookup (tab, s)) [], thm)),
       
    60       tab)) thy, thm)
       
    61   end handle TERM _ => (warn thm; p);
    53 
    62 
    54 fun get_equations thy (s, T) =
    63 fun get_equations thy (s, T) =
    55   (case Symtab.lookup (CodegenData.get thy, s) of
    64   (case Symtab.lookup (CodegenData.get thy, s) of
    56      None => []
    65      None => []
    57    | Some thms => filter (fn thm => is_instance thy T
    66    | Some thms => filter (fn thm => is_instance thy T
   137 
   146 
   138 
   147 
   139 val setup =
   148 val setup =
   140   [CodegenData.init,
   149   [CodegenData.init,
   141    add_codegen "recfun" recfun_codegen,
   150    add_codegen "recfun" recfun_codegen,
   142    add_attribute "" add];
   151    add_attribute "" (Args.del |-- Scan.succeed del || Scan.succeed add)];
   143 
   152 
   144 end;
   153 end;