src/Pure/Isar/method.ML
author wenzelm
Sun Nov 11 21:35:04 2001 +0100 (2001-11-11)
changeset 12144 f84eb7334d04
parent 12119 fab22bdb1496
child 12244 179f142ffb03
permissions -rw-r--r--
added RAW_METHOD, RAW_METHOD_CASES;
METHOD, METHOD_CASES etc.: conjunction_tac;
wenzelm@5824
     1
(*  Title:      Pure/Isar/method.ML
wenzelm@5824
     2
    ID:         $Id$
wenzelm@5824
     3
    Author:     Markus Wenzel, TU Muenchen
wenzelm@8807
     4
    License:    GPL (GNU GENERAL PUBLIC LICENSE)
wenzelm@5824
     5
wenzelm@5824
     6
Proof methods.
wenzelm@5824
     7
*)
wenzelm@5824
     8
wenzelm@5824
     9
signature BASIC_METHOD =
wenzelm@5824
    10
sig
wenzelm@11731
    11
  val trace_rules: bool ref
wenzelm@5824
    12
  val print_methods: theory -> unit
wenzelm@5824
    13
  val Method: bstring -> (Args.src -> Proof.context -> Proof.method) -> string -> unit
wenzelm@5824
    14
end;
wenzelm@5824
    15
wenzelm@5824
    16
signature METHOD =
wenzelm@5824
    17
sig
wenzelm@5824
    18
  include BASIC_METHOD
wenzelm@12055
    19
  val trace: Proof.context -> thm list -> unit
wenzelm@8153
    20
  val print_global_rules: theory -> unit
wenzelm@8153
    21
  val print_local_rules: Proof.context -> unit
wenzelm@8153
    22
  val dest_global: theory attribute
wenzelm@8153
    23
  val elim_global: theory attribute
wenzelm@8153
    24
  val intro_global: theory attribute
wenzelm@11785
    25
  val dest_bang_global: theory attribute
wenzelm@11785
    26
  val elim_bang_global: theory attribute
wenzelm@11785
    27
  val intro_bang_global: theory attribute
wenzelm@9938
    28
  val rule_del_global: theory attribute
wenzelm@8153
    29
  val dest_local: Proof.context attribute
wenzelm@8153
    30
  val elim_local: Proof.context attribute
wenzelm@8153
    31
  val intro_local: Proof.context attribute
wenzelm@11785
    32
  val dest_bang_local: Proof.context attribute
wenzelm@11785
    33
  val elim_bang_local: Proof.context attribute
wenzelm@11785
    34
  val intro_bang_local: Proof.context attribute
wenzelm@9938
    35
  val rule_del_local: Proof.context attribute
wenzelm@12144
    36
  val RAW_METHOD: (thm list -> tactic) -> Proof.method
wenzelm@12144
    37
  val RAW_METHOD_CASES:
wenzelm@12144
    38
    (thm list -> thm -> (thm * (string * RuleCases.T) list) Seq.seq) -> Proof.method
wenzelm@6091
    39
  val METHOD: (thm list -> tactic) -> Proof.method
wenzelm@8372
    40
  val METHOD_CASES:
wenzelm@8372
    41
    (thm list -> thm -> (thm * (string * RuleCases.T) list) Seq.seq) -> Proof.method
wenzelm@9706
    42
  val SIMPLE_METHOD: tactic -> Proof.method
wenzelm@9706
    43
  val SIMPLE_METHOD': ((int -> tactic) -> tactic) -> (int -> tactic) -> Proof.method
wenzelm@5824
    44
  val fail: Proof.method
wenzelm@5824
    45
  val succeed: Proof.method
wenzelm@8167
    46
  val defer: int option -> Proof.method
wenzelm@8167
    47
  val prefer: int -> Proof.method
wenzelm@7419
    48
  val insert_tac: thm list -> int -> tactic
wenzelm@7574
    49
  val insert: thm list -> Proof.method
wenzelm@7555
    50
  val insert_facts: Proof.method
wenzelm@7601
    51
  val unfold: thm list -> Proof.method
wenzelm@7419
    52
  val fold: thm list -> Proof.method
wenzelm@7419
    53
  val multi_resolve: thm list -> thm -> thm Seq.seq
wenzelm@7419
    54
  val multi_resolves: thm list -> thm list -> thm Seq.seq
wenzelm@6091
    55
  val rule_tac: thm list -> thm list -> int -> tactic
wenzelm@10309
    56
  val some_rule_tac: thm list -> Proof.context -> thm list -> int -> tactic
wenzelm@6091
    57
  val rule: thm list -> Proof.method
wenzelm@10744
    58
  val erule: int -> thm list -> Proof.method
wenzelm@10744
    59
  val drule: int -> thm list -> Proof.method
wenzelm@10744
    60
  val frule: int -> thm list -> Proof.method
wenzelm@8195
    61
  val this: Proof.method
wenzelm@7555
    62
  val assumption: Proof.context -> Proof.method
wenzelm@12119
    63
  val impose_hyps_tac: Proof.context -> tactic
wenzelm@8351
    64
  val set_tactic: (Proof.context -> thm list -> tactic) -> unit
wenzelm@8351
    65
  val tactic: string -> Proof.context -> Proof.method
wenzelm@5916
    66
  exception METHOD_FAIL of (string * Position.T) * exn
wenzelm@5824
    67
  val method: theory -> Args.src -> Proof.context -> Proof.method
wenzelm@9539
    68
  val add_method: bstring * (Args.src -> Proof.context -> Proof.method) * string
wenzelm@9539
    69
    -> theory -> theory
wenzelm@5824
    70
  val add_methods: (bstring * (Args.src -> Proof.context -> Proof.method) * string) list
wenzelm@5824
    71
    -> theory -> theory
