author | wenzelm |
Thu, 14 Dec 2000 19:36:48 +0100 | |
changeset 10671 | ac6b3b671198 |
parent 10542 | 92cd56dfc17e |
child 10728 | 13cb6d29f7ff |
permissions | -rw-r--r-- |
6442 | 1 |
(* Title: HOL/Tools/induct_method.ML |
2 |
ID: $Id$ |
|
3 |
Author: Markus Wenzel, TU Muenchen |
|
9230 | 4 |
License: GPL (GNU GENERAL PUBLIC LICENSE) |
6442 | 5 |
|
8376 | 6 |
Proof by cases and induction on types and sets. |
6442 | 7 |
*) |
8 |
||
9 |
signature INDUCT_METHOD = |
|
10 |
sig |
|
8431 | 11 |
val vars_of: term -> term list |
8695 | 12 |
val concls_of: thm -> term list |
9299 | 13 |
val simp_case_tac: bool -> simpset -> int -> tactic |
6442 | 14 |
val setup: (theory -> theory) list |
15 |
end; |
|
16 |
||
17 |
structure InductMethod: INDUCT_METHOD = |
|
18 |
struct |
|
19 |
||
8337 | 20 |
|
10409 | 21 |
(** theory context references **) |
22 |
||
23 |
val inductive_atomize = thms "inductive_atomize"; |
|
10439
be2dc95dfe98
inductive_rulify2 accomodates malformed induction rules;
wenzelm
parents:
10409
diff
changeset
|
24 |
val inductive_rulify1 = thms "inductive_rulify1"; |
be2dc95dfe98
inductive_rulify2 accomodates malformed induction rules;
wenzelm
parents:
10409
diff
changeset
|
25 |
val inductive_rulify2 = thms "inductive_rulify2"; |
10409 | 26 |
|
27 |
||
28 |
||
8308 | 29 |
(** misc utils **) |
8278 | 30 |
|
9597 | 31 |
(* align lists *) |
32 |
||
33 |
fun align_left msg xs ys = |
|
34 |
let val m = length xs and n = length ys |
|
35 |
in if m < n then error msg else (Library.take (n, xs) ~~ ys) end; |
|
36 |
||
37 |
fun align_right msg xs ys = |
|
38 |
let val m = length xs and n = length ys |
|
39 |
in if m < n then error msg else (Library.drop (m - n, xs) ~~ ys) end; |
|
40 |
||
41 |
||
8695 | 42 |
(* thms and terms *) |
43 |
||
44 |
val concls_of = HOLogic.dest_conj o HOLogic.dest_Trueprop o Thm.concl_of; |
|
8344 | 45 |
|
8278 | 46 |
fun vars_of tm = (*ordered left-to-right, preferring right!*) |
8308 | 47 |
Term.foldl_aterms (fn (ts, t as Var _) => t :: ts | (ts, _) => ts) ([], tm) |
8278 | 48 |
|> Library.distinct |> rev; |
49 |
||
8308 | 50 |
fun type_name t = |
51 |
#1 (Term.dest_Type (Term.type_of t)) |
|
9597 | 52 |
handle TYPE _ => raise TERM ("Type of term argument is too general", [t]); |
53 |
||
10409 | 54 |
fun prep_inst align cert f (tm, ts) = |
9597 | 55 |
let |
10409 | 56 |
fun prep_var (x, Some t) = |
57 |
let |
|
58 |
val cx = cert x; |
|
59 |
val {T = xT, sign, ...} = Thm.rep_cterm cx; |
|
60 |
val orig_ct = cert t; |
|
61 |
val ct = f orig_ct; |
|
62 |
in |
|
63 |
if Sign.typ_instance sign (#T (Thm.rep_cterm ct), xT) then Some (cx, ct) |
|
64 |
else error (Pretty.string_of (Pretty.block |
|
65 |
[Pretty.str "Ill-typed instantiation:", Pretty.fbrk, |
|
66 |
Display.pretty_cterm orig_ct, Pretty.str " ::", Pretty.brk 1, |
|
67 |
Display.pretty_ctyp (#T (Thm.crep_cterm orig_ct))])) |
|
68 |
end |
|
9597 | 69 |
| prep_var (_, None) = None; |
70 |
in |
|
71 |
align "Rule has fewer variables than instantiations given" (vars_of tm) ts |
|
72 |
|> mapfilter prep_var |
|
73 |
end; |
|
8278 | 74 |
|
75 |
||
8337 | 76 |
(* simplifying cases rules *) |
77 |
||
78 |
local |
|
79 |
||
80 |
(*delete needless equality assumptions*) |
|
10409 | 81 |
val refl_thin = prove_goal HOL.thy "!!P. a = a ==> P ==> P" (fn _ => [assume_tac 1]); |
8337 | 82 |
val elim_rls = [asm_rl, FalseE, refl_thin, conjE, exE, Pair_inject]; |
83 |
val elim_tac = REPEAT o Tactic.eresolve_tac elim_rls; |
|
84 |
||
85 |
in |
|
86 |
||
9299 | 87 |
fun simp_case_tac solved ss i = |
88 |
EVERY' [elim_tac, asm_full_simp_tac ss, elim_tac, REPEAT o bound_hyp_subst_tac] i |
|
89 |
THEN_MAYBE (if solved then no_tac else all_tac); |
|
8337 | 90 |
|
91 |
end; |
|
92 |
||
93 |
||
10542
92cd56dfc17e
resolveq_cases_tac moved here from Pure/Isar/method.ML;
wenzelm
parents:
10527
diff
changeset
|
94 |
(* resolution and cases *) |
92cd56dfc17e
resolveq_cases_tac moved here from Pure/Isar/method.ML;
wenzelm
parents:
10527
diff
changeset
|
95 |
|
92cd56dfc17e
resolveq_cases_tac moved here from Pure/Isar/method.ML;
wenzelm
parents:
10527
diff
changeset
|
96 |
local |
92cd56dfc17e
resolveq_cases_tac moved here from Pure/Isar/method.ML;
wenzelm
parents:
10527
diff
changeset
|
97 |
|
92cd56dfc17e
resolveq_cases_tac moved here from Pure/Isar/method.ML;
wenzelm
parents:
10527
diff
changeset
|
98 |
fun gen_resolveq_tac tac rules i st = |
92cd56dfc17e
resolveq_cases_tac moved here from Pure/Isar/method.ML;
wenzelm
parents:
10527
diff
changeset
|
99 |
Seq.flat (Seq.map (fn rule => tac rule i st) rules); |
92cd56dfc17e
resolveq_cases_tac moved here from Pure/Isar/method.ML;
wenzelm
parents:
10527
diff
changeset
|
100 |
|
92cd56dfc17e
resolveq_cases_tac moved here from Pure/Isar/method.ML;
wenzelm
parents:
10527
diff
changeset
|
101 |
in |
92cd56dfc17e
resolveq_cases_tac moved here from Pure/Isar/method.ML;
wenzelm
parents:
10527
diff
changeset
|
102 |
|
92cd56dfc17e
resolveq_cases_tac moved here from Pure/Isar/method.ML;
wenzelm
parents:
10527
diff
changeset
|
103 |
fun resolveq_cases_tac make tac = gen_resolveq_tac (fn (rule, (cases, facts)) => fn i => fn st => |
92cd56dfc17e
resolveq_cases_tac moved here from Pure/Isar/method.ML;
wenzelm
parents:
10527
diff
changeset
|
104 |
Seq.map (rpair (make rule cases)) |
92cd56dfc17e
resolveq_cases_tac moved here from Pure/Isar/method.ML;
wenzelm
parents:
10527
diff
changeset
|
105 |
((Method.insert_tac facts THEN' tac THEN' Tactic.rtac rule) i st)); |
92cd56dfc17e
resolveq_cases_tac moved here from Pure/Isar/method.ML;
wenzelm
parents:
10527
diff
changeset
|
106 |
|
92cd56dfc17e
resolveq_cases_tac moved here from Pure/Isar/method.ML;
wenzelm
parents:
10527
diff
changeset
|
107 |
end; |
92cd56dfc17e
resolveq_cases_tac moved here from Pure/Isar/method.ML;
wenzelm
parents:
10527
diff
changeset
|
108 |
|
92cd56dfc17e
resolveq_cases_tac moved here from Pure/Isar/method.ML;
wenzelm
parents:
10527
diff
changeset
|
109 |
|
8278 | 110 |
|
111 |
(** cases method **) |
|
112 |
||
8308 | 113 |
(* |
114 |
rule selection: |
|
115 |
cases - classical case split |
|
8376 | 116 |
cases t - datatype exhaustion |
117 |
<x:A> cases ... - set elimination |
|
8451 | 118 |
... cases ... R - explicit rule |
8308 | 119 |
*) |
8278 | 120 |
|
9066 | 121 |
val case_split = RuleCases.name ["True", "False"] case_split_thm; |
122 |
||
8344 | 123 |
local |
124 |
||
9299 | 125 |
fun simplified_cases ctxt cases thm = |
126 |
let |
|
127 |
val nprems = Thm.nprems_of thm; |
|
128 |
val opt_cases = |
|
129 |
Library.replicate (nprems - Int.min (nprems, length cases)) None @ |
|
130 |
map Some (Library.take (nprems, cases)); |
|
8337 | 131 |
|
9299 | 132 |
val tac = simp_case_tac true (Simplifier.get_local_simpset ctxt); |
133 |
fun simp ((i, c), (th, cs)) = |
|
134 |
(case try (Tactic.rule_by_tactic (tac i)) th of |
|
9313 | 135 |
None => (th, c :: cs) |
136 |
| Some th' => (th', None :: cs)); |
|
9299 | 137 |
|
138 |
val (thm', opt_cases') = foldr simp (1 upto Thm.nprems_of thm ~~ opt_cases, (thm, [])); |
|
139 |
in (thm', mapfilter I opt_cases') end; |
|
140 |
||
9624
de254f375477
changed 'opaque' option to 'open' (opaque is default);
wenzelm
parents:
9597
diff
changeset
|
141 |
fun cases_tac (ctxt, ((simplified, open_parms), args)) facts = |
8308 | 142 |
let |
143 |
val sg = ProofContext.sign_of ctxt; |
|
144 |
val cert = Thm.cterm_of sg; |
|
8278 | 145 |
|
9597 | 146 |
fun inst_rule insts thm = |
9914 | 147 |
(align_left "Rule has fewer premises than arguments given" (Thm.prems_of thm) insts |
10409 | 148 |
|> (flat o map (prep_inst align_left cert I)) |
9597 | 149 |
|> Drule.cterm_instantiate) thm; |
6442 | 150 |
|
8376 | 151 |
fun find_cases th = |
10271
45b996639c45
split over two files: induct_attrib.ML, induct_method.ML;
wenzelm
parents:
10013
diff
changeset
|
152 |
NetRules.may_unify (#2 (InductAttrib.get_cases ctxt)) |
8376 | 153 |
(Logic.strip_assums_concl (#prop (Thm.rep_thm th))); |
154 |
||
155 |
val rules = |
|
8344 | 156 |
(case (args, facts) of |
9597 | 157 |
(([], None), []) => [RuleCases.add case_split] |
158 |
| ((insts, None), []) => |
|
159 |
let |
|
160 |
val name = type_name (hd (flat (map (mapfilter I) insts))) |
|
161 |
handle Library.LIST _ => error "Unable to figure out type cases rule" |
|
162 |
in |
|
10271
45b996639c45
split over two files: induct_attrib.ML, induct_method.ML;
wenzelm
parents:
10013
diff
changeset
|
163 |
(case InductAttrib.lookup_casesT ctxt name of |
8308 | 164 |
None => error ("No cases rule for type: " ^ quote name) |
9597 | 165 |
| Some thm => [(inst_rule insts thm, RuleCases.get thm)]) |
8308 | 166 |
end |
9597 | 167 |
| (([], None), th :: _) => map (RuleCases.add o #2) (find_cases th) |
168 |
| ((insts, None), th :: _) => |
|
9299 | 169 |
(case find_cases th of (*may instantiate first rule only!*) |
9597 | 170 |
(_, thm) :: _ => [(inst_rule insts thm, RuleCases.get thm)] |
8376 | 171 |
| [] => []) |
9597 | 172 |
| (([], Some thm), _) => [RuleCases.add thm] |
173 |
| ((insts, Some thm), _) => [(inst_rule insts thm, RuleCases.get thm)]); |
|
8376 | 174 |
|
9299 | 175 |
val cond_simp = if simplified then simplified_cases ctxt else rpair; |
176 |
||
10527 | 177 |
fun prep_rule (thm, (cases, n)) = Seq.map (apsnd (rpair (drop (n, facts))) o cond_simp cases) |
178 |
(Method.multi_resolves (take (n, facts)) [thm]); |
|
10409 | 179 |
in |
10542
92cd56dfc17e
resolveq_cases_tac moved here from Pure/Isar/method.ML;
wenzelm
parents:
10527
diff
changeset
|
180 |
resolveq_cases_tac (RuleCases.make open_parms) (K all_tac) |
10409 | 181 |
(Seq.flat (Seq.map prep_rule (Seq.of_list rules))) |
182 |
end; |
|
8278 | 183 |
|
8344 | 184 |
in |
185 |
||
8671 | 186 |
val cases_meth = Method.METHOD_CASES o (HEADGOAL oo cases_tac); |
8278 | 187 |
|
8344 | 188 |
end; |
189 |
||
8278 | 190 |
|
191 |
||
192 |
(** induct method **) |
|
193 |
||
8308 | 194 |
(* |
195 |
rule selection: |
|
8376 | 196 |
induct x - datatype induction |
197 |
<x:A> induct ... - set induction |
|
8451 | 198 |
... induct ... R - explicit rule |
8308 | 199 |
*) |
8278 | 200 |
|
8344 | 201 |
local |
202 |
||
10409 | 203 |
fun rewrite_cterm rews = |
204 |
#2 o Thm.dest_comb o #prop o Thm.crep_thm o Simplifier.full_rewrite (HOL_basic_ss addsimps rews); |
|
205 |
||
206 |
fun drop_Trueprop ct = |
|
207 |
let |
|
208 |
fun drop (Abs (x, T, t)) = Abs (x, T, drop t) |
|
209 |
| drop t = HOLogic.dest_Trueprop t; |
|
210 |
val {sign, t, ...} = Thm.rep_cterm ct; |
|
211 |
in Thm.cterm_of sign (drop t) handle TERM _ => ct end; |
|
212 |
||
213 |
val atomize_cterm = drop_Trueprop o rewrite_cterm inductive_atomize; |
|
10439
be2dc95dfe98
inductive_rulify2 accomodates malformed induction rules;
wenzelm
parents:
10409
diff
changeset
|
214 |
val atomize_tac = Tactic.rewrite_goal_tac inductive_atomize; |
be2dc95dfe98
inductive_rulify2 accomodates malformed induction rules;
wenzelm
parents:
10409
diff
changeset
|
215 |
val rulify_cterm = rewrite_cterm inductive_rulify2 o rewrite_cterm inductive_rulify1; |
be2dc95dfe98
inductive_rulify2 accomodates malformed induction rules;
wenzelm
parents:
10409
diff
changeset
|
216 |
|
be2dc95dfe98
inductive_rulify2 accomodates malformed induction rules;
wenzelm
parents:
10409
diff
changeset
|
217 |
val rulify_tac = |
be2dc95dfe98
inductive_rulify2 accomodates malformed induction rules;
wenzelm
parents:
10409
diff
changeset
|
218 |
Tactic.rewrite_goal_tac inductive_rulify1 THEN' |
be2dc95dfe98
inductive_rulify2 accomodates malformed induction rules;
wenzelm
parents:
10409
diff
changeset
|
219 |
Tactic.rewrite_goal_tac inductive_rulify2 THEN' |
be2dc95dfe98
inductive_rulify2 accomodates malformed induction rules;
wenzelm
parents:
10409
diff
changeset
|
220 |
Proof.norm_hhf_tac; |
10409 | 221 |
|
222 |
fun rulify_cases cert = |
|
223 |
map (apsnd (apsnd (map (Thm.term_of o rulify_cterm o cert)))) ooo RuleCases.make; |
|
224 |
||
10455 | 225 |
val weak_strip_tac = REPEAT o Tactic.match_tac [impI, allI, ballI]; |
226 |
||
10409 | 227 |
|
8376 | 228 |
infix 1 THEN_ALL_NEW_CASES; |
229 |
||
230 |
fun (tac1 THEN_ALL_NEW_CASES tac2) i st = |
|
231 |
st |> Seq.THEN (tac1 i, (fn (st', cases) => |
|
8540 | 232 |
Seq.map (rpair cases) (Seq.INTERVAL tac2 i (i + nprems_of st' - nprems_of st) st'))); |
8376 | 233 |
|
234 |
||
8330 | 235 |
fun induct_rule ctxt t = |
236 |
let val name = type_name t in |
|
10271
45b996639c45
split over two files: induct_attrib.ML, induct_method.ML;
wenzelm
parents:
10013
diff
changeset
|
237 |
(case InductAttrib.lookup_inductT ctxt name of |
8330 | 238 |
None => error ("No induct rule for type: " ^ quote name) |
8332 | 239 |
| Some thm => (name, thm)) |
8330 | 240 |
end; |
241 |
||
8332 | 242 |
fun join_rules [(_, thm)] = thm |
8330 | 243 |
| join_rules raw_thms = |
244 |
let |
|
8332 | 245 |
val thms = (map (apsnd Drule.freeze_all) raw_thms); |
246 |
fun eq_prems ((_, th1), (_, th2)) = |
|
247 |
Term.aconvs (Thm.prems_of th1, Thm.prems_of th2); |
|
8330 | 248 |
in |
8332 | 249 |
(case Library.gen_distinct eq_prems thms of |
250 |
[(_, thm)] => |
|
251 |
let |
|
252 |
val cprems = Drule.cprems_of thm; |
|
253 |
val asms = map Thm.assume cprems; |
|
254 |
fun strip (_, th) = Drule.implies_elim_list th asms; |
|
255 |
in |
|
256 |
foldr1 (fn (th, th') => [th, th'] MRS conjI) (map strip thms) |
|
257 |
|> Drule.implies_intr_list cprems |
|
258 |
|> Drule.standard |
|
259 |
end |
|
260 |
| [] => error "No rule given" |
|
261 |
| bads => error ("Incompatible rules for " ^ commas_quote (map #1 bads))) |
|
8330 | 262 |
end; |
263 |
||
8376 | 264 |
|
9624
de254f375477
changed 'opaque' option to 'open' (opaque is default);
wenzelm
parents:
9597
diff
changeset
|
265 |
fun induct_tac (ctxt, ((stripped, open_parms), args)) facts = |
8308 | 266 |
let |
267 |
val sg = ProofContext.sign_of ctxt; |
|
268 |
val cert = Thm.cterm_of sg; |
|
269 |
||
270 |
fun inst_rule insts thm = |
|
9597 | 271 |
(align_right "Rule has fewer conclusions than arguments given" (concls_of thm) insts |
10409 | 272 |
|> (flat o map (prep_inst align_right cert atomize_cterm)) |
9597 | 273 |
|> Drule.cterm_instantiate) thm; |
8278 | 274 |
|
8376 | 275 |
fun find_induct th = |
10271
45b996639c45
split over two files: induct_attrib.ML, induct_method.ML;
wenzelm
parents:
10013
diff
changeset
|
276 |
NetRules.may_unify (#2 (InductAttrib.get_induct ctxt)) |
8376 | 277 |
(Logic.strip_assums_concl (#prop (Thm.rep_thm th))); |
278 |
||
279 |
val rules = |
|
8308 | 280 |
(case (args, facts) of |
8540 | 281 |
(([], None), []) => [] |
8376 | 282 |
| ((insts, None), []) => |
8695 | 283 |
let val thms = map (induct_rule ctxt o last_elem o mapfilter I) insts |
284 |
handle Library.LIST _ => error "Unable to figure out type induction rule" |
|
8376 | 285 |
in [(inst_rule insts (join_rules thms), RuleCases.get (#2 (hd thms)))] end |
286 |
| (([], None), th :: _) => map (RuleCases.add o #2) (find_induct th) |
|
287 |
| ((insts, None), th :: _) => |
|
9299 | 288 |
(case find_induct th of (*may instantiate first rule only!*) |
289 |
(_, thm) :: _ => [(inst_rule insts thm, RuleCases.get thm)] |
|
8376 | 290 |
| [] => []) |
291 |
| (([], Some thm), _) => [RuleCases.add thm] |
|
292 |
| ((insts, Some thm), _) => [(inst_rule insts thm, RuleCases.get thm)]); |
|
293 |
||
10527 | 294 |
fun prep_rule (thm, (cases, n)) = |
295 |
Seq.map (rpair (cases, drop (n, facts))) (Method.multi_resolves (take (n, facts)) [thm]); |
|
10542
92cd56dfc17e
resolveq_cases_tac moved here from Pure/Isar/method.ML;
wenzelm
parents:
10527
diff
changeset
|
296 |
val tac = resolveq_cases_tac (rulify_cases cert open_parms) atomize_tac |
9624
de254f375477
changed 'opaque' option to 'open' (opaque is default);
wenzelm
parents:
9597
diff
changeset
|
297 |
(Seq.flat (Seq.map prep_rule (Seq.of_list rules))); |
8344 | 298 |
in |
10542
92cd56dfc17e
resolveq_cases_tac moved here from Pure/Isar/method.ML;
wenzelm
parents:
10527
diff
changeset
|
299 |
tac THEN_ALL_NEW_CASES (rulify_tac THEN' (if stripped then weak_strip_tac else K all_tac)) |
8344 | 300 |
end; |
301 |
||
302 |
in |
|
8278 | 303 |
|
8671 | 304 |
val induct_meth = Method.METHOD_CASES o (HEADGOAL oo induct_tac); |
8278 | 305 |
|
8344 | 306 |
end; |
307 |
||
8278 | 308 |
|
309 |
||
310 |
(** concrete syntax **) |
|
311 |
||
8337 | 312 |
val simplifiedN = "simplified"; |
8344 | 313 |
val strippedN = "stripped"; |
9624
de254f375477
changed 'opaque' option to 'open' (opaque is default);
wenzelm
parents:
9597
diff
changeset
|
314 |
val openN = "open"; |
8308 | 315 |
val ruleN = "rule"; |
316 |
||
8278 | 317 |
local |
6442 | 318 |
|
8308 | 319 |
fun err k get name = |
320 |
(case get name of Some x => x |
|
321 |
| None => error ("No rule for " ^ k ^ " " ^ quote name)); |
|
6442 | 322 |
|
10271
45b996639c45
split over two files: induct_attrib.ML, induct_method.ML;
wenzelm
parents:
10013
diff
changeset
|
323 |
fun spec k = (Args.$$$ k -- Args.colon) |-- Args.!!! Args.name; |
45b996639c45
split over two files: induct_attrib.ML, induct_method.ML;
wenzelm
parents:
10013
diff
changeset
|
324 |
|
8308 | 325 |
fun rule get_type get_set = |
326 |
Scan.depend (fn ctxt => |
|
327 |
let val sg = ProofContext.sign_of ctxt in |
|
10271
45b996639c45
split over two files: induct_attrib.ML, induct_method.ML;
wenzelm
parents:
10013
diff
changeset
|
328 |
spec InductAttrib.typeN >> (err InductAttrib.typeN (get_type ctxt) o Sign.intern_tycon sg) || |
45b996639c45
split over two files: induct_attrib.ML, induct_method.ML;
wenzelm
parents:
10013
diff
changeset
|
329 |
spec InductAttrib.setN >> (err InductAttrib.setN (get_set ctxt) o Sign.intern_const sg) |
8308 | 330 |
end >> pair ctxt) || |
8815 | 331 |
Scan.lift (Args.$$$ ruleN -- Args.colon) |-- Attrib.local_thm; |
6442 | 332 |
|
10271
45b996639c45
split over two files: induct_attrib.ML, induct_method.ML;
wenzelm
parents:
10013
diff
changeset
|
333 |
val cases_rule = rule InductAttrib.lookup_casesT InductAttrib.lookup_casesS; |
45b996639c45
split over two files: induct_attrib.ML, induct_method.ML;
wenzelm
parents:
10013
diff
changeset
|
334 |
val induct_rule = rule InductAttrib.lookup_inductT InductAttrib.lookup_inductS; |
6442 | 335 |
|
10271
45b996639c45
split over two files: induct_attrib.ML, induct_method.ML;
wenzelm
parents:
10013
diff
changeset
|
336 |
val kind = |
45b996639c45
split over two files: induct_attrib.ML, induct_method.ML;
wenzelm
parents:
10013
diff
changeset
|
337 |
(Args.$$$ InductAttrib.typeN || Args.$$$ InductAttrib.setN || Args.$$$ ruleN) -- Args.colon; |
8308 | 338 |
val term = Scan.unless (Scan.lift kind) Args.local_term; |
8695 | 339 |
val term_dummy = Scan.unless (Scan.lift kind) |
340 |
(Scan.lift (Args.$$$ "_") >> K None || Args.local_term >> Some); |
|
6446 | 341 |
|
9597 | 342 |
val instss = Args.and_list (Scan.repeat1 term_dummy); |
343 |
||
8278 | 344 |
in |
345 |
||
9299 | 346 |
val cases_args = Method.syntax |
9803 | 347 |
(Args.mode simplifiedN -- Args.mode openN -- (instss -- Scan.option cases_rule)); |
9299 | 348 |
|
8695 | 349 |
val induct_args = Method.syntax |
9803 | 350 |
(Args.mode strippedN -- Args.mode openN -- (instss -- Scan.option induct_rule)); |
8278 | 351 |
|
352 |
end; |
|
6446 | 353 |
|
354 |
||
6442 | 355 |
|
8278 | 356 |
(** theory setup **) |
6446 | 357 |
|
8278 | 358 |
val setup = |
10271
45b996639c45
split over two files: induct_attrib.ML, induct_method.ML;
wenzelm
parents:
10013
diff
changeset
|
359 |
[Method.add_methods |
45b996639c45
split over two files: induct_attrib.ML, induct_method.ML;
wenzelm
parents:
10013
diff
changeset
|
360 |
[(InductAttrib.casesN, cases_meth oo cases_args, "case analysis on types or sets"), |
45b996639c45
split over two files: induct_attrib.ML, induct_method.ML;
wenzelm
parents:
10013
diff
changeset
|
361 |
(InductAttrib.inductN, induct_meth oo induct_args, "induction on types or sets")], |
9066 | 362 |
(#1 o PureThy.add_thms [(("case_split", case_split), [])])]; |
6442 | 363 |
|
364 |
end; |