src/HOLCF/domain/theorems.ML
changeset 4030 ca44afcc259c
parent 4008 2444085532c6
child 4043 35766855f344
equal deleted inserted replaced
4029:22f2d1b17f97 4030:ca44afcc259c
    57                                 resolve_tac prems 1]);
    57                                 resolve_tac prems 1]);
    58 
    58 
    59 in
    59 in
    60 
    60 
    61 
    61 
    62 fun theorems thy (((dname,_),cons) : eq, eqs :eq list) =
    62 type thms = (thm list * thm * thm * thm list *
       
    63 	     thm list * thm list * thm list * thm list * thm  list * thm list *
       
    64 	     thm list * thm list);
       
    65 fun (theorems thy: eq list -> eq -> thms) eqs ((dname,_),cons)  =
    63 let
    66 let
    64 
    67 
    65 val dummy = writeln ("Proving isomorphism   properties of domain "^dname^"...");
    68 val dummy = writeln ("Proving isomorphism properties of domain "^dname^" ...");
    66 val pg = pg' thy;
    69 val pg = pg' thy;
    67 (*
    70 (*
    68 infixr 0 y;
    71 infixr 0 y;
    69 val b = 0;
    72 val b = 0;
    70 fun _ y t = by t;
    73 fun _ y t = by t;
    71 fun  g  defs t = let val sg = sign_of thy;
    74 fun g defs t = let val sg = sign_of thy;
    72                      val ct = Thm.cterm_of sg (inferT sg t);
    75                      val ct = Thm.cterm_of sg (inferT sg t);
    73                  in goalw_cterm defs ct end;
    76                  in goalw_cterm defs ct end;
    74 *)
    77 *)
    75 
    78 
    76 
    79 
   326         con_rews, sel_rews, dis_rews, dists_le, dists_eq, inverts, injects,
   329         con_rews, sel_rews, dis_rews, dists_le, dists_eq, inverts, injects,
   327         copy_rews)
   330         copy_rews)
   328 end; (* let *)
   331 end; (* let *)
   329 
   332 
   330 
   333 
   331 fun comp_theorems thy (comp_dnam, eqs: eq list, casess, con_rews, copy_rews) =
   334 fun comp_theorems thy (comp_dnam, eqs: eq list, thmss: thms list) =
   332 let
   335 let
   333 
   336 val casess    =       map #3  thmss;
       
   337 val con_rews  = flat (map #5  thmss);
       
   338 val copy_rews = flat (map #12 thmss);
   334 val dnames = map (fst o fst) eqs;
   339 val dnames = map (fst o fst) eqs;
   335 val conss  = map  snd        eqs;
   340 val conss  = map  snd        eqs;
   336 val comp_dname = Sign.full_name (sign_of thy) comp_dnam;
   341 val comp_dname = Sign.full_name (sign_of thy) comp_dnam;
   337 
   342 
   338 val dummy = writeln("Proving induction properties of domain "^comp_dname^"...");
   343 val d = writeln("Proving induction   properties of domain "^comp_dname^" ...");
   339 val pg = pg' thy;
   344 val pg = pg' thy;
   340 
   345 
   341 (* ----- getting the composite axiom and definitions ------------------------ *)
   346 (* ----- getting the composite axiom and definitions ------------------------ *)
   342 
   347 
   343 local val ga = get_axiom thy in
   348 local val ga = get_axiom thy in
   359   val iterate_Cprod_ss = simpset_of "Fix"
   364   val iterate_Cprod_ss = simpset_of "Fix"
   360                          addsimps [cfst_strict, csnd_strict]addsimps Cprod_rews;
   365                          addsimps [cfst_strict, csnd_strict]addsimps Cprod_rews;
   361   val copy_con_rews  = copy_rews @ con_rews;
   366   val copy_con_rews  = copy_rews @ con_rews;
   362   val copy_take_defs =(if n_eqs = 1 then [] else [ax_copy2_def]) @ axs_take_def;
   367   val copy_take_defs =(if n_eqs = 1 then [] else [ax_copy2_def]) @ axs_take_def;
   363   val take_stricts=pg copy_take_defs(mk_trp(foldr' mk_conj(map(fn((dn,args),_)=>
   368   val take_stricts=pg copy_take_defs(mk_trp(foldr' mk_conj(map(fn((dn,args),_)=>
   364             strict(dc_take dn $ %"n")) eqs)))([
   369             strict(dc_take dn $ %"n")) eqs))) ([
       
   370 			if n_eqs = 1 then all_tac else rewtac ax_copy2_def,
   365                         nat_ind_tac "n" 1,
   371                         nat_ind_tac "n" 1,
   366                         simp_tac iterate_Cprod_ss 1,
   372                          simp_tac iterate_Cprod_ss 1,
   367                         asm_simp_tac (iterate_Cprod_ss addsimps copy_rews)1]);
   373                         asm_simp_tac (iterate_Cprod_ss addsimps copy_rews)1]);
   368   val take_stricts' = rewrite_rule copy_take_defs take_stricts;
   374   val take_stricts' = rewrite_rule copy_take_defs take_stricts;
   369   val take_0s = mapn(fn n=> fn dn => pg axs_take_def(mk_trp((dc_take dn $ %%"0")
   375   val take_0s = mapn(fn n=> fn dn => pg axs_take_def(mk_trp((dc_take dn $ %%"0")
   370                                                         `%x_name n === UU))[
   376                                                         `%x_name n === UU))[
   371                                 simp_tac iterate_Cprod_ss 1]) 1 dnames;
   377                                 simp_tac iterate_Cprod_ss 1]) 1 dnames;
   418           ((rec_of arg =  n andalso nfn(lazy_rec orelse is_lazy arg)) orelse 
   424           ((rec_of arg =  n andalso nfn(lazy_rec orelse is_lazy arg)) orelse 
   419             rec_of arg <> n andalso rec_to quant nfn rfn (rec_of arg::ns) 
   425             rec_of arg <> n andalso rec_to quant nfn rfn (rec_of arg::ns) 
   420               (lazy_rec orelse is_lazy arg) (n, (nth_elem(rec_of arg,conss))))
   426               (lazy_rec orelse is_lazy arg) (n, (nth_elem(rec_of arg,conss))))
   421           ) o snd) cons;
   427           ) o snd) cons;
   422     fun all_rec_to ns  = rec_to forall not all_rec_to  ns;
   428     fun all_rec_to ns  = rec_to forall not all_rec_to  ns;
   423     fun warn (n,cons)  = if all_rec_to [] false (n,cons) then (writeln 
   429     fun warn (n,cons)  = if all_rec_to [] false (n,cons) then (warning
   424         ("WARNING: domain "^nth_elem(n,dnames)^" is empty!"); true) else false;
   430         ("domain "^nth_elem(n,dnames)^" is empty!"); true) else false;
   425     fun lazy_rec_to ns = rec_to exists Id  lazy_rec_to ns;
   431     fun lazy_rec_to ns = rec_to exists Id  lazy_rec_to ns;
   426 
   432 
   427   in val n__eqs     = mapn (fn n => fn (_,cons) => (n,cons)) 0 eqs;
   433   in val n__eqs     = mapn (fn n => fn (_,cons) => (n,cons)) 0 eqs;
   428      val is_emptys = map warn n__eqs;
   434      val is_emptys = map warn n__eqs;
   429      val is_finite = forall (not o lazy_rec_to [] false) n__eqs;
   435      val is_finite = forall (not o lazy_rec_to [] false) n__eqs;
   528                1 dnames, ind_term (fn n => fn dn => %(P_name n) $ %(x_name n))))
   534                1 dnames, ind_term (fn n => fn dn => %(P_name n) $ %(x_name n))))
   529                    (fn prems => map (fn ax_reach => rtac (ax_reach RS subst) 1) 
   535                    (fn prems => map (fn ax_reach => rtac (ax_reach RS subst) 1) 
   530                                     axs_reach @ [
   536                                     axs_reach @ [
   531                                 quant_tac 1,
   537                                 quant_tac 1,
   532                                 rtac (adm_impl_admw RS wfix_ind) 1,
   538                                 rtac (adm_impl_admw RS wfix_ind) 1,
   533                                 REPEAT_DETERM(rtac adm_all2 1),
   539                                  REPEAT_DETERM(rtac adm_all2 1),
   534                                 REPEAT_DETERM(TRY(rtac adm_conj 1) THEN 
   540                                  REPEAT_DETERM(TRY(rtac adm_conj 1) THEN 
   535                                                   rtac adm_subst 1 THEN 
   541                                                    rtac adm_subst 1 THEN 
   536                                         cont_tacR 1 THEN resolve_tac prems 1),
   542                                         cont_tacR 1 THEN resolve_tac prems 1),
   537                                 strip_tac 1,
   543                                 strip_tac 1,
   538                                 rtac (rewrite_rule axs_take_def finite_ind) 1,
   544                                 rtac (rewrite_rule axs_take_def finite_ind) 1,
   539                                 ind_prems_tac prems])
   545                                 ind_prems_tac prems])
   540 )
   546 )