| author | wenzelm | 
| Tue, 26 Apr 2016 16:20:28 +0200 | |
| changeset 63056 | 9b95ae9ec671 | 
| parent 62969 | 9f394a16c557 | 
| child 63090 | 7aa9ac5165e4 | 
| permissions | -rw-r--r-- | 
| 5824 | 1 | (* Title: Pure/Isar/method.ML | 
| 2 | Author: Markus Wenzel, TU Muenchen | |
| 3 | ||
| 17110 | 4 | Isar proof methods. | 
| 5824 | 5 | *) | 
| 6 | ||
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 7 | infix 1 CONTEXT_THEN_ALL_NEW; | 
| 61834 | 8 | |
| 9 | signature BASIC_METHOD = | |
| 10 | sig | |
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 11 | type context_state = Proof.context * thm | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 12 | type context_tactic = context_state -> context_state Seq.result Seq.seq | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 13 | val CONTEXT_CASES: Rule_Cases.cases -> tactic -> context_tactic | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 14 | val CONTEXT_SUBGOAL: (term * int -> context_tactic) -> int -> context_tactic | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 15 | val CONTEXT_THEN_ALL_NEW: (int -> context_tactic) * (int -> tactic) -> int -> context_tactic | 
| 61834 | 16 | end; | 
| 17 | ||
| 5824 | 18 | signature METHOD = | 
| 19 | sig | |
| 61834 | 20 | include BASIC_METHOD | 
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 21 | type method = thm list -> context_tactic | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 22 | val CONTEXT: Proof.context -> thm Seq.seq -> context_state Seq.result Seq.seq | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 23 | val CONTEXT_TACTIC: tactic -> context_tactic | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 24 | val NO_CONTEXT_TACTIC: Proof.context -> context_tactic -> tactic | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 25 | val CONTEXT_METHOD: (thm list -> context_tactic) -> method | 
| 17110 | 26 | val METHOD: (thm list -> tactic) -> method | 
| 27 | val fail: method | |
| 28 | val succeed: method | |
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 29 | val insert_tac: Proof.context -> thm list -> int -> tactic | 
| 17110 | 30 | val insert: thm list -> method | 
| 31 | val SIMPLE_METHOD: tactic -> method | |
| 21592 | 32 | val SIMPLE_METHOD': (int -> tactic) -> method | 
| 33 | val SIMPLE_METHOD'': ((int -> tactic) -> tactic) -> (int -> tactic) -> method | |
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 34 | val goal_cases_tac: string list -> context_tactic | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 35 | val cheating: bool -> method | 
| 58957 | 36 | val intro: Proof.context -> thm list -> method | 
| 37 | val elim: Proof.context -> thm list -> method | |
| 20289 | 38 | val unfold: thm list -> Proof.context -> method | 
| 39 | val fold: thm list -> Proof.context -> method | |
| 54742 
7a86358a3c0b
proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
 wenzelm parents: 
53171diff
changeset | 40 | val atomize: bool -> Proof.context -> method | 
| 59498 
50b60f501b05
proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
 wenzelm parents: 
59067diff
changeset | 41 | val this: Proof.context -> method | 
| 20289 | 42 | val fact: thm list -> Proof.context -> method | 
| 30234 
7dd251bce291
renamed Method.assumption_tac back to Method.assm_tac -- as assumption_tac it would have to be exactly the tactic behind the assumption method (with facts);
 wenzelm parents: 
30190diff
changeset | 43 | val assm_tac: Proof.context -> int -> tactic | 
| 30567 
cd8e20f86795
close/all_assm_tac: finish all subgoals from left to right (cf. Proof.goal_tac a28d83e903ce) -- NB: ALLGOALS/THEN_ALL_NEW operate from right to left;
 wenzelm parents: 
30544diff
changeset | 44 | val all_assm_tac: Proof.context -> tactic | 
| 20289 | 45 | val assumption: Proof.context -> method | 
| 46466 
61c7214b4885
tuned signature, according to actual usage of these operations;
 wenzelm parents: 
45375diff
changeset | 46 | val rule_trace: bool Config.T | 
| 20289 | 47 | val trace: Proof.context -> thm list -> unit | 
| 54742 
7a86358a3c0b
proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
 wenzelm parents: 
53171diff
changeset | 48 | val rule_tac: Proof.context -> thm list -> thm list -> int -> tactic | 
| 
7a86358a3c0b
proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
 wenzelm parents: 
53171diff
changeset | 49 | val some_rule_tac: Proof.context -> thm list -> thm list -> int -> tactic | 
| 59498 
50b60f501b05
proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
 wenzelm parents: 
59067diff
changeset | 50 | val intros_tac: Proof.context -> thm list -> thm list -> tactic | 
| 
50b60f501b05
proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
 wenzelm parents: 
59067diff
changeset | 51 | val try_intros_tac: Proof.context -> thm list -> thm list -> tactic | 
| 54742 
7a86358a3c0b
proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
 wenzelm parents: 
53171diff
changeset | 52 | val rule: Proof.context -> thm list -> method | 
| 
7a86358a3c0b
proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
 wenzelm parents: 
53171diff
changeset | 53 | val erule: Proof.context -> int -> thm list -> method | 
| 
7a86358a3c0b
proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
 wenzelm parents: 
53171diff
changeset | 54 | val drule: Proof.context -> int -> thm list -> method | 
| 
7a86358a3c0b
proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
 wenzelm parents: 
53171diff
changeset | 55 | val frule: Proof.context -> int -> thm list -> method | 
| 58018 
beb4b7c0bb30
proper static closure of ML tactic -- data slot is used twice, for ML compiler and transformed declaration;
 wenzelm parents: 
58016diff
changeset | 56 | val set_tactic: (morphism -> thm list -> tactic) -> Context.generic -> Context.generic | 
| 55765 | 57 | type combinator_info | 
| 58 | val no_combinator_info: combinator_info | |
| 59660 
49e498cedd02
support structural composition (THEN_ALL_NEW) for proof methods;
 wenzelm parents: 
59498diff
changeset | 59 | datatype combinator = Then | Then_All_New | Orelse | Try | Repeat1 | Select_Goals of int | 
| 5824 | 60 | datatype text = | 
| 58011 
bc6bced136e5
tuned signature -- moved type src to Token, without aliases;
 wenzelm parents: 
58007diff
changeset | 61 | Source of Token.src | | 
| 32193 
c314b4836031
basic method application: avoid Position.setmp_thread_data_seq, which destroys transaction context;
 wenzelm parents: 
32091diff
changeset | 62 | Basic of Proof.context -> method | | 
| 58005 | 63 | Combinator of combinator_info * combinator * text list | 
| 58011 
bc6bced136e5
tuned signature -- moved type src to Token, without aliases;
 wenzelm parents: 
58007diff
changeset | 64 | val map_source: (Token.src -> Token.src) -> text -> text | 
| 54883 
dd04a8b654fc
proper context for norm_hhf and derived operations;
 wenzelm parents: 
54742diff
changeset | 65 | val primitive_text: (Proof.context -> thm -> thm) -> text | 
| 17857 | 66 | val succeed_text: text | 
| 60618 
4c79543cc376
renamed "default" to "standard", to make semantically clear what it is;
 wenzelm parents: 
60609diff
changeset | 67 | val standard_text: text | 
| 17110 | 68 | val this_text: text | 
| 69 | val done_text: text | |
| 17356 
09afdf37cdb3
added cheating, sorry_text (from skip_proofs.ML);
 wenzelm parents: 
17314diff
changeset | 70 | val sorry_text: bool -> text | 
| 32193 
c314b4836031
basic method application: avoid Position.setmp_thread_data_seq, which destroys transaction context;
 wenzelm parents: 
32091diff
changeset | 71 | val finish_text: text option * bool -> text | 
| 59917 
9830c944670f
more uniform "verbose" option to print name space;
 wenzelm parents: 
59914diff
changeset | 72 | val print_methods: bool -> Proof.context -> unit | 
| 55742 
a989bdaf8121
modernized Method.check_name/check_source (with reports) vs. strict Method.the_method (without interning nor reports), e.g. relevant for semantic completion;
 wenzelm parents: 
55709diff
changeset | 73 | val check_name: Proof.context -> xstring * Position.T -> string | 
| 59907 | 74 | val check_src: Proof.context -> Token.src -> Token.src | 
| 61814 
1ca1142e1711
clarified type Token.src: plain token list, with usual implicit value assignment;
 wenzelm parents: 
61812diff
changeset | 75 | val check_text: Proof.context -> text -> text | 
| 61917 
35ec3757d3c1
check and report source at most once, notably in body of "match" method;
 wenzelm parents: 
61843diff
changeset | 76 | val checked_text: text -> bool | 
| 58011 
bc6bced136e5
tuned signature -- moved type src to Token, without aliases;
 wenzelm parents: 
58007diff
changeset | 77 | val method_syntax: (Proof.context -> method) context_parser -> | 
| 
bc6bced136e5
tuned signature -- moved type src to Token, without aliases;
 wenzelm parents: 
58007diff
changeset | 78 | Token.src -> Proof.context -> method | 
| 30512 | 79 | val setup: binding -> (Proof.context -> method) context_parser -> string -> theory -> theory | 
| 57935 
c578f3a37a67
localized method definitions (see also f14c1248d064);
 wenzelm parents: 
57863diff
changeset | 80 | val local_setup: binding -> (Proof.context -> method) context_parser -> string -> | 
| 
c578f3a37a67
localized method definitions (see also f14c1248d064);
 wenzelm parents: 
57863diff
changeset | 81 | local_theory -> local_theory | 
| 59064 | 82 | val method_setup: bstring * Position.T -> Input.source -> string -> local_theory -> local_theory | 
| 58011 
bc6bced136e5
tuned signature -- moved type src to Token, without aliases;
 wenzelm parents: 
58007diff
changeset | 83 | val method: Proof.context -> Token.src -> Proof.context -> method | 
| 
bc6bced136e5
tuned signature -- moved type src to Token, without aliases;
 wenzelm parents: 
58007diff
changeset | 84 | val method_closure: Proof.context -> Token.src -> Token.src | 
| 59909 | 85 | val closure: bool Config.T | 
| 58011 
bc6bced136e5
tuned signature -- moved type src to Token, without aliases;
 wenzelm parents: 
58007diff
changeset | 86 | val method_cmd: Proof.context -> Token.src -> Proof.context -> method | 
| 60553 | 87 | val detect_closure_state: thm -> bool | 
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 88 | val STATIC: (unit -> unit) -> context_tactic | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 89 | val RUNTIME: context_tactic -> context_tactic | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 90 | val sleep: Time.time -> context_tactic | 
| 58007 
671c607fb4af
just one context for Method.evaluate (in contrast to a989bdaf8121, but in accordance to old global situation);
 wenzelm parents: 
