src/Pure/Isar/attrib.ML
author skalberg
Sun Feb 13 17:15:14 2005 +0100 (2005-02-13)
changeset 15531 08c8dad8e399
parent 15456 956d6acacf89
child 15570 8d8c70b41bab
permissions -rw-r--r--
Deleted Library.option type.
wenzelm@5823
     1
(*  Title:      Pure/Isar/attrib.ML
wenzelm@5823
     2
    ID:         $Id$
wenzelm@5823
     3
    Author:     Markus Wenzel, TU Muenchen
wenzelm@5823
     4
wenzelm@5823
     5
Symbolic theorem attributes.
wenzelm@5823
     6
*)
wenzelm@5823
     7
wenzelm@5823
     8
signature BASIC_ATTRIB =
wenzelm@5823
     9
sig
wenzelm@5823
    10
  val print_attributes: theory -> unit
wenzelm@5879
    11
  val Attribute: bstring -> (Args.src -> theory attribute) * (Args.src -> Proof.context attribute)
wenzelm@5879
    12
    -> string -> unit
wenzelm@5823
    13
end;
wenzelm@5823
    14
wenzelm@5823
    15
signature ATTRIB =
wenzelm@5823
    16
sig
wenzelm@5823
    17
  include BASIC_ATTRIB
wenzelm@5912
    18
  exception ATTRIB_FAIL of (string * Position.T) * exn
wenzelm@5823
    19
  val global_attribute: theory -> Args.src -> theory attribute
wenzelm@5823
    20
  val local_attribute: theory -> Args.src -> Proof.context attribute
wenzelm@5912
    21
  val local_attribute': Proof.context -> Args.src -> Proof.context attribute
wenzelm@7673
    22
  val undef_global_attribute: theory attribute
wenzelm@7673
    23
  val undef_local_attribute: Proof.context attribute
wenzelm@5823
    24
  val add_attributes: (bstring * ((Args.src -> theory attribute) *
wenzelm@5823
    25
      (Args.src -> Proof.context attribute)) * string) list -> theory -> theory
wenzelm@6091
    26
  val global_thm: theory * Args.T list -> thm * (theory * Args.T list)
wenzelm@6091
    27
  val global_thms: theory * Args.T list -> thm list * (theory * Args.T list)
wenzelm@6091
    28
  val global_thmss: theory * Args.T list -> thm list * (theory * Args.T list)
wenzelm@6091
    29
  val local_thm: Proof.context * Args.T list -> thm * (Proof.context * Args.T list)
wenzelm@6091
    30
  val local_thms: Proof.context * Args.T list -> thm list * (Proof.context * Args.T list)
wenzelm@6091
    31
  val local_thmss: Proof.context * Args.T list -> thm list * (Proof.context * Args.T list)
