src/HOLCF/domain/theorems.ML
changeset 4755 843b5f159c7e
parent 4721 c8a8482a8124
child 4861 7ed04b370b71
equal deleted inserted replaced
4754:2c090aef2ca2 4755:843b5f159c7e
    53 
    53 
    54 val dist_eqI = prove_goal Porder.thy "~(x::'a::po) << y ==> x ~= y" (fn prems => [
    54 val dist_eqI = prove_goal Porder.thy "~(x::'a::po) << y ==> x ~= y" (fn prems => [
    55                                 rtac rev_contrapos 1,
    55                                 rtac rev_contrapos 1,
    56                                 etac (antisym_less_inverse RS conjunct1) 1,
    56                                 etac (antisym_less_inverse RS conjunct1) 1,
    57                                 resolve_tac prems 1]);
    57                                 resolve_tac prems 1]);
    58 
       
    59 in
       
    60 
       
    61 fun theorems (((dname,_),cons) : eq, eqs : eq list) thy =
       
    62 let
       
    63 
       
    64 val dummy = writeln ("Proving isomorphism properties of domain "^dname^" ...");
       
    65 val pg = pg' thy;
       
    66 (*
    58 (*
    67 infixr 0 y;
    59 infixr 0 y;
    68 val b = 0;
    60 val b = 0;
    69 fun _ y t = by t;
    61 fun _ y t = by t;
    70 fun g defs t = let val sg = sign_of thy;
    62 fun g defs t = let val sg = sign_of thy;
    71                      val ct = Thm.cterm_of sg (inferT sg t);
    63                      val ct = Thm.cterm_of sg (inferT sg t);
    72                  in goalw_cterm defs ct end;
    64                  in goalw_cterm defs ct end;
    73 *)
    65 *)
       
    66 
       
    67 in
       
    68 
       
    69 fun theorems (((dname,_),cons) : eq, eqs : eq list) thy =
       
    70 let
       
    71 
       
    72 val dummy = writeln ("Proving isomorphism properties of domain "^dname^" ...");
       
    73 val pg = pg' thy;
    74 
    74 
    75 
    75 
    76 (* ----- getting the axioms and definitions --------------------------------- *)
    76 (* ----- getting the axioms and definitions --------------------------------- *)
    77 
    77 
    78 local fun ga s dn = get_axiom thy (dn^"."^s) in
    78 local fun ga s dn = get_axiom thy (dn^"."^s) in
   307                    asm_simp_tac(HOLCF_ss addsimps [abs_strict, when_strict,
   307                    asm_simp_tac(HOLCF_ss addsimps [abs_strict, when_strict,
   308                                                    cfst_strict,csnd_strict]) 1];
   308                                                    cfst_strict,csnd_strict]) 1];
   309 val copy_apps = map (fn (con,args) => pg [ax_copy_def]
   309 val copy_apps = map (fn (con,args) => pg [ax_copy_def]
   310                     (lift_defined % (nonlazy_rec args,
   310                     (lift_defined % (nonlazy_rec args,
   311                         mk_trp(dc_copy`%"f"`(con_app con args) ===
   311                         mk_trp(dc_copy`%"f"`(con_app con args) ===
   312                 (con_app2 con (app_rec_arg (cproj (%"f") (length eqs))) args))))
   312                 (con_app2 con (app_rec_arg (cproj (%"f") eqs)) args))))
   313                         (map (case_UU_tac (abs_strict::when_strict::con_stricts)
   313                         (map (case_UU_tac (abs_strict::when_strict::con_stricts)
   314                                  1 o vname)
   314                                  1 o vname)
   315                          (filter (fn a => not (is_rec a orelse is_lazy a)) args)
   315                          (filter (fn a => not (is_rec a orelse is_lazy a)) args)
   316                         @[asm_simp_tac (HOLCF_ss addsimps when_apps) 1,
   316                         @[asm_simp_tac (HOLCF_ss addsimps when_apps) 1,
   317                           simp_tac (HOLCF_ss addsimps axs_con_def) 1]))cons;
   317                           simp_tac (HOLCF_ss addsimps axs_con_def) 1]))cons;
   552                                                    rtac adm_subst 1 THEN 
   552                                                    rtac adm_subst 1 THEN 
   553                                         cont_tacR 1 THEN resolve_tac prems 1),
   553                                         cont_tacR 1 THEN resolve_tac prems 1),
   554                                 strip_tac 1,
   554                                 strip_tac 1,
   555                                 rtac (rewrite_rule axs_take_def finite_ind) 1,
   555                                 rtac (rewrite_rule axs_take_def finite_ind) 1,
   556                                 ind_prems_tac prems])
   556                                 ind_prems_tac prems])
   557 )
   557   handle ERROR => (warning "Cannot prove infinite induction rule"; refl))
   558 end; (* local *)
   558 end; (* local *)
   559 
   559 
   560 (* ----- theorem concerning coinduction ------------------------------------- *)
   560 (* ----- theorem concerning coinduction ------------------------------------- *)
   561 
   561 
   562 local
   562 local
   563   val xs = mapn (fn n => K (x_name n)) 1 dnames;
   563   val xs = mapn (fn n => K (x_name n)) 1 dnames;
   564   fun bnd_arg n i = Bound(2*(n_eqs - n)-i-1);
   564   fun bnd_arg n i = Bound(2*(n_eqs - n)-i-1);
   565   val take_ss = HOL_ss addsimps take_rews;
   565   val take_ss = HOL_ss addsimps take_rews;
   566   val sproj   = prj (fn s => "fst("^s^")") (fn s => "snd("^s^")");
   566   val sproj   = prj (fn s => K("fst("^s^")")) (fn s => K("snd("^s^")"));
   567   val coind_lemma=pg[ax_bisim_def](mk_trp(mk_imp(%%(comp_dname^"_bisim") $ %"R",
   567   val coind_lemma=pg[ax_bisim_def](mk_trp(mk_imp(%%(comp_dname^"_bisim") $ %"R",
   568                 foldr (fn (x,t)=> mk_all(x,mk_all(x^"'",t))) (xs,
   568                 foldr (fn (x,t)=> mk_all(x,mk_all(x^"'",t))) (xs,
   569                   foldr mk_imp (mapn (fn n => K(proj (%"R") n_eqs n $ 
   569                   foldr mk_imp (mapn (fn n => K(proj (%"R") eqs n $ 
   570                                       bnd_arg n 0 $ bnd_arg n 1)) 0 dnames,
   570                                       bnd_arg n 0 $ bnd_arg n 1)) 0 dnames,
   571                     foldr' mk_conj (mapn (fn n => fn dn => 
   571                     foldr' mk_conj (mapn (fn n => fn dn => 
   572                                 (dc_take dn $ %"n" `bnd_arg n 0 === 
   572                                 (dc_take dn $ %"n" `bnd_arg n 0 === 
   573                                 (dc_take dn $ %"n" `bnd_arg n 1)))0 dnames))))))
   573                                 (dc_take dn $ %"n" `bnd_arg n 1)))0 dnames))))))
   574                              ([ rtac impI 1,
   574                              ([ rtac impI 1,
   576                                 simp_tac take_ss 1,
   576                                 simp_tac take_ss 1,
   577                                 safe_tac HOL_cs] @
   577                                 safe_tac HOL_cs] @
   578                                 flat(mapn (fn n => fn x => [
   578                                 flat(mapn (fn n => fn x => [
   579                                   rotate_tac (n+1) 1,
   579                                   rotate_tac (n+1) 1,
   580                                   etac all2E 1,
   580                                   etac all2E 1,
   581                                   eres_inst_tac [("P1", sproj "R" n_eqs n^
   581                                   eres_inst_tac [("P1", sproj "R" eqs n^
   582                                         " "^x^" "^x^"'")](mp RS disjE) 1,
   582                                         " "^x^" "^x^"'")](mp RS disjE) 1,
   583                                   TRY(safe_tac HOL_cs),
   583                                   TRY(safe_tac HOL_cs),
   584                                   REPEAT(CHANGED(asm_simp_tac take_ss 1))]) 
   584                                   REPEAT(CHANGED(asm_simp_tac take_ss 1))]) 
   585                                 0 xs));
   585                                 0 xs));
   586 in
   586 in
   587 val coind = pg [] (mk_trp(%%(comp_dname^"_bisim") $ %"R") ===>
   587 val coind = pg [] (mk_trp(%%(comp_dname^"_bisim") $ %"R") ===>
   588                 foldr (op ===>) (mapn (fn n => fn x => 
   588                 foldr (op ===>) (mapn (fn n => fn x => 
   589                   mk_trp(proj (%"R") n_eqs n $ %x $ %(x^"'"))) 0 xs,
   589                   mk_trp(proj (%"R") eqs n $ %x $ %(x^"'"))) 0 xs,
   590                   mk_trp(foldr' mk_conj (map (fn x => %x === %(x^"'")) xs)))) ([
   590                   mk_trp(foldr' mk_conj (map (fn x => %x === %(x^"'")) xs)))) ([
   591                                 TRY(safe_tac HOL_cs)] @
   591                                 TRY(safe_tac HOL_cs)] @
   592                                 flat(map (fn take_lemma => [
   592                                 flat(map (fn take_lemma => [
   593                                   rtac take_lemma 1,
   593                                   rtac take_lemma 1,
   594                                   cut_facts_tac [coind_lemma] 1,
   594                                   cut_facts_tac [coind_lemma] 1,