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