180 val dis_apps = let fun one_dis c (con,args)= pg axs_dis_def |
180 val dis_apps = let fun one_dis c (con,args)= pg axs_dis_def |
181 (lift_defined %: (nonlazy args, |
181 (lift_defined %: (nonlazy args, |
182 (mk_trp((%%:(dis_name c))`(con_app con args) === |
182 (mk_trp((%%:(dis_name c))`(con_app con args) === |
183 %%:(if con=c then "TT" else "FF"))))) [ |
183 %%:(if con=c then "TT" else "FF"))))) [ |
184 asm_simp_tac (HOLCF_ss addsimps when_rews) 1]; |
184 asm_simp_tac (HOLCF_ss addsimps when_rews) 1]; |
185 in flat(map (fn (c,_) => map (one_dis c) cons) cons) end; |
185 in List.concat(map (fn (c,_) => map (one_dis c) cons) cons) end; |
186 val dis_defins = map (fn (con,args) => pg [] (defined(%:x_name) ==> |
186 val dis_defins = map (fn (con,args) => pg [] (defined(%:x_name) ==> |
187 defined(%%:(dis_name con)`%x_name)) [ |
187 defined(%%:(dis_name con)`%x_name)) [ |
188 rtac casedist 1, |
188 rtac casedist 1, |
189 contr_tac 1, |
189 contr_tac 1, |
190 DETERM_UNTIL_SOLVED (CHANGED(asm_simp_tac |
190 DETERM_UNTIL_SOLVED (CHANGED(asm_simp_tac |
191 (HOLCF_ss addsimps dis_apps) 1))]) cons; |
191 (HOLCF_ss addsimps dis_apps) 1))]) cons; |
192 in dis_stricts @ dis_defins @ dis_apps end; |
192 in dis_stricts @ dis_defins @ dis_apps end; |
193 |
193 |
194 val con_stricts = flat(map (fn (con,args) => map (fn vn => |
194 val con_stricts = List.concat(map (fn (con,args) => map (fn vn => |
195 pg (axs_con_def) |
195 pg (axs_con_def) |
196 (mk_trp(con_app2 con (fn arg => if vname arg = vn |
196 (mk_trp(con_app2 con (fn arg => if vname arg = vn |
197 then UU else %# arg) args === UU))[ |
197 then UU else %# arg) args === UU))[ |
198 asm_simp_tac (HOLCF_ss addsimps [abs_strict]) 1] |
198 asm_simp_tac (HOLCF_ss addsimps [abs_strict]) 1] |
199 ) (nonlazy args)) cons); |
199 ) (nonlazy args)) cons); |
205 asm_simp_tac (HOLCF_ss addsimps dis_rews) 1] )) cons; |
205 asm_simp_tac (HOLCF_ss addsimps dis_rews) 1] )) cons; |
206 val con_rews = con_stricts @ con_defins; |
206 val con_rews = con_stricts @ con_defins; |
207 |
207 |
208 val sel_stricts = let fun one_sel sel = pg axs_sel_def (mk_trp(strict(%%:sel))) [ |
208 val sel_stricts = let fun one_sel sel = pg axs_sel_def (mk_trp(strict(%%:sel))) [ |
209 simp_tac (HOLCF_ss addsimps when_rews) 1]; |
209 simp_tac (HOLCF_ss addsimps when_rews) 1]; |
210 in flat(map (fn (_,args) =>map (fn arg => one_sel (sel_of arg)) args) cons) end; |
210 in List.concat(map (fn (_,args) =>map (fn arg => one_sel (sel_of arg)) args) cons) end; |
211 val sel_apps = let fun one_sel c n sel = map (fn (con,args) => |
211 val sel_apps = let fun one_sel c n sel = map (fn (con,args) => |
212 let val nlas = nonlazy args; |
212 let val nlas = nonlazy args; |
213 val vns = map vname args; |
213 val vns = map vname args; |
214 in pg axs_sel_def (lift_defined %: |
214 in pg axs_sel_def (lift_defined %: |
215 (filter (fn v => con=c andalso (v<>nth_elem(n,vns))) nlas, |
215 (List.filter (fn v => con=c andalso (v<>List.nth(vns,n))) nlas, |
216 mk_trp((%%:sel)`(con_app con args) === |
216 mk_trp((%%:sel)`(con_app con args) === |
217 (if con=c then %:(nth_elem(n,vns)) else UU)))) |
217 (if con=c then %:(List.nth(vns,n)) else UU)))) |
218 ( (if con=c then [] |
218 ( (if con=c then [] |
219 else map(case_UU_tac(when_rews@con_stricts)1) nlas) |
219 else map(case_UU_tac(when_rews@con_stricts)1) nlas) |
220 @(if con=c andalso ((nth_elem(n,vns)) mem nlas) |
220 @(if con=c andalso ((List.nth(vns,n)) mem nlas) |
221 then[case_UU_tac (when_rews @ con_stricts) 1 |
221 then[case_UU_tac (when_rews @ con_stricts) 1 |
222 (nth_elem(n,vns))] else []) |
222 (List.nth(vns,n))] else []) |
223 @ [asm_simp_tac(HOLCF_ss addsimps when_rews)1])end) cons; |
223 @ [asm_simp_tac(HOLCF_ss addsimps when_rews)1])end) cons; |
224 in flat(map (fn (c,args) => |
224 in List.concat(map (fn (c,args) => |
225 flat(mapn (fn n => fn arg => one_sel c n (sel_of arg)) 0 args)) cons) end; |
225 List.concat(mapn (fn n => fn arg => one_sel c n (sel_of arg)) 0 args)) cons) end; |
226 val sel_defins = if length cons=1 then map (fn arg => pg [](defined(%:x_name)==> |
226 val sel_defins = if length cons=1 then map (fn arg => pg [](defined(%:x_name)==> |
227 defined(%%:(sel_of arg)`%x_name)) [ |
227 defined(%%:(sel_of arg)`%x_name)) [ |
228 rtac casedist 1, |
228 rtac casedist 1, |
229 contr_tac 1, |
229 contr_tac 1, |
230 DETERM_UNTIL_SOLVED (CHANGED(asm_simp_tac |
230 DETERM_UNTIL_SOLVED (CHANGED(asm_simp_tac |
247 (args2, variantlist(map vname args2,map vname args1))) |
247 (args2, variantlist(map vname args2,map vname args1))) |
248 in [dist arg1 arg2, dist arg2 arg1] end; |
248 in [dist arg1 arg2, dist arg2 arg1] end; |
249 fun distincts [] = [] |
249 fun distincts [] = [] |
250 | distincts (c::cs) = (map (distinct c) cs) :: distincts cs; |
250 | distincts (c::cs) = (map (distinct c) cs) :: distincts cs; |
251 in distincts cons end; |
251 in distincts cons end; |
252 val dist_les = flat (flat distincts_le); |
252 val dist_les = List.concat (List.concat distincts_le); |
253 val dist_eqs = let |
253 val dist_eqs = let |
254 fun distinct (_,args1) ((_,args2),leqs) = let |
254 fun distinct (_,args1) ((_,args2),leqs) = let |
255 val (le1,le2) = (hd leqs, hd(tl leqs)); |
255 val (le1,le2) = (hd leqs, hd(tl leqs)); |
256 val (eq1,eq2) = (le1 RS dist_eqI, le2 RS dist_eqI) in |
256 val (eq1,eq2) = (le1 RS dist_eqI, le2 RS dist_eqI) in |
257 if nonlazy args1 = [] then [eq1, eq1 RS not_sym] else |
257 if nonlazy args1 = [] then [eq1, eq1 RS not_sym] else |
271 in pg [] (mk_trp (rel(con_app con largs,con_app con rargs)) ===> |
271 in pg [] (mk_trp (rel(con_app con largs,con_app con rargs)) ===> |
272 lift_defined %: ((nonlazy largs),lift_defined %: ((nonlazy rargs), |
272 lift_defined %: ((nonlazy largs),lift_defined %: ((nonlazy rargs), |
273 mk_trp (foldr' mk_conj |
273 mk_trp (foldr' mk_conj |
274 (ListPair.map rel |
274 (ListPair.map rel |
275 (map %# largs, map %# rargs)))))) end; |
275 (map %# largs, map %# rargs)))))) end; |
276 val cons' = filter (fn (_,args) => args<>[]) cons; |
276 val cons' = List.filter (fn (_,args) => args<>[]) cons; |
277 in |
277 in |
278 val inverts = map (fn (con,args) => |
278 val inverts = map (fn (con,args) => |
279 pgterm (op <<) con args (flat(map (fn arg => [ |
279 pgterm (op <<) con args (List.concat(map (fn arg => [ |
280 TRY(rtac conjI 1), |
280 TRY(rtac conjI 1), |
281 dres_inst_tac [("fo",sel_of arg)] monofun_cfun_arg 1, |
281 dres_inst_tac [("fo",sel_of arg)] monofun_cfun_arg 1, |
282 asm_full_simp_tac (HOLCF_ss addsimps sel_apps) 1] |
282 asm_full_simp_tac (HOLCF_ss addsimps sel_apps) 1] |
283 ) args))) cons'; |
283 ) args))) cons'; |
284 val injects = map (fn ((con,args),inv_thm) => |
284 val injects = map (fn ((con,args),inv_thm) => |
300 (lift_defined %: (nonlazy_rec args, |
300 (lift_defined %: (nonlazy_rec args, |
301 mk_trp(dc_copy`%"f"`(con_app con args) === |
301 mk_trp(dc_copy`%"f"`(con_app con args) === |
302 (con_app2 con (app_rec_arg (cproj (%:"f") eqs)) args)))) |
302 (con_app2 con (app_rec_arg (cproj (%:"f") eqs)) args)))) |
303 (map (case_UU_tac (abs_strict::when_strict::con_stricts) |
303 (map (case_UU_tac (abs_strict::when_strict::con_stricts) |
304 1 o vname) |
304 1 o vname) |
305 (filter (fn a => not (is_rec a orelse is_lazy a)) args) |
305 (List.filter (fn a => not (is_rec a orelse is_lazy a)) args) |
306 @[asm_simp_tac (HOLCF_ss addsimps when_apps) 1, |
306 @[asm_simp_tac (HOLCF_ss addsimps when_apps) 1, |
307 simp_tac (HOLCF_ss addsimps axs_con_def) 1]))cons; |
307 simp_tac (HOLCF_ss addsimps axs_con_def) 1]))cons; |
308 val copy_stricts = map (fn (con,args) => pg [] (mk_trp(dc_copy`UU` |
308 val copy_stricts = map (fn (con,args) => pg [] (mk_trp(dc_copy`UU` |
309 (con_app con args) ===UU)) |
309 (con_app con args) ===UU)) |
310 (let val rews = cfst_strict::csnd_strict::copy_strict::copy_apps@con_rews |
310 (let val rews = cfst_strict::csnd_strict::copy_strict::copy_apps@con_rews |
311 in map (case_UU_tac rews 1) (nonlazy args) @ [ |
311 in map (case_UU_tac rews 1) (nonlazy args) @ [ |
312 asm_simp_tac (HOLCF_ss addsimps rews) 1] end)) |
312 asm_simp_tac (HOLCF_ss addsimps rews) 1] end)) |
313 (filter (fn (_,args)=>exists is_nonlazy_rec args) cons); |
313 (List.filter (fn (_,args)=>exists is_nonlazy_rec args) cons); |
314 val copy_rews = copy_strict::copy_apps @ copy_stricts; |
314 val copy_rews = copy_strict::copy_apps @ copy_stricts; |
315 in thy |> Theory.add_path (Sign.base_name dname) |
315 in thy |> Theory.add_path (Sign.base_name dname) |
316 |> (#1 o (PureThy.add_thmss (map Thm.no_attributes [ |
316 |> (#1 o (PureThy.add_thmss (map Thm.no_attributes [ |
317 ("iso_rews" , iso_rews ), |
317 ("iso_rews" , iso_rews ), |
318 ("exhaust" , [exhaust] ), |
318 ("exhaust" , [exhaust] ), |
377 val take_0s = mapn(fn n=> fn dn => pg axs_take_def(mk_trp((dc_take dn $ %%:"0") |
377 val take_0s = mapn(fn n=> fn dn => pg axs_take_def(mk_trp((dc_take dn $ %%:"0") |
378 `%x_name n === UU))[ |
378 `%x_name n === UU))[ |
379 simp_tac iterate_Cprod_ss 1]) 1 dnames; |
379 simp_tac iterate_Cprod_ss 1]) 1 dnames; |
380 val c_UU_tac = case_UU_tac (take_stricts'::copy_con_rews) 1; |
380 val c_UU_tac = case_UU_tac (take_stricts'::copy_con_rews) 1; |
381 val take_apps = pg copy_take_defs (mk_trp(foldr' mk_conj |
381 val take_apps = pg copy_take_defs (mk_trp(foldr' mk_conj |
382 (flat(map (fn ((dn,_),cons) => map (fn (con,args) => foldr mk_all |
382 (List.concat(map (fn ((dn,_),cons) => map (fn (con,args) => Library.foldr mk_all |
383 (map vname args,(dc_take dn $ (%%:"Suc" $ %:"n"))`(con_app con args) === |
383 (map vname args,(dc_take dn $ (%%:"Suc" $ %:"n"))`(con_app con args) === |
384 con_app2 con (app_rec_arg (fn n=>dc_take (nth_elem(n,dnames))$ %:"n")) |
384 con_app2 con (app_rec_arg (fn n=>dc_take (List.nth(dnames,n))$ %:"n")) |
385 args)) cons) eqs)))) ([ |
385 args)) cons) eqs)))) ([ |
386 simp_tac iterate_Cprod_ss 1, |
386 simp_tac iterate_Cprod_ss 1, |
387 induct_tac "n" 1, |
387 induct_tac "n" 1, |
388 simp_tac(iterate_Cprod_ss addsimps copy_con_rews) 1, |
388 simp_tac(iterate_Cprod_ss addsimps copy_con_rews) 1, |
389 asm_full_simp_tac (HOLCF_ss addsimps |
389 asm_full_simp_tac (HOLCF_ss addsimps |
390 (filter (has_fewer_prems 1) copy_rews)) 1, |
390 (List.filter (has_fewer_prems 1) copy_rews)) 1, |
391 TRY(safe_tac HOL_cs)] @ |
391 TRY(safe_tac HOL_cs)] @ |
392 (flat(map (fn ((dn,_),cons) => map (fn (con,args) => |
392 (List.concat(map (fn ((dn,_),cons) => map (fn (con,args) => |
393 if nonlazy_rec args = [] then all_tac else |
393 if nonlazy_rec args = [] then all_tac else |
394 EVERY(map c_UU_tac (nonlazy_rec args)) THEN |
394 EVERY(map c_UU_tac (nonlazy_rec args)) THEN |
395 asm_full_simp_tac (HOLCF_ss addsimps copy_rews)1 |
395 asm_full_simp_tac (HOLCF_ss addsimps copy_rews)1 |
396 ) cons) eqs))); |
396 ) cons) eqs))); |
397 in |
397 in |
398 val take_rews = map standard (atomize take_stricts @ take_0s @ atomize take_apps); |
398 val take_rews = map standard (atomize take_stricts @ take_0s @ atomize take_apps); |
399 end; (* local *) |
399 end; (* local *) |
400 |
400 |
401 local |
401 local |
402 fun one_con p (con,args) = foldr mk_All (map vname args, |
402 fun one_con p (con,args) = Library.foldr mk_All (map vname args, |
403 lift_defined (bound_arg (map vname args)) (nonlazy args, |
403 lift_defined (bound_arg (map vname args)) (nonlazy args, |
404 lift (fn arg => %:(P_name (1+rec_of arg)) $ bound_arg args arg) |
404 lift (fn arg => %:(P_name (1+rec_of arg)) $ bound_arg args arg) |
405 (filter is_rec args,mk_trp(%:p $ con_app2 con (bound_arg args) args)))); |
405 (List.filter is_rec args,mk_trp(%:p $ con_app2 con (bound_arg args) args)))); |
406 fun one_eq ((p,cons),concl) = (mk_trp(%:p $ UU) ===> |
406 fun one_eq ((p,cons),concl) = (mk_trp(%:p $ UU) ===> |
407 foldr (op ===>) (map (one_con p) cons,concl)); |
407 Library.foldr (op ===>) (map (one_con p) cons,concl)); |
408 fun ind_term concf = foldr one_eq (mapn (fn n => fn x => (P_name n, x))1conss, |
408 fun ind_term concf = Library.foldr one_eq (mapn (fn n => fn x => (P_name n, x))1conss, |
409 mk_trp(foldr' mk_conj (mapn concf 1 dnames))); |
409 mk_trp(foldr' mk_conj (mapn concf 1 dnames))); |
410 val take_ss = HOL_ss addsimps take_rews; |
410 val take_ss = HOL_ss addsimps take_rews; |
411 fun quant_tac i = EVERY(mapn(fn n=> fn _=> res_inst_tac[("x",x_name n)]spec i) |
411 fun quant_tac i = EVERY(mapn(fn n=> fn _=> res_inst_tac[("x",x_name n)]spec i) |
412 1 dnames); |
412 1 dnames); |
413 fun ind_prems_tac prems = EVERY(flat (map (fn cons => ( |
413 fun ind_prems_tac prems = EVERY(List.concat (map (fn cons => ( |
414 resolve_tac prems 1 :: |
414 resolve_tac prems 1 :: |
415 flat (map (fn (_,args) => |
415 List.concat (map (fn (_,args) => |
416 resolve_tac prems 1 :: |
416 resolve_tac prems 1 :: |
417 map (K(atac 1)) (nonlazy args) @ |
417 map (K(atac 1)) (nonlazy args) @ |
418 map (K(atac 1)) (filter is_rec args)) |
418 map (K(atac 1)) (List.filter is_rec args)) |
419 cons))) conss)); |
419 cons))) conss)); |
420 local |
420 local |
421 (* check whether every/exists constructor of the n-th part of the equation: |
421 (* check whether every/exists constructor of the n-th part of the equation: |
422 it has a possibly indirectly recursive argument that isn't/is possibly |
422 it has a possibly indirectly recursive argument that isn't/is possibly |
423 indirectly lazy *) |
423 indirectly lazy *) |
424 fun rec_to quant nfn rfn ns lazy_rec (n,cons) = quant (exists (fn arg => |
424 fun rec_to quant nfn rfn ns lazy_rec (n,cons) = quant (exists (fn arg => |
425 is_rec arg andalso not(rec_of arg mem ns) andalso |
425 is_rec arg andalso not(rec_of arg mem ns) andalso |
426 ((rec_of arg = n andalso nfn(lazy_rec orelse is_lazy arg)) orelse |
426 ((rec_of arg = n andalso nfn(lazy_rec orelse is_lazy arg)) orelse |
427 rec_of arg <> n andalso rec_to quant nfn rfn (rec_of arg::ns) |
427 rec_of arg <> n andalso rec_to quant nfn rfn (rec_of arg::ns) |
428 (lazy_rec orelse is_lazy arg) (n, (nth_elem(rec_of arg,conss)))) |
428 (lazy_rec orelse is_lazy arg) (n, (List.nth(conss,rec_of arg)))) |
429 ) o snd) cons; |
429 ) o snd) cons; |
430 fun all_rec_to ns = rec_to forall not all_rec_to ns; |
430 fun all_rec_to ns = rec_to forall not all_rec_to ns; |
431 fun warn (n,cons) = if all_rec_to [] false (n,cons) then (warning |
431 fun warn (n,cons) = if all_rec_to [] false (n,cons) then (warning |
432 ("domain "^nth_elem(n,dnames)^" is empty!"); true) else false; |
432 ("domain "^List.nth(dnames,n)^" is empty!"); true) else false; |
433 fun lazy_rec_to ns = rec_to exists Id lazy_rec_to ns; |
433 fun lazy_rec_to ns = rec_to exists Id lazy_rec_to ns; |
434 |
434 |
435 in val n__eqs = mapn (fn n => fn (_,cons) => (n,cons)) 0 eqs; |
435 in val n__eqs = mapn (fn n => fn (_,cons) => (n,cons)) 0 eqs; |
436 val is_emptys = map warn n__eqs; |
436 val is_emptys = map warn n__eqs; |
437 val is_finite = forall (not o lazy_rec_to [] false) n__eqs; |
437 val is_finite = forall (not o lazy_rec_to [] false) n__eqs; |
442 quant_tac 1, |
442 quant_tac 1, |
443 simp_tac HOL_ss 1, |
443 simp_tac HOL_ss 1, |
444 induct_tac "n" 1, |
444 induct_tac "n" 1, |
445 simp_tac (take_ss addsimps prems) 1, |
445 simp_tac (take_ss addsimps prems) 1, |
446 TRY(safe_tac HOL_cs)] |
446 TRY(safe_tac HOL_cs)] |
447 @ flat(map (fn (cons,cases) => [ |
447 @ List.concat(map (fn (cons,cases) => [ |
448 res_inst_tac [("x","x")] cases 1, |
448 res_inst_tac [("x","x")] cases 1, |
449 asm_simp_tac (take_ss addsimps prems) 1] |
449 asm_simp_tac (take_ss addsimps prems) 1] |
450 @ flat(map (fn (con,args) => |
450 @ List.concat(map (fn (con,args) => |
451 asm_simp_tac take_ss 1 :: |
451 asm_simp_tac take_ss 1 :: |
452 map (fn arg => |
452 map (fn arg => |
453 case_UU_tac (prems@con_rews) 1 ( |
453 case_UU_tac (prems@con_rews) 1 ( |
454 nth_elem(rec_of arg,dnames)^"_take n$"^vname arg)) |
454 List.nth(dnames,rec_of arg)^"_take n$"^vname arg)) |
455 (filter is_nonlazy_rec args) @ [ |
455 (List.filter is_nonlazy_rec args) @ [ |
456 resolve_tac prems 1] @ |
456 resolve_tac prems 1] @ |
457 map (K (atac 1)) (nonlazy args) @ |
457 map (K (atac 1)) (nonlazy args) @ |
458 map (K (etac spec 1)) (filter is_rec args)) |
458 map (K (etac spec 1)) (List.filter is_rec args)) |
459 cons)) |
459 cons)) |
460 (conss~~cases))); |
460 (conss~~cases))); |
461 |
461 |
462 val take_lemmas =mapn(fn n=> fn(dn,ax_reach)=> pg'' thy axs_take_def(mk_All("n", |
462 val take_lemmas =mapn(fn n=> fn(dn,ax_reach)=> pg'' thy axs_take_def(mk_All("n", |
463 mk_trp(dc_take dn $ Bound 0 `%(x_name n) === |
463 mk_trp(dc_take dn $ Bound 0 `%(x_name n) === |
494 dc_take dn $ Bound 1 ` Bound 0 === Bound 0))) 1 eqs)))) ([ |
494 dc_take dn $ Bound 1 ` Bound 0 === Bound 0))) 1 eqs)))) ([ |
495 rtac allI 1, |
495 rtac allI 1, |
496 induct_tac "n" 1, |
496 induct_tac "n" 1, |
497 simp_tac take_ss 1, |
497 simp_tac take_ss 1, |
498 TRY(safe_tac(empty_cs addSEs[conjE] addSIs[conjI]))] @ |
498 TRY(safe_tac(empty_cs addSEs[conjE] addSIs[conjI]))] @ |
499 flat(mapn (fn n => fn (cons,cases) => [ |
499 List.concat(mapn (fn n => fn (cons,cases) => [ |
500 simp_tac take_ss 1, |
500 simp_tac take_ss 1, |
501 rtac allI 1, |
501 rtac allI 1, |
502 res_inst_tac [("x",x_name n)] cases 1, |
502 res_inst_tac [("x",x_name n)] cases 1, |
503 asm_simp_tac take_ss 1] @ |
503 asm_simp_tac take_ss 1] @ |
504 flat(map (fn (con,args) => |
504 List.concat(map (fn (con,args) => |
505 asm_simp_tac take_ss 1 :: |
505 asm_simp_tac take_ss 1 :: |
506 flat(map (fn vn => [ |
506 List.concat(map (fn vn => [ |
507 eres_inst_tac [("x",vn)] all_dupE 1, |
507 eres_inst_tac [("x",vn)] all_dupE 1, |
508 etac disjE 1, |
508 etac disjE 1, |
509 asm_simp_tac (HOL_ss addsimps con_rews) 1, |
509 asm_simp_tac (HOL_ss addsimps con_rews) 1, |
510 asm_simp_tac take_ss 1]) |
510 asm_simp_tac take_ss 1]) |
511 (nonlazy_rec args))) |
511 (nonlazy_rec args))) |
521 fast_tac HOL_cs 1]) (dnames~~atomize finite_lemma1b); |
521 fast_tac HOL_cs 1]) (dnames~~atomize finite_lemma1b); |
522 in |
522 in |
523 (finites, |
523 (finites, |
524 pg'' thy[](ind_term (fn n => fn dn => %:(P_name n) $ %:(x_name n)))(fn prems => |
524 pg'' thy[](ind_term (fn n => fn dn => %:(P_name n) $ %:(x_name n)))(fn prems => |
525 TRY(safe_tac HOL_cs) :: |
525 TRY(safe_tac HOL_cs) :: |
526 flat (map (fn (finite,fin_ind) => [ |
526 List.concat (map (fn (finite,fin_ind) => [ |
527 rtac(rewrite_rule axs_finite_def finite RS exE)1, |
527 rtac(rewrite_rule axs_finite_def finite RS exE)1, |
528 etac subst 1, |
528 etac subst 1, |
529 rtac fin_ind 1, |
529 rtac fin_ind 1, |
530 ind_prems_tac prems]) |
530 ind_prems_tac prems]) |
531 (finites~~(atomize finite_ind)) )) |
531 (finites~~(atomize finite_ind)) )) |
532 ) end (* let *) else |
532 ) end (* let *) else |
533 (mapn (fn n => fn dn => read_instantiate_sg (sign_of thy) |
533 (mapn (fn n => fn dn => read_instantiate_sg (sign_of thy) |
534 [("P",dn^"_finite "^x_name n)] excluded_middle) 1 dnames, |
534 [("P",dn^"_finite "^x_name n)] excluded_middle) 1 dnames, |
535 pg'' thy [] (foldr (op ===>) (mapn (fn n => K(mk_trp(%%:"adm" $ %:(P_name n)))) |
535 pg'' thy [] (Library.foldr (op ===>) (mapn (fn n => K(mk_trp(%%:"adm" $ %:(P_name n)))) |
536 1 dnames, ind_term (fn n => fn dn => %:(P_name n) $ %:(x_name n)))) |
536 1 dnames, ind_term (fn n => fn dn => %:(P_name n) $ %:(x_name n)))) |
537 (fn prems => map (fn ax_reach => rtac (ax_reach RS subst) 1) |
537 (fn prems => map (fn ax_reach => rtac (ax_reach RS subst) 1) |
538 axs_reach @ [ |
538 axs_reach @ [ |
539 quant_tac 1, |
539 quant_tac 1, |
540 rtac (adm_impl_admw RS wfix_ind) 1, |
540 rtac (adm_impl_admw RS wfix_ind) 1, |
554 val xs = mapn (fn n => K (x_name n)) 1 dnames; |
554 val xs = mapn (fn n => K (x_name n)) 1 dnames; |
555 fun bnd_arg n i = Bound(2*(n_eqs - n)-i-1); |
555 fun bnd_arg n i = Bound(2*(n_eqs - n)-i-1); |
556 val take_ss = HOL_ss addsimps take_rews; |
556 val take_ss = HOL_ss addsimps take_rews; |
557 val sproj = prj (fn s => K("fst("^s^")")) (fn s => K("snd("^s^")")); |
557 val sproj = prj (fn s => K("fst("^s^")")) (fn s => K("snd("^s^")")); |
558 val coind_lemma=pg[ax_bisim_def](mk_trp(mk_imp(%%:(comp_dname^"_bisim") $ %:"R", |
558 val coind_lemma=pg[ax_bisim_def](mk_trp(mk_imp(%%:(comp_dname^"_bisim") $ %:"R", |
559 foldr (fn (x,t)=> mk_all(x,mk_all(x^"'",t))) (xs, |
559 Library.foldr (fn (x,t)=> mk_all(x,mk_all(x^"'",t))) (xs, |
560 foldr mk_imp (mapn (fn n => K(proj (%:"R") eqs n $ |
560 Library.foldr mk_imp (mapn (fn n => K(proj (%:"R") eqs n $ |
561 bnd_arg n 0 $ bnd_arg n 1)) 0 dnames, |
561 bnd_arg n 0 $ bnd_arg n 1)) 0 dnames, |
562 foldr' mk_conj (mapn (fn n => fn dn => |
562 foldr' mk_conj (mapn (fn n => fn dn => |
563 (dc_take dn $ %:"n" `bnd_arg n 0 === |
563 (dc_take dn $ %:"n" `bnd_arg n 0 === |
564 (dc_take dn $ %:"n" `bnd_arg n 1)))0 dnames)))))) |
564 (dc_take dn $ %:"n" `bnd_arg n 1)))0 dnames)))))) |
565 ([ rtac impI 1, |
565 ([ rtac impI 1, |
566 induct_tac "n" 1, |
566 induct_tac "n" 1, |
567 simp_tac take_ss 1, |
567 simp_tac take_ss 1, |
568 safe_tac HOL_cs] @ |
568 safe_tac HOL_cs] @ |
569 flat(mapn (fn n => fn x => [ |
569 List.concat(mapn (fn n => fn x => [ |
570 rotate_tac (n+1) 1, |
570 rotate_tac (n+1) 1, |
571 etac all2E 1, |
571 etac all2E 1, |
572 eres_inst_tac [("P1", sproj "R" eqs n^ |
572 eres_inst_tac [("P1", sproj "R" eqs n^ |
573 " "^x^" "^x^"'")](mp RS disjE) 1, |
573 " "^x^" "^x^"'")](mp RS disjE) 1, |
574 TRY(safe_tac HOL_cs), |
574 TRY(safe_tac HOL_cs), |
575 REPEAT(CHANGED(asm_simp_tac take_ss 1))]) |
575 REPEAT(CHANGED(asm_simp_tac take_ss 1))]) |
576 0 xs)); |
576 0 xs)); |
577 in |
577 in |
578 val coind = pg [] (mk_trp(%%:(comp_dname^"_bisim") $ %:"R") ===> |
578 val coind = pg [] (mk_trp(%%:(comp_dname^"_bisim") $ %:"R") ===> |
579 foldr (op ===>) (mapn (fn n => fn x => |
579 Library.foldr (op ===>) (mapn (fn n => fn x => |
580 mk_trp(proj (%:"R") eqs n $ %:x $ %:(x^"'"))) 0 xs, |
580 mk_trp(proj (%:"R") eqs n $ %:x $ %:(x^"'"))) 0 xs, |
581 mk_trp(foldr' mk_conj (map (fn x => %:x === %:(x^"'")) xs)))) ([ |
581 mk_trp(foldr' mk_conj (map (fn x => %:x === %:(x^"'")) xs)))) ([ |
582 TRY(safe_tac HOL_cs)] @ |
582 TRY(safe_tac HOL_cs)] @ |
583 flat(map (fn take_lemma => [ |
583 List.concat(map (fn take_lemma => [ |
584 rtac take_lemma 1, |
584 rtac take_lemma 1, |
585 cut_facts_tac [coind_lemma] 1, |
585 cut_facts_tac [coind_lemma] 1, |
586 fast_tac HOL_cs 1]) |
586 fast_tac HOL_cs 1]) |
587 take_lemmas)); |
587 take_lemmas)); |
588 end; (* local *) |
588 end; (* local *) |