58006diff
changeset | 91 | val evaluate: text -> Proof.context -> method | 
| 58048 
aa6296d09e0e
more explicit Method.modifier with reported position;
 wenzelm parents: 
58034diff
changeset | 92 |   type modifier = {init: Proof.context -> Proof.context, attribute: attribute, pos: Position.T}
 | 
| 
aa6296d09e0e
more explicit Method.modifier with reported position;
 wenzelm parents: 
58034diff
changeset | 93 | val modifier: attribute -> Position.T -> modifier | 
| 59982 
f402fd001429
option for old section parser (before 2137e60b6f6d) for the sake of Eisbach;
 wenzelm parents: 
59981diff
changeset | 94 | val old_section_parser: bool Config.T | 
| 
f402fd001429
option for old section parser (before 2137e60b6f6d) for the sake of Eisbach;
 wenzelm parents: 
59981diff
changeset | 95 | val sections: modifier parser list -> unit context_parser | 
| 49889 
00ea087e83d8
more method position information, notably finished_pos after end of previous text;
 wenzelm parents: 
49866diff
changeset | 96 | type text_range = text * Position.range | 
| 
00ea087e83d8
more method position information, notably finished_pos after end of previous text;
 wenzelm parents: 
49866diff
changeset | 97 | val text: text_range option -> text option | 
| 
00ea087e83d8
more method position information, notably finished_pos after end of previous text;
 wenzelm parents: 
49866diff
changeset | 98 | val position: text_range option -> Position.T | 
| 55795 | 99 | val reports_of: text_range -> Position.report list | 
| 100 | val report: text_range -> unit | |
| 59981 | 101 | val parser: int -> text_range parser | 
| 55761 
213b9811f59f
method language markup, e.g. relevant to prevent outer keyword completion;
 wenzelm parents: 
55742diff
changeset | 102 | val parse: text_range parser | 
| 5824 | 103 | end; | 
| 104 | ||
| 105 | structure Method: METHOD = | |
| 106 | struct | |
| 107 | ||
| 12324 
5db4b4596d1a
rule context and attributes moved to rule_context.ML;
 wenzelm parents: 
12311diff
changeset | 108 | (** proof methods **) | 
| 
5db4b4596d1a
rule context and attributes moved to rule_context.ML;
 wenzelm parents: 
