203 |
203 |
204 fun prep_var (Var (ixn, _), SOME x) = SOME (ixn, x) |
204 fun prep_var (Var (ixn, _), SOME x) = SOME (ixn, x) |
205 | prep_var _ = NONE; |
205 | prep_var _ = NONE; |
206 |
206 |
207 fun prep_inst (concl, xs) = (*exception Library.UnequalLengths*) |
207 fun prep_inst (concl, xs) = (*exception Library.UnequalLengths*) |
208 let val vs = InductAttrib.vars_of concl |
208 let val vs = Induct.vars_of concl |
209 in map_filter prep_var (Library.drop (length vs - length xs, vs) ~~ xs) end; |
209 in map_filter prep_var (Library.drop (length vs - length xs, vs) ~~ xs) end; |
210 |
210 |
211 in |
211 in |
212 |
212 |
213 fun gen_induct_tac inst_tac (varss, opt_rule) i state = |
213 fun gen_induct_tac inst_tac (varss, opt_rule) i state = |
338 fun add_cases_induct infos induction thy = |
338 fun add_cases_induct infos induction thy = |
339 let |
339 let |
340 val inducts = ProjectRule.projections (ProofContext.init thy) induction; |
340 val inducts = ProjectRule.projections (ProofContext.init thy) induction; |
341 |
341 |
342 fun named_rules (name, {index, exhaustion, ...}: datatype_info) = |
342 fun named_rules (name, {index, exhaustion, ...}: datatype_info) = |
343 [(("", nth inducts index), [InductAttrib.induct_type name]), |
343 [(("", nth inducts index), [Induct.induct_type name]), |
344 (("", exhaustion), [InductAttrib.cases_type name])]; |
344 (("", exhaustion), [Induct.cases_type name])]; |
345 fun unnamed_rule i = |
345 fun unnamed_rule i = |
346 (("", nth inducts i), [PureThy.kind_internal, InductAttrib.induct_type ""]); |
346 (("", nth inducts i), [PureThy.kind_internal, Induct.induct_type ""]); |
347 in |
347 in |
348 thy |> PureThy.add_thms |
348 thy |> PureThy.add_thms |
349 (maps named_rules infos @ |
349 (maps named_rules infos @ |
350 map unnamed_rule (length infos upto length inducts - 1)) |> snd |
350 map unnamed_rule (length infos upto length inducts - 1)) |> snd |
351 |> PureThy.add_thmss [(("inducts", inducts), [])] |> snd |
351 |> PureThy.add_thmss [(("inducts", inducts), [])] |> snd |