src/Pure/Isar/method.ML
author wenzelm
Fri Apr 07 17:36:25 2000 +0200 (2000-04-07 ago)
changeset 8681 957a5fe9b212
parent 8671 6ce91a80f616
child 8720 840c75ab2a7f
permissions -rw-r--r--
apply etc.: comments;
     1 (*  Title:      Pure/Isar/method.ML
     2     ID:         $Id$
     3     Author:     Markus Wenzel, TU Muenchen
     4 
     5 Proof methods.
     6 *)
     7 
     8 signature BASIC_METHOD =
     9 sig
    10   val print_methods: theory -> unit
    11   val Method: bstring -> (Args.src -> Proof.context -> Proof.method) -> string -> unit
    12 end;
    13 
    14 signature METHOD =
    15 sig
    16   include BASIC_METHOD
    17   val print_global_rules: theory -> unit
    18   val print_local_rules: Proof.context -> unit
    19   val dest_global: theory attribute
    20   val elim_global: theory attribute
    21   val intro_global: theory attribute
    22   val delrule_global: theory attribute
    23   val dest_local: Proof.context attribute
    24   val elim_local: Proof.context attribute
    25   val intro_local: Proof.context attribute
    26   val delrule_local: Proof.context attribute
    27   val METHOD: (thm list -> tactic) -> Proof.method
    28   val METHOD_CASES:
    29     (thm list -> thm -> (thm * (string * RuleCases.T) list) Seq.seq) -> Proof.method
    30   val METHOD0: tactic -> Proof.method
    31   val fail: Proof.method
    32   val succeed: Proof.method
    33   val defer: int option -> Proof.method
    34   val prefer: int -> Proof.method
    35   val insert_tac: thm list -> int -> tactic
    36   val insert: thm list -> Proof.method
    37   val insert_facts: Proof.method
    38   val unfold: thm list -> Proof.method
    39   val fold: thm list -> Proof.method
    40   val multi_resolve: thm list -> thm -> thm Seq.seq
    41   val multi_resolves: thm list -> thm list -> thm Seq.seq
    42   val resolveq_tac: thm Seq.seq -> int -> tactic
    43   val resolveq_cases_tac: (thm * string list) Seq.seq
    44     -> int -> thm -> (thm * (string * RuleCases.T) list) Seq.seq
    45   val rule_tac: thm list -> thm list -> int -> tactic
    46   val rule: thm list -> Proof.method
    47   val erule: thm list -> Proof.method
    48   val drule: thm list -> Proof.method
    49   val frule: thm list -> Proof.method
    50   val this: Proof.method
    51   val assumption: Proof.context -> Proof.method
    52   val set_tactic: (Proof.context -> thm list -> tactic) -> unit
    53   val tactic: string -> Proof.context -> Proof.method
    54   exception METHOD_FAIL of (string * Position.T) * exn
    55   val help_methods: theory option -> unit
    56   val method: theory -> Args.src -> Proof.context -> Proof.method
    57   val add_methods: (bstring * (Args.src -> Proof.context -> Proof.method) * string) list
    58     -> theory -> theory
    59   val syntax: (Proof.context * Args.T list -> 'a * (Proof.context * Args.T list)) ->
    60     Args.src -> Proof.context -> Proof.context * 'a
    61   val simple_args: (Args.T list -> 'a * Args.T list)
    62     -> ('a -> Proof.context -> Proof.method) -> Args.src -> Proof.context -> Proof.method
    63   val ctxt_args: (Proof.context -> Proof.method) -> Args.src -> Proof.context -> Proof.method
    64   val no_args: Proof.method -> Args.src -> Proof.context -> Proof.method
    65   type modifier
    66   val sectioned_args: (Proof.context * Args.T list -> 'a * (Proof.context * Args.T list)) ->
    67     (Args.T list -> modifier * Args.T list) list ->
    68     ('a -> Proof.context -> Proof.method) -> Args.src -> Proof.context -> Proof.method
    69   val bang_sectioned_args:
    70     (Args.T list -> modifier * Args.T list) list ->
    71     (thm list -> Proof.context -> Proof.method) -> Args.src -> Proof.context -> Proof.method
    72   val only_sectioned_args:
    73     (Args.T list -> modifier * Args.T list) list ->
    74     (Proof.context -> Proof.method) -> Args.src -> Proof.context -> Proof.method
    75   val thms_ctxt_args: (thm list -> Proof.context -> Proof.method)
    76     -> Args.src -> Proof.context -> Proof.method
    77   val thms_args: (thm list -> Proof.method) -> Args.src -> Proof.context -> Proof.method
    78   datatype text =
    79     Basic of (Proof.context -> Proof.method) |
    80     Source of Args.src |
    81     Then of text list |
    82     Orelse of text list |
    83     Try of text |
    84     Repeat1 of text
    85   val refine: text -> Proof.state -> Proof.state Seq.seq
    86   val refine_end: text -> Proof.state -> Proof.state Seq.seq
    87   val proof: text option -> Proof.state -> Proof.state Seq.seq
    88   val local_qed: text option
    89     -> ({kind: string, name: string, thm: thm} -> unit) * (thm -> unit)
    90     -> Proof.state -> Proof.state Seq.seq
    91   val local_terminal_proof: text * text option
    92     -> ({kind: string, name: string, thm: thm} -> unit) * (thm -> unit)
    93     -> Proof.state -> Proof.state Seq.seq
    94   val local_immediate_proof: ({kind: string, name: string, thm: thm} -> unit) * (thm -> unit)
    95     -> Proof.state -> Proof.state Seq.seq
    96   val local_default_proof: ({kind: string, name: string, thm: thm} -> unit) * (thm -> unit)
    97     -> Proof.state -> Proof.state Seq.seq
    98   val global_qed: text option -> Proof.state -> theory * {kind: string, name: string, thm: thm}
    99   val global_terminal_proof: text * text option
   100     -> Proof.state -> theory * {kind: string, name: string, thm: thm}
   101   val global_immediate_proof: Proof.state -> theory * {kind: string, name: string, thm: thm}
   102   val global_default_proof: Proof.state -> theory * {kind: string, name: string, thm: thm}
   103   val setup: (theory -> theory) list
   104 end;
   105 
   106 structure Method: METHOD =
   107 struct
   108 
   109 
   110 (** global and local rule data **)
   111 
   112 fun prt_rules kind ths =
   113   Pretty.writeln (Pretty.big_list ("standard " ^ kind ^ " rules:") (map Display.pretty_thm ths));
   114 
   115 fun print_rules (intro, elim) =
   116   (prt_rules "introduction" intro; prt_rules "elimination" elim);
   117 
   118 fun merge_rules (ths1, ths2) = Library.generic_merge Thm.eq_thm I I ths1 ths2;
   119 
   120 
   121 (* theory data kind 'Isar/rules' *)
   122 
   123 structure GlobalRulesArgs =
   124 struct
   125   val name = "Isar/rules";
   126   type T = thm list * thm list;
   127 
   128   val empty = ([], []);
   129   val copy = I;
   130   val prep_ext = I;
   131   fun merge ((intro1, elim1), (intro2, elim2)) =
   132     (merge_rules (intro1, intro2), merge_rules (elim1, elim2));
   133   fun print _ = print_rules;
   134 end;
   135 
   136 structure GlobalRules = TheoryDataFun(GlobalRulesArgs);
   137 val print_global_rules = GlobalRules.print;
   138 
   139 
   140 (* proof data kind 'Isar/rules' *)
   141 
   142 structure LocalRulesArgs =
   143 struct
   144   val name = "Isar/rules";
   145   type T = thm list * thm list;
   146 
   147   val init = GlobalRules.get;
   148   fun print _ = print_rules;
   149 end;
   150 
   151 structure LocalRules = ProofDataFun(LocalRulesArgs);
   152 val print_local_rules = LocalRules.print;
   153 
   154 
   155 
   156 (** attributes **)
   157 
   158 (* add rules *)
   159 
   160 local
   161 
   162 fun add_rule thm rules = Library.gen_ins Thm.eq_thm (thm, rules);
   163 fun del_rule thm rules = Library.gen_rem Thm.eq_thm (rules, thm);
   164 
   165 fun add_dest thm (intro, elim) = (intro, add_rule (Tactic.make_elim thm) elim);
   166 fun add_elim thm (intro, elim) = (intro, add_rule thm elim);
   167 fun add_intro thm (intro, elim) = (add_rule thm intro, elim);
   168 fun delrule thm (intro, elim) = (del_rule thm intro, del_rule thm elim);
   169 
   170 fun mk_att f g (x, thm) = (f (g thm) x, thm);
   171 
   172 in
   173 
   174 val dest_global = mk_att GlobalRules.map add_dest;
   175 val elim_global = mk_att GlobalRules.map add_elim;
   176 val intro_global = mk_att GlobalRules.map add_intro;
   177 val delrule_global = mk_att GlobalRules.map delrule;
   178 
   179 val dest_local = mk_att LocalRules.map add_dest;
   180 val elim_local = mk_att LocalRules.map add_elim;
   181 val intro_local = mk_att LocalRules.map add_intro;
   182 val delrule_local = mk_att LocalRules.map delrule;
   183 
   184 end;
   185 
   186 
   187 (* concrete syntax *)
   188 
   189 val rule_atts =
   190  [("dest", (Attrib.no_args dest_global, Attrib.no_args dest_local), "declare destruction rule"),
   191   ("elim", (Attrib.no_args elim_global, Attrib.no_args elim_local), "declare elimination rule"),
   192   ("intro", (Attrib.no_args intro_global, Attrib.no_args intro_local), "declare introduction rule"),
   193   ("delrule", (Attrib.no_args delrule_global, Attrib.no_args delrule_local), "undeclare rule")];
   194 
   195 
   196 
   197 (** proof methods **)
   198 
   199 (* make methods *)
   200 
   201 val METHOD = Proof.method;
   202 val METHOD_CASES = Proof.method_cases;
   203 
   204 fun METHOD0 tac = METHOD (fn [] => tac | _ => error "Method may not be used with facts");
   205 
   206 
   207 (* primitive *)
   208 
   209 val fail = METHOD (K no_tac);
   210 val succeed = METHOD (K all_tac);
   211 
   212 
   213 (* shuffle *)
   214 
   215 fun prefer i = METHOD (K (Tactic.defer_tac i THEN PRIMITIVE (Thm.permute_prems 0 ~1)));
   216 fun defer opt_i = METHOD (K (Tactic.defer_tac (if_none opt_i 1)));
   217 
   218 
   219 (* insert *)
   220 
   221 local
   222 
   223 fun cut_rule_tac raw_rule =
   224   let
   225     val rule = Drule.forall_intr_vars raw_rule;
   226     val revcut_rl = Drule.incr_indexes_wrt [] [] [] [rule] Drule.revcut_rl;
   227   in Tactic.rtac (rule COMP revcut_rl) end;
   228 
   229 in
   230 
   231 fun insert_tac [] i = all_tac
   232   | insert_tac facts i = EVERY (map (fn th => cut_rule_tac th i) facts);
   233 
   234 val insert_facts = METHOD (ALLGOALS o insert_tac);
   235 fun insert thms = METHOD (fn _ => ALLGOALS (insert_tac thms));
   236 
   237 end;
   238 
   239 
   240 (* unfold / fold definitions *)
   241 
   242 fun unfold thms = METHOD (fn facts => ALLGOALS (insert_tac facts) THEN rewrite_goals_tac thms);
   243 fun fold thms = METHOD (fn facts => ALLGOALS (insert_tac facts) THEN fold_goals_tac thms);
   244 
   245 
   246 (* multi_resolve *)
   247 
   248 local
   249 
   250 fun res th i rule =
   251   Thm.biresolution false [(false, th)] i rule handle THM _ => Seq.empty;
   252 
   253 fun multi_res _ [] rule = Seq.single rule
   254   | multi_res i (th :: ths) rule = Seq.flat (Seq.map (res th i) (multi_res (i + 1) ths rule));
   255 
   256 in
   257 
   258 val multi_resolve = multi_res 1;
   259 fun multi_resolves facts rules = Seq.flat (Seq.map (multi_resolve facts) (Seq.of_list rules));
   260 
   261 end;
   262 
   263 
   264 (* general rule *)
   265 
   266 fun gen_resolveq_tac tac rules i st =
   267   Seq.flat (Seq.map (fn rule => tac rule i st) rules);
   268 
   269 val resolveq_tac = gen_resolveq_tac Tactic.rtac;
   270 
   271 val resolveq_cases_tac = gen_resolveq_tac (fn (rule, cases) => fn i => fn st =>
   272   Seq.map (rpair (RuleCases.make rule cases)) (Tactic.rtac rule i st));
   273 
   274 
   275 (* simple rule *)
   276 
   277 local
   278 
   279 fun gen_rule_tac tac rules [] = tac rules
   280   | gen_rule_tac tac erules facts = gen_resolveq_tac (tac o single) (multi_resolves facts erules);
   281 
   282 fun gen_rule tac rules = METHOD (HEADGOAL o tac rules);
   283 
   284 fun gen_rule' tac arg_rules ctxt = METHOD (fn facts =>
   285   let val rules =
   286     if not (null arg_rules) then arg_rules
   287     else if null facts then #1 (LocalRules.get ctxt)
   288     else op @ (LocalRules.get ctxt);
   289   in HEADGOAL (tac rules facts) end);
   290 
   291 fun setup raw_tac =
   292   let val tac = gen_rule_tac raw_tac
   293   in (tac, gen_rule tac, gen_rule' tac) end;
   294 
   295 in
   296 
   297 val (rule_tac, rule, some_rule) = setup Tactic.resolve_tac;
   298 val (erule_tac, erule, some_erule) = setup Tactic.eresolve_tac;
   299 val (drule_tac, drule, some_drule) = setup Tactic.dresolve_tac;
   300 val (frule_tac, frule, some_frule) = setup Tactic.forward_tac;
   301 
   302 end;
   303 
   304 
   305 (* this *)
   306 
   307 val this = METHOD (EVERY o map (HEADGOAL o Tactic.rtac));
   308 
   309 
   310 (* assumption *)
   311 
   312 fun assm_tac ctxt =
   313   assume_tac APPEND' resolve_tac (filter Thm.no_prems (ProofContext.prems_of ctxt));
   314 
   315 fun assumption_tac ctxt [] = assm_tac ctxt
   316   | assumption_tac _ [fact] = resolve_tac [fact]
   317   | assumption_tac _ _ = K no_tac;
   318 
   319 fun assumption ctxt = METHOD (HEADGOAL o assumption_tac ctxt);
   320 
   321 
   322 (* res_inst_tac emulations *)
   323 
   324 (*Note: insts refer to the implicit (!) goal context; use at your own risk*)
   325 fun gen_res_inst tac (quant, (insts, thm)) =
   326   METHOD (fn facts => (quant (insert_tac facts THEN' tac insts thm)));
   327 
   328 val res_inst = gen_res_inst Tactic.res_inst_tac;
   329 val eres_inst = gen_res_inst Tactic.eres_inst_tac;
   330 val dres_inst = gen_res_inst Tactic.dres_inst_tac;
   331 val forw_inst = gen_res_inst Tactic.forw_inst_tac;
   332 
   333 
   334 (* simple Prolog interpreter *)
   335 
   336 fun prolog_tac rules facts =
   337   DEPTH_SOLVE_1 (HEADGOAL (Tactic.assume_tac APPEND' Tactic.resolve_tac (facts @ rules)));
   338 
   339 val prolog = METHOD o prolog_tac;
   340 
   341 
   342 (* ML tactics *)
   343 
   344 val tactic_ref = ref ((fn _ => raise Match): Proof.context -> thm list -> tactic);
   345 fun set_tactic f = tactic_ref := f;
   346 
   347 fun tactic txt ctxt = METHOD (fn facts =>
   348  (Context.use_mltext
   349    ("let fun tactic (ctxt: PureIsar.Proof.context) (facts: thm list) : tactic = \
   350     \let val thm = PureIsar.ProofContext.get_thm ctxt and thms = PureIsar.ProofContext.get_thms ctxt in\n"
   351     ^ txt ^
   352     "\nend in PureIsar.Method.set_tactic tactic end")
   353   false (Some (ProofContext.theory_of ctxt)); ! tactic_ref ctxt facts));
   354 
   355 
   356 
   357 (** methods theory data **)
   358 
   359 (* data kind 'Isar/methods' *)
   360 
   361 structure MethodsDataArgs =
   362 struct
   363   val name = "Isar/methods";
   364   type T =
   365     {space: NameSpace.T,
   366      meths: (((Args.src -> Proof.context -> Proof.method) * string) * stamp) Symtab.table};
   367 
   368   val empty = {space = NameSpace.empty, meths = Symtab.empty};
   369   val copy = I;
   370   val prep_ext = I;
   371   fun merge ({space = space1, meths = meths1}, {space = space2, meths = meths2}) =
   372     {space = NameSpace.merge (space1, space2),
   373       meths = Symtab.merge eq_snd (meths1, meths2) handle Symtab.DUPS dups =>
   374         error ("Attempt to merge different versions of methods " ^ commas_quote dups)};
   375 
   376   fun print_meths verbose {space, meths} =
   377     let
   378       fun prt_meth (name, ((_, comment), _)) = Pretty.block
   379         [Pretty.str (name ^ ":"), Pretty.brk 2, Pretty.str comment];
   380     in
   381       if not verbose then ()
   382       else Pretty.writeln (Display.pretty_name_space ("method name space", space));
   383       Pretty.writeln (Pretty.big_list "methods:"
   384         (map prt_meth (NameSpace.cond_extern_table space meths)))
   385     end;
   386 
   387   fun print _ = print_meths true;
   388 end;
   389 
   390 structure MethodsData = TheoryDataFun(MethodsDataArgs);
   391 val print_methods = MethodsData.print;
   392 
   393 fun help_methods None = writeln "methods: (unkown theory context)"
   394   | help_methods (Some thy) = MethodsDataArgs.print_meths false (MethodsData.get thy);
   395 
   396 
   397 (* get methods *)
   398 
   399 exception METHOD_FAIL of (string * Position.T) * exn;
   400 
   401 fun method thy =
   402   let
   403     val {space, meths} = MethodsData.get thy;
   404 
   405     fun meth src =
   406       let
   407         val ((raw_name, _), pos) = Args.dest_src src;
   408         val name = NameSpace.intern space raw_name;
   409       in
   410         (case Symtab.lookup (meths, name) of
   411           None => error ("Unknown proof method: " ^ quote name ^ Position.str_of pos)
   412         | Some ((mth, _), _) => transform_failure (curry METHOD_FAIL (name, pos)) (mth src))
   413       end;
   414   in meth end;
   415 
   416 
   417 (* add_methods *)
   418 
   419 fun add_methods raw_meths thy =
   420   let
   421     val full = Sign.full_name (Theory.sign_of thy);
   422     val new_meths =
   423       map (fn (name, f, comment) => (full name, ((f, comment), stamp ()))) raw_meths;
   424 
   425     val {space, meths} = MethodsData.get thy;
   426     val space' = NameSpace.extend (space, map fst new_meths);
   427     val meths' = Symtab.extend (meths, new_meths) handle Symtab.DUPS dups =>
   428       error ("Duplicate declaration of method(s) " ^ commas_quote dups);
   429   in
   430     thy |> MethodsData.put {space = space', meths = meths'}
   431   end;
   432 
   433 (*implicit version*)
   434 fun Method name meth cmt = Context.>> (add_methods [(name, meth, cmt)]);
   435 
   436 
   437 
   438 (** method syntax **)
   439 
   440 (* basic *)
   441 
   442 fun syntax (scan: (Proof.context * Args.T list -> 'a * (Proof.context * Args.T list))) =
   443   Args.syntax "method" scan;
   444 
   445 fun simple_args scan f src ctxt : Proof.method =
   446   #2 (syntax (Scan.lift (scan >> (fn x => f x ctxt))) src ctxt);
   447 
   448 fun ctxt_args (f: Proof.context -> Proof.method) src ctxt =
   449   #2 (syntax (Scan.succeed (f ctxt)) src ctxt);
   450 
   451 fun no_args m = ctxt_args (K m);
   452 
   453 
   454 
   455 (* sections *)
   456 
   457 type modifier = (Proof.context -> Proof.context) * Proof.context attribute;
   458 
   459 local
   460 
   461 fun sect ss = Scan.first (map Scan.lift ss);
   462 fun thms ss = Scan.unless (sect ss) Attrib.local_thms;
   463 fun thmss ss = Scan.repeat (thms ss) >> flat;
   464 
   465 fun apply (f, att) (ctxt, ths) = Thm.applys_attributes ((f ctxt, ths), [att]);
   466 
   467 fun section ss = (sect ss -- thmss ss) :-- (fn (m, ths) => Scan.depend (fn ctxt =>
   468   Scan.succeed (apply m (ctxt, ths)))) >> #2;
   469 
   470 fun sectioned args ss = args -- Scan.repeat (section ss);
   471 
   472 in
   473 
   474 fun sectioned_args args ss f src ctxt =
   475   let val (ctxt', (x, _)) = syntax (sectioned args ss) src ctxt
   476   in f x ctxt' end;
   477 
   478 fun bang_sectioned_args ss f = sectioned_args Args.bang_facts ss f;
   479 fun only_sectioned_args ss f = sectioned_args (Scan.succeed ()) ss (fn () => f);
   480 
   481 fun thms_ctxt_args f = sectioned_args (thmss []) [] f;
   482 fun thms_args f = thms_ctxt_args (K o f);
   483 
   484 end;
   485 
   486 
   487 (* insts *)
   488 
   489 val insts =
   490   Args.enum1 "and" (Scan.lift (Args.name -- Args.!!! (Args.$$$ "=" |-- Args.name))) --
   491     (Scan.lift (Args.$$$ "in") |-- Attrib.local_thm);
   492 
   493 fun inst_args f = f oo (#2 oo syntax (Args.goal_spec HEADGOAL -- insts));
   494 
   495 
   496 (* subgoal *)
   497 
   498 fun subgoal x = (Args.goal_spec HEADGOAL -- Scan.lift Args.name >>
   499   (fn (quant, s) => METHOD (fn facts => quant (insert_tac facts THEN' Tactic.subgoal_tac s)))) x;
   500 
   501 val subgoal_meth = #2 oo syntax subgoal;
   502 
   503 
   504 
   505 (** method text **)
   506 
   507 (* datatype text *)
   508 
   509 datatype text =
   510   Basic of (Proof.context -> Proof.method) |
   511   Source of Args.src |
   512   Then of text list |
   513   Orelse of text list |
   514   Try of text |
   515   Repeat1 of text;
   516 
   517 
   518 (* refine *)
   519 
   520 fun gen_refine f text state =
   521   let
   522     val thy = Proof.theory_of state;
   523 
   524     fun eval (Basic mth) = f mth
   525       | eval (Source src) = f (method thy src)
   526       | eval (Then txts) = Seq.EVERY (map eval txts)
   527       | eval (Orelse txts) = Seq.FIRST (map eval txts)
   528       | eval (Try txt) = Seq.TRY (eval txt)
   529       | eval (Repeat1 txt) = Seq.REPEAT1 (eval txt);
   530   in eval text state end;
   531 
   532 val refine = gen_refine Proof.refine;
   533 val refine_end = gen_refine Proof.refine_end;
   534 
   535 
   536 (* structured proof steps *)
   537 
   538 val default_text = Source (Args.src (("default", []), Position.none));
   539 val this_text = Basic (K this);
   540 
   541 fun finish ctxt = METHOD (K (FILTER Thm.no_prems (ALLGOALS (assm_tac ctxt) THEN flexflex_tac)));
   542 
   543 fun finish_text None = Basic finish
   544   | finish_text (Some txt) = Then [txt, Basic finish];
   545 
   546 fun proof opt_text state =
   547   state
   548   |> Proof.assert_backward
   549   |> refine (if_none opt_text default_text)
   550   |> Seq.map (Proof.goal_facts (K []))
   551   |> Seq.map Proof.enter_forward;
   552 
   553 fun local_qed opt_text = Proof.local_qed (refine (finish_text opt_text));
   554 fun local_terminal_proof (text, opt_text) pr = Seq.THEN (proof (Some text), local_qed opt_text pr);
   555 val local_immediate_proof = local_terminal_proof (this_text, None);
   556 val local_default_proof = local_terminal_proof (default_text, None);
   557 
   558 
   559 fun global_qeds opt_text = Proof.global_qed (refine (finish_text opt_text));
   560 
   561 fun global_qed opt_text state =
   562   state
   563   |> global_qeds opt_text
   564   |> Proof.check_result "Failed to finish proof" state
   565   |> Seq.hd;
   566 
   567 fun global_terminal_proof (text, opt_text) state =
   568   state
   569   |> proof (Some text)
   570   |> Proof.check_result "Terminal proof method failed" state
   571   |> (Seq.flat o Seq.map (global_qeds opt_text))
   572   |> Proof.check_result "Failed to finish proof (after successful terminal method)" state
   573   |> Seq.hd;
   574 
   575 val global_immediate_proof = global_terminal_proof (this_text, None);
   576 val global_default_proof = global_terminal_proof (default_text, None);
   577 
   578 
   579 
   580 (** theory setup **)
   581 
   582 (* pure_methods *)
   583 
   584 val pure_methods =
   585  [("fail", no_args fail, "force failure"),
   586   ("succeed", no_args succeed, "succeed"),
   587   ("-", no_args insert_facts, "do nothing, inserting current facts only"),
   588   ("insert", thms_args insert, "insert theorems, ignoring facts (improper!)"),
   589   ("unfold", thms_args unfold, "unfold definitions"),
   590   ("fold", thms_args fold, "fold definitions"),
   591   ("default", thms_ctxt_args some_rule, "apply some rule"),
   592   ("rule", thms_ctxt_args some_rule, "apply some rule"),
   593   ("erule", thms_ctxt_args some_erule, "apply some rule in elimination manner (improper!)"),
   594   ("drule", thms_ctxt_args some_drule, "apply some rule in destruct manner (improper!)"),
   595   ("frule", thms_ctxt_args some_frule, "apply some rule in forward manner (improper!)"),
   596   ("this", no_args this, "apply current facts as rules"),
   597   ("assumption", ctxt_args assumption, "proof by assumption, preferring facts"),
   598   ("res_inst_tac", inst_args res_inst, "res_inst_tac emulation (dynamic instantiation!)"),
   599   ("eres_inst_tac", inst_args eres_inst, "eres_inst_tac emulation (dynamic instantiation!)"),
   600   ("dres_inst_tac", inst_args dres_inst, "dres_inst_tac emulation (dynamic instantiation!)"),
   601   ("forw_inst_tac", inst_args forw_inst, "forw_inst_tac emulation (dynamic instantiation!)"),
   602   ("subgoal_tac", subgoal_meth, "subgoal_tac emulation (dynamic instantiation!)"),
   603   ("prolog", thms_args prolog, "simple prolog interpreter"),
   604   ("tactic", simple_args Args.name tactic, "ML tactic as proof method")];
   605 
   606 
   607 (* setup *)
   608 
   609 val setup =
   610  [GlobalRules.init, LocalRules.init, Attrib.add_attributes rule_atts,
   611   MethodsData.init, add_methods pure_methods];
   612 
   613 
   614 end;
   615 
   616 
   617 structure BasicMethod: BASIC_METHOD = Method;
   618 open BasicMethod;