src/HOLCF/domain/theorems.ML
changeset 1461 6bcb44e4d6e5
parent 1274 ea0668a1c0ba
child 1512 ce37c64244c0
     1.1 --- a/src/HOLCF/domain/theorems.ML	Mon Jan 29 14:16:13 1996 +0100
     1.2 +++ b/src/HOLCF/domain/theorems.ML	Tue Jan 30 13:42:57 1996 +0100
     1.3 @@ -34,31 +34,31 @@
     1.4  val b=0;
     1.5  fun _ y t = by t;
     1.6  fun  g  defs t = let val sg = sign_of thy;
     1.7 -		     val ct = Thm.cterm_of sg (inferT sg t);
     1.8 -		 in goalw_cterm defs ct end;
     1.9 +                     val ct = Thm.cterm_of sg (inferT sg t);
    1.10 +                 in goalw_cterm defs ct end;
    1.11  *)
    1.12  
    1.13  fun pg'' thy defs t = let val sg = sign_of thy;
    1.14 -		          val ct = Thm.cterm_of sg (inferT sg t);
    1.15 -		      in prove_goalw_cterm defs ct end;
    1.16 +                          val ct = Thm.cterm_of sg (inferT sg t);
    1.17 +                      in prove_goalw_cterm defs ct end;
    1.18  fun pg'  thy defs t tacsf=pg'' thy defs t (fn []   => tacsf 
    1.19 -					    | prems=> (cut_facts_tac prems 1)::tacsf);
    1.20 +                                            | prems=> (cut_facts_tac prems 1)::tacsf);
    1.21  
    1.22  fun REPEAT_DETERM_UNTIL p tac = 
    1.23  let fun drep st = if p st then Sequence.single st
    1.24 -			  else (case Sequence.pull(tapply(tac,st)) of
    1.25 -		                  None        => Sequence.null
    1.26 -				| Some(st',_) => drep st')
    1.27 +                          else (case Sequence.pull(tapply(tac,st)) of
    1.28 +                                  None        => Sequence.null
    1.29 +                                | Some(st',_) => drep st')
    1.30  in Tactic drep end;
    1.31  val UNTIL_SOLVED = REPEAT_DETERM_UNTIL (has_fewer_prems 1);
    1.32  
    1.33  local val trueI2 = prove_goal HOL.thy "f~=x ==> True" (fn prems => [rtac TrueI 1]) in
    1.34  val kill_neq_tac = dtac trueI2 end;
    1.35 -fun case_UU_tac rews i v =	res_inst_tac [("Q",v^"=UU")] classical2 i THEN
    1.36 -				asm_simp_tac (HOLCF_ss addsimps rews) i;
    1.37 +fun case_UU_tac rews i v =      res_inst_tac [("Q",v^"=UU")] classical2 i THEN
    1.38 +                                asm_simp_tac (HOLCF_ss addsimps rews) i;
    1.39  
    1.40  val chain_tac = REPEAT_DETERM o resolve_tac 
    1.41 -		[is_chain_iterate, ch2ch_fappR, ch2ch_fappL];
    1.42 +                [is_chain_iterate, ch2ch_fappR, ch2ch_fappL];
    1.43  
    1.44  (* ----- general proofs ----------------------------------------------------------- *)
    1.45  
    1.46 @@ -66,17 +66,17 @@
    1.47                                  cut_facts_tac prems 1,
    1.48                                  etac swap 1,
    1.49                                  dtac notnotD 1,
    1.50 -				etac (hd prems) 1]);
    1.51 +                                etac (hd prems) 1]);
    1.52  
    1.53  val dist_eqI = prove_goal Porder0.thy "~ x << y ==> x ~= y" (fn prems => [
    1.54 -				cut_facts_tac prems 1,
    1.55 -				etac swap 1,
    1.56 -				dtac notnotD 1,
    1.57 -				asm_simp_tac HOLCF_ss 1]);
    1.58 +                                cut_facts_tac prems 1,
    1.59 +                                etac swap 1,
    1.60 +                                dtac notnotD 1,
    1.61 +                                asm_simp_tac HOLCF_ss 1]);
    1.62  val cfst_strict  = prove_goal Cprod3.thy "cfst`UU = UU" (fn _ => [
    1.63 -				(simp_tac (HOLCF_ss addsimps [inst_cprod_pcpo2]) 1)]);
    1.64 +                                (simp_tac (HOLCF_ss addsimps [inst_cprod_pcpo2]) 1)]);
    1.65  val csnd_strict  = prove_goal Cprod3.thy "csnd`UU = UU" (fn _ => [
    1.66 -			(simp_tac (HOLCF_ss addsimps [inst_cprod_pcpo2]) 1)]);
    1.67 +                        (simp_tac (HOLCF_ss addsimps [inst_cprod_pcpo2]) 1)]);
    1.68  
    1.69  in
    1.70  
    1.71 @@ -96,7 +96,7 @@
    1.72  val axs_con_def   = map (fn (con,_) => ga (extern_name con ^"_def")) cons;
    1.73  val axs_dis_def   = map (fn (con,_) => ga (   dis_name con ^"_def")) cons;
    1.74  val axs_sel_def   = flat(map (fn (_,args) => 
    1.75 -		    map (fn     arg => ga (sel_of arg      ^"_def")) args) cons);
    1.76 +                    map (fn     arg => ga (sel_of arg      ^"_def")) args) cons);
    1.77  val ax_copy_def   = ga (dname^"_copy_def"  );
    1.78  end; (* local *)
    1.79  
    1.80 @@ -108,238 +108,238 @@
    1.81  val x_name = "x";
    1.82  
    1.83  val (rep_strict, abs_strict) = let 
    1.84 -	       val r = ax_rep_iso RS (ax_abs_iso RS (allI  RSN(2,allI RS iso_strict)))
    1.85 -	       in (r RS conjunct1, r RS conjunct2) end;
    1.86 +               val r = ax_rep_iso RS (ax_abs_iso RS (allI  RSN(2,allI RS iso_strict)))
    1.87 +               in (r RS conjunct1, r RS conjunct2) end;
    1.88  val abs_defin' = pg [] ((dc_abs`%x_name === UU) ==> (%x_name === UU)) [
    1.89 -				res_inst_tac [("t",x_name)] (ax_abs_iso RS subst) 1,
    1.90 -				etac ssubst 1,
    1.91 -				rtac rep_strict 1];
    1.92 +                                res_inst_tac [("t",x_name)] (ax_abs_iso RS subst) 1,
    1.93 +                                etac ssubst 1,
    1.94 +                                rtac rep_strict 1];
    1.95  val rep_defin' = pg [] ((dc_rep`%x_name === UU) ==> (%x_name === UU)) [
    1.96 -				res_inst_tac [("t",x_name)] (ax_rep_iso RS subst) 1,
    1.97 -				etac ssubst 1,
    1.98 -				rtac abs_strict 1];
    1.99 +                                res_inst_tac [("t",x_name)] (ax_rep_iso RS subst) 1,
   1.100 +                                etac ssubst 1,
   1.101 +                                rtac abs_strict 1];
   1.102  val iso_rews = [ax_abs_iso,ax_rep_iso,abs_strict,rep_strict];
   1.103  
   1.104  local 
   1.105  val iso_swap = pg [] (dc_rep`%"x" === %"y" ==> %"x" === dc_abs`%"y") [
   1.106 -				dres_inst_tac [("f",dname^"_abs")] cfun_arg_cong 1,
   1.107 -				etac (ax_rep_iso RS subst) 1];
   1.108 +                                dres_inst_tac [("f",dname^"_abs")] cfun_arg_cong 1,
   1.109 +                                etac (ax_rep_iso RS subst) 1];
   1.110  fun exh foldr1 cn quant foldr2 var = let
   1.111    fun one_con (con,args) = let val vns = map vname args in
   1.112      foldr quant (vns, foldr2 ((%x_name === con_app2 con (var vns) vns)::
   1.113 -			      map (defined o (var vns)) (nonlazy args))) end
   1.114 +                              map (defined o (var vns)) (nonlazy args))) end
   1.115    in foldr1 ((cn(%x_name===UU))::map one_con cons) end;
   1.116  in
   1.117  val cases = let 
   1.118 -	    fun common_tac thm = rtac thm 1 THEN contr_tac 1;
   1.119 -	    fun unit_tac true = common_tac liftE1
   1.120 -	    |   unit_tac _    = all_tac;
   1.121 -	    fun prod_tac []          = common_tac oneE
   1.122 -	    |   prod_tac [arg]       = unit_tac (is_lazy arg)
   1.123 -	    |   prod_tac (arg::args) = 
   1.124 -				common_tac sprodE THEN
   1.125 -				kill_neq_tac 1 THEN
   1.126 -				unit_tac (is_lazy arg) THEN
   1.127 -				prod_tac args;
   1.128 -	    fun sum_one_tac p = SELECT_GOAL(EVERY[
   1.129 -				rtac p 1,
   1.130 -				rewrite_goals_tac axs_con_def,
   1.131 -				dtac iso_swap 1,
   1.132 -				simp_tac HOLCF_ss 1,
   1.133 -				UNTIL_SOLVED(fast_tac HOL_cs 1)]) 1;
   1.134 -	    fun sum_tac [(_,args)]       [p]        = 
   1.135 -				prod_tac args THEN sum_one_tac p
   1.136 -	    |   sum_tac ((_,args)::cons') (p::prems) = DETERM(
   1.137 -				common_tac ssumE THEN
   1.138 -				kill_neq_tac 1 THEN kill_neq_tac 2 THEN
   1.139 -				prod_tac args THEN sum_one_tac p) THEN
   1.140 -				sum_tac cons' prems
   1.141 -	    |   sum_tac _ _ = Imposs "theorems:sum_tac";
   1.142 -	  in pg'' thy [] (exh (fn l => foldr (op ===>) (l,mk_trp(%"P")))
   1.143 -			      (fn T => T ==> %"P") mk_All
   1.144 -			      (fn l => foldr (op ===>) (map mk_trp l,mk_trp(%"P")))
   1.145 -			      bound_arg)
   1.146 -			     (fn prems => [
   1.147 -				cut_facts_tac [excluded_middle] 1,
   1.148 -				etac disjE 1,
   1.149 -				rtac (hd prems) 2,
   1.150 -				etac rep_defin' 2,
   1.151 -				if is_one_con_one_arg (not o is_lazy) cons
   1.152 -				then rtac (hd (tl prems)) 1 THEN atac 2 THEN
   1.153 -				     rewrite_goals_tac axs_con_def THEN
   1.154 -				     simp_tac (HOLCF_ss addsimps [ax_rep_iso]) 1
   1.155 -				else sum_tac cons (tl prems)])end;
   1.156 +            fun common_tac thm = rtac thm 1 THEN contr_tac 1;
   1.157 +            fun unit_tac true = common_tac liftE1
   1.158 +            |   unit_tac _    = all_tac;
   1.159 +            fun prod_tac []          = common_tac oneE
   1.160 +            |   prod_tac [arg]       = unit_tac (is_lazy arg)
   1.161 +            |   prod_tac (arg::args) = 
   1.162 +                                common_tac sprodE THEN
   1.163 +                                kill_neq_tac 1 THEN
   1.164 +                                unit_tac (is_lazy arg) THEN
   1.165 +                                prod_tac args;
   1.166 +            fun sum_one_tac p = SELECT_GOAL(EVERY[
   1.167 +                                rtac p 1,
   1.168 +                                rewrite_goals_tac axs_con_def,
   1.169 +                                dtac iso_swap 1,
   1.170 +                                simp_tac HOLCF_ss 1,
   1.171 +                                UNTIL_SOLVED(fast_tac HOL_cs 1)]) 1;
   1.172 +            fun sum_tac [(_,args)]       [p]        = 
   1.173 +                                prod_tac args THEN sum_one_tac p
   1.174 +            |   sum_tac ((_,args)::cons') (p::prems) = DETERM(
   1.175 +                                common_tac ssumE THEN
   1.176 +                                kill_neq_tac 1 THEN kill_neq_tac 2 THEN
   1.177 +                                prod_tac args THEN sum_one_tac p) THEN
   1.178 +                                sum_tac cons' prems
   1.179 +            |   sum_tac _ _ = Imposs "theorems:sum_tac";
   1.180 +          in pg'' thy [] (exh (fn l => foldr (op ===>) (l,mk_trp(%"P")))
   1.181 +                              (fn T => T ==> %"P") mk_All
   1.182 +                              (fn l => foldr (op ===>) (map mk_trp l,mk_trp(%"P")))
   1.183 +                              bound_arg)
   1.184 +                             (fn prems => [
   1.185 +                                cut_facts_tac [excluded_middle] 1,
   1.186 +                                etac disjE 1,
   1.187 +                                rtac (hd prems) 2,
   1.188 +                                etac rep_defin' 2,
   1.189 +                                if is_one_con_one_arg (not o is_lazy) cons
   1.190 +                                then rtac (hd (tl prems)) 1 THEN atac 2 THEN
   1.191 +                                     rewrite_goals_tac axs_con_def THEN
   1.192 +                                     simp_tac (HOLCF_ss addsimps [ax_rep_iso]) 1
   1.193 +                                else sum_tac cons (tl prems)])end;
   1.194  val exhaust = pg [] (mk_trp(exh (foldr' mk_disj) Id mk_ex (foldr' mk_conj) (K %))) [
   1.195 -				rtac cases 1,
   1.196 -				UNTIL_SOLVED(fast_tac HOL_cs 1)];
   1.197 +                                rtac cases 1,
   1.198 +                                UNTIL_SOLVED(fast_tac HOL_cs 1)];
   1.199  end;
   1.200  
   1.201  local 
   1.202  val when_app = foldl (op `) (%%(dname^"_when"), map % (when_funs cons));
   1.203  val when_appl = pg [ax_when_def] (mk_trp(when_app`%x_name===when_body cons 
   1.204 -		(fn (_,n) => %(nth_elem(n-1,when_funs cons)))`(dc_rep`%x_name))) [
   1.205 -				simp_tac HOLCF_ss 1];
   1.206 +                (fn (_,n) => %(nth_elem(n-1,when_funs cons)))`(dc_rep`%x_name))) [
   1.207 +                                simp_tac HOLCF_ss 1];
   1.208  in
   1.209  val when_strict = pg [] ((if is_one_con_one_arg (K true) cons 
   1.210 -	then fn t => mk_trp(strict(%"f")) ===> t else Id)(mk_trp(strict when_app))) [
   1.211 -				simp_tac(HOLCF_ss addsimps [when_appl,rep_strict]) 1];
   1.212 +        then fn t => mk_trp(strict(%"f")) ===> t else Id)(mk_trp(strict when_app))) [
   1.213 +                                simp_tac(HOLCF_ss addsimps [when_appl,rep_strict]) 1];
   1.214  val when_apps = let fun one_when n (con,args) = pg axs_con_def
   1.215 -		(lift_defined % (nonlazy args, mk_trp(when_app`(con_app con args) ===
   1.216 -		 mk_cfapp(%(nth_elem(n,when_funs cons)),map %# args))))[
   1.217 -			asm_simp_tac (HOLCF_ss addsimps [when_appl,ax_abs_iso]) 1];
   1.218 -		in mapn one_when 0 cons end;
   1.219 +                (lift_defined % (nonlazy args, mk_trp(when_app`(con_app con args) ===
   1.220 +                 mk_cfapp(%(nth_elem(n,when_funs cons)),map %# args))))[
   1.221 +                        asm_simp_tac (HOLCF_ss addsimps [when_appl,ax_abs_iso]) 1];
   1.222 +                in mapn one_when 0 cons end;
   1.223  end;
   1.224  val when_rews = when_strict::when_apps;
   1.225  
   1.226  (* ----- theorems concerning the constructors, discriminators and selectors ------- *)
   1.227  
   1.228  val dis_stricts = map (fn (con,_) => pg axs_dis_def (mk_trp(
   1.229 -			(if is_one_con_one_arg (K true) cons then mk_not else Id)
   1.230 -		         (strict(%%(dis_name con))))) [
   1.231 -		simp_tac (HOLCF_ss addsimps (if is_one_con_one_arg (K true) cons 
   1.232 -					then [ax_when_def] else when_rews)) 1]) cons;
   1.233 +                        (if is_one_con_one_arg (K true) cons then mk_not else Id)
   1.234 +                         (strict(%%(dis_name con))))) [
   1.235 +                simp_tac (HOLCF_ss addsimps (if is_one_con_one_arg (K true) cons 
   1.236 +                                        then [ax_when_def] else when_rews)) 1]) cons;
   1.237  val dis_apps = let fun one_dis c (con,args)= pg (axs_dis_def)
   1.238 -		   (lift_defined % (nonlazy args, (*(if is_one_con_one_arg is_lazy cons
   1.239 -			then curry (lift_defined %#) args else Id)
   1.240 +                   (lift_defined % (nonlazy args, (*(if is_one_con_one_arg is_lazy cons
   1.241 +                        then curry (lift_defined %#) args else Id)
   1.242  #################*)
   1.243 -			(mk_trp((%%(dis_name c))`(con_app con args) ===
   1.244 -			      %%(if con=c then "TT" else "FF"))))) [
   1.245 -				asm_simp_tac (HOLCF_ss addsimps when_rews) 1];
   1.246 -	in flat(map (fn (c,_) => map (one_dis c) cons) cons) end;
   1.247 +                        (mk_trp((%%(dis_name c))`(con_app con args) ===
   1.248 +                              %%(if con=c then "TT" else "FF"))))) [
   1.249 +                                asm_simp_tac (HOLCF_ss addsimps when_rews) 1];
   1.250 +        in flat(map (fn (c,_) => map (one_dis c) cons) cons) end;
   1.251  val dis_defins = map (fn (con,args) => pg [] (defined(%x_name)==> 
   1.252 -		      defined(%%(dis_name con)`%x_name)) [
   1.253 -				rtac cases 1,
   1.254 -				contr_tac 1,
   1.255 -				UNTIL_SOLVED (CHANGED(asm_simp_tac 
   1.256 -				              (HOLCF_ss addsimps dis_apps) 1))]) cons;
   1.257 +                      defined(%%(dis_name con)`%x_name)) [
   1.258 +                                rtac cases 1,
   1.259 +                                contr_tac 1,
   1.260 +                                UNTIL_SOLVED (CHANGED(asm_simp_tac 
   1.261 +                                              (HOLCF_ss addsimps dis_apps) 1))]) cons;
   1.262  val dis_rews = dis_stricts @ dis_defins @ dis_apps;
   1.263  
   1.264  val con_stricts = flat(map (fn (con,args) => map (fn vn =>
   1.265 -			pg (axs_con_def) 
   1.266 -			   (mk_trp(con_app2 con (fn arg => if vname arg = vn 
   1.267 -					then UU else %# arg) args === UU))[
   1.268 -				asm_simp_tac (HOLCF_ss addsimps [abs_strict]) 1]
   1.269 -			) (nonlazy args)) cons);
   1.270 +                        pg (axs_con_def) 
   1.271 +                           (mk_trp(con_app2 con (fn arg => if vname arg = vn 
   1.272 +                                        then UU else %# arg) args === UU))[
   1.273 +                                asm_simp_tac (HOLCF_ss addsimps [abs_strict]) 1]
   1.274 +                        ) (nonlazy args)) cons);
   1.275  val con_defins = map (fn (con,args) => pg []
   1.276 -			(lift_defined % (nonlazy args,
   1.277 -				mk_trp(defined(con_app con args)))) ([
   1.278 -				rtac swap3 1] @ (if is_one_con_one_arg (K true) cons 
   1.279 -				then [
   1.280 -				  if is_lazy (hd args) then rtac defined_up 2
   1.281 -						       else atac 2,
   1.282 -				  rtac abs_defin' 1,	
   1.283 -				  asm_full_simp_tac (HOLCF_ss addsimps axs_con_def) 1]
   1.284 -				else [
   1.285 -				  eres_inst_tac [("f",dis_name con)] cfun_arg_cong 1,
   1.286 -				  asm_simp_tac (HOLCF_ss addsimps dis_rews) 1])))cons;
   1.287 +                        (lift_defined % (nonlazy args,
   1.288 +                                mk_trp(defined(con_app con args)))) ([
   1.289 +                                rtac swap3 1] @ (if is_one_con_one_arg (K true) cons 
   1.290 +                                then [
   1.291 +                                  if is_lazy (hd args) then rtac defined_up 2
   1.292 +                                                       else atac 2,
   1.293 +                                  rtac abs_defin' 1,    
   1.294 +                                  asm_full_simp_tac (HOLCF_ss addsimps axs_con_def) 1]
   1.295 +                                else [
   1.296 +                                  eres_inst_tac [("f",dis_name con)] cfun_arg_cong 1,
   1.297 +                                  asm_simp_tac (HOLCF_ss addsimps dis_rews) 1])))cons;
   1.298  val con_rews = con_stricts @ con_defins;
   1.299  
   1.300  val sel_stricts = let fun one_sel sel = pg axs_sel_def (mk_trp(strict(%%sel))) [
   1.301 -				simp_tac (HOLCF_ss addsimps when_rews) 1];
   1.302 +                                simp_tac (HOLCF_ss addsimps when_rews) 1];
   1.303  in flat(map (fn (_,args) => map (fn arg => one_sel (sel_of arg)) args) cons) end;
   1.304  val sel_apps = let fun one_sel c n sel = map (fn (con,args) => 
   1.305 -		let val nlas = nonlazy args;
   1.306 -		    val vns  = map vname args;
   1.307 -		in pg axs_sel_def (lift_defined %
   1.308 -		   (filter (fn v => con=c andalso (v<>nth_elem(n,vns))) nlas,
   1.309 +                let val nlas = nonlazy args;
   1.310 +                    val vns  = map vname args;
   1.311 +                in pg axs_sel_def (lift_defined %
   1.312 +                   (filter (fn v => con=c andalso (v<>nth_elem(n,vns))) nlas,
   1.313     mk_trp((%%sel)`(con_app con args) === (if con=c then %(nth_elem(n,vns)) else UU))))
   1.314 -			    ( (if con=c then [] 
   1.315 -			       else map(case_UU_tac(when_rews@con_stricts)1) nlas)
   1.316 -			     @(if con=c andalso ((nth_elem(n,vns)) mem nlas)
   1.317 -					 then[case_UU_tac (when_rews @ con_stricts) 1 
   1.318 -							  (nth_elem(n,vns))] else [])
   1.319 -			     @ [asm_simp_tac(HOLCF_ss addsimps when_rews)1])end) cons;
   1.320 +                            ( (if con=c then [] 
   1.321 +                               else map(case_UU_tac(when_rews@con_stricts)1) nlas)
   1.322 +                             @(if con=c andalso ((nth_elem(n,vns)) mem nlas)
   1.323 +                                         then[case_UU_tac (when_rews @ con_stricts) 1 
   1.324 +                                                          (nth_elem(n,vns))] else [])
   1.325 +                             @ [asm_simp_tac(HOLCF_ss addsimps when_rews)1])end) cons;
   1.326  in flat(map  (fn (c,args) => 
   1.327 -	flat(mapn (fn n => fn arg => one_sel c n (sel_of arg)) 0 args)) cons) end;
   1.328 +        flat(mapn (fn n => fn arg => one_sel c n (sel_of arg)) 0 args)) cons) end;
   1.329  val sel_defins = if length cons = 1 then map (fn arg => pg [] (defined(%x_name) ==> 
   1.330 -			defined(%%(sel_of arg)`%x_name)) [
   1.331 -				rtac cases 1,
   1.332 -				contr_tac 1,
   1.333 -				UNTIL_SOLVED (CHANGED(asm_simp_tac 
   1.334 -				              (HOLCF_ss addsimps sel_apps) 1))]) 
   1.335 -		 (filter_out is_lazy (snd(hd cons))) else [];
   1.336 +                        defined(%%(sel_of arg)`%x_name)) [
   1.337 +                                rtac cases 1,
   1.338 +                                contr_tac 1,
   1.339 +                                UNTIL_SOLVED (CHANGED(asm_simp_tac 
   1.340 +                                              (HOLCF_ss addsimps sel_apps) 1))]) 
   1.341 +                 (filter_out is_lazy (snd(hd cons))) else [];
   1.342  val sel_rews = sel_stricts @ sel_defins @ sel_apps;
   1.343  
   1.344  val distincts_le = let
   1.345      fun dist (con1, args1) (con2, args2) = pg []
   1.346 -	      (lift_defined % ((nonlazy args1),
   1.347 -			     (mk_trp (con_app con1 args1 ~<< con_app con2 args2))))([
   1.348 -			rtac swap3 1,
   1.349 -			eres_inst_tac [("fo5",dis_name con1)] monofun_cfun_arg 1]
   1.350 -		      @ map (case_UU_tac (con_stricts @ dis_rews) 1) (nonlazy args2)
   1.351 -		      @[asm_simp_tac (HOLCF_ss addsimps dis_rews) 1]);
   1.352 +              (lift_defined % ((nonlazy args1),
   1.353 +                             (mk_trp (con_app con1 args1 ~<< con_app con2 args2))))([
   1.354 +                        rtac swap3 1,
   1.355 +                        eres_inst_tac [("fo5",dis_name con1)] monofun_cfun_arg 1]
   1.356 +                      @ map (case_UU_tac (con_stricts @ dis_rews) 1) (nonlazy args2)
   1.357 +                      @[asm_simp_tac (HOLCF_ss addsimps dis_rews) 1]);
   1.358      fun distinct (con1,args1) (con2,args2) =
   1.359 -	let val arg1 = (con1, args1);
   1.360 -	    val arg2 = (con2, (map (fn (arg,vn) => upd_vname (K vn) arg)
   1.361 -			      (args2~~variantlist(map vname args2,map vname args1))));
   1.362 -	in [dist arg1 arg2, dist arg2 arg1] end;
   1.363 +        let val arg1 = (con1, args1);
   1.364 +            val arg2 = (con2, (map (fn (arg,vn) => upd_vname (K vn) arg)
   1.365 +                              (args2~~variantlist(map vname args2,map vname args1))));
   1.366 +        in [dist arg1 arg2, dist arg2 arg1] end;
   1.367      fun distincts []      = []
   1.368      |   distincts (c::cs) = (map (distinct c) cs) :: distincts cs;
   1.369  in distincts cons end;
   1.370  val dists_le = flat (flat distincts_le);
   1.371  val dists_eq = let
   1.372      fun distinct (_,args1) ((_,args2),leqs) = let
   1.373 -	val (le1,le2) = (hd leqs, hd(tl leqs));
   1.374 -	val (eq1,eq2) = (le1 RS dist_eqI, le2 RS dist_eqI) in
   1.375 -	if nonlazy args1 = [] then [eq1, eq1 RS not_sym] else
   1.376 -	if nonlazy args2 = [] then [eq2, eq2 RS not_sym] else
   1.377 -					[eq1, eq2] end;
   1.378 +        val (le1,le2) = (hd leqs, hd(tl leqs));
   1.379 +        val (eq1,eq2) = (le1 RS dist_eqI, le2 RS dist_eqI) in
   1.380 +        if nonlazy args1 = [] then [eq1, eq1 RS not_sym] else
   1.381 +        if nonlazy args2 = [] then [eq2, eq2 RS not_sym] else
   1.382 +                                        [eq1, eq2] end;
   1.383      fun distincts []      = []
   1.384      |   distincts ((c,leqs)::cs) = flat(map (distinct c) ((map fst cs)~~leqs)) @
   1.385 -				   distincts cs;
   1.386 +                                   distincts cs;
   1.387      in distincts (cons~~distincts_le) end;
   1.388  
   1.389  local 
   1.390    fun pgterm rel con args = let
   1.391 -		fun append s = upd_vname(fn v => v^s);
   1.392 -		val (largs,rargs) = (args, map (append "'") args);
   1.393 -		in pg [] (mk_trp (rel(con_app con largs,con_app con rargs)) ===>
   1.394 -		      lift_defined % ((nonlazy largs),lift_defined % ((nonlazy rargs),
   1.395 -			    mk_trp (foldr' mk_conj 
   1.396 -				(map rel (map %# largs ~~ map %# rargs)))))) end;
   1.397 +                fun append s = upd_vname(fn v => v^s);
   1.398 +                val (largs,rargs) = (args, map (append "'") args);
   1.399 +                in pg [] (mk_trp (rel(con_app con largs,con_app con rargs)) ===>
   1.400 +                      lift_defined % ((nonlazy largs),lift_defined % ((nonlazy rargs),
   1.401 +                            mk_trp (foldr' mk_conj 
   1.402 +                                (map rel (map %# largs ~~ map %# rargs)))))) end;
   1.403    val cons' = filter (fn (_,args) => args<>[]) cons;
   1.404  in
   1.405  val inverts = map (fn (con,args) => 
   1.406 -		pgterm (op <<) con args (flat(map (fn arg => [
   1.407 -				TRY(rtac conjI 1),
   1.408 -				dres_inst_tac [("fo5",sel_of arg)] monofun_cfun_arg 1,
   1.409 -				asm_full_simp_tac (HOLCF_ss addsimps sel_apps) 1]
   1.410 -			     			      ) args))) cons';
   1.411 +                pgterm (op <<) con args (flat(map (fn arg => [
   1.412 +                                TRY(rtac conjI 1),
   1.413 +                                dres_inst_tac [("fo5",sel_of arg)] monofun_cfun_arg 1,
   1.414 +                                asm_full_simp_tac (HOLCF_ss addsimps sel_apps) 1]
   1.415 +                                                      ) args))) cons';
   1.416  val injects = map (fn ((con,args),inv_thm) => 
   1.417 -			   pgterm (op ===) con args [
   1.418 -				etac (antisym_less_inverse RS conjE) 1,
   1.419 -				dtac inv_thm 1, REPEAT(atac 1),
   1.420 -				dtac inv_thm 1, REPEAT(atac 1),
   1.421 -				TRY(safe_tac HOL_cs),
   1.422 -				REPEAT(rtac antisym_less 1 ORELSE atac 1)] )
   1.423 -		  (cons'~~inverts);
   1.424 +                           pgterm (op ===) con args [
   1.425 +                                etac (antisym_less_inverse RS conjE) 1,
   1.426 +                                dtac inv_thm 1, REPEAT(atac 1),
   1.427 +                                dtac inv_thm 1, REPEAT(atac 1),
   1.428 +                                TRY(safe_tac HOL_cs),
   1.429 +                                REPEAT(rtac antisym_less 1 ORELSE atac 1)] )
   1.430 +                  (cons'~~inverts);
   1.431  end;
   1.432  
   1.433  (* ----- theorems concerning one induction step ----------------------------------- *)
   1.434  
   1.435  val copy_strict = pg [ax_copy_def] ((if is_one_con_one_arg (K true) cons then fn t =>
   1.436 -	 mk_trp(strict(cproj (%"f") eqs (rec_of (hd(snd(hd cons)))))) ===> t
   1.437 -	else Id) (mk_trp(strict(dc_copy`%"f")))) [
   1.438 -				asm_simp_tac(HOLCF_ss addsimps [abs_strict,rep_strict,
   1.439 -							cfst_strict,csnd_strict]) 1];
   1.440 +         mk_trp(strict(cproj (%"f") eqs (rec_of (hd(snd(hd cons)))))) ===> t
   1.441 +        else Id) (mk_trp(strict(dc_copy`%"f")))) [
   1.442 +                                asm_simp_tac(HOLCF_ss addsimps [abs_strict,rep_strict,
   1.443 +                                                        cfst_strict,csnd_strict]) 1];
   1.444  val copy_apps = map (fn (con,args) => pg (ax_copy_def::axs_con_def)
   1.445 -		    (lift_defined %# (filter is_nonlazy_rec args,
   1.446 -			mk_trp(dc_copy`%"f"`(con_app con args) ===
   1.447 -			   (con_app2 con (app_rec_arg (cproj (%"f") eqs)) args))))
   1.448 -				 (map (case_UU_tac [ax_abs_iso] 1 o vname)
   1.449 -				   (filter(fn a=>not(is_rec a orelse is_lazy a))args)@
   1.450 -				 [asm_simp_tac (HOLCF_ss addsimps [ax_abs_iso]) 1])
   1.451 -		)cons;
   1.452 +                    (lift_defined %# (filter is_nonlazy_rec args,
   1.453 +                        mk_trp(dc_copy`%"f"`(con_app con args) ===
   1.454 +                           (con_app2 con (app_rec_arg (cproj (%"f") eqs)) args))))
   1.455 +                                 (map (case_UU_tac [ax_abs_iso] 1 o vname)
   1.456 +                                   (filter(fn a=>not(is_rec a orelse is_lazy a))args)@
   1.457 +                                 [asm_simp_tac (HOLCF_ss addsimps [ax_abs_iso]) 1])
   1.458 +                )cons;
   1.459  val copy_stricts = map(fn(con,args)=>pg[](mk_trp(dc_copy`UU`(con_app con args) ===UU))
   1.460 -	     (let val rews = cfst_strict::csnd_strict::copy_strict::copy_apps@con_rews
   1.461 -			 in map (case_UU_tac rews 1) (nonlazy args) @ [
   1.462 -			     asm_simp_tac (HOLCF_ss addsimps rews) 1] end))
   1.463 -		   (filter (fn (_,args)=>exists is_nonlazy_rec args) cons);
   1.464 +             (let val rews = cfst_strict::csnd_strict::copy_strict::copy_apps@con_rews
   1.465 +                         in map (case_UU_tac rews 1) (nonlazy args) @ [
   1.466 +                             asm_simp_tac (HOLCF_ss addsimps rews) 1] end))
   1.467 +                   (filter (fn (_,args)=>exists is_nonlazy_rec args) cons);
   1.468  val copy_rews = copy_strict::copy_apps @ copy_stricts;
   1.469  
   1.470  in     (iso_rews, exhaust, cases, when_rews,
   1.471 -	con_rews, sel_rews, dis_rews, dists_eq, dists_le, inverts, injects,
   1.472 -	copy_rews)
   1.473 +        con_rews, sel_rews, dis_rews, dists_eq, dists_le, inverts, injects,
   1.474 +        copy_rews)
   1.475  end; (* let *)
   1.476  
   1.477  
   1.478 @@ -369,186 +369,186 @@
   1.479  val P_name = idx_name dnames "P";
   1.480  
   1.481  local
   1.482 -  val iterate_ss = simpset_of "Fix";	
   1.483 +  val iterate_ss = simpset_of "Fix";    
   1.484    val iterate_Cprod_strict_ss = iterate_ss addsimps [cfst_strict, csnd_strict];
   1.485    val iterate_Cprod_ss = iterate_ss addsimps [cfst2,csnd2,csplit2];
   1.486    val copy_con_rews  = copy_rews @ con_rews;
   1.487    val copy_take_defs = (if length dnames=1 then [] else [ax_copy2_def]) @axs_take_def;
   1.488    val take_stricts = pg copy_take_defs (mk_trp(foldr' mk_conj (map (fn ((dn,args),_)=>
   1.489 -		  (dc_take dn $ %"n")`UU === mk_constrain(Type(dn,args),UU)) eqs)))([
   1.490 -				nat_ind_tac "n" 1,
   1.491 -				simp_tac iterate_ss 1,
   1.492 -				simp_tac iterate_Cprod_strict_ss 1,
   1.493 -				asm_simp_tac iterate_Cprod_ss 1,
   1.494 -				TRY(safe_tac HOL_cs)] @
   1.495 -			map(K(asm_simp_tac (HOL_ss addsimps copy_rews)1))dnames);
   1.496 +                  (dc_take dn $ %"n")`UU === mk_constrain(Type(dn,args),UU)) eqs)))([
   1.497 +                                nat_ind_tac "n" 1,
   1.498 +                                simp_tac iterate_ss 1,
   1.499 +                                simp_tac iterate_Cprod_strict_ss 1,
   1.500 +                                asm_simp_tac iterate_Cprod_ss 1,
   1.501 +                                TRY(safe_tac HOL_cs)] @
   1.502 +                        map(K(asm_simp_tac (HOL_ss addsimps copy_rews)1))dnames);
   1.503    val take_stricts' = rewrite_rule copy_take_defs take_stricts;
   1.504    val take_0s = mapn (fn n => fn dn => pg axs_take_def(mk_trp((dc_take dn $ %%"0")
   1.505 -								`%x_name n === UU))[
   1.506 -				simp_tac iterate_Cprod_strict_ss 1]) 1 dnames;
   1.507 +                                                                `%x_name n === UU))[
   1.508 +                                simp_tac iterate_Cprod_strict_ss 1]) 1 dnames;
   1.509    val take_apps = pg copy_take_defs (mk_trp(foldr' mk_conj 
   1.510 -	    (flat(map (fn ((dn,_),cons) => map (fn (con,args) => foldr mk_all 
   1.511 -		(map vname args,(dc_take dn $ (%%"Suc" $ %"n"))`(con_app con args) ===
   1.512 -  		 con_app2 con (app_rec_arg (fn n=>dc_take (nth_elem(n,dnames))$ %"n"))
   1.513 -			      args)) cons) eqs)))) ([
   1.514 -				nat_ind_tac "n" 1,
   1.515 -				simp_tac iterate_Cprod_strict_ss 1,
   1.516 -				simp_tac (HOLCF_ss addsimps copy_con_rews) 1,
   1.517 -				TRY(safe_tac HOL_cs)] @
   1.518 -			(flat(map (fn ((dn,_),cons) => map (fn (con,args) => EVERY (
   1.519 -				asm_full_simp_tac iterate_Cprod_ss 1::
   1.520 -				map (case_UU_tac (take_stricts'::copy_con_rews) 1)
   1.521 -				    (nonlazy args) @[
   1.522 -				asm_full_simp_tac (HOLCF_ss addsimps copy_rews) 1])
   1.523 -		 	) cons) eqs)));
   1.524 +            (flat(map (fn ((dn,_),cons) => map (fn (con,args) => foldr mk_all 
   1.525 +                (map vname args,(dc_take dn $ (%%"Suc" $ %"n"))`(con_app con args) ===
   1.526 +                 con_app2 con (app_rec_arg (fn n=>dc_take (nth_elem(n,dnames))$ %"n"))
   1.527 +                              args)) cons) eqs)))) ([
   1.528 +                                nat_ind_tac "n" 1,
   1.529 +                                simp_tac iterate_Cprod_strict_ss 1,
   1.530 +                                simp_tac (HOLCF_ss addsimps copy_con_rews) 1,
   1.531 +                                TRY(safe_tac HOL_cs)] @
   1.532 +                        (flat(map (fn ((dn,_),cons) => map (fn (con,args) => EVERY (
   1.533 +                                asm_full_simp_tac iterate_Cprod_ss 1::
   1.534 +                                map (case_UU_tac (take_stricts'::copy_con_rews) 1)
   1.535 +                                    (nonlazy args) @[
   1.536 +                                asm_full_simp_tac (HOLCF_ss addsimps copy_rews) 1])
   1.537 +                        ) cons) eqs)));
   1.538  in
   1.539  val take_rews = atomize take_stricts @ take_0s @ atomize take_apps;
   1.540  end; (* local *)
   1.541  
   1.542  val take_lemmas = mapn (fn n => fn(dn,ax_reach) => pg'' thy axs_take_def (mk_All("n",
   1.543 -		mk_trp(dc_take dn $ Bound 0 `%(x_name n) === 
   1.544 -		       dc_take dn $ Bound 0 `%(x_name n^"'")))
   1.545 -	   ===> mk_trp(%(x_name n) === %(x_name n^"'"))) (fn prems => [
   1.546 -				res_inst_tac[("t",x_name n    )](ax_reach RS subst) 1,
   1.547 -				res_inst_tac[("t",x_name n^"'")](ax_reach RS subst) 1,
   1.548 -				rtac (fix_def2 RS ssubst) 1,
   1.549 -				REPEAT(CHANGED(rtac (contlub_cfun_arg RS ssubst) 1
   1.550 -					       THEN chain_tac 1)),
   1.551 -				rtac (contlub_cfun_fun RS ssubst) 1,
   1.552 -				rtac (contlub_cfun_fun RS ssubst) 2,
   1.553 -				rtac lub_equal 3,
   1.554 -				chain_tac 1,
   1.555 -				rtac allI 1,
   1.556 -				resolve_tac prems 1])) 1 (dnames~~axs_reach);
   1.557 +                mk_trp(dc_take dn $ Bound 0 `%(x_name n) === 
   1.558 +                       dc_take dn $ Bound 0 `%(x_name n^"'")))
   1.559 +           ===> mk_trp(%(x_name n) === %(x_name n^"'"))) (fn prems => [
   1.560 +                                res_inst_tac[("t",x_name n    )](ax_reach RS subst) 1,
   1.561 +                                res_inst_tac[("t",x_name n^"'")](ax_reach RS subst) 1,
   1.562 +                                rtac (fix_def2 RS ssubst) 1,
   1.563 +                                REPEAT(CHANGED(rtac (contlub_cfun_arg RS ssubst) 1
   1.564 +                                               THEN chain_tac 1)),
   1.565 +                                rtac (contlub_cfun_fun RS ssubst) 1,
   1.566 +                                rtac (contlub_cfun_fun RS ssubst) 2,
   1.567 +                                rtac lub_equal 3,
   1.568 +                                chain_tac 1,
   1.569 +                                rtac allI 1,
   1.570 +                                resolve_tac prems 1])) 1 (dnames~~axs_reach);
   1.571  
   1.572  local
   1.573    fun one_con p (con,args) = foldr mk_All (map vname args,
   1.574 -	lift_defined (bound_arg (map vname args)) (nonlazy args,
   1.575 -	lift (fn arg => %(P_name (1+rec_of arg)) $ bound_arg args arg)
   1.576 -	     (filter is_rec args,mk_trp(%p $ con_app2 con (bound_arg args) args))));
   1.577 +        lift_defined (bound_arg (map vname args)) (nonlazy args,
   1.578 +        lift (fn arg => %(P_name (1+rec_of arg)) $ bound_arg args arg)
   1.579 +             (filter is_rec args,mk_trp(%p $ con_app2 con (bound_arg args) args))));
   1.580    fun one_eq ((p,cons),concl) = (mk_trp(%p $ UU) ===> 
   1.581 -			   foldr (op ===>) (map (one_con p) cons,concl));
   1.582 +                           foldr (op ===>) (map (one_con p) cons,concl));
   1.583    fun ind_term concf = foldr one_eq (mapn (fn n => fn x => (P_name n, x)) 1 conss,
   1.584 -	mk_trp(foldr' mk_conj (mapn (fn n => concf (P_name n,x_name n)) 1 dnames)));
   1.585 +        mk_trp(foldr' mk_conj (mapn (fn n => concf (P_name n,x_name n)) 1 dnames)));
   1.586    val take_ss = HOL_ss addsimps take_rews;
   1.587    fun ind_tacs tacsf thms1 thms2 prems = TRY(safe_tac HOL_cs)::
   1.588 -				flat (mapn (fn n => fn (thm1,thm2) => 
   1.589 -				  tacsf (n,prems) (thm1,thm2) @ 
   1.590 -				  flat (map (fn cons =>
   1.591 -				    (resolve_tac prems 1 ::
   1.592 -				     flat (map (fn (_,args) => 
   1.593 -				       resolve_tac prems 1::
   1.594 -				       map (K(atac 1)) (nonlazy args) @
   1.595 -				       map (K(atac 1)) (filter is_rec args))
   1.596 -				     cons)))
   1.597 -				   conss))
   1.598 -				0 (thms1~~thms2));
   1.599 +                                flat (mapn (fn n => fn (thm1,thm2) => 
   1.600 +                                  tacsf (n,prems) (thm1,thm2) @ 
   1.601 +                                  flat (map (fn cons =>
   1.602 +                                    (resolve_tac prems 1 ::
   1.603 +                                     flat (map (fn (_,args) => 
   1.604 +                                       resolve_tac prems 1::
   1.605 +                                       map (K(atac 1)) (nonlazy args) @
   1.606 +                                       map (K(atac 1)) (filter is_rec args))
   1.607 +                                     cons)))
   1.608 +                                   conss))
   1.609 +                                0 (thms1~~thms2));
   1.610    local 
   1.611      fun all_rec_to ns lazy_rec (n,cons) = forall (exists (fn arg => 
   1.612 -		  is_rec arg andalso not(rec_of arg mem ns) andalso
   1.613 -		  ((rec_of arg =  n andalso not(lazy_rec orelse is_lazy arg)) orelse 
   1.614 -		    rec_of arg <> n andalso all_rec_to (rec_of arg::ns) 
   1.615 -		      (lazy_rec orelse is_lazy arg) (n, (nth_elem(rec_of arg,conss))))
   1.616 -		  ) o snd) cons;
   1.617 +                  is_rec arg andalso not(rec_of arg mem ns) andalso
   1.618 +                  ((rec_of arg =  n andalso not(lazy_rec orelse is_lazy arg)) orelse 
   1.619 +                    rec_of arg <> n andalso all_rec_to (rec_of arg::ns) 
   1.620 +                      (lazy_rec orelse is_lazy arg) (n, (nth_elem(rec_of arg,conss))))
   1.621 +                  ) o snd) cons;
   1.622      fun warn (n,cons) = if all_rec_to [] false (n,cons) then (writeln 
   1.623 -			   ("WARNING: domain "^nth_elem(n,dnames)^" is empty!"); true)
   1.624 -			else false;
   1.625 +                           ("WARNING: domain "^nth_elem(n,dnames)^" is empty!"); true)
   1.626 +                        else false;
   1.627      fun lazy_rec_to ns lazy_rec (n,cons) = exists (exists (fn arg => 
   1.628 -		  is_rec arg andalso not(rec_of arg mem ns) andalso
   1.629 -		  ((rec_of arg =  n andalso (lazy_rec orelse is_lazy arg)) orelse 
   1.630 -		    rec_of arg <> n andalso lazy_rec_to (rec_of arg::ns)
   1.631 -		     (lazy_rec orelse is_lazy arg) (n, (nth_elem(rec_of arg,conss))))
   1.632 -		 ) o snd) cons;
   1.633 +                  is_rec arg andalso not(rec_of arg mem ns) andalso
   1.634 +                  ((rec_of arg =  n andalso (lazy_rec orelse is_lazy arg)) orelse 
   1.635 +                    rec_of arg <> n andalso lazy_rec_to (rec_of arg::ns)
   1.636 +                     (lazy_rec orelse is_lazy arg) (n, (nth_elem(rec_of arg,conss))))
   1.637 +                 ) o snd) cons;
   1.638    in val is_emptys = map warn (mapn (fn n => fn (_,cons) => (n,cons)) 0 eqs);
   1.639       val is_finite = forall (not o lazy_rec_to [] false) 
   1.640 -			    (mapn (fn n => fn (_,cons) => (n,cons)) 0 eqs)
   1.641 +                            (mapn (fn n => fn (_,cons) => (n,cons)) 0 eqs)
   1.642    end;
   1.643  in
   1.644  val finite_ind = pg'' thy [] (ind_term (fn (P,x) => fn dn => 
   1.645 -			  mk_all(x,%P $ (dc_take dn $ %"n" `Bound 0)))) (fn prems=> [
   1.646 -				nat_ind_tac "n" 1,
   1.647 -				simp_tac (take_ss addsimps prems) 1,
   1.648 -				TRY(safe_tac HOL_cs)]
   1.649 -				@ flat(mapn (fn n => fn (cons,cases) => [
   1.650 -				 res_inst_tac [("x",x_name n)] cases 1,
   1.651 -				 asm_simp_tac (take_ss addsimps prems) 1]
   1.652 -				 @ flat(map (fn (con,args) => 
   1.653 -				  asm_simp_tac take_ss 1 ::
   1.654 -				  map (fn arg =>
   1.655 -				   case_UU_tac (prems@con_rews) 1 (
   1.656 -				   nth_elem(rec_of arg,dnames)^"_take n1`"^vname arg))
   1.657 -				  (filter is_nonlazy_rec args) @ [
   1.658 -				  resolve_tac prems 1] @
   1.659 -				  map (K (atac 1))      (nonlazy args) @
   1.660 -				  map (K (etac spec 1)) (filter is_rec args)) 
   1.661 -				 cons))
   1.662 -				1 (conss~~casess)));
   1.663 +                          mk_all(x,%P $ (dc_take dn $ %"n" `Bound 0)))) (fn prems=> [
   1.664 +                                nat_ind_tac "n" 1,
   1.665 +                                simp_tac (take_ss addsimps prems) 1,
   1.666 +                                TRY(safe_tac HOL_cs)]
   1.667 +                                @ flat(mapn (fn n => fn (cons,cases) => [
   1.668 +                                 res_inst_tac [("x",x_name n)] cases 1,
   1.669 +                                 asm_simp_tac (take_ss addsimps prems) 1]
   1.670 +                                 @ flat(map (fn (con,args) => 
   1.671 +                                  asm_simp_tac take_ss 1 ::
   1.672 +                                  map (fn arg =>
   1.673 +                                   case_UU_tac (prems@con_rews) 1 (
   1.674 +                                   nth_elem(rec_of arg,dnames)^"_take n1`"^vname arg))
   1.675 +                                  (filter is_nonlazy_rec args) @ [
   1.676 +                                  resolve_tac prems 1] @
   1.677 +                                  map (K (atac 1))      (nonlazy args) @
   1.678 +                                  map (K (etac spec 1)) (filter is_rec args)) 
   1.679 +                                 cons))
   1.680 +                                1 (conss~~casess)));
   1.681  
   1.682  val (finites,ind) = if is_finite then
   1.683  let 
   1.684    fun take_enough dn = mk_ex ("n",dc_take dn $ Bound 0 ` %"x" === %"x");
   1.685    val finite_lemmas1a = map (fn dn => pg [] (mk_trp(defined (%"x")) ===> 
   1.686 -	mk_trp(mk_disj(mk_all("n",dc_take dn $ Bound 0 ` %"x" === UU),
   1.687 -	take_enough dn)) ===> mk_trp(take_enough dn)) [
   1.688 -				etac disjE 1,
   1.689 -				etac notE 1,
   1.690 -				resolve_tac take_lemmas 1,
   1.691 -				asm_simp_tac take_ss 1,
   1.692 -				atac 1]) dnames;
   1.693 +        mk_trp(mk_disj(mk_all("n",dc_take dn $ Bound 0 ` %"x" === UU),
   1.694 +        take_enough dn)) ===> mk_trp(take_enough dn)) [
   1.695 +                                etac disjE 1,
   1.696 +                                etac notE 1,
   1.697 +                                resolve_tac take_lemmas 1,
   1.698 +                                asm_simp_tac take_ss 1,
   1.699 +                                atac 1]) dnames;
   1.700    val finite_lemma1b = pg [] (mk_trp (mk_all("n",foldr' mk_conj (mapn 
   1.701 -	(fn n => fn ((dn,args),_) => mk_constrainall(x_name n,Type(dn,args),
   1.702 -	 mk_disj(dc_take dn $ Bound 1 ` Bound 0 === UU,
   1.703 -		 dc_take dn $ Bound 1 ` Bound 0 === Bound 0))) 1 eqs)))) ([
   1.704 -				rtac allI 1,
   1.705 -				nat_ind_tac "n" 1,
   1.706 -				simp_tac take_ss 1,
   1.707 -				TRY(safe_tac(empty_cs addSEs[conjE] addSIs[conjI]))] @
   1.708 -				flat(mapn (fn n => fn (cons,cases) => [
   1.709 -				  simp_tac take_ss 1,
   1.710 -				  rtac allI 1,
   1.711 -				  res_inst_tac [("x",x_name n)] cases 1,
   1.712 -				  asm_simp_tac take_ss 1] @ 
   1.713 -				  flat(map (fn (con,args) => 
   1.714 -				    asm_simp_tac take_ss 1 ::
   1.715 -				    flat(map (fn arg => [
   1.716 -				      eres_inst_tac [("x",vname arg)] all_dupE 1,
   1.717 -				      etac disjE 1,
   1.718 -				      asm_simp_tac (HOL_ss addsimps con_rews) 1,
   1.719 -				      asm_simp_tac take_ss 1])
   1.720 -				    (filter is_nonlazy_rec args)))
   1.721 -				  cons))
   1.722 -				1 (conss~~casess))) handle ERROR => raise ERROR;
   1.723 +        (fn n => fn ((dn,args),_) => mk_constrainall(x_name n,Type(dn,args),
   1.724 +         mk_disj(dc_take dn $ Bound 1 ` Bound 0 === UU,
   1.725 +                 dc_take dn $ Bound 1 ` Bound 0 === Bound 0))) 1 eqs)))) ([
   1.726 +                                rtac allI 1,
   1.727 +                                nat_ind_tac "n" 1,
   1.728 +                                simp_tac take_ss 1,
   1.729 +                                TRY(safe_tac(empty_cs addSEs[conjE] addSIs[conjI]))] @
   1.730 +                                flat(mapn (fn n => fn (cons,cases) => [
   1.731 +                                  simp_tac take_ss 1,
   1.732 +                                  rtac allI 1,
   1.733 +                                  res_inst_tac [("x",x_name n)] cases 1,
   1.734 +                                  asm_simp_tac take_ss 1] @ 
   1.735 +                                  flat(map (fn (con,args) => 
   1.736 +                                    asm_simp_tac take_ss 1 ::
   1.737 +                                    flat(map (fn arg => [
   1.738 +                                      eres_inst_tac [("x",vname arg)] all_dupE 1,
   1.739 +                                      etac disjE 1,
   1.740 +                                      asm_simp_tac (HOL_ss addsimps con_rews) 1,
   1.741 +                                      asm_simp_tac take_ss 1])
   1.742 +                                    (filter is_nonlazy_rec args)))
   1.743 +                                  cons))
   1.744 +                                1 (conss~~casess))) handle ERROR => raise ERROR;
   1.745    val all_finite=map (fn(dn,l1b)=>pg axs_finite_def (mk_trp(%%(dn^"_finite") $ %"x"))[
   1.746 -				case_UU_tac take_rews 1 "x",
   1.747 -				eresolve_tac finite_lemmas1a 1,
   1.748 -				step_tac HOL_cs 1,
   1.749 -				step_tac HOL_cs 1,
   1.750 -				cut_facts_tac [l1b] 1,
   1.751 -				fast_tac HOL_cs 1]) (dnames~~atomize finite_lemma1b);
   1.752 +                                case_UU_tac take_rews 1 "x",
   1.753 +                                eresolve_tac finite_lemmas1a 1,
   1.754 +                                step_tac HOL_cs 1,
   1.755 +                                step_tac HOL_cs 1,
   1.756 +                                cut_facts_tac [l1b] 1,
   1.757 +                                fast_tac HOL_cs 1]) (dnames~~atomize finite_lemma1b);
   1.758  in
   1.759  (all_finite,
   1.760   pg'' thy [] (ind_term (fn (P,x) => fn dn => %P $ %x))
   1.761 -			       (ind_tacs (fn _ => fn (all_fin,finite_ind) => [
   1.762 -				rtac (rewrite_rule axs_finite_def all_fin RS exE) 1,
   1.763 -				etac subst 1,
   1.764 -				rtac finite_ind 1]) all_finite (atomize finite_ind))
   1.765 +                               (ind_tacs (fn _ => fn (all_fin,finite_ind) => [
   1.766 +                                rtac (rewrite_rule axs_finite_def all_fin RS exE) 1,
   1.767 +                                etac subst 1,
   1.768 +                                rtac finite_ind 1]) all_finite (atomize finite_ind))
   1.769  ) end (* let *) else
   1.770  (mapn (fn n => fn dn => read_instantiate_sg (sign_of thy) 
   1.771 -	  	    [("P",dn^"_finite "^x_name n)] excluded_middle) 1 dnames,
   1.772 +                    [("P",dn^"_finite "^x_name n)] excluded_middle) 1 dnames,
   1.773   pg'' thy [] (foldr (op ===>) (mapn (fn n =>K(mk_trp(%%"adm" $ %(P_name n))))1
   1.774 -				       dnames,ind_term (fn(P,x)=>fn dn=> %P $ %x)))
   1.775 -			       (ind_tacs (fn (n,prems) => fn (ax_reach,finite_ind) =>[
   1.776 -				rtac (ax_reach RS subst) 1,
   1.777 -				res_inst_tac [("x",x_name n)] spec 1,
   1.778 -				rtac wfix_ind 1,
   1.779 -				rtac adm_impl_admw 1,
   1.780 -				resolve_tac adm_thms 1,
   1.781 -				rtac adm_subst 1,
   1.782 -				cont_tacR 1,
   1.783 -				resolve_tac prems 1,
   1.784 -				strip_tac 1,
   1.785 -			        rtac(rewrite_rule axs_take_def finite_ind) 1])
   1.786 -				 axs_reach (atomize finite_ind))
   1.787 +                                       dnames,ind_term (fn(P,x)=>fn dn=> %P $ %x)))
   1.788 +                               (ind_tacs (fn (n,prems) => fn (ax_reach,finite_ind) =>[
   1.789 +                                rtac (ax_reach RS subst) 1,
   1.790 +                                res_inst_tac [("x",x_name n)] spec 1,
   1.791 +                                rtac wfix_ind 1,
   1.792 +                                rtac adm_impl_admw 1,
   1.793 +                                resolve_tac adm_thms 1,
   1.794 +                                rtac adm_subst 1,
   1.795 +                                cont_tacR 1,
   1.796 +                                resolve_tac prems 1,
   1.797 +                                strip_tac 1,
   1.798 +                                rtac(rewrite_rule axs_take_def finite_ind) 1])
   1.799 +                                 axs_reach (atomize finite_ind))
   1.800  )
   1.801  end; (* local *)
   1.802  
   1.803 @@ -558,34 +558,34 @@
   1.804    val take_ss = HOL_ss addsimps take_rews;
   1.805    val sproj   = bin_branchr (fn s => "fst("^s^")") (fn s => "snd("^s^")");
   1.806    val coind_lemma = pg [ax_bisim_def] (mk_trp(mk_imp(%%(comp_dname^"_bisim") $ %"R",
   1.807 -		foldr (fn (x,t)=> mk_all(x,mk_all(x^"'",t))) (xs,
   1.808 -		  foldr mk_imp (mapn (fn n => K(proj (%"R") dnames n $ 
   1.809 -				      bnd_arg n 0 $ bnd_arg n 1)) 0 dnames,
   1.810 -		    foldr' mk_conj (mapn (fn n => fn dn => 
   1.811 -				(dc_take dn $ %"n" `bnd_arg n 0 === 
   1.812 -				(dc_take dn $ %"n" `bnd_arg n 1))) 0 dnames)))))) ([
   1.813 -				rtac impI 1,
   1.814 -				nat_ind_tac "n" 1,
   1.815 -				simp_tac take_ss 1,
   1.816 -				safe_tac HOL_cs] @
   1.817 -				flat(mapn (fn n => fn x => [
   1.818 -				  etac allE 1, etac allE 1, 
   1.819 -				  eres_inst_tac [("P1",sproj "R" dnames n^
   1.820 -						  " "^x^" "^x^"'")](mp RS disjE) 1,
   1.821 -				  TRY(safe_tac HOL_cs),
   1.822 -				  REPEAT(CHANGED(asm_simp_tac take_ss 1))]) 
   1.823 -				0 xs));
   1.824 +                foldr (fn (x,t)=> mk_all(x,mk_all(x^"'",t))) (xs,
   1.825 +                  foldr mk_imp (mapn (fn n => K(proj (%"R") dnames n $ 
   1.826 +                                      bnd_arg n 0 $ bnd_arg n 1)) 0 dnames,
   1.827 +                    foldr' mk_conj (mapn (fn n => fn dn => 
   1.828 +                                (dc_take dn $ %"n" `bnd_arg n 0 === 
   1.829 +                                (dc_take dn $ %"n" `bnd_arg n 1))) 0 dnames)))))) ([
   1.830 +                                rtac impI 1,
   1.831 +                                nat_ind_tac "n" 1,
   1.832 +                                simp_tac take_ss 1,
   1.833 +                                safe_tac HOL_cs] @
   1.834 +                                flat(mapn (fn n => fn x => [
   1.835 +                                  etac allE 1, etac allE 1, 
   1.836 +                                  eres_inst_tac [("P1",sproj "R" dnames n^
   1.837 +                                                  " "^x^" "^x^"'")](mp RS disjE) 1,
   1.838 +                                  TRY(safe_tac HOL_cs),
   1.839 +                                  REPEAT(CHANGED(asm_simp_tac take_ss 1))]) 
   1.840 +                                0 xs));
   1.841  in
   1.842  val coind = pg [] (mk_trp(%%(comp_dname^"_bisim") $ %"R") ===>
   1.843 -		foldr (op ===>) (mapn (fn n => fn x => 
   1.844 -			mk_trp(proj (%"R") dnames n $ %x $ %(x^"'"))) 0 xs,
   1.845 -			mk_trp(foldr' mk_conj (map (fn x => %x === %(x^"'")) xs)))) ([
   1.846 -				TRY(safe_tac HOL_cs)] @
   1.847 -				flat(map (fn take_lemma => [
   1.848 -				  rtac take_lemma 1,
   1.849 -				  cut_facts_tac [coind_lemma] 1,
   1.850 -				  fast_tac HOL_cs 1])
   1.851 -				take_lemmas));
   1.852 +                foldr (op ===>) (mapn (fn n => fn x => 
   1.853 +                        mk_trp(proj (%"R") dnames n $ %x $ %(x^"'"))) 0 xs,
   1.854 +                        mk_trp(foldr' mk_conj (map (fn x => %x === %(x^"'")) xs)))) ([
   1.855 +                                TRY(safe_tac HOL_cs)] @
   1.856 +                                flat(map (fn take_lemma => [
   1.857 +                                  rtac take_lemma 1,
   1.858 +                                  cut_facts_tac [coind_lemma] 1,
   1.859 +                                  fast_tac HOL_cs 1])
   1.860 +                                take_lemmas));
   1.861  end; (* local *)
   1.862  
   1.863