17 val mk_coinduct_tac: Proof.context -> thm list -> int -> int list -> thm -> thm list -> |
17 val mk_coinduct_tac: Proof.context -> thm list -> int -> int list -> thm -> thm list -> |
18 thm list -> thm list -> thm list -> thm list -> thm list list -> thm list list list -> |
18 thm list -> thm list -> thm list -> thm list -> thm list list -> thm list list list -> |
19 thm list list list -> tactic |
19 thm list list list -> tactic |
20 val mk_corec_tac: thm list -> thm list -> thm -> thm -> thm -> thm -> Proof.context -> tactic |
20 val mk_corec_tac: thm list -> thm list -> thm -> thm -> thm -> thm -> Proof.context -> tactic |
21 val mk_corec_disc_iff_tac: thm list -> thm list -> thm list -> Proof.context -> tactic |
21 val mk_corec_disc_iff_tac: thm list -> thm list -> thm list -> Proof.context -> tactic |
|
22 val mk_corec_transfer_tac: Proof.context -> cterm list -> cterm list -> thm list -> thm list -> |
|
23 thm list -> thm list -> thm list -> ''a list -> ''a list list -> ''a list list list list -> |
|
24 ''a list list list list -> tactic |
22 val mk_ctor_iff_dtor_tac: Proof.context -> ctyp option list -> cterm -> cterm -> thm -> thm -> |
25 val mk_ctor_iff_dtor_tac: Proof.context -> ctyp option list -> cterm -> cterm -> thm -> thm -> |
23 tactic |
26 tactic |
24 val mk_ctr_transfer_tac: Proof.context -> thm list -> thm list -> tactic |
27 val mk_ctr_transfer_tac: Proof.context -> thm list -> thm list -> tactic |
25 val mk_disc_transfer_tac: thm -> thm -> thm list -> tactic |
28 val mk_disc_transfer_tac: thm -> thm -> thm list -> tactic |
26 val mk_exhaust_tac: Proof.context -> int -> thm list -> thm -> thm -> tactic |
29 val mk_exhaust_tac: Proof.context -> int -> thm list -> thm -> thm -> tactic |
212 HEADGOAL case_split_tac THEN unfold_thms_tac ctxt [corec_thm] THEN |
215 HEADGOAL case_split_tac THEN unfold_thms_tac ctxt [corec_thm] THEN |
213 HEADGOAL (asm_simp_tac (ss_only basic_simp_thms ctxt)) THEN |
216 HEADGOAL (asm_simp_tac (ss_only basic_simp_thms ctxt)) THEN |
214 (if is_refl disc then all_tac else HEADGOAL (rtac disc))) |
217 (if is_refl disc then all_tac else HEADGOAL (rtac disc))) |
215 (map rtac case_splits' @ [K all_tac]) corecs discs); |
218 (map rtac case_splits' @ [K all_tac]) corecs discs); |
216 |
219 |
|
220 fun mk_corec_transfer_tac ctxt actives passives type_definitions corec_defs dtor_corec_transfers |
|
221 rel_pre_T_defs rel_eqs pgs pss qssss gssss = |
|
222 let |
|
223 val num_pgs = length pgs; |
|
224 fun prem_no_of x = 1 + find_index (curry (op =) x) pgs; |
|
225 |
|
226 val Inl_Inr_Pair_tac = REPEAT_DETERM o |
|
227 (rtac (mk_rel_funDN 1 @{thm Inl_transfer}) ORELSE' |
|
228 rtac (mk_rel_funDN 1 @{thm Inr_transfer}) ORELSE' |
|
229 rtac (mk_rel_funDN 2 @{thm Pair_transfer})); |
|
230 |
|
231 fun mk_unfold_If_tac total pos = |
|
232 HEADGOAL (Inl_Inr_Pair_tac THEN' |
|
233 rtac (mk_rel_funDN 3 @{thm If_transfer}) THEN' |
|
234 select_prem_tac total (dtac asm_rl) pos THEN' |
|
235 dtac rel_funD THEN' atac THEN' atac); |
|
236 |
|
237 fun mk_unfold_Inl_Inr_Pair_tac total pos = |
|
238 HEADGOAL (Inl_Inr_Pair_tac THEN' |
|
239 select_prem_tac total (dtac asm_rl) pos THEN' |
|
240 dtac rel_funD THEN' atac THEN' atac); |
|
241 |
|
242 fun mk_unfold_arg_tac qs gs = |
|
243 EVERY (map (mk_unfold_If_tac num_pgs o prem_no_of) qs) THEN |
|
244 EVERY (map (mk_unfold_Inl_Inr_Pair_tac num_pgs o prem_no_of) gs); |
|
245 |
|
246 fun mk_unfold_ctr_tac type_definition qss gss = |
|
247 HEADGOAL (rtac (mk_rel_funDN 1 (@{thm Abs_transfer} OF |
|
248 [type_definition, type_definition])) THEN' Inl_Inr_Pair_tac) THEN |
|
249 (case (qss, gss) of |
|
250 ([], []) => HEADGOAL (rtac refl) |
|
251 | _ => EVERY (map2 mk_unfold_arg_tac qss gss)); |
|
252 |
|
253 fun mk_unfold_type_tac type_definition ps qsss gsss = |
|
254 let |
|
255 val p_tacs = map (mk_unfold_If_tac num_pgs o prem_no_of) ps; |
|
256 val qg_tacs = map2 (mk_unfold_ctr_tac type_definition) qsss gsss; |
|
257 fun mk_unfold_ty [] [qg_tac] = qg_tac |
|
258 | mk_unfold_ty (p_tac :: p_tacs) (qg_tac :: qg_tacs) = |
|
259 p_tac THEN qg_tac THEN mk_unfold_ty p_tacs qg_tacs |
|
260 in |
|
261 HEADGOAL (rtac rel_funI) THEN mk_unfold_ty p_tacs qg_tacs |
|
262 end; |
|
263 |
|
264 fun mk_unfold_corec_type_tac dtor_corec_transfer corec_def = |
|
265 let |
|
266 val active :: actives' = actives; |
|
267 val dtor_corec_transfer' = cterm_instantiate_pos |
|
268 (SOME active :: map SOME passives @ map SOME actives') dtor_corec_transfer; |
|
269 in |
|
270 HEADGOAL Goal.conjunction_tac THEN |
|
271 REPEAT_DETERM (HEADGOAL (rtac rel_funI)) THEN |
|
272 unfold_thms_tac ctxt [corec_def] THEN |
|
273 HEADGOAL (etac (mk_rel_funDN_rotated (1 + length actives) dtor_corec_transfer')) THEN |
|
274 unfold_thms_tac ctxt (rel_pre_T_defs @ rel_eqs) |
|
275 end; |
|
276 |
|
277 fun mk_unfold_prop_tac dtor_corec_transfer corec_def = |
|
278 mk_unfold_corec_type_tac dtor_corec_transfer corec_def THEN |
|
279 EVERY (map4 mk_unfold_type_tac type_definitions pss qssss gssss); |
|
280 in |
|
281 HEADGOAL Goal.conjunction_tac THEN |
|
282 EVERY (map2 mk_unfold_prop_tac dtor_corec_transfers corec_defs) |
|
283 end; |
|
284 |
217 fun solve_prem_prem_tac ctxt = |
285 fun solve_prem_prem_tac ctxt = |
218 REPEAT o (eresolve_tac @{thms bexE rev_bexI} ORELSE' rtac @{thm rev_bexI[OF UNIV_I]} ORELSE' |
286 REPEAT o (eresolve_tac @{thms bexE rev_bexI} ORELSE' rtac @{thm rev_bexI[OF UNIV_I]} ORELSE' |
219 hyp_subst_tac ctxt ORELSE' resolve_tac @{thms disjI1 disjI2}) THEN' |
287 hyp_subst_tac ctxt ORELSE' resolve_tac @{thms disjI1 disjI2}) THEN' |
220 (rtac refl ORELSE' atac ORELSE' rtac @{thm singletonI}); |
288 (rtac refl ORELSE' atac ORELSE' rtac @{thm singletonI}); |
221 |
289 |