2 Author: Markus Wenzel, TU Muenchen |
2 Author: Markus Wenzel, TU Muenchen |
3 |
3 |
4 Annotations and local contexts of rules. |
4 Annotations and local contexts of rules. |
5 *) |
5 *) |
6 |
6 |
7 infix 1 THEN_ALL_NEW_CASES; |
|
8 |
|
9 signature BASIC_RULE_CASES = |
|
10 sig |
|
11 type cases |
|
12 type cases_state = cases * thm |
|
13 type cases_tactic = thm -> cases_state Seq.seq |
|
14 val CASES: cases -> tactic -> cases_tactic |
|
15 val EMPTY_CASES: tactic -> cases_tactic |
|
16 val SUBGOAL_CASES: (term * int -> cases_tactic) -> int -> cases_tactic |
|
17 val THEN_ALL_NEW_CASES: (int -> cases_tactic) * (int -> tactic) -> int -> cases_tactic |
|
18 end |
|
19 |
|
20 signature RULE_CASES = |
7 signature RULE_CASES = |
21 sig |
8 sig |
22 include BASIC_RULE_CASES |
|
23 datatype T = Case of |
9 datatype T = Case of |
24 {fixes: (binding * typ) list, |
10 {fixes: (binding * typ) list, |
25 assumes: (string * term list) list, |
11 assumes: (string * term list) list, |
26 binds: (indexname * term option) list, |
12 binds: (indexname * term option) list, |
27 cases: (string * T) list} |
13 cases: (string * T) list} |
|
14 type cases = (string * T option) list |
28 val case_hypsN: string |
15 val case_hypsN: string |
29 val strip_params: term -> (string * typ) list |
16 val strip_params: term -> (string * typ) list |
30 type info = ((string * string list) * string list) list |
17 type info = ((string * string list) * string list) list |
31 val make_common: Proof.context -> term -> info -> cases |
18 val make_common: Proof.context -> term -> info -> cases |
32 val make_nested: Proof.context -> term -> term -> info -> cases |
19 val make_nested: Proof.context -> term -> term -> info -> cases |
182 |
169 |
183 end; |
170 end; |
184 |
171 |
185 |
172 |
186 |
173 |
187 (** tactics with cases **) |
|
188 |
|
189 type cases_state = cases * thm; |
|
190 type cases_tactic = thm -> cases_state Seq.seq; |
|
191 |
|
192 fun CASES cases tac st = Seq.map (pair cases) (tac st); |
|
193 fun EMPTY_CASES tac = CASES [] tac; |
|
194 |
|
195 fun SUBGOAL_CASES tac i st = |
|
196 (case try Logic.nth_prem (i, Thm.prop_of st) of |
|
197 SOME goal => tac (goal, i) st |
|
198 | NONE => Seq.empty); |
|
199 |
|
200 fun (tac1 THEN_ALL_NEW_CASES tac2) i st = |
|
201 st |> tac1 i |> Seq.maps (fn (cases, st') => |
|
202 CASES cases (Seq.INTERVAL tac2 i (i + Thm.nprems_of st' - Thm.nprems_of st)) st'); |
|
203 |
|
204 |
|
205 |
|
206 (** annotations and operations on rules **) |
174 (** annotations and operations on rules **) |
207 |
175 |
208 (* consume facts *) |
176 (* consume facts *) |
209 |
177 |
210 local |
178 local |