wenzelm@5879
    32
  val syntax: ('a * Args.T list -> 'a attribute * ('a * Args.T list)) -> Args.src -> 'a attribute
wenzelm@5823
    33
  val no_args: 'a attribute -> Args.src -> 'a attribute
wenzelm@8633
    34
  val add_del_args: 'a attribute -> 'a attribute -> Args.src -> 'a attribute
wenzelm@5823
    35
  val setup: (theory -> theory) list
wenzelm@5823
    36
end;
wenzelm@5823
    37
wenzelm@5823
    38
structure Attrib: ATTRIB =
wenzelm@5823
    39
struct
wenzelm@5823
    40
wenzelm@5823
    41
wenzelm@5823
    42
(** attributes theory data **)
wenzelm@5823
    43
wenzelm@5823
    44
(* data kind 'Isar/attributes' *)
wenzelm@5823
    45
wenzelm@5823
    46
structure AttributesDataArgs =
wenzelm@5823
    47
struct
wenzelm@5823
    48
  val name = "Isar/attributes";
wenzelm@5823
    49
  type T =
wenzelm@5823
    50
    {space: NameSpace.T,
wenzelm@5823
    51
     attrs:
wenzelm@5823
    52
       ((((Args.src -> theory attribute) * (Args.src -> Proof.context attribute))
wenzelm@5823
    53
         * string) * stamp) Symtab.table};
wenzelm@5823
    54
wenzelm@5823
    55
  val empty = {space = NameSpace.empty, attrs = Symtab.empty};
wenzelm@6546
    56
  val copy = I;
wenzelm@5823
    57
  val prep_ext = I;
wenzelm@5823
    58
wenzelm@5823
    59
  fun merge ({space = space1, attrs = attrs1}, {space = space2, attrs = attrs2}) =
wenzelm@5823
    60
    {space = NameSpace.merge (space1, space2),
wenzelm@5823
    61
      attrs = Symtab.merge eq_snd (attrs1, attrs2) handle Symtab.DUPS dups =>
wenzelm@5823
    62
        error ("Attempt to merge different versions of attributes " ^ commas_quote dups)};
wenzelm@5823
    63
wenzelm@9216
    64
  fun print _ {space, attrs} =
wenzelm@5823
    65
    let
wenzelm@5823
    66
      fun prt_attr (name, ((_, comment), _)) = Pretty.block
wenzelm@6846
    67
        [Pretty.str (name ^ ":"), Pretty.brk 2, Pretty.str comment];
wenzelm@5823
    68
    in
wenzelm@8720
    69
      [Pretty.big_list "attributes:" (map prt_attr (NameSpace.cond_extern_table space attrs))]
wenzelm@9216
    70
      |> Pretty.chunks |> Pretty.writeln
wenzelm@5823
    71
    end;
wenzelm@5823
    72
end;
wenzelm@5823
    73
wenzelm@5823
    74
structure AttributesData = TheoryDataFun(AttributesDataArgs);
wenzelm@5823
    75
val print_attributes = AttributesData.print;
wenzelm@7611
    76
wenzelm@5823
    77
wenzelm@5823
    78
(* get global / local attributes *)
wenzelm@5823
    79
wenzelm@5912
    80
exception ATTRIB_FAIL of (string * Position.T) * exn;
wenzelm@5912
    81
wenzelm@5823
    82
fun gen_attribute which thy =
wenzelm@5823
    83
  let
wenzelm@5823
    84
    val {space, attrs} = AttributesData.get thy;
wenzelm@5823
    85
wenzelm@5879
    86
    fun attr src =
wenzelm@5879
    87
      let
wenzelm@5879
    88
        val ((raw_name, _), pos) = Args.dest_src src;
wenzelm@5879
    89
        val name = NameSpace.intern space raw_name;
wenzelm@5879
    90
      in
wenzelm@5823
    91
        (case Symtab.lookup (attrs, name) of
skalberg@15531
    92
          NONE => error ("Unknown attribute: " ^ quote name ^ Position.str_of pos)
skalberg@15531
    93
        | SOME ((p, _), _) => transform_failure (curry ATTRIB_FAIL (name, pos)) (which p src))
wenzelm@5823
    94
      end;
wenzelm@5823
    95
  in attr end;
wenzelm@5823
    96
wenzelm@5823
    97
val global_attribute = gen_attribute fst;
wenzelm@5823
    98
val local_attribute = gen_attribute snd;
wenzelm@5879
    99
val local_attribute' = local_attribute o ProofContext.theory_of;
wenzelm@5823
   100
wenzelm@7673
   101
val undef_global_attribute: theory attribute =
wenzelm@7673
   102
  fn _ => error "attribute undefined in theory context";
wenzelm@7673
   103
wenzelm@7673
   104
val undef_local_attribute: Proof.context attribute =
wenzelm@7673
   105
  fn _ => error "attribute undefined in proof context";
wenzelm@7673
   106
wenzelm@5823
   107
wenzelm@5823
   108
(* add_attributes *)
wenzelm@5823
   109
wenzelm@5823
   110
fun add_attributes raw_attrs thy =
wenzelm@5823
   111
  let
wenzelm@5823
   112
    val full = Sign.full_name (Theory.sign_of thy);
wenzelm@5823
   113
    val new_attrs =
wenzelm@5823
   114
      map (fn (name, (f, g), comment) => (full name, (((f, g), comment), stamp ()))) raw_attrs;
wenzelm@5823
   115
wenzelm@5823
   116
    val {space, attrs} = AttributesData.get thy;
wenzelm@5823
   117
    val space' = NameSpace.extend (space, map fst new_attrs);
wenzelm@5823
   118
    val attrs' = Symtab.extend (attrs, new_attrs) handle Symtab.DUPS dups =>
wenzelm@5823
   119
      error ("Duplicate declaration of attributes(s) " ^ commas_quote dups);
wenzelm@5823
   120
  in thy |> AttributesData.put {space = space', attrs = attrs'} end;
wenzelm@5823
   121
wenzelm@5879
   122
(*implicit version*)
wenzelm@5879
   123
fun Attribute name att cmt = Context.>> (add_attributes [(name, att, cmt)]);
wenzelm@5823
   124
wenzelm@5879
   125
wenzelm@5879
   126
wenzelm@5879
   127
(** attribute parsers **)
wenzelm@5879
   128
wenzelm@5879
   129
(* tags *)
wenzelm@5823
   130
wenzelm@5879
   131
fun tag x = Scan.lift (Args.name -- Scan.repeat Args.name) x;
wenzelm@5879
   132
wenzelm@5879
   133
wenzelm@5879
   134
(* theorems *)
wenzelm@5879
   135
berghofe@15456
   136
val thm_sel = Args.parens (Scan.pass () (Args.enum1 "," (Scan.lift
berghofe@15456
   137
  (   Args.nat --| Args.$$$ "-" -- Args.nat >> op upto
berghofe@15456
   138
   || Args.nat >> single)) >> flat));
berghofe@15456
   139
wenzelm@5879
   140
fun gen_thm get attrib app =
berghofe@15456
   141
  Scan.depend (fn st => Args.name -- Scan.option thm_sel -- Args.opt_attribs >>
wenzelm@5879
   142
    (fn (name, srcs) => app ((st, get st name), map (attrib st) srcs)));
wenzelm@5823
   143
wenzelm@6091
   144
val global_thm = gen_thm PureThy.get_thm global_attribute Thm.apply_attributes;
wenzelm@6091
   145
val global_thms = gen_thm PureThy.get_thms global_attribute Thm.applys_attributes;
wenzelm@5879
   146
val global_thmss = Scan.repeat global_thms >> flat;
wenzelm@5879
   147
wenzelm@6091
   148
val local_thm = gen_thm ProofContext.get_thm local_attribute' Thm.apply_attributes;
wenzelm@6091
   149
val local_thms = gen_thm ProofContext.get_thms local_attribute' Thm.applys_attributes;
wenzelm@5879
   150
val local_thmss = Scan.repeat local_thms >> flat;
wenzelm@5879
   151
wenzelm@5823
   152
wenzelm@5879
   153
wenzelm@5879
   154
(** attribute syntax **)
wenzelm@5823
   155
wenzelm@5879
   156
fun syntax scan src (st, th) =
wenzelm@8282
   157
  let val (st', f) = Args.syntax "attribute" scan src st
wenzelm@5879
   158
  in f (st', th) end;
wenzelm@5879
   159
wenzelm@5879
   160
fun no_args x = syntax (Scan.succeed x);
wenzelm@5823
   161
wenzelm@10034
   162
fun add_del_args add del x = syntax
wenzelm@10034
   163
  (Scan.lift (Args.add >> K add || Args.del >> K del || Scan.succeed add)) x;
wenzelm@8633
   164
wenzelm@5823
   165
wenzelm@5823
   166
wenzelm@5823
   167
(** Pure attributes **)
wenzelm@5823
   168
wenzelm@5823
   169
(* tags *)
wenzelm@5823
   170
wenzelm@9902
   171
fun gen_tagged x = syntax (tag >> Drule.tag) x;
wenzelm@9902
   172
fun gen_untagged x = syntax (Scan.lift Args.name >> Drule.untag) x;
wenzelm@5823
   173
wenzelm@5823
   174
wenzelm@6772
   175
(* COMP *)
wenzelm@6772
   176
wenzelm@6948
   177
fun comp (i, B) (x, A) = (x, Drule.compose_single (A, i, B));
wenzelm@6772
   178
wenzelm@10151
   179
fun gen_COMP thm = syntax (Scan.lift (Scan.optional (Args.bracks Args.nat) 1) -- thm >> comp);
wenzelm@9902
   180
val COMP_global = gen_COMP global_thm;
wenzelm@9902
   181
val COMP_local = gen_COMP local_thm;
wenzelm@6772
   182
wenzelm@6772
   183
paulson@15117
   184
(* THEN, which corresponds to RS *)
wenzelm@5879
   185
wenzelm@6091
   186
fun resolve (i, B) (x, A) = (x, A RSN (i, B));
wenzelm@5879
   187
paulson@15117
   188
fun gen_THEN thm = syntax (Scan.lift (Scan.optional (Args.bracks Args.nat) 1) -- thm >> resolve);
paulson@15117
   189
val THEN_global = gen_THEN global_thm;
paulson@15117
   190
val THEN_local = gen_THEN local_thm;
wenzelm@5879
   191
wenzelm@5879
   192
wenzelm@9902
   193
(* OF *)
wenzelm@5879
   194
wenzelm@6091
   195
fun apply Bs (x, A) = (x, Bs MRS A);
wenzelm@5879
   196
wenzelm@9902
   197
val OF_global = syntax (global_thmss >> apply);
wenzelm@9902
   198
val OF_local = syntax (local_thmss >> apply);
wenzelm@5879
   199
wenzelm@5879
   200
wenzelm@14718
   201
(* where *)
wenzelm@14718
   202
wenzelm@14718
   203
(*named instantiations; permits instantiation of type and term variables*)
wenzelm@5879
   204
wenzelm@10807
   205
fun read_instantiate _ [] _ thm = thm
wenzelm@10807
   206
  | read_instantiate context_of insts x thm =
wenzelm@10807
   207
      let
wenzelm@10807
   208
        val ctxt = context_of x;
wenzelm@10807
   209
        val sign = ProofContext.sign_of ctxt;
wenzelm@10807
   210
ballarin@14287
   211
        (* Separate type and term insts,
ballarin@14287
   212
           type insts must occur strictly before term insts *)
ballarin@14287
   213
        fun has_type_var ((x, _), _) = (case Symbol.explode x of
ballarin@14287
   214
             "'"::cs => true | cs => false);
ballarin@14287
   215
        val (Tinst, tinsts) = take_prefix has_type_var insts;
wenzelm@14718
   216
        val _ = if exists has_type_var tinsts
ballarin@14287
   217
              then error
ballarin@14287
   218
                "Type instantiations must occur before term instantiations."
ballarin@14287
   219
              else ();
ballarin@14287
   220
ballarin@14287
   221
        val Tinsts = filter has_type_var insts;
ballarin@14287
   222
        val tinsts = filter_out has_type_var insts;
ballarin@14287
   223
ballarin@14287
   224
        (* Type instantiations first *)
wenzelm@14718
   225
        (* Process type insts: Tinsts_env *)
wenzelm@14718
   226
        fun absent xi = error
wenzelm@14718
   227
              ("No such type variable in theorem: " ^
ballarin@14287
   228
               Syntax.string_of_vname xi);
wenzelm@14718
   229
        val (rtypes, rsorts) = types_sorts thm;
wenzelm@14718
   230
        fun readT (xi, s) =
skalberg@15531
   231
            let val S = case rsorts xi of SOME S => S | NONE => absent xi;
wenzelm@14718
   232
                val T = ProofContext.read_typ ctxt s;
wenzelm@14718
   233
            in if Sign.typ_instance sign (T, TVar (xi, S)) then (xi, T)
wenzelm@14718
   234
               else error
wenzelm@14718
   235
                 ("Instantiation of " ^ Syntax.string_of_vname xi ^ " fails")
wenzelm@14718
   236
            end;
wenzelm@14718
   237
        val Tinsts_env = map readT Tinsts;
wenzelm@14718
   238
        val cenvT = map (apsnd (Thm.ctyp_of sign)) (Tinsts_env);
ballarin@14287
   239
        val thm' = Thm.instantiate (cenvT, []) thm;
ballarin@14287
   240
           (* Instantiate, but don't normalise: *)
ballarin@14287
   241
           (* this happens after term insts anyway. *)
ballarin@14287
   242
ballarin@14287
   243
        (* Term instantiations *)
ballarin@14287
   244
        val vars = Drule.vars_of thm';
wenzelm@10807
   245
        fun get_typ xi =
wenzelm@10807
   246
          (case assoc (vars, xi) of
skalberg@15531
   247
            SOME T => T
skalberg@15531
   248
          | NONE => error ("No such variable in theorem: " ^ Syntax.string_of_vname xi));
wenzelm@5879
   249
ballarin@14287
   250
        val (xs, ss) = Library.split_list tinsts;
wenzelm@10807
   251
        val Ts = map get_typ xs;
wenzelm@5879
   252
ballarin@14287
   253
        val used = add_term_tvarnames (prop_of thm',[])
wenzelm@14718
   254
        (* Names of TVars occuring in thm'.  read_def_termTs ensures
ballarin@14257
   255
           that new TVars introduced when reading the instantiation string
ballarin@14287
   256
           are distinct from those occuring in the theorem. *)
ballarin@14257
   257
wenzelm@14718
   258
        val (ts, envT) =
skalberg@15531
   259
          ProofContext.read_termTs ctxt (K false) (K NONE) (K NONE) used (ss ~~ Ts);
wenzelm@14718
   260
wenzelm@10807
   261
        val cenvT = map (apsnd (Thm.ctyp_of sign)) envT;
wenzelm@10807
   262
        val cenv =
wenzelm@10807
   263
          map (fn (xi, t) => pairself (Thm.cterm_of sign) (Var (xi, fastype_of t), t))
wenzelm@10807
   264
            (gen_distinct (fn ((x1, t1), (x2, t2)) => x1 = x2 andalso t1 aconv t2) (xs ~~ ts));
wenzelm@10807
   265
      in
ballarin@14287
   266
        thm'
wenzelm@10807
   267
        |> Drule.instantiate (cenvT, cenv)
wenzelm@10807
   268
        |> RuleCases.save thm
wenzelm@10807
   269
      end;
wenzelm@5879
   270
wenzelm@6448
   271
fun insts x = Args.and_list (Scan.lift (Args.var --| Args.$$$ "=" -- Args.name)) x;
wenzelm@5879
   272
wenzelm@6091
   273
fun gen_where context_of = syntax (insts >> (Drule.rule_attribute o read_instantiate context_of));
wenzelm@5823
   274
wenzelm@9902
   275
val where_global = gen_where ProofContext.init;
wenzelm@9902
   276
val where_local = gen_where I;
wenzelm@5879
   277
wenzelm@5879
   278
wenzelm@9902
   279
(* of: positional instantiations *)
ballarin@14287
   280
(*        permits instantiation of term variables only *)
wenzelm@5912
   281
wenzelm@10807
   282
fun read_instantiate' _ ([], []) _ thm = thm
wenzelm@10807
   283
  | read_instantiate' context_of (args, concl_args) x thm =
wenzelm@10807
   284
      let
wenzelm@10807
   285
        fun zip_vars _ [] = []
skalberg@15531
   286
          | zip_vars (_ :: xs) (NONE :: opt_ts) = zip_vars xs opt_ts
skalberg@15531
   287
          | zip_vars ((x, _) :: xs) (SOME t :: opt_ts) = (x, t) :: zip_vars xs opt_ts
wenzelm@10807
   288
          | zip_vars [] _ = error "More instantiations than variables in theorem";
wenzelm@10807
   289
        val insts =
wenzelm@12804
   290
          zip_vars (Drule.vars_of_terms [Thm.prop_of thm]) args @
wenzelm@10807
   291
          zip_vars (Drule.vars_of_terms [Thm.concl_of thm]) concl_args;
wenzelm@10807
   292
      in
wenzelm@10807
   293
        thm
wenzelm@10807
   294
        |> read_instantiate context_of insts x
wenzelm@10807
   295
        |> RuleCases.save thm
wenzelm@10807
   296
      end;
wenzelm@5912
   297
wenzelm@10807
   298
val concl = Args.$$$ "concl" -- Args.colon;
wenzelm@8687
   299
val inst_arg = Scan.unless concl Args.name_dummy;
wenzelm@5912
   300
val inst_args = Scan.repeat inst_arg;
wenzelm@10807
   301
fun insts' x = (inst_args -- Scan.optional (concl |-- Args.!!! inst_args) []) x;
wenzelm@5912
   302
wenzelm@10807
   303
fun gen_of context_of =
wenzelm@10807
   304
  syntax (Scan.lift insts' >> (Drule.rule_attribute o read_instantiate' context_of));
wenzelm@5912
   305
wenzelm@9902
   306
val of_global = gen_of ProofContext.init;
wenzelm@9902
   307
val of_local = gen_of I;
wenzelm@5912
   308
wenzelm@5912
   309
berghofe@13782
   310
(* rename_abs *)
berghofe@13782
   311
berghofe@13782
   312
fun rename_abs src = syntax
berghofe@14082
   313
  (Scan.lift (Scan.repeat Args.name_dummy >> (apsnd o Drule.rename_bvars'))) src;
berghofe@13782
   314
berghofe@13782
   315
wenzelm@7598
   316
(* unfold / fold definitions *)
wenzelm@7598
   317
wenzelm@7598
   318
fun gen_rewrite rew defs (x, thm) = (x, rew defs thm);
wenzelm@7598
   319
wenzelm@9902
   320
val unfolded_global = syntax (global_thmss >> gen_rewrite Tactic.rewrite_rule);
wenzelm@9902
   321
val unfolded_local = syntax (local_thmss >> gen_rewrite Tactic.rewrite_rule);
wenzelm@9902
   322
val folded_global = syntax (global_thmss >> gen_rewrite Tactic.fold_rule);
wenzelm@9902
   323
val folded_local = syntax (local_thmss >> gen_rewrite Tactic.fold_rule);
wenzelm@7598
   324
wenzelm@7598
   325
wenzelm@8368
   326
(* rule cases *)
wenzelm@8368
   327
wenzelm@10528
   328
fun consumes x = syntax (Scan.lift (Scan.optional Args.nat 1) >> RuleCases.consumes) x;
wenzelm@8368
   329
fun case_names x = syntax (Scan.lift (Scan.repeat1 Args.name) >> RuleCases.case_names) x;
wenzelm@8368
   330
fun params x = syntax (Args.and_list1 (Scan.lift (Scan.repeat Args.name)) >> RuleCases.params) x;
wenzelm@8368
   331
wenzelm@8368
   332
wenzelm@11770
   333
(* rule_format *)
wenzelm@11770
   334
wenzelm@11770
   335
fun rule_format_att x = syntax
wenzelm@11770
   336
  (Scan.lift (Args.parens (Args.$$$ "no_asm")
wenzelm@11770
   337
  >> K ObjectLogic.rule_format_no_asm || Scan.succeed ObjectLogic.rule_format)) x;
wenzelm@11770
   338
wenzelm@11770
   339
wenzelm@5879
   340
(* misc rules *)
wenzelm@5879
   341
wenzelm@6091
   342
fun standard x = no_args (Drule.rule_attribute (K Drule.standard)) x;
wenzelm@9941
   343
fun elim_format x = no_args (Drule.rule_attribute (K Tactic.make_elim)) x;
wenzelm@9216
   344
fun no_vars x = no_args (Drule.rule_attribute (K (#1 o Drule.freeze_thaw))) x;
wenzelm@5879
   345
wenzelm@5879
   346
wenzelm@13370
   347
(* rule declarations *)
wenzelm@13370
   348
wenzelm@13370
   349
local
wenzelm@13370
   350
wenzelm@13370
   351
fun add_args a b c x = syntax
wenzelm@13370
   352
  (Scan.lift ((Args.bang >> K a || Args.query >> K c || Scan.succeed b) -- (Scan.option Args.nat))
wenzelm@13370
   353
    >> (fn (f, n) => f n)) x;
wenzelm@13370
   354
wenzelm@13370
   355
fun del_args att = syntax (Scan.lift Args.del >> K att);
wenzelm@13370
   356
wenzelm@13370
   357
open ContextRules;
wenzelm@13370
   358
wenzelm@13370
   359
in
wenzelm@13370
   360
wenzelm@13370
   361
val rule_atts =
wenzelm@13370
   362
 [("intro",
wenzelm@13370
   363
   (add_args intro_bang_global intro_global intro_query_global,
wenzelm@13370
   364
    add_args intro_bang_local intro_local intro_query_local),
wenzelm@13370
   365
    "declaration of introduction rule"),
wenzelm@13370
   366
  ("elim",
wenzelm@13370
   367
   (add_args elim_bang_global elim_global elim_query_global,
wenzelm@13370
   368
    add_args elim_bang_local elim_local elim_query_local),
wenzelm@13370
   369
    "declaration of elimination rule"),
wenzelm@13370
   370
  ("dest",
wenzelm@13370
   371
   (add_args dest_bang_global dest_global dest_query_global,
wenzelm@13370
   372
    add_args dest_bang_local dest_local dest_query_local),
wenzelm@13370
   373
    "declaration of destruction rule"),
wenzelm@13370
   374
  ("rule", (del_args rule_del_global, del_args rule_del_local),
wenzelm@13370
   375
    "remove declaration of intro/elim/dest rule")];
wenzelm@13370
   376
wenzelm@13370
   377
end;
wenzelm@13370
   378
wenzelm@13370
   379
wenzelm@11770
   380
wenzelm@5879
   381
(** theory setup **)
wenzelm@5823
   382
wenzelm@5823
   383
(* pure_attributes *)
wenzelm@5823
   384
wenzelm@5823
   385
val pure_attributes =
wenzelm@9902
   386
 [("tagged", (gen_tagged, gen_tagged), "tagged theorem"),
wenzelm@9902
   387
  ("untagged", (gen_untagged, gen_untagged), "untagged theorem"),
wenzelm@9902
   388
  ("COMP", (COMP_global, COMP_local), "direct composition with rules (no lifting)"),
paulson@15117
   389
  ("THEN", (THEN_global, THEN_local), "resolution with rule"),
wenzelm@9902
   390
  ("OF", (OF_global, OF_local), "rule applied to facts"),
wenzelm@9902
   391
  ("where", (where_global, where_local), "named instantiation of theorem"),
wenzelm@9902
   392
  ("of", (of_global, of_local), "rule applied to terms"),
berghofe@13782
   393
  ("rename_abs", (rename_abs, rename_abs), "rename bound variables in abstractions"),
wenzelm@9902
   394
  ("unfolded", (unfolded_global, unfolded_local), "unfolded definitions"),
wenzelm@9902
   395
  ("folded", (folded_global, folded_local), "folded definitions"),
wenzelm@9902
   396
  ("standard", (standard, standard), "result put into standard form"),
wenzelm@9941
   397
  ("elim_format", (elim_format, elim_format), "destruct rule turned into elimination rule format"),
wenzelm@9902
   398
  ("no_vars", (no_vars, no_vars), "frozen schematic vars"),
wenzelm@10528
   399
  ("consumes", (consumes, consumes), "number of consumed facts"),
wenzelm@9902
   400
  ("case_names", (case_names, case_names), "named rule cases"),
wenzelm@9902
   401
  ("params", (params, params), "named rule parameters"),
wenzelm@11770
   402
  ("atomize", (no_args ObjectLogic.declare_atomize, no_args undef_local_attribute),
wenzelm@11770
   403
    "declaration of atomize rule"),
wenzelm@11770
   404
  ("rulify", (no_args ObjectLogic.declare_rulify, no_args undef_local_attribute),
wenzelm@11770
   405
    "declaration of rulify rule"),
wenzelm@13370
   406
  ("rule_format", (rule_format_att, rule_format_att), "result put into standard rule format")] @
wenzelm@13370
   407
  rule_atts;
wenzelm@5823
   408
wenzelm@5823
   409
wenzelm@5879
   410
(* setup *)
wenzelm@5823
   411
wenzelm@5823
   412
val setup = [AttributesData.init, add_attributes pure_attributes];
wenzelm@5823
   413
wenzelm@5823
   414
end;
wenzelm@5823
   415
wenzelm@5823
   416
structure BasicAttrib: BASIC_ATTRIB = Attrib;
wenzelm@5823
   417
open BasicAttrib;