wenzelm@5884
    72
  val syntax: (Proof.context * Args.T list -> 'a * (Proof.context * Args.T list)) ->
wenzelm@8282
    73
    Args.src -> Proof.context -> Proof.context * 'a
wenzelm@8351
    74
  val simple_args: (Args.T list -> 'a * Args.T list)
wenzelm@8351
    75
    -> ('a -> Proof.context -> Proof.method) -> Args.src -> Proof.context -> Proof.method
wenzelm@7555
    76
  val ctxt_args: (Proof.context -> Proof.method) -> Args.src -> Proof.context -> Proof.method
wenzelm@5884
    77
  val no_args: Proof.method -> Args.src -> Proof.context -> Proof.method
wenzelm@7268
    78
  type modifier
wenzelm@7601
    79
  val sectioned_args: (Proof.context * Args.T list -> 'a * (Proof.context * Args.T list)) ->
wenzelm@7268
    80
    (Args.T list -> modifier * Args.T list) list ->
wenzelm@9864
    81
    ('a -> Proof.context -> 'b) -> Args.src -> Proof.context -> 'b
wenzelm@7601
    82
  val bang_sectioned_args:
wenzelm@7601
    83
    (Args.T list -> modifier * Args.T list) list ->
wenzelm@9864
    84
    (thm list -> Proof.context -> 'a) -> Args.src -> Proof.context -> 'a
wenzelm@9777
    85
  val bang_sectioned_args':
wenzelm@9777
    86
    (Args.T list -> modifier * Args.T list) list ->
wenzelm@9777
    87
    (Proof.context * Args.T list -> 'a * (Proof.context * Args.T list)) ->
wenzelm@9864
    88
    ('a -> thm list -> Proof.context -> 'b) -> Args.src -> Proof.context -> 'b
wenzelm@7601
    89
  val only_sectioned_args:
wenzelm@7601
    90
    (Args.T list -> modifier * Args.T list) list ->
wenzelm@9864
    91
    (Proof.context -> 'a) -> Args.src -> Proof.context -> 'a
wenzelm@9864
    92
  val thms_ctxt_args: (thm list -> Proof.context -> 'a) -> Args.src -> Proof.context -> 'a
wenzelm@9864
    93
  val thms_args: (thm list -> 'a) -> Args.src -> Proof.context -> 'a
wenzelm@9864
    94
  val thm_args: (thm -> 'a) -> Args.src -> Proof.context -> 'a
wenzelm@5824
    95
  datatype text =
wenzelm@5824
    96
    Basic of (Proof.context -> Proof.method) |
wenzelm@5824
    97
    Source of Args.src |
wenzelm@5824
    98
    Then of text list |
wenzelm@5824
    99
    Orelse of text list |
wenzelm@5824
   100
    Try of text |
wenzelm@5824
   101
    Repeat1 of text
wenzelm@5824
   102
  val refine: text -> Proof.state -> Proof.state Seq.seq
wenzelm@8238
   103
  val refine_end: text -> Proof.state -> Proof.state Seq.seq
wenzelm@5824
   104
  val proof: text option -> Proof.state -> Proof.state Seq.seq
wenzelm@8966
   105
  val local_qed: bool -> text option
wenzelm@12144
   106
    -> (Proof.context -> string * (string * thm list) list -> unit) *
wenzelm@12055
   107
      (Proof.context -> thm -> unit) -> Proof.state -> Proof.state Seq.seq
wenzelm@6981
   108
  val local_terminal_proof: text * text option
wenzelm@12144
   109
    -> (Proof.context -> string * (string * thm list) list -> unit) *
wenzelm@12055
   110
      (Proof.context -> thm -> unit) -> Proof.state -> Proof.state Seq.seq
wenzelm@12144
   111
  val local_default_proof: (Proof.context -> string * (string * thm list) list -> unit) *
wenzelm@12055
   112
    (Proof.context -> thm -> unit) -> Proof.state -> Proof.state Seq.seq
wenzelm@12144
   113
  val local_immediate_proof: (Proof.context -> string * (string * thm list) list -> unit) *
wenzelm@12055
   114
    (Proof.context -> thm -> unit) -> Proof.state -> Proof.state Seq.seq
wenzelm@12144
   115
  val local_done_proof: (Proof.context -> string * (string * thm list) list -> unit) *
wenzelm@12055
   116
    (Proof.context -> thm -> unit) -> Proof.state -> Proof.state Seq.seq
wenzelm@8966
   117
  val global_qed: bool -> text option
wenzelm@12144
   118
    -> Proof.state -> theory * (string * (string * thm list) list)
wenzelm@6934
   119
  val global_terminal_proof: text * text option
wenzelm@12144
   120
    -> Proof.state -> theory * (string * (string * thm list) list)
wenzelm@12144
   121
  val global_default_proof: Proof.state -> theory * (string * (string * thm list) list)
wenzelm@12144
   122
  val global_immediate_proof: Proof.state -> theory * (string * (string * thm list) list)
wenzelm@12144
   123
  val global_done_proof: Proof.state -> theory * (string * (string * thm list) list)
wenzelm@9539
   124
  val goal_args: (Args.T list -> 'a * Args.T list) -> ('a -> int -> tactic)
wenzelm@9539
   125
    -> Args.src -> Proof.context -> Proof.method
wenzelm@9539
   126
  val goal_args': (Proof.context * Args.T list -> 'a * (Proof.context * Args.T list))
wenzelm@9539
   127
    -> ('a -> int -> tactic) -> Args.src -> Proof.context -> Proof.method
wenzelm@5824
   128
  val setup: (theory -> theory) list
wenzelm@5824
   129
end;
wenzelm@5824
   130
wenzelm@5824
   131
structure Method: METHOD =
wenzelm@5824
   132
struct
wenzelm@5824
   133
wenzelm@5824
   134
wenzelm@11731
   135
(** tracing *)
wenzelm@11731
   136
wenzelm@11731
   137
val trace_rules = ref false;
wenzelm@11731
   138
wenzelm@12055
   139
fun trace ctxt rules =
wenzelm@11905
   140
  if not (! trace_rules) orelse null rules then ()
wenzelm@12055
   141
  else Pretty.writeln (Pretty.big_list "rules:" (map (ProofContext.pretty_thm ctxt) rules));
wenzelm@11731
   142
wenzelm@11731
   143
wenzelm@11731
   144
wenzelm@8153
   145
(** global and local rule data **)
wenzelm@8153
   146
wenzelm@11794
   147
val intro_bangK = 0;
wenzelm@11794
   148
val elim_bangK = 1;
wenzelm@11794
   149
val introK = 2;
wenzelm@11794
   150
val elimK = 3;
wenzelm@11785
   151
wenzelm@10008
   152
local
wenzelm@11785
   153
wenzelm@11794
   154
fun kind_name 0 = "safe introduction rules (intro!)"
wenzelm@11794
   155
  | kind_name 1 = "safe elimination rules (elim!)"
wenzelm@11794
   156
  | kind_name 2 = "introduction rules (intro)"
wenzelm@11794
   157
  | kind_name 3 = "elimination rules (elim)"
wenzelm@11794
   158
  | kind_name _ = "unknown";
wenzelm@11785
   159
wenzelm@12055
   160
fun prt_rules prt x (k, rs) =
wenzelm@12055
   161
  Pretty.writeln (Pretty.big_list (kind_name k ^ ":") (map (prt x) (NetRules.rules rs)));
wenzelm@11785
   162
wenzelm@10008
   163
in
wenzelm@12055
   164
  fun print_rules prt x rules = seq (prt_rules prt x) (0 upto length rules - 1 ~~ rules);
wenzelm@10008
   165
end;
wenzelm@8153
   166
wenzelm@8153
   167
wenzelm@8153
   168
(* theory data kind 'Isar/rules' *)
wenzelm@8153
   169
wenzelm@8153
   170
structure GlobalRulesArgs =
wenzelm@8153
   171
struct
wenzelm@8153
   172
  val name = "Isar/rules";
wenzelm@11785
   173
  type T = thm NetRules.T list;
wenzelm@8153
   174
wenzelm@11785
   175
  val empty = [NetRules.intro, NetRules.elim, NetRules.intro, NetRules.elim];
wenzelm@8153
   176
  val copy = I;
wenzelm@12119
   177
  val finish = I;
wenzelm@8153
   178
  val prep_ext = I;
wenzelm@11785
   179
  fun merge x = map2 NetRules.merge x;
wenzelm@12055
   180
  val print = print_rules Display.pretty_thm_sg;
wenzelm@8153
   181
end;
wenzelm@8153
   182
wenzelm@8153
   183
structure GlobalRules = TheoryDataFun(GlobalRulesArgs);
wenzelm@8153
   184
val print_global_rules = GlobalRules.print;
wenzelm@8153
   185
wenzelm@8153
   186
wenzelm@8153
   187
(* proof data kind 'Isar/rules' *)
wenzelm@8153
   188
wenzelm@8153
   189
structure LocalRulesArgs =
wenzelm@8153
   190
struct
wenzelm@11785
   191
  val name = GlobalRulesArgs.name;
wenzelm@11785
   192
  type T = GlobalRulesArgs.T;
wenzelm@8153
   193
  val init = GlobalRules.get;
wenzelm@12055
   194
  val print = print_rules ProofContext.pretty_thm;
wenzelm@8153
   195
end;
wenzelm@8153
   196
wenzelm@8153
   197
structure LocalRules = ProofDataFun(LocalRulesArgs);
wenzelm@8153
   198
val print_local_rules = LocalRules.print;
wenzelm@8153
   199
wenzelm@8153
   200
wenzelm@8153
   201
wenzelm@8153
   202
(** attributes **)
wenzelm@8153
   203
wenzelm@8153
   204
(* add rules *)
wenzelm@8153
   205
wenzelm@8153
   206
local
wenzelm@8153
   207
wenzelm@11785
   208
fun add_rule k view th = Library.map_nth_elem k (NetRules.insert (view th));
wenzelm@8153
   209
wenzelm@11785
   210
val add_intro      = add_rule introK I;
wenzelm@11785
   211
val add_elim       = add_rule elimK I;
wenzelm@11785
   212
val add_dest       = add_rule elimK Tactic.make_elim;
wenzelm@11785
   213
val add_intro_bang = add_rule intro_bangK I;
wenzelm@11785
   214
val add_elim_bang  = add_rule elim_bangK I;
wenzelm@11785
   215
val add_dest_bang  = add_rule elim_bangK Tactic.make_elim;
wenzelm@11785
   216
wenzelm@11785
   217
fun del_rule th = map (NetRules.delete th o NetRules.delete (Tactic.make_elim th));
wenzelm@8153
   218
wenzelm@9938
   219
fun mk_att f g (x, th) = (f (g th) x, th);
wenzelm@8153
   220
wenzelm@8153
   221
in
wenzelm@8153
   222
wenzelm@8153
   223
val dest_global = mk_att GlobalRules.map add_dest;
wenzelm@8153
   224
val elim_global = mk_att GlobalRules.map add_elim;
wenzelm@8153
   225
val intro_global = mk_att GlobalRules.map add_intro;
wenzelm@11785
   226
val dest_bang_global = mk_att GlobalRules.map add_dest_bang;
wenzelm@11785
   227
val elim_bang_global = mk_att GlobalRules.map add_elim_bang;
wenzelm@11785
   228
val intro_bang_global = mk_att GlobalRules.map add_intro_bang;
wenzelm@9938
   229
val rule_del_global = mk_att GlobalRules.map del_rule;
wenzelm@8153
   230
wenzelm@8153
   231
val dest_local = mk_att LocalRules.map add_dest;
wenzelm@8153
   232
val elim_local = mk_att LocalRules.map add_elim;
wenzelm@8153
   233
val intro_local = mk_att LocalRules.map add_intro;
wenzelm@11785
   234
val dest_bang_local = mk_att LocalRules.map add_dest_bang;
wenzelm@11785
   235
val elim_bang_local = mk_att LocalRules.map add_elim_bang;
wenzelm@11785
   236
val intro_bang_local = mk_att LocalRules.map add_intro_bang;
wenzelm@9938
   237
val rule_del_local = mk_att LocalRules.map del_rule;
wenzelm@9938
   238
wenzelm@10034
   239
fun del_args att = Attrib.syntax (Scan.lift Args.del >> K att);
wenzelm@8153
   240
wenzelm@8153
   241
end;
wenzelm@8153
   242
wenzelm@8153
   243
wenzelm@8153
   244
(* concrete syntax *)
wenzelm@8153
   245
wenzelm@8153
   246
val rule_atts =
wenzelm@11785
   247
 [("dest",
wenzelm@11785
   248
   (Attrib.bang_args dest_bang_global dest_global,
wenzelm@11785
   249
    Attrib.bang_args dest_bang_local dest_local),
wenzelm@9900
   250
    "declaration of destruction rule"),
wenzelm@11785
   251
  ("elim",
wenzelm@11785
   252
   (Attrib.bang_args elim_bang_global elim_global,
wenzelm@11785
   253
    Attrib.bang_args elim_bang_local elim_local),
wenzelm@9900
   254
    "declaration of elimination rule"),
wenzelm@11785
   255
  ("intro",
wenzelm@11785
   256
   (Attrib.bang_args intro_bang_global intro_global,
wenzelm@11785
   257
    Attrib.bang_args intro_bang_local intro_local),
wenzelm@9900
   258
    "declaration of introduction rule"),
wenzelm@9938
   259
  ("rule", (del_args rule_del_global, del_args rule_del_local),
wenzelm@9900
   260
    "remove declaration of elim/intro rule")];
wenzelm@8153
   261
wenzelm@8153
   262
wenzelm@8153
   263
wenzelm@5824
   264
(** proof methods **)
wenzelm@5824
   265
wenzelm@8372
   266
(* make methods *)
wenzelm@5824
   267
wenzelm@12144
   268
val RAW_METHOD = Proof.method;
wenzelm@12144
   269
val RAW_METHOD_CASES = Proof.method_cases;
wenzelm@12144
   270
wenzelm@12144
   271
fun METHOD m = Proof.method (fn facts => TRY Tactic.conjunction_tac THEN m facts);
wenzelm@12144
   272
fun METHOD_CASES m =
wenzelm@12144
   273
  Proof.method_cases (fn facts => Seq.THEN (TRY Tactic.conjunction_tac, m facts));
wenzelm@8372
   274
wenzelm@5824
   275
wenzelm@5824
   276
(* primitive *)
wenzelm@5824
   277
wenzelm@5824
   278
val fail = METHOD (K no_tac);
wenzelm@5824
   279
val succeed = METHOD (K all_tac);
wenzelm@5824
   280
wenzelm@5824
   281
wenzelm@8167
   282
(* shuffle *)
wenzelm@8167
   283
wenzelm@8240
   284
fun prefer i = METHOD (K (Tactic.defer_tac i THEN PRIMITIVE (Thm.permute_prems 0 ~1)));
wenzelm@8167
   285
fun defer opt_i = METHOD (K (Tactic.defer_tac (if_none opt_i 1)));
wenzelm@8167
   286
wenzelm@8167
   287
wenzelm@7419
   288
(* insert *)
wenzelm@7419
   289
wenzelm@7419
   290
local
wenzelm@5824
   291
wenzelm@6981
   292
fun cut_rule_tac raw_rule =
wenzelm@6981
   293
  let
wenzelm@6981
   294
    val rule = Drule.forall_intr_vars raw_rule;
wenzelm@6981
   295
    val revcut_rl = Drule.incr_indexes_wrt [] [] [] [rule] Drule.revcut_rl;
wenzelm@7555
   296
  in Tactic.rtac (rule COMP revcut_rl) end;
wenzelm@6981
   297
wenzelm@7419
   298
in
wenzelm@5824
   299
wenzelm@7419
   300
fun insert_tac [] i = all_tac
wenzelm@7419
   301
  | insert_tac facts i = EVERY (map (fn th => cut_rule_tac th i) facts);
wenzelm@6981
   302
wenzelm@7555
   303
val insert_facts = METHOD (ALLGOALS o insert_tac);
wenzelm@7664
   304
fun insert thms = METHOD (fn _ => ALLGOALS (insert_tac thms));
wenzelm@7419
   305
wenzelm@7419
   306
end;
wenzelm@5824
   307
wenzelm@5824
   308
wenzelm@9706
   309
(* simple methods *)
wenzelm@9706
   310
wenzelm@9706
   311
fun SIMPLE_METHOD tac = METHOD (fn facts => ALLGOALS (insert_tac facts) THEN tac);
wenzelm@9706
   312
fun SIMPLE_METHOD' quant tac = METHOD (fn facts => quant (insert_tac facts THEN' tac));
wenzelm@9706
   313
wenzelm@9706
   314
wenzelm@7601
   315
(* unfold / fold definitions *)
wenzelm@6532
   316
wenzelm@10821
   317
fun unfold thms = SIMPLE_METHOD (CHANGED_PROP (rewrite_goals_tac thms));
wenzelm@10821
   318
fun fold thms = SIMPLE_METHOD (CHANGED_PROP (fold_goals_tac thms));
wenzelm@9484
   319
wenzelm@9484
   320
wenzelm@7419
   321
(* multi_resolve *)
wenzelm@7419
   322
wenzelm@7419
   323
local
wenzelm@7419
   324
wenzelm@7419
   325
fun res th i rule =
wenzelm@7419
   326
  Thm.biresolution false [(false, th)] i rule handle THM _ => Seq.empty;
wenzelm@7419
   327
wenzelm@7419
   328
fun multi_res _ [] rule = Seq.single rule
wenzelm@7419
   329
  | multi_res i (th :: ths) rule = Seq.flat (Seq.map (res th i) (multi_res (i + 1) ths rule));
wenzelm@7419
   330
wenzelm@7419
   331
in
wenzelm@7419
   332
wenzelm@7419
   333
val multi_resolve = multi_res 1;
wenzelm@8372
   334
fun multi_resolves facts rules = Seq.flat (Seq.map (multi_resolve facts) (Seq.of_list rules));
wenzelm@7419
   335
wenzelm@7419
   336
end;
wenzelm@7419
   337
wenzelm@7419
   338
wenzelm@10744
   339
(* basic rules *)
wenzelm@8372
   340
wenzelm@7419
   341
local
wenzelm@5824
   342
wenzelm@10541
   343
fun gen_rule_tac tac rules [] i st = tac rules i st
wenzelm@10541
   344
  | gen_rule_tac tac erules facts i st =
wenzelm@10541
   345
      Seq.flat (Seq.map (fn rule => (tac o single) rule i st) (multi_resolves facts erules));
wenzelm@7130
   346
wenzelm@10744
   347
fun gen_arule_tac tac j rules facts =
wenzelm@10744
   348
  EVERY' (gen_rule_tac tac rules facts :: replicate j Tactic.assume_tac);
wenzelm@10744
   349
wenzelm@11785
   350
fun find_erules [] _ = []
wenzelm@11785
   351
  | find_erules (fact :: _) rs =
wenzelm@11785
   352
      NetRules.retrieve rs (Logic.strip_assums_concl (#prop (Thm.rep_thm fact)));
wenzelm@11785
   353
wenzelm@11785
   354
fun find_rules goal rs = NetRules.retrieve rs (Logic.strip_assums_concl goal);
wenzelm@11785
   355
wenzelm@11785
   356
fun gen_some_rule_tac tac arg_rules ctxt facts = SUBGOAL (fn (goal, i) =>
wenzelm@11785
   357
  let
wenzelm@11785
   358
    fun get k = nth_elem (k, LocalRules.get ctxt);
wenzelm@11785
   359
    val rules =
wenzelm@11785
   360
      if not (null arg_rules) then arg_rules
wenzelm@11785
   361
      else find_erules facts (get elim_bangK) @ find_erules facts (get elimK) @
wenzelm@11785
   362
        find_rules goal (get intro_bangK) @ find_rules goal (get introK);
wenzelm@12055
   363
  in trace ctxt rules; tac rules facts i end);
wenzelm@10309
   364
wenzelm@10744
   365
fun meth tac x = METHOD (HEADGOAL o tac x);
wenzelm@10744
   366
fun meth' tac x y = METHOD (HEADGOAL o tac x y);
wenzelm@8220
   367
wenzelm@7419
   368
in
wenzelm@7419
   369
wenzelm@10744
   370
val rule_tac = gen_rule_tac Tactic.resolve_tac;
wenzelm@10744
   371
val rule = meth rule_tac;
wenzelm@10744
   372
val some_rule_tac = gen_some_rule_tac rule_tac;
wenzelm@10744
   373
val some_rule = meth' some_rule_tac;
wenzelm@10744
   374
wenzelm@10744
   375
val erule = meth' (gen_arule_tac Tactic.eresolve_tac);
wenzelm@10744
   376
val drule = meth' (gen_arule_tac Tactic.dresolve_tac);
wenzelm@10744
   377
val frule = meth' (gen_arule_tac Tactic.forward_tac);
wenzelm@5824
   378
wenzelm@7419
   379
end;
wenzelm@7419
   380
wenzelm@7419
   381
wenzelm@8195
   382
(* this *)
wenzelm@8195
   383
wenzelm@8671
   384
val this = METHOD (EVERY o map (HEADGOAL o Tactic.rtac));
wenzelm@8195
   385
wenzelm@8195
   386
wenzelm@8195
   387
(* assumption *)
wenzelm@7555
   388
wenzelm@10378
   389
fun asm_tac ths =
wenzelm@10378
   390
  foldr (op APPEND') (map (fn th => Tactic.rtac th THEN_ALL_NEW assume_tac) ths, K no_tac);
wenzelm@10378
   391
wenzelm@10405
   392
fun assm_tac ctxt =
wenzelm@10405
   393
  assume_tac APPEND'
wenzelm@10405
   394
  asm_tac (ProofContext.prems_of ctxt) APPEND'
wenzelm@10405
   395
  Tactic.rtac Drule.reflexive_thm;
wenzelm@7419
   396
wenzelm@7555
   397
fun assumption_tac ctxt [] = assm_tac ctxt
wenzelm@10378
   398
  | assumption_tac _ [fact] = asm_tac [fact]
wenzelm@7555
   399
  | assumption_tac _ _ = K no_tac;
wenzelm@7419
   400
wenzelm@8671
   401
fun assumption ctxt = METHOD (HEADGOAL o assumption_tac ctxt);
wenzelm@7419
   402
wenzelm@7419
   403
wenzelm@9539
   404
(* res_inst_tac etc. *)
wenzelm@8238
   405
wenzelm@12119
   406
(*robustify instantiation by imposing (part of) the present static context*)
wenzelm@12119
   407
val impose_hyps_tac =
wenzelm@12119
   408
  PRIMITIVE o Drule.impose_hyps o flat o map #1 o ProofContext.assumptions_of;
wenzelm@12119
   409
wenzelm@9539
   410
(*Note: insts refer to the implicit (!!) goal context; use at your own risk*)
wenzelm@12119
   411
fun gen_res_inst _ tac _ (quant, ([], thms)) =
wenzelm@9565
   412
      METHOD (fn facts => (quant (insert_tac facts THEN' tac thms)))
wenzelm@12119
   413
  | gen_res_inst tac _ ctxt (quant, (insts, [thm])) =
wenzelm@12119
   414
      METHOD (fn facts => (impose_hyps_tac ctxt THEN quant (insert_tac facts THEN' tac insts thm)))
wenzelm@12119
   415
  | gen_res_inst _ _ _ _ = error "Cannot have instantiations with multiple rules";
wenzelm@8238
   416
wenzelm@9565
   417
val res_inst = gen_res_inst Tactic.res_inst_tac Tactic.resolve_tac;
wenzelm@9565
   418
val eres_inst = gen_res_inst Tactic.eres_inst_tac Tactic.eresolve_tac;
wenzelm@9565
   419
val dres_inst = gen_res_inst Tactic.dres_inst_tac Tactic.dresolve_tac;
wenzelm@9565
   420
val forw_inst = gen_res_inst Tactic.forw_inst_tac Tactic.forward_tac;
wenzelm@9565
   421
val cut_inst = gen_res_inst Tactic.cut_inst_tac Tactic.cut_facts_tac;
wenzelm@8238
   422
wenzelm@8238
   423
wenzelm@8329
   424
(* simple Prolog interpreter *)
wenzelm@8329
   425
wenzelm@8329
   426
fun prolog_tac rules facts =
wenzelm@8329
   427
  DEPTH_SOLVE_1 (HEADGOAL (Tactic.assume_tac APPEND' Tactic.resolve_tac (facts @ rules)));
wenzelm@8329
   428
wenzelm@8329
   429
val prolog = METHOD o prolog_tac;
wenzelm@8329
   430
wenzelm@8329
   431
wenzelm@8351
   432
(* ML tactics *)
wenzelm@8351
   433
wenzelm@8351
   434
val tactic_ref = ref ((fn _ => raise Match): Proof.context -> thm list -> tactic);
wenzelm@8351
   435
fun set_tactic f = tactic_ref := f;
wenzelm@8351
   436
wenzelm@8351
   437
fun tactic txt ctxt = METHOD (fn facts =>
wenzelm@9631
   438
  (Context.use_mltext
wenzelm@9631
   439
    ("let fun tactic (ctxt: PureIsar.Proof.context) (facts: thm list) : tactic = \
wenzelm@9631
   440
     \let val thm = PureIsar.ProofContext.get_thm_closure ctxt\n\
wenzelm@9631
   441
     \  and thms = PureIsar.ProofContext.get_thms_closure ctxt in\n"
wenzelm@9631
   442
     ^ txt ^
wenzelm@9631
   443
     "\nend in PureIsar.Method.set_tactic tactic end")
wenzelm@9631
   444
    false None;
wenzelm@9631
   445
    Context.setmp (Some (ProofContext.theory_of ctxt)) (! tactic_ref ctxt) facts));
wenzelm@8351
   446
wenzelm@8351
   447
wenzelm@5824
   448
wenzelm@5824
   449
(** methods theory data **)
wenzelm@5824
   450
wenzelm@5824
   451
(* data kind 'Isar/methods' *)
wenzelm@5824
   452
wenzelm@5824
   453
structure MethodsDataArgs =
wenzelm@5824
   454
struct
wenzelm@5824
   455
  val name = "Isar/methods";
wenzelm@5824
   456
  type T =
wenzelm@5824
   457
    {space: NameSpace.T,
wenzelm@5824
   458
     meths: (((Args.src -> Proof.context -> Proof.method) * string) * stamp) Symtab.table};
wenzelm@5824
   459
wenzelm@5824
   460
  val empty = {space = NameSpace.empty, meths = Symtab.empty};
wenzelm@6546
   461
  val copy = I;
wenzelm@12119
   462
  val finish = I;
wenzelm@5824
   463
  val prep_ext = I;
wenzelm@5824
   464
  fun merge ({space = space1, meths = meths1}, {space = space2, meths = meths2}) =
wenzelm@5824
   465
    {space = NameSpace.merge (space1, space2),
wenzelm@5824
   466
      meths = Symtab.merge eq_snd (meths1, meths2) handle Symtab.DUPS dups =>
wenzelm@5824
   467
        error ("Attempt to merge different versions of methods " ^ commas_quote dups)};
wenzelm@5824
   468
wenzelm@9222
   469
  fun print _ {space, meths} =
wenzelm@5824
   470
    let
wenzelm@5824
   471
      fun prt_meth (name, ((_, comment), _)) = Pretty.block
wenzelm@6849
   472
        [Pretty.str (name ^ ":"), Pretty.brk 2, Pretty.str comment];
wenzelm@5824
   473
    in
wenzelm@8720
   474
      [Pretty.big_list "methods:" (map prt_meth (NameSpace.cond_extern_table space meths))]
wenzelm@9222
   475
      |> Pretty.chunks |> Pretty.writeln
wenzelm@5824
   476
    end;
wenzelm@5824
   477
end;
wenzelm@5824
   478
wenzelm@5824
   479
structure MethodsData = TheoryDataFun(MethodsDataArgs);
wenzelm@5824
   480
val print_methods = MethodsData.print;
wenzelm@7611
   481
wenzelm@5824
   482
wenzelm@5824
   483
(* get methods *)
wenzelm@5824
   484
wenzelm@5916
   485
exception METHOD_FAIL of (string * Position.T) * exn;
wenzelm@5916
   486
wenzelm@5824
   487
fun method thy =
wenzelm@5824
   488
  let
wenzelm@5824
   489
    val {space, meths} = MethodsData.get thy;
wenzelm@5824
   490
wenzelm@5884
   491
    fun meth src =
wenzelm@5884
   492
      let
wenzelm@5884
   493
        val ((raw_name, _), pos) = Args.dest_src src;
wenzelm@5884
   494
        val name = NameSpace.intern space raw_name;
wenzelm@5884
   495
      in
wenzelm@5824
   496
        (case Symtab.lookup (meths, name) of
wenzelm@5824
   497
          None => error ("Unknown proof method: " ^ quote name ^ Position.str_of pos)
wenzelm@5916
   498
        | Some ((mth, _), _) => transform_failure (curry METHOD_FAIL (name, pos)) (mth src))
wenzelm@5824
   499
      end;
wenzelm@5824
   500
  in meth end;
wenzelm@5824
   501
wenzelm@5824
   502
wenzelm@9194
   503
(* add_method(s) *)
wenzelm@5824
   504
wenzelm@5824
   505
fun add_methods raw_meths thy =
wenzelm@5824
   506
  let
wenzelm@5824
   507
    val full = Sign.full_name (Theory.sign_of thy);
wenzelm@5824
   508
    val new_meths =
wenzelm@5824
   509
      map (fn (name, f, comment) => (full name, ((f, comment), stamp ()))) raw_meths;
wenzelm@5824
   510
wenzelm@5824
   511
    val {space, meths} = MethodsData.get thy;
wenzelm@5824
   512
    val space' = NameSpace.extend (space, map fst new_meths);
wenzelm@5824
   513
    val meths' = Symtab.extend (meths, new_meths) handle Symtab.DUPS dups =>
wenzelm@5824
   514
      error ("Duplicate declaration of method(s) " ^ commas_quote dups);
wenzelm@5824
   515
  in
wenzelm@5824
   516
    thy |> MethodsData.put {space = space', meths = meths'}
wenzelm@5824
   517
  end;
wenzelm@5824
   518
wenzelm@9194
   519
val add_method = add_methods o Library.single;
wenzelm@9194
   520
wenzelm@5824
   521
(*implicit version*)
wenzelm@5824
   522
fun Method name meth cmt = Context.>> (add_methods [(name, meth, cmt)]);
wenzelm@5824
   523
wenzelm@5824
   524
wenzelm@5884
   525
wenzelm@5884
   526
(** method syntax **)
wenzelm@5824
   527
wenzelm@5884
   528
(* basic *)
wenzelm@5884
   529
wenzelm@5884
   530
fun syntax (scan: (Proof.context * Args.T list -> 'a * (Proof.context * Args.T list))) =
wenzelm@5884
   531
  Args.syntax "method" scan;
wenzelm@5824
   532
wenzelm@8351
   533
fun simple_args scan f src ctxt : Proof.method =
wenzelm@8351
   534
  #2 (syntax (Scan.lift (scan >> (fn x => f x ctxt))) src ctxt);
wenzelm@8351
   535
wenzelm@7555
   536
fun ctxt_args (f: Proof.context -> Proof.method) src ctxt =
wenzelm@8282
   537
  #2 (syntax (Scan.succeed (f ctxt)) src ctxt);
wenzelm@7555
   538
wenzelm@7555
   539
fun no_args m = ctxt_args (K m);
wenzelm@5884
   540
wenzelm@5884
   541
wenzelm@5884
   542
(* sections *)
wenzelm@5824
   543
wenzelm@7268
   544
type modifier = (Proof.context -> Proof.context) * Proof.context attribute;
wenzelm@7268
   545
wenzelm@7268
   546
local
wenzelm@7268
   547
wenzelm@8381
   548
fun sect ss = Scan.first (map Scan.lift ss);
wenzelm@5884
   549
fun thms ss = Scan.unless (sect ss) Attrib.local_thms;
wenzelm@5884
   550
fun thmss ss = Scan.repeat (thms ss) >> flat;
wenzelm@5884
   551
wenzelm@7268
   552
fun apply (f, att) (ctxt, ths) = Thm.applys_attributes ((f ctxt, ths), [att]);
wenzelm@5824
   553
wenzelm@7268
   554
fun section ss = (sect ss -- thmss ss) :-- (fn (m, ths) => Scan.depend (fn ctxt =>
wenzelm@7268
   555
  Scan.succeed (apply m (ctxt, ths)))) >> #2;
wenzelm@5884
   556
wenzelm@7601
   557
fun sectioned args ss = args -- Scan.repeat (section ss);
wenzelm@5884
   558
wenzelm@7268
   559
in
wenzelm@5824
   560
wenzelm@5884
   561
fun sectioned_args args ss f src ctxt =
wenzelm@8282
   562
  let val (ctxt', (x, _)) = syntax (sectioned args ss) src ctxt
wenzelm@5921
   563
  in f x ctxt' end;
wenzelm@5884
   564
wenzelm@7601
   565
fun bang_sectioned_args ss f = sectioned_args Args.bang_facts ss f;
wenzelm@9777
   566
fun bang_sectioned_args' ss scan f =
wenzelm@9777
   567
  sectioned_args (Args.bang_facts -- scan >> swap) ss (uncurry f);
wenzelm@7601
   568
fun only_sectioned_args ss f = sectioned_args (Scan.succeed ()) ss (fn () => f);
wenzelm@7268
   569
wenzelm@8093
   570
fun thms_ctxt_args f = sectioned_args (thmss []) [] f;
wenzelm@8093
   571
fun thms_args f = thms_ctxt_args (K o f);
wenzelm@9706
   572
fun thm_args f = thms_args (fn [thm] => f thm | _ => error "Single theorem expected");
wenzelm@5824
   573
wenzelm@7268
   574
end;
wenzelm@7268
   575
wenzelm@5824
   576
wenzelm@9539
   577
(* tactic syntax *)
wenzelm@8238
   578
wenzelm@10744
   579
fun nat_thms_args f = uncurry f oo
wenzelm@10744
   580
  (#2 oo syntax (Scan.lift (Scan.optional (Args.parens Args.nat) 0) -- Attrib.local_thmss));
wenzelm@10744
   581
wenzelm@8238
   582
val insts =
wenzelm@9539
   583
  Scan.optional
wenzelm@9565
   584
    (Args.enum1 "and" (Scan.lift (Args.name -- (Args.$$$ "=" |-- Args.!!! Args.name))) --|
wenzelm@9565
   585
      Scan.lift (Args.$$$ "in")) [] -- Attrib.local_thmss;
wenzelm@8238
   586
wenzelm@12119
   587
fun inst_args f src ctxt = f ctxt (#2 (syntax (Args.goal_spec HEADGOAL -- insts) src ctxt));
wenzelm@8537
   588
wenzelm@8537
   589
wenzelm@12119
   590
fun goal_args' args tac src ctxt = #2 (syntax (Args.goal_spec HEADGOAL -- args >>
wenzelm@12119
   591
  (fn (quant, s) => SIMPLE_METHOD' quant (K (impose_hyps_tac ctxt) THEN' tac s))) src ctxt);
wenzelm@8537
   592
wenzelm@9539
   593
fun goal_args args tac = goal_args' (Scan.lift args) tac;
wenzelm@8238
   594
wenzelm@8238
   595
wenzelm@5824
   596
wenzelm@5824
   597
(** method text **)
wenzelm@5824
   598
wenzelm@5824
   599
(* datatype text *)
wenzelm@5824
   600
wenzelm@5824
   601
datatype text =
wenzelm@5824
   602
  Basic of (Proof.context -> Proof.method) |
wenzelm@5824
   603
  Source of Args.src |
wenzelm@5824
   604
  Then of text list |
wenzelm@5824
   605
  Orelse of text list |
wenzelm@5824
   606
  Try of text |
wenzelm@5824
   607
  Repeat1 of text;
wenzelm@5824
   608
wenzelm@5824
   609
wenzelm@5824
   610
(* refine *)
wenzelm@5824
   611
wenzelm@8238
   612
fun gen_refine f text state =
wenzelm@5824
   613
  let
wenzelm@5824
   614
    val thy = Proof.theory_of state;
wenzelm@5824
   615
wenzelm@8238
   616
    fun eval (Basic mth) = f mth
wenzelm@8238
   617
      | eval (Source src) = f (method thy src)
wenzelm@5824
   618
      | eval (Then txts) = Seq.EVERY (map eval txts)
wenzelm@5824
   619
      | eval (Orelse txts) = Seq.FIRST (map eval txts)
wenzelm@5824
   620
      | eval (Try txt) = Seq.TRY (eval txt)
wenzelm@5824
   621
      | eval (Repeat1 txt) = Seq.REPEAT1 (eval txt);
wenzelm@5824
   622
  in eval text state end;
wenzelm@5824
   623
wenzelm@8238
   624
val refine = gen_refine Proof.refine;
wenzelm@8238
   625
val refine_end = gen_refine Proof.refine_end;
wenzelm@6404
   626
wenzelm@5824
   627
wenzelm@6404
   628
(* structured proof steps *)
wenzelm@5824
   629
wenzelm@7506
   630
val default_text = Source (Args.src (("default", []), Position.none));
wenzelm@8195
   631
val this_text = Basic (K this);
wenzelm@9706
   632
val done_text = Basic (K (SIMPLE_METHOD all_tac));
wenzelm@7555
   633
wenzelm@8966
   634
fun close_text asm = Basic (fn ctxt => METHOD (K
wenzelm@8966
   635
  (FILTER Thm.no_prems ((if asm then ALLGOALS (assm_tac ctxt) else all_tac) THEN flexflex_tac))));
wenzelm@8966
   636
wenzelm@8966
   637
fun finish_text asm None = close_text asm
wenzelm@8966
   638
  | finish_text asm (Some txt) = Then [txt, close_text asm];
wenzelm@6872
   639
wenzelm@5824
   640
fun proof opt_text state =
wenzelm@5824
   641
  state
wenzelm@5824
   642
  |> Proof.assert_backward
wenzelm@6404
   643
  |> refine (if_none opt_text default_text)
wenzelm@8242
   644
  |> Seq.map (Proof.goal_facts (K []))
wenzelm@5824
   645
  |> Seq.map Proof.enter_forward;
wenzelm@5824
   646
wenzelm@8966
   647
fun local_qed asm opt_text = Proof.local_qed (refine (finish_text asm opt_text));
wenzelm@8966
   648
fun local_terminal_proof (text, opt_text) pr =
wenzelm@8966
   649
  Seq.THEN (proof (Some text), local_qed true opt_text pr);
wenzelm@8966
   650
val local_default_proof = local_terminal_proof (default_text, None);
wenzelm@8195
   651
val local_immediate_proof = local_terminal_proof (this_text, None);
wenzelm@8966
   652
fun local_done_proof pr = Seq.THEN (proof (Some done_text), local_qed false None pr);
wenzelm@5824
   653
wenzelm@6872
   654
wenzelm@8966
   655
fun global_qeds asm opt_text = Proof.global_qed (refine (finish_text asm opt_text));
wenzelm@5824
   656
wenzelm@8966
   657
fun global_qed asm opt_text state =
wenzelm@6872
   658
  state
wenzelm@8966
   659
  |> global_qeds asm opt_text
wenzelm@6872
   660
  |> Proof.check_result "Failed to finish proof" state
wenzelm@6872
   661
  |> Seq.hd;
wenzelm@6872
   662
wenzelm@8966
   663
fun global_term_proof asm (text, opt_text) state =
wenzelm@6872
   664
  state
wenzelm@6872
   665
  |> proof (Some text)
wenzelm@6872
   666
  |> Proof.check_result "Terminal proof method failed" state
wenzelm@8966
   667
  |> (Seq.flat o Seq.map (global_qeds asm opt_text))
wenzelm@6872
   668
  |> Proof.check_result "Failed to finish proof (after successful terminal method)" state
wenzelm@6872
   669
  |> Seq.hd;
wenzelm@6872
   670
wenzelm@8966
   671
val global_terminal_proof = global_term_proof true;
wenzelm@6934
   672
val global_default_proof = global_terminal_proof (default_text, None);
wenzelm@8966
   673
val global_immediate_proof = global_terminal_proof (this_text, None);
wenzelm@8966
   674
val global_done_proof = global_term_proof false (done_text, None);
wenzelm@5824
   675
wenzelm@5824
   676
wenzelm@5824
   677
(** theory setup **)
wenzelm@5824
   678
wenzelm@9539
   679
(* misc tactic emulations *)
wenzelm@9539
   680
wenzelm@9539
   681
val subgoal_meth = goal_args (Scan.repeat1 Args.name) Tactic.subgoals_tac;
wenzelm@9539
   682
val thin_meth = goal_args Args.name Tactic.thin_tac;
wenzelm@9539
   683
val rename_meth = goal_args (Scan.repeat1 Args.name) Tactic.rename_params_tac;
wenzelm@9631
   684
val rotate_meth = goal_args (Scan.optional Args.int 1) Tactic.rotate_tac;
wenzelm@9539
   685
wenzelm@9539
   686
wenzelm@5824
   687
(* pure_methods *)
wenzelm@5824
   688
wenzelm@5824
   689
val pure_methods =
wenzelm@5824
   690
 [("fail", no_args fail, "force failure"),
wenzelm@5824
   691
  ("succeed", no_args succeed, "succeed"),
wenzelm@9587
   692
  ("-", no_args insert_facts, "do nothing (insert current facts only)"),
wenzelm@9539
   693
  ("insert", thms_args insert, "insert theorems, ignoring facts (improper)"),
wenzelm@7601
   694
  ("unfold", thms_args unfold, "unfold definitions"),
wenzelm@7601
   695
  ("fold", thms_args fold, "fold definitions"),
wenzelm@12007
   696
  ("atomize", no_args (SIMPLE_METHOD' HEADGOAL (CHANGED_PROP o ObjectLogic.atomize_tac)),
wenzelm@11962
   697
    "present local premises as object-level statements"),
wenzelm@8153
   698
  ("rule", thms_ctxt_args some_rule, "apply some rule"),
wenzelm@10744
   699
  ("erule", nat_thms_args erule, "apply rule in elimination manner (improper)"),
wenzelm@10744
   700
  ("drule", nat_thms_args drule, "apply rule in destruct manner (improper)"),
wenzelm@10744
   701
  ("frule", nat_thms_args frule, "apply rule in forward manner (improper)"),
wenzelm@8195
   702
  ("this", no_args this, "apply current facts as rules"),
wenzelm@8238
   703
  ("assumption", ctxt_args assumption, "proof by assumption, preferring facts"),
wenzelm@9539
   704
  ("rule_tac", inst_args res_inst, "apply rule (dynamic instantiation!)"),
wenzelm@9539
   705
  ("erule_tac", inst_args eres_inst, "apply rule in elimination manner (dynamic instantiation!)"),
wenzelm@9539
   706
  ("drule_tac", inst_args dres_inst, "apply rule in destruct manner (dynamic instantiation!)"),
wenzelm@9539
   707
  ("frule_tac", inst_args forw_inst, "apply rule in forward manner (dynamic instantiation!)"),
wenzelm@9539
   708
  ("cut_tac", inst_args cut_inst, "cut rule (dynamic instantiation!)"),
wenzelm@9565
   709
  ("subgoal_tac", subgoal_meth, "insert subgoal (dynamic instantiation!)"),
wenzelm@9565
   710
  ("thin_tac", thin_meth, "remove premise (dynamic instantiation!)"),
wenzelm@9631
   711
  ("rename_tac", rename_meth, "rename parameters of goal (dynamic instantiation!)"),
wenzelm@9631
   712
  ("rotate_tac", rotate_meth, "rotate assumptions of goal"),
wenzelm@8351
   713
  ("prolog", thms_args prolog, "simple prolog interpreter"),
wenzelm@8351
   714
  ("tactic", simple_args Args.name tactic, "ML tactic as proof method")];
wenzelm@5824
   715
wenzelm@5824
   716
wenzelm@5824
   717
(* setup *)
wenzelm@5824
   718
wenzelm@8153
   719
val setup =
wenzelm@8153
   720
 [GlobalRules.init, LocalRules.init, Attrib.add_attributes rule_atts,
wenzelm@11971
   721
  MethodsData.init, add_methods pure_methods,
wenzelm@11971
   722
  (#1 o PureThy.add_thms [(("", Drule.equal_intr_rule), [intro_global])])];
wenzelm@5824
   723
wenzelm@5824
   724
wenzelm@5824
   725
end;
wenzelm@5824
   726
wenzelm@5824
   727
wenzelm@5824
   728
structure BasicMethod: BASIC_METHOD = Method;
wenzelm@5824
   729
open BasicMethod;