12311diff
changeset | 109 | |
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 110 | (* tactics with proof context / cases *) | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 111 | |
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 112 | type context_state = Proof.context * thm; | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 113 | type context_tactic = context_state -> context_state Seq.result Seq.seq; | 
| 61834 | 114 | |
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 115 | fun CONTEXT ctxt : thm Seq.seq -> context_state Seq.result Seq.seq = | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 116 | Seq.map (Seq.Result o pair ctxt); | 
| 61834 | 117 | |
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 118 | fun CONTEXT_TACTIC tac : context_tactic = | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 119 | fn (ctxt, st) => CONTEXT ctxt (tac st); | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 120 | |
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 121 | fun NO_CONTEXT_TACTIC ctxt (tac: context_tactic) st = | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 122 | tac (ctxt, st) |> Seq.filter_results |> Seq.map snd; | 
| 61834 | 123 | |
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 124 | fun CONTEXT_CASES cases tac : context_tactic = | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 125 | fn (ctxt, st) => CONTEXT (Proof_Context.update_cases cases ctxt) (tac st); | 
| 61834 | 126 | |
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 127 | fun CONTEXT_SUBGOAL tac i : context_tactic = | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 128 | fn (ctxt, st) => | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 129 | (case try Logic.nth_prem (i, Thm.prop_of st) of | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 130 | SOME goal => tac (goal, i) (ctxt, st) | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 131 | | NONE => Seq.empty); | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 132 | |
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 133 | fun (tac1 CONTEXT_THEN_ALL_NEW tac2) i : context_tactic = | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 134 | fn (ctxt, st) => | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 135 | (ctxt, st) |> tac1 i |> Seq.maps_results (fn (ctxt', st') => | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 136 | CONTEXT ctxt' ((Seq.INTERVAL tac2 i (i + Thm.nprems_of st' - Thm.nprems_of st)) st')); | 
| 61834 | 137 | |
| 138 | ||
| 139 | (* type method *) | |
| 11731 | 140 | |
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 141 | type method = thm list -> context_tactic; | 
| 11731 | 142 | |
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 143 | fun CONTEXT_METHOD tac : method = | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 144 | fn facts => CONTEXT_TACTIC (ALLGOALS Goal.conjunction_tac) #> Seq.maps_results (tac facts); | 
| 59953 | 145 | |
| 146 | fun METHOD tac : method = | |
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 147 | fn facts => CONTEXT_TACTIC (ALLGOALS Goal.conjunction_tac THEN tac facts); | 
| 5824 | 148 | |
| 149 | val fail = METHOD (K no_tac); | |
| 150 | val succeed = METHOD (K all_tac); | |
| 151 | ||
| 152 | ||
| 17110 | 153 | (* insert facts *) | 
| 7419 | 154 | |
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 155 | fun insert_tac _ [] _ = all_tac | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 156 | | insert_tac ctxt facts i = | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 157 | EVERY (map (fn r => resolve_tac ctxt [Drule.forall_intr_vars r COMP_INCR revcut_rl] i) facts); | 
| 5824 | 158 | |
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 159 | fun insert thms = | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 160 | CONTEXT_METHOD (fn _ => fn (ctxt, st) => st |> ALLGOALS (insert_tac ctxt thms) |> CONTEXT ctxt); | 
| 6981 | 161 | |
| 5824 | 162 | |
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 163 | fun SIMPLE_METHOD tac = | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 164 | CONTEXT_METHOD (fn facts => fn (ctxt, st) => | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 165 | st |> (ALLGOALS (insert_tac ctxt facts) THEN tac) |> CONTEXT ctxt); | 
| 7419 | 166 | |
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 167 | fun SIMPLE_METHOD'' quant tac = | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 168 | CONTEXT_METHOD (fn facts => fn (ctxt, st) => | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 169 | st |> quant (insert_tac ctxt facts THEN' tac) |> CONTEXT ctxt); | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 170 | |
| 21592 | 171 | val SIMPLE_METHOD' = SIMPLE_METHOD'' HEADGOAL; | 
| 9706 | 172 | |
| 173 | ||
| 60578 | 174 | (* goals as cases *) | 
| 175 | ||
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 176 | fun goal_cases_tac case_names : context_tactic = | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 177 | fn (ctxt, st) => | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 178 | let | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 179 | val cases = | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 180 | (if null case_names then map string_of_int (1 upto Thm.nprems_of st) else case_names) | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 181 | |> map (rpair [] o rpair []) | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 182 | |> Rule_Cases.make_common ctxt (Thm.prop_of (Rule_Cases.internalize_params st)); | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 183 | in CONTEXT_CASES cases all_tac (ctxt, st) end; | 
| 60578 | 184 | |
| 185 | ||
| 17356 
09afdf37cdb3
added cheating, sorry_text (from skip_proofs.ML);
 wenzelm parents: 
17314diff
changeset | 186 | (* cheating *) | 
| 
09afdf37cdb3
added cheating, sorry_text (from skip_proofs.ML);
 wenzelm parents: 
17314diff
changeset | 187 | |
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 188 | fun cheating int = CONTEXT_METHOD (fn _ => fn (ctxt, st) => | 
| 52059 | 189 | if int orelse Config.get ctxt quick_and_dirty then | 
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 190 | CONTEXT ctxt (ALLGOALS (Skip_Proof.cheat_tac ctxt) st) | 
| 51552 
c713c9505f68
clarified Skip_Proof.cheat_tac: more standard tactic;
 wenzelm parents: 
51383diff
changeset | 191 | else error "Cheating requires quick_and_dirty mode!"); | 
| 17356 
09afdf37cdb3
added cheating, sorry_text (from skip_proofs.ML);
 wenzelm parents: 
17314diff
changeset | 192 | |
| 
09afdf37cdb3
added cheating, sorry_text (from skip_proofs.ML);
 wenzelm parents: 
17314diff
changeset | 193 | |
| 17110 | 194 | (* unfold intro/elim rules *) | 
| 195 | ||
| 58957 | 196 | fun intro ctxt ths = SIMPLE_METHOD' (CHANGED_PROP o REPEAT_ALL_NEW (match_tac ctxt ths)); | 
| 197 | fun elim ctxt ths = SIMPLE_METHOD' (CHANGED_PROP o REPEAT_ALL_NEW (ematch_tac ctxt ths)); | |
| 17110 | 198 | |
| 199 | ||
| 12384 | 200 | (* unfold/fold definitions *) | 
| 201 | ||
| 35624 | 202 | fun unfold_meth ths ctxt = SIMPLE_METHOD (CHANGED_PROP (Local_Defs.unfold_tac ctxt ths)); | 
| 203 | fun fold_meth ths ctxt = SIMPLE_METHOD (CHANGED_PROP (Local_Defs.fold_tac ctxt ths)); | |
| 6532 | 204 | |
| 12384 | 205 | |
| 12829 | 206 | (* atomize rule statements *) | 
| 207 | ||
| 54742 
7a86358a3c0b
proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
 wenzelm parents: 
53171diff
changeset | 208 | fun atomize false ctxt = | 
| 
7a86358a3c0b
proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
 wenzelm parents: 
53171diff
changeset | 209 | SIMPLE_METHOD' (CHANGED_PROP o Object_Logic.atomize_prems_tac ctxt) | 
| 
7a86358a3c0b
proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
 wenzelm parents: 
53171diff
changeset | 210 | | atomize true ctxt = | 
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 211 | CONTEXT_TACTIC o K (HEADGOAL (CHANGED_PROP o Object_Logic.full_atomize_tac ctxt)); | 
| 12829 | 212 | |
| 213 | ||
| 18039 | 214 | (* this -- resolve facts directly *) | 
| 12384 | 215 | |
| 59498 
50b60f501b05
proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
 wenzelm parents: 
59067diff
changeset | 216 | fun this ctxt = METHOD (EVERY o map (HEADGOAL o resolve_tac ctxt o single)); | 
| 9484 | 217 | |
| 218 | ||
| 18039 | 219 | (* fact -- composition by facts from context *) | 
| 220 | ||
| 42360 | 221 | fun fact [] ctxt = SIMPLE_METHOD' (Proof_Context.some_fact_tac ctxt) | 
| 54742 
7a86358a3c0b
proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
 wenzelm parents: 
53171diff
changeset | 222 | | fact rules ctxt = SIMPLE_METHOD' (Proof_Context.fact_tac ctxt rules); | 
| 18039 | 223 | |
| 224 | ||
| 17110 | 225 | (* assumption *) | 
| 7419 | 226 | |
| 227 | local | |
| 228 | ||
| 59498 
50b60f501b05
proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
 wenzelm parents: 
59067diff
changeset | 229 | fun cond_rtac ctxt cond rule = SUBGOAL (fn (prop, i) => | 
| 19778 | 230 | if cond (Logic.strip_assums_concl prop) | 
| 59498 
50b60f501b05
proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
 wenzelm parents: 
59067diff
changeset | 231 | then resolve_tac ctxt [rule] i else no_tac); | 
| 7419 | 232 | |
| 29857 
2cc976ed8a3c
FindTheorems: add solves feature; tidy up const name subsettin; patch by Timothy Bourke
 kleing parents: 
29301diff
changeset | 233 | in | 
| 
2cc976ed8a3c
FindTheorems: add solves feature; tidy up const name subsettin; patch by Timothy Bourke
 kleing parents: 
29301diff
changeset | 234 | |
| 30234 
7dd251bce291
renamed Method.assumption_tac back to Method.assm_tac -- as assumption_tac it would have to be exactly the tactic behind the assumption method (with facts);
 wenzelm parents: 
30190diff
changeset | 235 | fun assm_tac ctxt = | 
| 58963 
26bf09b95dda
proper context for assume_tac (atac remains as fall-back without context);
 wenzelm parents: 
58957diff
changeset | 236 | assume_tac ctxt APPEND' | 
| 23349 | 237 | Goal.assume_rule_tac ctxt APPEND' | 
| 59498 
50b60f501b05
proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
 wenzelm parents: 
59067diff
changeset | 238 | cond_rtac ctxt (can Logic.dest_equals) Drule.reflexive_thm APPEND' | 
| 
50b60f501b05
proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
 wenzelm parents: 
59067diff
changeset | 239 | cond_rtac ctxt (can Logic.dest_term) Drule.termI; | 
| 17110 | 240 | |
| 49846 
8fae089f5a0c
refined Proof.the_finished_goal with more informative error;
 wenzelm parents: 
48992diff
changeset | 241 | fun all_assm_tac ctxt = | 
| 
8fae089f5a0c
refined Proof.the_finished_goal with more informative error;
 wenzelm parents: 
48992diff
changeset | 242 | let | 
| 
8fae089f5a0c
refined Proof.the_finished_goal with more informative error;
 wenzelm parents: 
48992diff
changeset | 243 | fun tac i st = | 
| 
8fae089f5a0c
refined Proof.the_finished_goal with more informative error;
 wenzelm parents: 
48992diff
changeset | 244 | if i > Thm.nprems_of st then all_tac st | 
| 
8fae089f5a0c
refined Proof.the_finished_goal with more informative error;
 wenzelm parents: 
48992diff
changeset | 245 | else ((assm_tac ctxt i THEN tac i) ORELSE tac (i + 1)) st; | 
| 
8fae089f5a0c
refined Proof.the_finished_goal with more informative error;
 wenzelm parents: 
48992diff
changeset | 246 | in tac 1 end; | 
| 30567 
cd8e20f86795
close/all_assm_tac: finish all subgoals from left to right (cf. Proof.goal_tac a28d83e903ce) -- NB: ALLGOALS/THEN_ALL_NEW operate from right to left;
 wenzelm parents: 
30544diff
changeset | 247 | |
| 23349 | 248 | fun assumption ctxt = METHOD (HEADGOAL o | 
| 30234 
7dd251bce291
renamed Method.assumption_tac back to Method.assm_tac -- as assumption_tac it would have to be exactly the tactic behind the assumption method (with facts);
 wenzelm parents: 
30190diff
changeset | 249 | (fn [] => assm_tac ctxt | 
| 59498 
50b60f501b05
proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
 wenzelm parents: 
59067diff
changeset | 250 | | [fact] => solve_tac ctxt [fact] | 
| 23349 | 251 | | _ => K no_tac)); | 
| 252 | ||
| 49846 
8fae089f5a0c
refined Proof.the_finished_goal with more informative error;
 wenzelm parents: 
48992diff
changeset | 253 | fun finish immed ctxt = | 
| 58950 
d07464875dd4
optional proof context for unify operations, for the sake of proper local options;
 wenzelm parents: 
58837diff
changeset | 254 | METHOD (K ((if immed then all_assm_tac ctxt else all_tac) THEN flexflex_tac ctxt)); | 
| 7419 | 255 | |
| 256 | end; | |
| 257 | ||
| 258 | ||
| 17110 | 259 | (* rule etc. -- single-step refinements *) | 
| 12347 | 260 | |
| 56204 | 261 | val rule_trace = Attrib.setup_config_bool @{binding rule_trace} (fn _ => false);
 | 
| 12347 | 262 | |
| 17110 | 263 | fun trace ctxt rules = | 
| 41379 | 264 | if Config.get ctxt rule_trace andalso not (null rules) then | 
| 61268 | 265 | Pretty.big_list "rules:" (map (Thm.pretty_thm_item ctxt) rules) | 
| 21962 | 266 | |> Pretty.string_of |> tracing | 
| 267 | else (); | |
| 12347 | 268 | |
| 269 | local | |
| 270 | ||
| 54742 
7a86358a3c0b
proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
 wenzelm parents: 
53171diff
changeset | 271 | fun gen_rule_tac tac ctxt rules facts = | 
| 18841 | 272 | (fn i => fn st => | 
| 59498 
50b60f501b05
proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
 wenzelm parents: 
59067diff
changeset | 273 | if null facts then tac ctxt rules i st | 
| 58950 
d07464875dd4
optional proof context for unify operations, for the sake of proper local options;
 wenzelm parents: 
58837diff
changeset | 274 | else | 
| 59498 
50b60f501b05
proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
 wenzelm parents: 
59067diff
changeset | 275 | Seq.maps (fn rule => (tac ctxt o single) rule i st) | 
| 58950 
d07464875dd4
optional proof context for unify operations, for the sake of proper local options;
 wenzelm parents: 
58837diff
changeset | 276 | (Drule.multi_resolves (SOME ctxt) facts rules)) | 
| 54742 
7a86358a3c0b
proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
 wenzelm parents: 
53171diff
changeset | 277 | THEN_ALL_NEW Goal.norm_hhf_tac ctxt; | 
| 7130 | 278 | |
| 54742 
7a86358a3c0b
proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
 wenzelm parents: 
53171diff
changeset | 279 | fun gen_arule_tac tac ctxt j rules facts = | 
| 58963 
26bf09b95dda
proper context for assume_tac (atac remains as fall-back without context);
 wenzelm parents: 
58957diff
changeset | 280 | EVERY' (gen_rule_tac tac ctxt rules facts :: replicate j (assume_tac ctxt)); | 
| 10744 | 281 | |
| 54742 
7a86358a3c0b
proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
 wenzelm parents: 
53171diff
changeset | 282 | fun gen_some_rule_tac tac ctxt arg_rules facts = SUBGOAL (fn (goal, i) => | 
| 11785 | 283 | let | 
| 284 | val rules = | |
| 285 | if not (null arg_rules) then arg_rules | |
| 61049 | 286 | else flat (Context_Rules.find_rules ctxt false facts goal); | 
| 54742 
7a86358a3c0b
proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
 wenzelm parents: 
53171diff
changeset | 287 | in trace ctxt rules; tac ctxt rules facts i end); | 
| 10309 | 288 | |
| 54742 
7a86358a3c0b
proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
 wenzelm parents: 
53171diff
changeset | 289 | fun meth tac x y = METHOD (HEADGOAL o tac x y); | 
| 
7a86358a3c0b
proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
 wenzelm parents: 
53171diff
changeset | 290 | fun meth' tac x y z = METHOD (HEADGOAL o tac x y z); | 
| 8220 | 291 | |
| 7419 | 292 | in | 
| 293 | ||
| 52732 | 294 | val rule_tac = gen_rule_tac resolve_tac; | 
| 10744 | 295 | val rule = meth rule_tac; | 
| 296 | val some_rule_tac = gen_some_rule_tac rule_tac; | |
| 54742 
7a86358a3c0b
proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
 wenzelm parents: 
53171diff
changeset | 297 | val some_rule = meth some_rule_tac; | 
| 10744 | 298 | |
| 52732 | 299 | val erule = meth' (gen_arule_tac eresolve_tac); | 
| 300 | val drule = meth' (gen_arule_tac dresolve_tac); | |
| 301 | val frule = meth' (gen_arule_tac forward_tac); | |
| 5824 | 302 | |
| 7419 | 303 | end; | 
| 304 | ||
| 305 | ||
| 25270 | 306 | (* intros_tac -- pervasive search spanned by intro rules *) | 
| 307 | ||
| 59498 
50b60f501b05
proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
 wenzelm parents: 
59067diff
changeset | 308 | fun gen_intros_tac goals ctxt intros facts = | 
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 309 | goals (insert_tac ctxt facts THEN' | 
| 59498 
50b60f501b05
proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
 wenzelm parents: 
59067diff
changeset | 310 | REPEAT_ALL_NEW (resolve_tac ctxt intros)) | 
| 25270 | 311 | THEN Tactic.distinct_subgoals_tac; | 
| 312 | ||
| 36093 
0880493627ca
Graceful treatment of non-locale subgoals by methods unfold_locales and intro_locales.
 ballarin parents: 
33522diff
changeset | 313 | val intros_tac = gen_intros_tac ALLGOALS; | 
| 
0880493627ca
Graceful treatment of non-locale subgoals by methods unfold_locales and intro_locales.
 ballarin parents: 
33522diff
changeset | 314 | val try_intros_tac = gen_intros_tac TRYALL; | 
| 25270 | 315 | |
| 37216 
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
 wenzelm parents: 
37198diff
changeset | 316 | |
| 58016 | 317 | |
| 318 | (** method syntax **) | |
| 319 | ||
| 320 | (* context data *) | |
| 8351 | 321 | |
| 58016 | 322 | structure Data = Generic_Data | 
| 26472 
9afdd61cf528
ml_tactic: non-critical version via proof data and thread data;
 wenzelm parents: 
26463diff
changeset | 323 | ( | 
| 58016 | 324 | type T = | 
| 325 | ((Token.src -> Proof.context -> method) * string) Name_Space.table * (*methods*) | |
| 58018 
beb4b7c0bb30
proper static closure of ML tactic -- data slot is used twice, for ML compiler and transformed declaration;
 wenzelm parents: 
58016diff
changeset | 326 | (morphism -> thm list -> tactic) option; (*ML tactic*) | 
| 58016 | 327 | val empty : T = (Name_Space.empty_table "method", NONE); | 
| 328 | val extend = I; | |
| 329 | fun merge ((tab, tac), (tab', tac')) : T = | |
| 330 | (Name_Space.merge_tables (tab, tab'), merge_options (tac, tac')); | |
| 26472 
9afdd61cf528
ml_tactic: non-critical version via proof data and thread data;
 wenzelm parents: 
26463diff
changeset | 331 | ); | 
| 
9afdd61cf528
ml_tactic: non-critical version via proof data and thread data;
 wenzelm parents: 
26463diff
changeset | 332 | |
| 58016 | 333 | val get_methods = fst o Data.get; | 
| 334 | val map_methods = Data.map o apfst; | |
| 335 | ||
| 336 | ||
| 337 | (* ML tactic *) | |
| 338 | ||
| 339 | val set_tactic = Data.map o apsnd o K o SOME; | |
| 340 | ||
| 341 | fun the_tactic context = | |
| 342 | (case snd (Data.get context) of | |
| 343 | SOME tac => tac | |
| 344 | | NONE => raise Fail "Undefined ML tactic"); | |
| 8351 | 345 | |
| 58018 
beb4b7c0bb30
proper static closure of ML tactic -- data slot is used twice, for ML compiler and transformed declaration;
 wenzelm parents: 
58016diff
changeset | 346 | val parse_tactic = | 
| 
beb4b7c0bb30
proper static closure of ML tactic -- data slot is used twice, for ML compiler and transformed declaration;
 wenzelm parents: 
58016diff
changeset | 347 | Scan.state :|-- (fn context => | 
| 
beb4b7c0bb30
proper static closure of ML tactic -- data slot is used twice, for ML compiler and transformed declaration;
 wenzelm parents: 
58016diff
changeset | 348 | Scan.lift (Args.text_declaration (fn source => | 
| 
beb4b7c0bb30
proper static closure of ML tactic -- data slot is used twice, for ML compiler and transformed declaration;
 wenzelm parents: 
58016diff
changeset | 349 | let | 
| 
beb4b7c0bb30
proper static closure of ML tactic -- data slot is used twice, for ML compiler and transformed declaration;
 wenzelm parents: 
58016diff
changeset | 350 | val context' = context |> | 
| 59064 | 351 | ML_Context.expression (Input.range_of source) | 
| 58991 
92b6f4e68c5a
more careful ML source positions, for improved PIDE markup;
 wenzelm parents: 
58979diff
changeset | 352 | "tactic" "Morphism.morphism -> thm list -> tactic" | 
| 
92b6f4e68c5a
more careful ML source positions, for improved PIDE markup;
 wenzelm parents: 
58979diff
changeset | 353 | "Method.set_tactic tactic" | 
| 59067 | 354 | (ML_Lex.read "fn morphism: Morphism.morphism => fn facts: thm list =>" @ | 
| 58991 
92b6f4e68c5a
more careful ML source positions, for improved PIDE markup;
 wenzelm parents: 
58979diff
changeset | 355 | ML_Lex.read_source false source); | 
| 58018 
beb4b7c0bb30
proper static closure of ML tactic -- data slot is used twice, for ML compiler and transformed declaration;
 wenzelm parents: 
58016diff
changeset | 356 | val tac = the_tactic context'; | 
| 
beb4b7c0bb30
proper static closure of ML tactic -- data slot is used twice, for ML compiler and transformed declaration;
 wenzelm parents: 
58016diff
changeset | 357 | in | 
| 62889 | 358 | fn phi => set_tactic (fn _ => Context.setmp_generic_context (SOME context) (tac phi)) | 
| 58018 
beb4b7c0bb30
proper static closure of ML tactic -- data slot is used twice, for ML compiler and transformed declaration;
 wenzelm parents: 
58016diff
changeset | 359 | end)) >> (fn decl => Morphism.form (the_tactic (Morphism.form decl context)))); | 
| 8351 | 360 | |
| 361 | ||
| 17110 | 362 | (* method text *) | 
| 363 | ||
| 55765 | 364 | datatype combinator_info = Combinator_Info of {keywords: Position.T list};
 | 
| 365 | fun combinator_info keywords = Combinator_Info {keywords = keywords};
 | |
| 366 | val no_combinator_info = combinator_info []; | |
| 367 | ||
| 59660 
49e498cedd02
support structural composition (THEN_ALL_NEW) for proof methods;
 wenzelm parents: 
59498diff
changeset | 368 | datatype combinator = Then | Then_All_New | Orelse | Try | Repeat1 | Select_Goals of int; | 
| 58005 | 369 | |
| 17110 | 370 | datatype text = | 
| 58011 
bc6bced136e5
tuned signature -- moved type src to Token, without aliases;
 wenzelm parents: 
58007diff
changeset | 371 | Source of Token.src | | 
| 32193 
c314b4836031
basic method application: avoid Position.setmp_thread_data_seq, which destroys transaction context;
 wenzelm parents: 
32091diff
changeset | 372 | Basic of Proof.context -> method | | 
| 58005 | 373 | Combinator of combinator_info * combinator * text list; | 
| 55765 | 374 | |
| 58006 | 375 | fun map_source f (Source src) = Source (f src) | 
| 376 | | map_source _ (Basic meth) = Basic meth | |
| 377 | | map_source f (Combinator (info, comb, txts)) = Combinator (info, comb, map (map_source f) txts); | |
| 378 | ||
| 54883 
dd04a8b654fc
proper context for norm_hhf and derived operations;
 wenzelm parents: 
54742diff
changeset | 379 | fun primitive_text r = Basic (SIMPLE_METHOD o PRIMITIVE o r); | 
| 32193 
c314b4836031
basic method application: avoid Position.setmp_thread_data_seq, which destroys transaction context;
 wenzelm parents: 
32091diff
changeset | 380 | val succeed_text = Basic (K succeed); | 
| 61814 
1ca1142e1711
clarified type Token.src: plain token list, with usual implicit value assignment;
 wenzelm parents: 
61812diff
changeset | 381 | val standard_text = Source (Token.make_src ("standard", Position.none) []);
 | 
| 59498 
50b60f501b05
proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
 wenzelm parents: 
59067diff
changeset | 382 | val this_text = Basic this; | 
| 32193 
c314b4836031
basic method application: avoid Position.setmp_thread_data_seq, which destroys transaction context;
 wenzelm parents: 
32091diff
changeset | 383 | val done_text = Basic (K (SIMPLE_METHOD all_tac)); | 
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 384 | fun sorry_text int = Basic (fn _ => cheating int); | 
| 17110 | 385 | |
| 49846 
8fae089f5a0c
refined Proof.the_finished_goal with more informative error;
 wenzelm parents: 
48992diff
changeset | 386 | fun finish_text (NONE, immed) = Basic (finish immed) | 
| 58005 | 387 | | finish_text (SOME txt, immed) = | 
| 388 | Combinator (no_combinator_info, Then, [txt, Basic (finish immed)]); | |
| 17110 | 389 | |
| 390 | ||
| 391 | (* method definitions *) | |
| 5824 | 392 | |
| 57937 | 393 | fun transfer_methods ctxt = | 
| 57935 
c578f3a37a67
localized method definitions (see also f14c1248d064);
 wenzelm parents: 
57863diff
changeset | 394 | let | 
| 58016 | 395 | val meths0 = get_methods (Context.Theory (Proof_Context.theory_of ctxt)); | 
| 396 | val meths' = Name_Space.merge_tables (meths0, get_methods (Context.Proof ctxt)); | |
| 397 | in Context.proof_map (map_methods (K meths')) ctxt end; | |
| 55742 
a989bdaf8121
modernized Method.check_name/check_source (with reports) vs. strict Method.the_method (without interning nor reports), e.g. relevant for semantic completion;
 wenzelm parents: 
55709diff
changeset | 398 | |
| 59917 
9830c944670f
more uniform "verbose" option to print name space;
 wenzelm parents: 
59914diff
changeset | 399 | fun print_methods verbose ctxt = | 
| 22846 | 400 | let | 
| 58016 | 401 | val meths = get_methods (Context.Proof ctxt); | 
| 50301 | 402 | fun prt_meth (name, (_, "")) = Pretty.mark_str name | 
| 42813 
6c841fa92fa2
optional description for 'attribute_setup' and 'method_setup';
 wenzelm parents: 
42616diff
changeset | 403 | | prt_meth (name, (_, comment)) = | 
| 50301 | 404 | Pretty.block | 
| 405 | (Pretty.mark_str name :: Pretty.str ":" :: Pretty.brk 2 :: Pretty.text comment); | |
| 22846 | 406 | in | 
| 59917 
9830c944670f
more uniform "verbose" option to print name space;
 wenzelm parents: 
59914diff
changeset | 407 | [Pretty.big_list "methods:" (map prt_meth (Name_Space.markup_table verbose ctxt meths))] | 
| 56334 
6b3739fee456
some shortcuts for chunks, which sometimes avoid bulky string output;
 wenzelm parents: 
56278diff
changeset | 408 | |> Pretty.writeln_chunks | 
| 22846 | 409 | end; | 
| 7611 | 410 | |
| 57935 
c578f3a37a67
localized method definitions (see also f14c1248d064);
 wenzelm parents: 
57863diff
changeset | 411 | |
| 
c578f3a37a67
localized method definitions (see also f14c1248d064);
 wenzelm parents: 
57863diff
changeset | 412 | (* define *) | 
| 
c578f3a37a67
localized method definitions (see also f14c1248d064);
 wenzelm parents: 
57863diff
changeset | 413 | |
| 
c578f3a37a67
localized method definitions (see also f14c1248d064);
 wenzelm parents: 
57863diff
changeset | 414 | fun define_global binding meth comment thy = | 
| 
c578f3a37a67
localized method definitions (see also f14c1248d064);
 wenzelm parents: 
57863diff
changeset | 415 | let | 
| 
c578f3a37a67
localized method definitions (see also f14c1248d064);
 wenzelm parents: 
57863diff
changeset | 416 | val context = Context.Theory thy; | 
| 
c578f3a37a67
localized method definitions (see also f14c1248d064);
 wenzelm parents: 
57863diff
changeset | 417 | val (name, meths') = | 
| 58016 | 418 | Name_Space.define context true (binding, (meth, comment)) (get_methods context); | 
| 419 | in (name, Context.the_theory (map_methods (K meths') context)) end; | |
| 57935 
c578f3a37a67
localized method definitions (see also f14c1248d064);
 wenzelm parents: 
57863diff
changeset | 420 | |
| 57941 
57200bdc2aa7
localized command 'method_setup' and 'attribute_setup';
 wenzelm parents: 
57938diff
changeset | 421 | fun define binding meth comment = | 
| 
57200bdc2aa7
localized command 'method_setup' and 'attribute_setup';
 wenzelm parents: 
57938diff
changeset | 422 | Local_Theory.background_theory_result (define_global binding meth comment) | 
| 
57200bdc2aa7
localized command 'method_setup' and 'attribute_setup';
 wenzelm parents: 
57938diff
changeset | 423 | #-> (fn name => | 
| 
57200bdc2aa7
localized command 'method_setup' and 'attribute_setup';
 wenzelm parents: 
57938diff
changeset | 424 | Local_Theory.map_contexts (K transfer_methods) | 
| 58016 | 425 | #> Local_Theory.generic_alias map_methods binding name | 
| 57941 
57200bdc2aa7
localized command 'method_setup' and 'attribute_setup';
 wenzelm parents: 
57938diff
changeset | 426 | #> pair name); | 
| 31304 | 427 | |
| 55997 
9dc5ce83202c
modernized Attrib.check_name/check_src similar to methods (see also a989bdaf8121);
 wenzelm parents: 
55917diff
changeset | 428 | |
| 
9dc5ce83202c
modernized Attrib.check_name/check_src similar to methods (see also a989bdaf8121);
 wenzelm parents: 
55917diff
changeset | 429 | (* check *) | 
| 
9dc5ce83202c
modernized Attrib.check_name/check_src similar to methods (see also a989bdaf8121);
 wenzelm parents: 
55917diff
changeset | 430 | |
| 58016 | 431 | fun check_name ctxt = | 
| 432 | let val context = Context.Proof ctxt | |
| 433 | in #1 o Name_Space.check context (get_methods context) end; | |
| 434 | ||
| 59907 | 435 | fun check_src ctxt = | 
| 61814 
1ca1142e1711
clarified type Token.src: plain token list, with usual implicit value assignment;
 wenzelm parents: 
61812diff
changeset | 436 | #1 o Token.check_src ctxt (get_methods o Context.Proof); | 
| 55997 
9dc5ce83202c
modernized Attrib.check_name/check_src similar to methods (see also a989bdaf8121);
 wenzelm parents: 
55917diff
changeset | 437 | |
| 61814 
1ca1142e1711
clarified type Token.src: plain token list, with usual implicit value assignment;
 wenzelm parents: 
61812diff
changeset | 438 | fun check_text ctxt (Source src) = Source (check_src ctxt src) | 
| 
1ca1142e1711
clarified type Token.src: plain token list, with usual implicit value assignment;
 wenzelm parents: 
61812diff
changeset | 439 | | check_text _ (Basic m) = Basic m | 
| 
1ca1142e1711
clarified type Token.src: plain token list, with usual implicit value assignment;
 wenzelm parents: 
61812diff
changeset | 440 | | check_text ctxt (Combinator (x, y, body)) = Combinator (x, y, map (check_text ctxt) body); | 
| 59914 
d1ddcd8df4e4
proper treatment of internal method name as already checked Token.src;
 wenzelm parents: 
59909diff
changeset | 441 | |
| 61917 
35ec3757d3c1
check and report source at most once, notably in body of "match" method;
 wenzelm parents: 
61843diff
changeset | 442 | fun checked_text (Source src) = Token.checked_src src | 
| 
35ec3757d3c1
check and report source at most once, notably in body of "match" method;
 wenzelm parents: 
61843diff
changeset | 443 | | checked_text (Basic _) = true | 
| 
35ec3757d3c1
check and report source at most once, notably in body of "match" method;
 wenzelm parents: 
61843diff
changeset | 444 | | checked_text (Combinator (_, _, body)) = forall checked_text body; | 
| 
35ec3757d3c1
check and report source at most once, notably in body of "match" method;
 wenzelm parents: 
61843diff
changeset | 445 | |
| 55997 
9dc5ce83202c
modernized Attrib.check_name/check_src similar to methods (see also a989bdaf8121);
 wenzelm parents: 
55917diff
changeset | 446 | |
| 30512 | 447 | (* method setup *) | 
| 448 | ||
| 57935 
c578f3a37a67
localized method definitions (see also f14c1248d064);
 wenzelm parents: 
57863diff
changeset | 449 | fun method_syntax scan src ctxt : method = | 
| 58011 
bc6bced136e5
tuned signature -- moved type src to Token, without aliases;
 wenzelm parents: 
58007diff
changeset | 450 | let val (m, ctxt') = Token.syntax scan src ctxt in m ctxt' end; | 
| 57935 
c578f3a37a67
localized method definitions (see also f14c1248d064);
 wenzelm parents: 
57863diff
changeset | 451 | |
| 
c578f3a37a67
localized method definitions (see also f14c1248d064);
 wenzelm parents: 
57863diff
changeset | 452 | fun setup binding scan comment = define_global binding (method_syntax scan) comment #> snd; | 
| 
c578f3a37a67
localized method definitions (see also f14c1248d064);
 wenzelm parents: 
57863diff
changeset | 453 | fun local_setup binding scan comment = define binding (method_syntax scan) comment #> snd; | 
| 17356 
09afdf37cdb3
added cheating, sorry_text (from skip_proofs.ML);
 wenzelm parents: 
17314diff
changeset | 454 | |
| 58979 
162a4c2e97bc
more careful ML source positions, for improved PIDE markup;
 wenzelm parents: 
58978diff
changeset | 455 | fun method_setup name source comment = | 
| 
162a4c2e97bc
more careful ML source positions, for improved PIDE markup;
 wenzelm parents: 
58978diff
changeset | 456 | ML_Lex.read_source false source | 
| 59064 | 457 | |> ML_Context.expression (Input.range_of source) "parser" | 
| 58991 
92b6f4e68c5a
more careful ML source positions, for improved PIDE markup;
 wenzelm parents: 
58979diff
changeset | 458 | "(Proof.context -> Proof.method) context_parser" | 
| 58979 
162a4c2e97bc
more careful ML source positions, for improved PIDE markup;
 wenzelm parents: 
58978diff
changeset | 459 |     ("Context.map_proof (Method.local_setup " ^ ML_Syntax.atomic (ML_Syntax.make_binding name) ^
 | 
| 
162a4c2e97bc
more careful ML source positions, for improved PIDE markup;
 wenzelm parents: 
58978diff
changeset | 460 | " parser " ^ ML_Syntax.print_string comment ^ ")") | 
| 57941 
57200bdc2aa7
localized command 'method_setup' and 'attribute_setup';
 wenzelm parents: 
57938diff
changeset | 461 | |> Context.proof_map; | 
| 17356 
09afdf37cdb3
added cheating, sorry_text (from skip_proofs.ML);
 wenzelm parents: 
17314diff
changeset | 462 | |
| 
09afdf37cdb3
added cheating, sorry_text (from skip_proofs.ML);
 wenzelm parents: 
17314diff
changeset | 463 | |
| 58006 | 464 | (* prepare methods *) | 
| 465 | ||
| 466 | fun method ctxt = | |
| 58016 | 467 | let val table = get_methods (Context.Proof ctxt) | 
| 58011 
bc6bced136e5
tuned signature -- moved type src to Token, without aliases;
 wenzelm parents: 
58007diff
changeset | 468 | in fn src => #1 (Name_Space.get table (#1 (Token.name_of_src src))) src end; | 
| 58006 | 469 | |
| 59909 | 470 | fun method_closure ctxt src = | 
| 58006 | 471 | let | 
| 61814 
1ca1142e1711
clarified type Token.src: plain token list, with usual implicit value assignment;
 wenzelm parents: 
61812diff
changeset | 472 | val src' = map Token.init_assignable src; | 
| 59909 | 473 | val ctxt' = Context_Position.not_really ctxt; | 
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 474 | val _ = Seq.pull (method ctxt' src' ctxt' [] (ctxt', Goal.protect 0 Drule.dummy_thm)); | 
| 61814 
1ca1142e1711
clarified type Token.src: plain token list, with usual implicit value assignment;
 wenzelm parents: 
61812diff
changeset | 475 | in map Token.closure src' end; | 
| 58006 | 476 | |
| 59909 | 477 | val closure = Config.bool (Config.declare ("Method.closure", @{here}) (K (Config.Bool true)));
 | 
| 478 | ||
| 479 | fun method_cmd ctxt = | |
| 480 | check_src ctxt #> | |
| 481 | Config.get ctxt closure ? method_closure ctxt #> | |
| 482 | method ctxt; | |
| 58006 | 483 | |
| 484 | ||
| 60609 | 485 | (* static vs. runtime state *) | 
| 60553 | 486 | |
| 487 | fun detect_closure_state st = | |
| 488 | (case try Logic.dest_term (Thm.concl_of (perhaps (try Goal.conclude) st)) of | |
| 489 | NONE => false | |
| 490 | | SOME t => Term.is_dummy_pattern t); | |
| 491 | ||
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 492 | fun STATIC test : context_tactic = | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 493 | fn (ctxt, st) => | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 494 | if detect_closure_state st then (test (); Seq.single (Seq.Result (ctxt, st))) else Seq.empty; | 
| 60609 | 495 | |
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 496 | fun RUNTIME (tac: context_tactic) (ctxt, st) = | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 497 | if detect_closure_state st then Seq.empty else tac (ctxt, st); | 
| 60553 | 498 | |
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 499 | fun sleep t = RUNTIME (fn ctxt_st => (OS.Process.sleep t; Seq.single (Seq.Result ctxt_st))); | 
| 60554 | 500 | |
| 60553 | 501 | |
| 58003 
250ecd2502ad
clarifed Method.evaluate: turn text into semantic method (like Basic);
 wenzelm parents: 
58002diff
changeset | 502 | (* evaluate method text *) | 
| 
250ecd2502ad
clarifed Method.evaluate: turn text into semantic method (like Basic);
 wenzelm parents: 
58002diff
changeset | 503 | |
| 
250ecd2502ad
clarifed Method.evaluate: turn text into semantic method (like Basic);
 wenzelm parents: 
58002diff
changeset | 504 | local | 
| 
250ecd2502ad
clarifed Method.evaluate: turn text into semantic method (like Basic);
 wenzelm parents: 
58002diff
changeset | 505 | |
| 
250ecd2502ad
clarifed Method.evaluate: turn text into semantic method (like Basic);
 wenzelm parents: 
58002diff
changeset | 506 | val op THEN = Seq.THEN; | 
| 
250ecd2502ad
clarifed Method.evaluate: turn text into semantic method (like Basic);
 wenzelm parents: 
58002diff
changeset | 507 | |
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 508 | fun BYPASS_CONTEXT (tac: tactic) = | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 509 | fn result => | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 510 | (case result of | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 511 | Seq.Error _ => Seq.single result | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 512 | | Seq.Result (ctxt, st) => tac st |> CONTEXT ctxt); | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 513 | |
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 514 | val preparation = BYPASS_CONTEXT (ALLGOALS Goal.conjunction_tac); | 
| 59660 
49e498cedd02
support structural composition (THEN_ALL_NEW) for proof methods;
 wenzelm parents: 
59498diff
changeset | 515 | |
| 
49e498cedd02
support structural composition (THEN_ALL_NEW) for proof methods;
 wenzelm parents: 
59498diff
changeset | 516 | fun RESTRICT_GOAL i n method = | 
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 517 | BYPASS_CONTEXT (PRIMITIVE (Goal.restrict i n)) THEN | 
| 59660 
49e498cedd02
support structural composition (THEN_ALL_NEW) for proof methods;
 wenzelm parents: 
59498diff
changeset | 518 | method THEN | 
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 519 | BYPASS_CONTEXT (PRIMITIVE (Goal.unrestrict i)); | 
| 59660 
49e498cedd02
support structural composition (THEN_ALL_NEW) for proof methods;
 wenzelm parents: 
59498diff
changeset | 520 | |
| 
49e498cedd02
support structural composition (THEN_ALL_NEW) for proof methods;
 wenzelm parents: 
59498diff
changeset | 521 | fun SELECT_GOAL method i = RESTRICT_GOAL i 1 method; | 
| 
49e498cedd02
support structural composition (THEN_ALL_NEW) for proof methods;
 wenzelm parents: 
59498diff
changeset | 522 | |
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 523 | fun (method1 THEN_ALL_NEW method2) i (result : context_state Seq.result) = | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 524 | (case result of | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 525 | Seq.Error _ => Seq.single result | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 526 | | Seq.Result (_, st) => | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 527 | result |> method1 i | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 528 | |> Seq.maps (fn result' => | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 529 | (case result' of | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 530 | Seq.Error _ => Seq.single result' | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 531 | | Seq.Result (_, st') => | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 532 | result' |> Seq.INTERVAL method2 i (i + Thm.nprems_of st' - Thm.nprems_of st)))) | 
| 58003 
250ecd2502ad
clarifed Method.evaluate: turn text into semantic method (like Basic);
 wenzelm parents: 
58002diff
changeset | 533 | |
| 58005 | 534 | fun COMBINATOR1 comb [meth] = comb meth | 
| 535 | | COMBINATOR1 _ _ = raise Fail "Method combinator requires exactly one argument"; | |
| 536 | ||
| 537 | fun combinator Then = Seq.EVERY | |
| 59660 
49e498cedd02
support structural composition (THEN_ALL_NEW) for proof methods;
 wenzelm parents: 
59498diff
changeset | 538 | | combinator Then_All_New = | 
| 
49e498cedd02
support structural composition (THEN_ALL_NEW) for proof methods;
 wenzelm parents: 
59498diff
changeset | 539 | (fn [] => Seq.single | 
| 
49e498cedd02
support structural composition (THEN_ALL_NEW) for proof methods;
 wenzelm parents: 
59498diff
changeset | 540 | | methods => | 
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 541 | preparation THEN (foldl1 (op THEN_ALL_NEW) (map SELECT_GOAL methods) 1)) | 
| 58005 | 542 | | combinator Orelse = Seq.FIRST | 
| 543 | | combinator Try = COMBINATOR1 Seq.TRY | |
| 544 | | combinator Repeat1 = COMBINATOR1 Seq.REPEAT1 | |
| 59660 
49e498cedd02
support structural composition (THEN_ALL_NEW) for proof methods;
 wenzelm parents: 
59498diff
changeset | 545 | | combinator (Select_Goals n) = | 
| 
49e498cedd02
support structural composition (THEN_ALL_NEW) for proof methods;
 wenzelm parents: 
59498diff
changeset | 546 | COMBINATOR1 (fn method => preparation THEN RESTRICT_GOAL 1 n method); | 
| 58003 
250ecd2502ad
clarifed Method.evaluate: turn text into semantic method (like Basic);
 wenzelm parents: 
58002diff
changeset | 547 | |
| 
250ecd2502ad
clarifed Method.evaluate: turn text into semantic method (like Basic);
 wenzelm parents: 
58002diff
changeset | 548 | in | 
| 
250ecd2502ad
clarifed Method.evaluate: turn text into semantic method (like Basic);
 wenzelm parents: 
58002diff
changeset | 549 | |
| 58007 
671c607fb4af
just one context for Method.evaluate (in contrast to a989bdaf8121, but in accordance to old global situation);
 wenzelm parents: 
58006diff
changeset | 550 | fun evaluate text ctxt = | 
| 58003 
250ecd2502ad
clarifed Method.evaluate: turn text into semantic method (like Basic);
 wenzelm parents: 
58002diff
changeset | 551 | let | 
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 552 | fun eval0 m facts = Seq.single #> Seq.maps_results (m facts); | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 553 | fun eval (Basic m) = eval0 (m ctxt) | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 554 | | eval (Source src) = eval0 (method_cmd ctxt src ctxt) | 
| 58005 | 555 | | eval (Combinator (_, c, txts)) = | 
| 556 | let | |
| 557 | val comb = combinator c; | |
| 58007 
671c607fb4af
just one context for Method.evaluate (in contrast to a989bdaf8121, but in accordance to old global situation);
 wenzelm parents: 
58006diff
changeset | 558 | val meths = map eval txts; | 
| 
671c607fb4af
just one context for Method.evaluate (in contrast to a989bdaf8121, but in accordance to old global situation);
 wenzelm parents: 
58006diff
changeset | 559 | in fn facts => comb (map (fn meth => meth facts) meths) end; | 
| 58003 
250ecd2502ad
clarifed Method.evaluate: turn text into semantic method (like Basic);
 wenzelm parents: 
58002diff
changeset | 560 | val meth = eval text; | 
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 561 | in fn facts => fn ctxt_st => meth facts (Seq.Result ctxt_st) end; | 
| 58003 
250ecd2502ad
clarifed Method.evaluate: turn text into semantic method (like Basic);
 wenzelm parents: 
58002diff
changeset | 562 | |
| 
250ecd2502ad
clarifed Method.evaluate: turn text into semantic method (like Basic);
 wenzelm parents: 
58002diff
changeset | 563 | end; | 
| 
250ecd2502ad
clarifed Method.evaluate: turn text into semantic method (like Basic);
 wenzelm parents: 
58002diff
changeset | 564 | |
| 
250ecd2502ad
clarifed Method.evaluate: turn text into semantic method (like Basic);
 wenzelm parents: 
58002diff
changeset | 565 | |
| 5884 | 566 | |
| 17110 | 567 | (** concrete syntax **) | 
| 5824 | 568 | |
| 58048 
aa6296d09e0e
more explicit Method.modifier with reported position;
 wenzelm parents: 
58034diff
changeset | 569 | (* type modifier *) | 
| 
aa6296d09e0e
more explicit Method.modifier with reported position;
 wenzelm parents: 
58034diff
changeset | 570 | |
| 
aa6296d09e0e
more explicit Method.modifier with reported position;
 wenzelm parents: 
58034diff
changeset | 571 | type modifier = | 
| 
aa6296d09e0e
more explicit Method.modifier with reported position;
 wenzelm parents: 
58034diff
changeset | 572 |   {init: Proof.context -> Proof.context, attribute: attribute, pos: Position.T};
 | 
| 5824 | 573 | |
| 58048 
aa6296d09e0e
more explicit Method.modifier with reported position;
 wenzelm parents: 
58034diff
changeset | 574 | fun modifier attribute pos : modifier = {init = I, attribute = attribute, pos = pos};
 | 
| 
aa6296d09e0e
more explicit Method.modifier with reported position;
 wenzelm parents: 
58034diff
changeset | 575 | |
| 
aa6296d09e0e
more explicit Method.modifier with reported position;
 wenzelm parents: 
58034diff
changeset | 576 | |
| 
aa6296d09e0e
more explicit Method.modifier with reported position;
 wenzelm parents: 
58034diff
changeset | 577 | (* sections *) | 
| 7268 | 578 | |
| 59982 
f402fd001429
option for old section parser (before 2137e60b6f6d) for the sake of Eisbach;
 wenzelm parents: 
59981diff
changeset | 579 | val old_section_parser = | 
| 
f402fd001429
option for old section parser (before 2137e60b6f6d) for the sake of Eisbach;
 wenzelm parents: 
59981diff
changeset | 580 |   Config.bool (Config.declare ("Method.old_section_parser", @{here}) (K (Config.Bool false)));
 | 
| 
f402fd001429
option for old section parser (before 2137e60b6f6d) for the sake of Eisbach;
 wenzelm parents: 
59981diff
changeset | 581 | |
| 
f402fd001429
option for old section parser (before 2137e60b6f6d) for the sake of Eisbach;
 wenzelm parents: 
59981diff
changeset | 582 | local | 
| 
f402fd001429
option for old section parser (before 2137e60b6f6d) for the sake of Eisbach;
 wenzelm parents: 
59981diff
changeset | 583 | |
| 
f402fd001429
option for old section parser (before 2137e60b6f6d) for the sake of Eisbach;
 wenzelm parents: 
59981diff
changeset | 584 | fun thms ss = | 
| 61476 | 585 | Scan.repeats (Scan.unless (Scan.lift (Scan.first ss)) Attrib.multi_thm); | 
| 59982 
f402fd001429
option for old section parser (before 2137e60b6f6d) for the sake of Eisbach;
 wenzelm parents: 
59981diff
changeset | 586 | |
| 
f402fd001429
option for old section parser (before 2137e60b6f6d) for the sake of Eisbach;
 wenzelm parents: 
59981diff
changeset | 587 | fun app {init, attribute, pos = _} ths context =
 | 
| 
f402fd001429
option for old section parser (before 2137e60b6f6d) for the sake of Eisbach;
 wenzelm parents: 
59981diff
changeset | 588 | fold_map (Thm.apply_attribute attribute) ths (Context.map_proof init context); | 
| 
f402fd001429
option for old section parser (before 2137e60b6f6d) for the sake of Eisbach;
 wenzelm parents: 
59981diff
changeset | 589 | |
| 
f402fd001429
option for old section parser (before 2137e60b6f6d) for the sake of Eisbach;
 wenzelm parents: 
59981diff
changeset | 590 | fun section ss = Scan.depend (fn context => (Scan.first ss -- Scan.pass context (thms ss)) :|-- | 
| 
f402fd001429
option for old section parser (before 2137e60b6f6d) for the sake of Eisbach;
 wenzelm parents: 
59981diff
changeset | 591 | (fn (m, ths) => Scan.succeed (swap (app m ths context)))); | 
| 
f402fd001429
option for old section parser (before 2137e60b6f6d) for the sake of Eisbach;
 wenzelm parents: 
59981diff
changeset | 592 | |
| 
f402fd001429
option for old section parser (before 2137e60b6f6d) for the sake of Eisbach;
 wenzelm parents: 
59981diff
changeset | 593 | in | 
| 
f402fd001429
option for old section parser (before 2137e60b6f6d) for the sake of Eisbach;
 wenzelm parents: 
59981diff
changeset | 594 | |
| 
f402fd001429
option for old section parser (before 2137e60b6f6d) for the sake of Eisbach;
 wenzelm parents: 
59981diff
changeset | 595 | fun old_sections ss = Scan.repeat (section ss) >> K (); | 
| 
f402fd001429
option for old section parser (before 2137e60b6f6d) for the sake of Eisbach;
 wenzelm parents: 
59981diff
changeset | 596 | |
| 
f402fd001429
option for old section parser (before 2137e60b6f6d) for the sake of Eisbach;
 wenzelm parents: 
59981diff
changeset | 597 | end; | 
| 
f402fd001429
option for old section parser (before 2137e60b6f6d) for the sake of Eisbach;
 wenzelm parents: 
59981diff
changeset | 598 | |
| 7268 | 599 | local | 
| 600 | ||
| 58048 
aa6296d09e0e
more explicit Method.modifier with reported position;
 wenzelm parents: 
58034diff
changeset | 601 | fun sect (modifier : modifier parser) = Scan.depend (fn context => | 
| 62969 | 602 | Scan.ahead Parse.not_eof -- Scan.trace modifier -- Scan.repeat (Scan.unless modifier Parse.thm) | 
| 60211 | 603 |     >> (fn ((tok0, ({init, attribute, pos}, modifier_toks)), xthms) =>
 | 
| 58029 
2137e60b6f6d
clarified Method.section: explicit declaration with static closure;
 wenzelm parents: 
58026diff
changeset | 604 | let | 
| 58068 | 605 | val decl = | 
| 60211 | 606 | (case Token.get_value tok0 of | 
| 58068 | 607 | SOME (Token.Declaration decl) => decl | 
| 608 | | _ => | |
| 609 | let | |
| 610 | val ctxt = Context.proof_of context; | |
| 61814 
1ca1142e1711
clarified type Token.src: plain token list, with usual implicit value assignment;
 wenzelm parents: 
61812diff
changeset | 611 | val prep_att = Attrib.check_src ctxt #> map (Token.assign NONE); | 
| 58068 | 612 | val thms = | 
| 613 | map (fn (a, bs) => (Proof_Context.get_fact ctxt a, map prep_att bs)) xthms; | |
| 614 | val facts = | |
| 615 | Attrib.partial_evaluation ctxt [((Binding.name "dummy", []), thms)] | |
| 616 | |> map (fn (_, bs) => ((Binding.empty, [Attrib.internal (K attribute)]), bs)); | |
| 60211 | 617 | |
| 58068 | 618 | fun decl phi = | 
| 619 | Context.mapping I init #> | |
| 620 | Attrib.generic_notes "" (Attrib.transform_facts phi facts) #> snd; | |
| 60211 | 621 | |
| 60212 | 622 | val modifier_report = | 
| 62795 
063d2f23cdf6
removed redundant Position.set_range -- already done in Position.range;
 wenzelm parents: 
61917diff
changeset | 623 | (#1 (Token.range_of modifier_toks), | 
| 60212 | 624 | Markup.properties (Position.def_properties_of pos) | 
| 625 | (Markup.entity Markup.method_modifierN "")); | |
| 60211 | 626 | val _ = | 
| 60212 | 627 | Context_Position.reports ctxt (modifier_report :: Token.reports_of_value tok0); | 
| 60211 | 628 | val _ = Token.assign (SOME (Token.Declaration decl)) tok0; | 
| 58068 | 629 | in decl end); | 
| 630 | in (Morphism.form decl context, decl) end)); | |
| 5824 | 631 | |
| 30540 | 632 | in | 
| 633 | ||
| 59982 
f402fd001429
option for old section parser (before 2137e60b6f6d) for the sake of Eisbach;
 wenzelm parents: 
59981diff
changeset | 634 | fun sections ss = | 
| 
f402fd001429
option for old section parser (before 2137e60b6f6d) for the sake of Eisbach;
 wenzelm parents: 
59981diff
changeset | 635 | Args.context :|-- (fn ctxt => | 
| 
f402fd001429
option for old section parser (before 2137e60b6f6d) for the sake of Eisbach;
 wenzelm parents: 
59981diff
changeset | 636 | if Config.get ctxt old_section_parser then old_sections ss | 
| 
f402fd001429
option for old section parser (before 2137e60b6f6d) for the sake of Eisbach;
 wenzelm parents: 
59981diff
changeset | 637 | else Scan.repeat (sect (Scan.first ss)) >> K ()); | 
| 5824 | 638 | |
| 7268 | 639 | end; | 
| 640 | ||
| 5824 | 641 | |
| 30515 | 642 | (* extra rule methods *) | 
| 643 | ||
| 54742 
7a86358a3c0b
proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
 wenzelm parents: 
53171diff
changeset | 644 | fun xrule_meth meth = | 
| 36950 | 645 | Scan.lift (Scan.optional (Args.parens Parse.nat) 0) -- Attrib.thms >> | 
| 54742 
7a86358a3c0b
proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
 wenzelm parents: 
53171diff
changeset | 646 | (fn (n, ths) => fn ctxt => meth ctxt n ths); | 
| 30515 | 647 | |
| 648 | ||
| 55761 
213b9811f59f
method language markup, e.g. relevant to prevent outer keyword completion;
 wenzelm parents: 
55742diff
changeset | 649 | (* text range *) | 
| 
213b9811f59f
method language markup, e.g. relevant to prevent outer keyword completion;
 wenzelm parents: 
55742diff
changeset | 650 | |
| 
213b9811f59f
method language markup, e.g. relevant to prevent outer keyword completion;
 wenzelm parents: 
55742diff
changeset | 651 | type text_range = text * Position.range; | 
| 
213b9811f59f
method language markup, e.g. relevant to prevent outer keyword completion;
 wenzelm parents: 
55742diff
changeset | 652 | |
| 
213b9811f59f
method language markup, e.g. relevant to prevent outer keyword completion;
 wenzelm parents: 
55742diff
changeset | 653 | fun text NONE = NONE | 
| 
213b9811f59f
method language markup, e.g. relevant to prevent outer keyword completion;
 wenzelm parents: 
55742diff
changeset | 654 | | text (SOME (txt, _)) = SOME txt; | 
| 
213b9811f59f
method language markup, e.g. relevant to prevent outer keyword completion;
 wenzelm parents: 
55742diff
changeset | 655 | |
| 
213b9811f59f
method language markup, e.g. relevant to prevent outer keyword completion;
 wenzelm parents: 
55742diff
changeset | 656 | fun position NONE = Position.none | 
| 
213b9811f59f
method language markup, e.g. relevant to prevent outer keyword completion;
 wenzelm parents: 
55742diff
changeset | 657 | | position (SOME (_, (pos, _))) = pos; | 
| 
213b9811f59f
method language markup, e.g. relevant to prevent outer keyword completion;
 wenzelm parents: 
55742diff
changeset | 658 | |
| 
213b9811f59f
method language markup, e.g. relevant to prevent outer keyword completion;
 wenzelm parents: 
55742diff
changeset | 659 | |
| 55795 | 660 | (* reports *) | 
| 661 | ||
| 662 | local | |
| 663 | ||
| 664 | fun keyword_positions (Source _) = [] | |
| 665 | | keyword_positions (Basic _) = [] | |
| 58005 | 666 |   | keyword_positions (Combinator (Combinator_Info {keywords}, _, texts)) =
 | 
| 667 | keywords @ maps keyword_positions texts; | |
| 55795 | 668 | |
| 669 | in | |
| 670 | ||
| 671 | fun reports_of ((text, (pos, _)): text_range) = | |
| 672 | (pos, Markup.language_method) :: | |
| 55917 
5438ed05e1c9
special treatment of method combinators like Args.$$$ keywords, although parsed via Parse.$$$;
 wenzelm parents: 
55828diff
changeset | 673 | maps (fn p => map (pair p) (Markup.keyword3 :: Completion.suppress_abbrevs "")) | 
| 
5438ed05e1c9
special treatment of method combinators like Args.$$$ keywords, although parsed via Parse.$$$;
 wenzelm parents: 
55828diff
changeset | 674 | (keyword_positions text); | 
| 55795 | 675 | |
| 676 | val report = Position.reports o reports_of; | |
| 677 | ||
| 678 | end; | |
| 679 | ||
| 680 | ||
| 59666 | 681 | (* parser *) | 
| 682 | ||
| 683 | local | |
| 27813 
96fbe385a0d0
unified Args.T with OuterLex.token, renamed some operations;
 wenzelm parents: 
27751diff
changeset | 684 | |
| 
96fbe385a0d0
unified Args.T with OuterLex.token, renamed some operations;
 wenzelm parents: 
27751diff
changeset | 685 | fun is_symid_meth s = | 
| 36959 
f5417836dbea
renamed structure OuterLex to Token and type token to Token.T, keeping legacy aliases for some time;
 wenzelm parents: 
36950diff
changeset | 686 | s <> "|" andalso s <> "?" andalso s <> "+" andalso Token.ident_or_symbolic s; | 
| 27813 
96fbe385a0d0
unified Args.T with OuterLex.token, renamed some operations;
 wenzelm parents: 
27751diff
changeset | 687 | |
| 61814 
1ca1142e1711
clarified type Token.src: plain token list, with usual implicit value assignment;
 wenzelm parents: 
61812diff
changeset | 688 | in | 
| 
1ca1142e1711
clarified type Token.src: plain token list, with usual implicit value assignment;
 wenzelm parents: 
61812diff
changeset | 689 | |
| 
1ca1142e1711
clarified type Token.src: plain token list, with usual implicit value assignment;
 wenzelm parents: 
61812diff
changeset | 690 | fun parser pri = | 
| 59666 | 691 | let | 
| 62969 | 692 | val meth_name = Parse.token Parse.name; | 
| 27813 
96fbe385a0d0
unified Args.T with OuterLex.token, renamed some operations;
 wenzelm parents: 
27751diff
changeset | 693 | |
| 59666 | 694 | fun meth5 x = | 
| 61814 
1ca1142e1711
clarified type Token.src: plain token list, with usual implicit value assignment;
 wenzelm parents: 
61812diff
changeset | 695 | (meth_name >> (Source o single) || | 
| 59666 | 696 | Scan.ahead Parse.cartouche |-- Parse.not_eof >> (fn tok => | 
| 61814 
1ca1142e1711
clarified type Token.src: plain token list, with usual implicit value assignment;
 wenzelm parents: 
61812diff
changeset | 697 |         Source (Token.make_src ("cartouche", Position.none) [tok])) ||
 | 
| 59666 | 698 |       Parse.$$$ "(" |-- Parse.!!! (meth0 --| Parse.$$$ ")")) x
 | 
| 699 | and meth4 x = | |
| 700 | (meth5 -- Parse.position (Parse.$$$ "?") | |
| 701 | >> (fn (m, (_, pos)) => Combinator (combinator_info [pos], Try, [m])) || | |
| 702 | meth5 -- Parse.position (Parse.$$$ "+") | |
| 703 | >> (fn (m, (_, pos)) => Combinator (combinator_info [pos], Repeat1, [m])) || | |
| 59914 
d1ddcd8df4e4
proper treatment of internal method name as already checked Token.src;
 wenzelm parents: 
59909diff
changeset | 704 | meth5 -- (Parse.position (Parse.$$$ "[") -- | 
| 
d1ddcd8df4e4
proper treatment of internal method name as already checked Token.src;
 wenzelm parents: 
59909diff
changeset | 705 | Scan.optional Parse.nat 1 -- Parse.position (Parse.$$$ "]")) | 
| 59666 | 706 | >> (fn (m, (((_, pos1), n), (_, pos2))) => | 
| 707 | Combinator (combinator_info [pos1, pos2], Select_Goals n, [m])) || | |
| 708 | meth5) x | |
| 709 | and meth3 x = | |
| 61814 
1ca1142e1711
clarified type Token.src: plain token list, with usual implicit value assignment;
 wenzelm parents: 
61812diff
changeset | 710 | (meth_name ::: Parse.args1 is_symid_meth >> Source || | 
| 59666 | 711 | meth4) x | 
| 712 | and meth2 x = | |
| 713 | (Parse.enum1_positions "," meth3 | |
| 714 | >> (fn ([m], _) => m | (ms, ps) => Combinator (combinator_info ps, Then, ms))) x | |
| 715 | and meth1 x = | |
| 716 | (Parse.enum1_positions ";" meth2 | |
| 717 | >> (fn ([m], _) => m | (ms, ps) => Combinator (combinator_info ps, Then_All_New, ms))) x | |
| 718 | and meth0 x = | |
| 719 | (Parse.enum1_positions "|" meth1 | |
| 720 | >> (fn ([m], _) => m | (ms, ps) => Combinator (combinator_info ps, Orelse, ms))) x; | |
| 59981 | 721 | |
| 722 | val meth = | |
| 723 | nth [meth0, meth1, meth2, meth3, meth4, meth5] pri | |
| 724 |         handle General.Subscript => raise Fail ("Bad method parser priority " ^ string_of_int pri);
 | |
| 725 | in Scan.trace meth >> (fn (m, toks) => (m, Token.range_of toks)) end; | |
| 27813 
96fbe385a0d0
unified Args.T with OuterLex.token, renamed some operations;
 wenzelm parents: 
27751diff
changeset | 726 | |
| 59981 | 727 | val parse = parser 4; | 
| 49866 | 728 | |
| 55761 
213b9811f59f
method language markup, e.g. relevant to prevent outer keyword completion;
 wenzelm parents: 
55742diff
changeset | 729 | end; | 
| 27813 
96fbe385a0d0
unified Args.T with OuterLex.token, renamed some operations;
 wenzelm parents: 
27751diff
changeset | 730 | |
| 
96fbe385a0d0
unified Args.T with OuterLex.token, renamed some operations;
 wenzelm parents: 
27751diff
changeset | 731 | |
| 18708 | 732 | (* theory setup *) | 
| 5824 | 733 | |
| 53171 | 734 | val _ = Theory.setup | 
| 56204 | 735 |  (setup @{binding fail} (Scan.succeed (K fail)) "force failure" #>
 | 
| 736 |   setup @{binding succeed} (Scan.succeed (K succeed)) "succeed" #>
 | |
| 60554 | 737 |   setup @{binding sleep} (Scan.lift Parse.real >> (fn s => fn _ => fn _ => sleep (seconds s)))
 | 
| 738 | "succeed after delay (in seconds)" #> | |
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 739 |   setup @{binding "-"} (Scan.succeed (K (SIMPLE_METHOD all_tac)))
 | 
| 60578 | 740 | "insert current facts, nothing else" #> | 
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 741 |   setup @{binding goal_cases} (Scan.lift (Scan.repeat Args.name_token) >> (fn names => fn _ =>
 | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 742 | CONTEXT_METHOD (fn _ => fn (ctxt, st) => | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 743 | (case drop (Thm.nprems_of st) names of | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 744 | [] => NONE | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 745 | | bad => | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 746 | if detect_closure_state st then NONE | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 747 | else | 
| 61843 | 748 |             SOME (fn () => ("Excessive case name(s): " ^ commas_quote (map Token.content_of bad) ^
 | 
| 62795 
063d2f23cdf6
removed redundant Position.set_range -- already done in Position.range;
 wenzelm parents: 
61917diff
changeset | 749 | Position.here (#1 (Token.range_of bad))))) | 
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 750 | |> (fn SOME msg => Seq.single (Seq.Error msg) | 
| 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 751 | | NONE => goal_cases_tac (map Token.content_of names) (ctxt, st))))) | 
| 61164 | 752 | "bind cases for goals" #> | 
| 56204 | 753 |   setup @{binding insert} (Attrib.thms >> (K o insert))
 | 
| 60578 | 754 | "insert theorems, ignoring facts" #> | 
| 58957 | 755 |   setup @{binding intro} (Attrib.thms >> (fn ths => fn ctxt => intro ctxt ths))
 | 
| 30515 | 756 | "repeatedly apply introduction rules" #> | 
| 58957 | 757 |   setup @{binding elim} (Attrib.thms >> (fn ths => fn ctxt => elim ctxt ths))
 | 
| 30515 | 758 | "repeatedly apply elimination rules" #> | 
| 56204 | 759 |   setup @{binding unfold} (Attrib.thms >> unfold_meth) "unfold definitions" #>
 | 
| 760 |   setup @{binding fold} (Attrib.thms >> fold_meth) "fold definitions" #>
 | |
| 761 |   setup @{binding atomize} (Scan.lift (Args.mode "full") >> atomize)
 | |
| 30515 | 762 | "present local premises as object-level statements" #> | 
| 56204 | 763 |   setup @{binding rule} (Attrib.thms >> (fn ths => fn ctxt => some_rule ctxt ths))
 | 
| 54742 
7a86358a3c0b
proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
 wenzelm parents: 
53171diff
changeset | 764 | "apply some intro/elim rule" #> | 
| 56204 | 765 |   setup @{binding erule} (xrule_meth erule) "apply rule in elimination manner (improper)" #>
 | 
| 766 |   setup @{binding drule} (xrule_meth drule) "apply rule in destruct manner (improper)" #>
 | |
| 767 |   setup @{binding frule} (xrule_meth frule) "apply rule in forward manner (improper)" #>
 | |
| 59498 
50b60f501b05
proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
 wenzelm parents: 
59067diff
changeset | 768 |   setup @{binding this} (Scan.succeed this) "apply current facts as rules" #>
 | 
| 56204 | 769 |   setup @{binding fact} (Attrib.thms >> fact) "composition by facts from context" #>
 | 
| 770 |   setup @{binding assumption} (Scan.succeed assumption)
 | |
| 30515 | 771 | "proof by assumption, preferring facts" #> | 
| 56204 | 772 |   setup @{binding rename_tac} (Args.goal_spec -- Scan.lift (Scan.repeat1 Args.name) >>
 | 
| 52732 | 773 | (fn (quant, xs) => K (SIMPLE_METHOD'' quant (rename_tac xs)))) | 
| 30515 | 774 | "rename parameters of goal" #> | 
| 56204 | 775 |   setup @{binding rotate_tac} (Args.goal_spec -- Scan.lift (Scan.optional Parse.int 1) >>
 | 
| 52732 | 776 | (fn (quant, i) => K (SIMPLE_METHOD'' quant (rotate_tac i)))) | 
| 30515 | 777 | "rotate assumptions of goal" #> | 
| 58018 
beb4b7c0bb30
proper static closure of ML tactic -- data slot is used twice, for ML compiler and transformed declaration;
 wenzelm parents: 
58016diff
changeset | 778 |   setup @{binding tactic} (parse_tactic >> (K o METHOD))
 | 
| 30515 | 779 | "ML tactic as proof method" #> | 
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 780 |   setup @{binding raw_tactic} (parse_tactic >> (fn tac => fn _ => CONTEXT_TACTIC o tac))
 | 
| 53171 | 781 | "ML tactic as raw proof method"); | 
| 5824 | 782 | |
| 783 | ||
| 16145 | 784 | (*final declarations of this structure!*) | 
| 785 | val unfold = unfold_meth; | |
| 786 | val fold = fold_meth; | |
| 787 | ||
| 5824 | 788 | end; | 
| 789 | ||
| 61834 | 790 | structure Basic_Method: BASIC_METHOD = Method; | 
| 791 | open Basic_Method; | |
| 792 | ||
| 61841 
4d3527b94f2a
more general types Proof.method / context_tactic;
 wenzelm parents: 
61834diff
changeset | 793 | val CONTEXT_METHOD = Method.CONTEXT_METHOD; | 
| 30508 
958cc116d03b
tuned Method exports: non-pervasive type method (cf. Proof.method), pervasive METHOD combinators;
 wenzelm parents: 
30466diff
changeset | 794 | val METHOD = Method.METHOD; | 
| 
958cc116d03b
tuned Method exports: non-pervasive type method (cf. Proof.method), pervasive METHOD combinators;
 wenzelm parents: 
30466diff
changeset | 795 | val SIMPLE_METHOD = Method.SIMPLE_METHOD; | 
| 
958cc116d03b
tuned Method exports: non-pervasive type method (cf. Proof.method), pervasive METHOD combinators;
 wenzelm parents: 
30466diff
changeset | 796 | val SIMPLE_METHOD' = Method.SIMPLE_METHOD'; | 
| 
958cc116d03b
tuned Method exports: non-pervasive type method (cf. Proof.method), pervasive METHOD combinators;
 wenzelm parents: 
30466diff
changeset | 797 | val SIMPLE_METHOD'' = Method.SIMPLE_METHOD''; |