new session Complex for the complex numbers
authorpaulson
Mon May 05 18:22:31 2003 +0200 (2003-05-05)
changeset 1395710dbf16be15f
parent 13956 8fe7e12290e1
child 13958 c1c67582c9b5
new session Complex for the complex numbers
src/HOL/Complex/CLim.ML
src/HOL/Complex/CLim.thy
src/HOL/Complex/CSeries.ML
src/HOL/Complex/CSeries.thy
src/HOL/Complex/CStar.ML
src/HOL/Complex/CStar.thy
src/HOL/Complex/Complex.ML
src/HOL/Complex/Complex.thy
src/HOL/Complex/ComplexArith0.ML
src/HOL/Complex/ComplexArith0.thy
src/HOL/Complex/ComplexBin.ML
src/HOL/Complex/ComplexBin.thy
src/HOL/Complex/NSCA.ML
src/HOL/Complex/NSCA.thy
src/HOL/Complex/NSComplex.ML
src/HOL/Complex/NSComplex.thy
src/HOL/Complex/NSComplexArith0.ML
src/HOL/Complex/NSComplexArith0.thy
src/HOL/Complex/NSComplexBin.ML
src/HOL/Complex/NSComplexBin.thy
src/HOL/Complex/NSInduct.ML
src/HOL/Complex/NSInduct.thy
src/HOL/Complex/ROOT.ML
src/HOL/Complex/ex/NSPrimes.ML
src/HOL/Complex/ex/NSPrimes.thy
src/HOL/Complex/ex/ROOT.ML
src/HOL/Complex/ex/Sqrt.thy
src/HOL/Complex/ex/Sqrt_Script.thy
src/HOL/Complex/ex/document/root.tex
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/HOL/Complex/CLim.ML	Mon May 05 18:22:31 2003 +0200
     1.3 @@ -0,0 +1,1191 @@
     1.4 +(*  Title       : CLim.ML
     1.5 +    Author      : Jacques D. Fleuriot
     1.6 +    Copyright   : 2001 University of Edinburgh
     1.7 +    Description : A first theory of limits, continuity and 
     1.8 +                  differentiation for complex functions
     1.9 +*)
    1.10 +
    1.11 +(*------------------------------------------------------------------------------------*)
    1.12 +(* Limit of complex to complex function                                               *)
    1.13 +(*------------------------------------------------------------------------------------*)
    1.14 +
    1.15 +Goalw [NSCLIM_def,NSCRLIM_def] 
    1.16 +   "f -- a --NSC> L ==> (%x. Re(f x)) -- a --NSCR> Re(L)";
    1.17 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
    1.18 +by (auto_tac (claset(),simpset() addsimps [starfunC_approx_Re_Im_iff,
    1.19 +    hRe_hcomplex_of_complex]));
    1.20 +qed "NSCLIM_NSCRLIM_Re";
    1.21 +
    1.22 +Goalw [NSCLIM_def,NSCRLIM_def] 
    1.23 +   "f -- a --NSC> L ==> (%x. Im(f x)) -- a --NSCR> Im(L)";
    1.24 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
    1.25 +by (auto_tac (claset(),simpset() addsimps [starfunC_approx_Re_Im_iff,
    1.26 +    hIm_hcomplex_of_complex]));
    1.27 +qed "NSCLIM_NSCRLIM_Im";
    1.28 +
    1.29 +Goalw [CLIM_def,NSCLIM_def,capprox_def] 
    1.30 +      "f -- x --C> L ==> f -- x --NSC> L";
    1.31 +by Auto_tac;
    1.32 +by (res_inst_tac [("z","xa")] eq_Abs_hcomplex 1);
    1.33 +by (auto_tac (claset(),simpset() addsimps [hcomplex_of_complex_def,
    1.34 +    starfunC,hcomplex_diff,CInfinitesimal_hcmod_iff,hcmod,
    1.35 +    Infinitesimal_FreeUltrafilterNat_iff]));
    1.36 +by (rtac bexI 1 THEN rtac lemma_hyprel_refl 2);
    1.37 +by (Step_tac 1);
    1.38 +by (dres_inst_tac [("x","u")] spec 1 THEN Auto_tac);
    1.39 +by (dres_inst_tac [("x","s")] spec 1 THEN Auto_tac);
    1.40 +by (Ultra_tac 1);
    1.41 +by (dtac sym 1 THEN Auto_tac);
    1.42 +qed "CLIM_NSCLIM";
    1.43 +
    1.44 +Goal "(ALL t. P t) = (ALL X. P (Abs_hcomplex(hcomplexrel `` {X})))";
    1.45 +by Auto_tac;
    1.46 +by (res_inst_tac [("z","t")] eq_Abs_hcomplex 1);
    1.47 +by Auto_tac;
    1.48 +qed "eq_Abs_hcomplex_ALL";
    1.49 +
    1.50 +Goal "ALL s. 0 < s --> (EX xa.  xa ~= x & \
    1.51 +\        cmod (xa - x) < s  & r <= cmod (f xa - L)) \
    1.52 +\     ==> ALL (n::nat). EX xa.  xa ~= x & \
    1.53 +\             cmod(xa - x) < inverse(real(Suc n)) & r <= cmod(f xa - L)";
    1.54 +by (Clarify_tac 1); 
    1.55 +by (cut_inst_tac [("n1","n")]
    1.56 +    (real_of_nat_Suc_gt_zero RS real_inverse_gt_0) 1);
    1.57 +by Auto_tac;
    1.58 +val lemma_CLIM = result();
    1.59 +
    1.60 +(* not needed? *)
    1.61 +Goal "ALL x z. EX y. Q x z y ==> EX f. ALL x z. Q x z (f x z)";
    1.62 +by (rtac choice 1 THEN Step_tac 1);
    1.63 +by (blast_tac (claset() addIs [choice]) 1);
    1.64 +qed "choice2";
    1.65 +
    1.66 +Goal "ALL s. 0 < s --> (EX xa.  xa ~= x & \
    1.67 +\        cmod (xa - x) < s  & r <= cmod (f xa - L)) \
    1.68 +\     ==> EX X. ALL (n::nat). X n ~= x & \
    1.69 +\               cmod(X n - x) < inverse(real(Suc n)) & r <= cmod(f (X n) - L)";
    1.70 +by (dtac lemma_CLIM 1);
    1.71 +by (dtac choice 1);
    1.72 +by (Blast_tac 1);
    1.73 +val lemma_skolemize_CLIM2 = result();
    1.74 +
    1.75 +Goal "ALL n. X n ~= x & \
    1.76 +\         cmod (X n - x) < inverse (real(Suc n)) & \
    1.77 +\         r <= cmod (f (X n) - L) ==> \
    1.78 +\         ALL n. cmod (X n - x) < inverse (real(Suc n))";
    1.79 +by (Auto_tac );
    1.80 +val lemma_csimp = result();
    1.81 +
    1.82 +Goalw [CLIM_def,NSCLIM_def] 
    1.83 +     "f -- x --NSC> L ==> f -- x --C> L";
    1.84 +by (auto_tac (claset(),simpset() addsimps [eq_Abs_hcomplex_ALL,
    1.85 +    starfunC,CInfinitesimal_capprox_minus RS sym,hcomplex_diff,
    1.86 +    CInfinitesimal_hcmod_iff,hcomplex_of_complex_def,
    1.87 +    Infinitesimal_FreeUltrafilterNat_iff,hcmod]));
    1.88 +by (EVERY1[rtac ccontr, Asm_full_simp_tac]);
    1.89 +by (fold_tac [real_le_def]);
    1.90 +by (dtac lemma_skolemize_CLIM2 1);
    1.91 +by (Step_tac 1);
    1.92 +by (dres_inst_tac [("x","X")] spec 1);
    1.93 +by Auto_tac;
    1.94 +by (dtac (lemma_csimp RS complex_seq_to_hcomplex_CInfinitesimal) 1);
    1.95 +by (asm_full_simp_tac (simpset() addsimps [CInfinitesimal_hcmod_iff,
    1.96 +    hcomplex_of_complex_def,Infinitesimal_FreeUltrafilterNat_iff,
    1.97 +    hcomplex_diff,hcmod]) 1);
    1.98 +by (Blast_tac 1); 
    1.99 +by (dres_inst_tac [("x","r")] spec 1);
   1.100 +by (Clarify_tac 1);
   1.101 +by (dtac FreeUltrafilterNat_all 1);
   1.102 +by (Ultra_tac 1);
   1.103 +by (arith_tac 1);
   1.104 +qed "NSCLIM_CLIM";
   1.105 +
   1.106 +(**** First key result ****)
   1.107 +
   1.108 +Goal "(f -- x --C> L) = (f -- x --NSC> L)";
   1.109 +by (blast_tac (claset() addIs [CLIM_NSCLIM,NSCLIM_CLIM]) 1);
   1.110 +qed "CLIM_NSCLIM_iff";
   1.111 +
   1.112 +(*------------------------------------------------------------------------------------*)
   1.113 +(* Limit of complex to real function                                                  *)
   1.114 +(*------------------------------------------------------------------------------------*)
   1.115 +
   1.116 +Goalw [CRLIM_def,NSCRLIM_def,capprox_def] 
   1.117 +      "f -- x --CR> L ==> f -- x --NSCR> L";
   1.118 +by Auto_tac;
   1.119 +by (res_inst_tac [("z","xa")] eq_Abs_hcomplex 1);
   1.120 +by (auto_tac (claset(),simpset() addsimps [hcomplex_of_complex_def,
   1.121 +    starfunCR,hcomplex_diff,CInfinitesimal_hcmod_iff,hcmod,hypreal_diff,
   1.122 +    Infinitesimal_FreeUltrafilterNat_iff,Infinitesimal_approx_minus RS sym,
   1.123 +    hypreal_of_real_def]));
   1.124 +by (rtac bexI 1 THEN rtac lemma_hyprel_refl 2);
   1.125 +by (Step_tac 1);
   1.126 +by (dres_inst_tac [("x","u")] spec 1 THEN Auto_tac);
   1.127 +by (dres_inst_tac [("x","s")] spec 1 THEN Auto_tac);
   1.128 +by (Ultra_tac 1);
   1.129 +by (dtac sym 1 THEN Auto_tac);
   1.130 +qed "CRLIM_NSCRLIM";
   1.131 +
   1.132 +Goal "ALL s. 0 < s --> (EX xa.  xa ~= x & \
   1.133 +\        cmod (xa - x) < s  & r <= abs (f xa - L)) \
   1.134 +\     ==> ALL (n::nat). EX xa.  xa ~= x & \
   1.135 +\             cmod(xa - x) < inverse(real(Suc n)) & r <= abs (f xa - L)";
   1.136 +by (Clarify_tac 1); 
   1.137 +by (cut_inst_tac [("n1","n")]
   1.138 +    (real_of_nat_Suc_gt_zero RS real_inverse_gt_0) 1);
   1.139 +by Auto_tac;
   1.140 +val lemma_CRLIM = result();
   1.141 +
   1.142 +Goal "ALL s. 0 < s --> (EX xa.  xa ~= x & \
   1.143 +\        cmod (xa - x) < s  & r <= abs (f xa - L)) \
   1.144 +\     ==> EX X. ALL (n::nat). X n ~= x & \
   1.145 +\               cmod(X n - x) < inverse(real(Suc n)) & r <= abs (f (X n) - L)";
   1.146 +by (dtac lemma_CRLIM 1);
   1.147 +by (dtac choice 1);
   1.148 +by (Blast_tac 1);
   1.149 +val lemma_skolemize_CRLIM2 = result();
   1.150 +
   1.151 +Goal "ALL n. X n ~= x & \
   1.152 +\         cmod (X n - x) < inverse (real(Suc n)) & \
   1.153 +\         r <= abs (f (X n) - L) ==> \
   1.154 +\         ALL n. cmod (X n - x) < inverse (real(Suc n))";
   1.155 +by (Auto_tac );
   1.156 +val lemma_crsimp = result();
   1.157 +
   1.158 +Goalw [CRLIM_def,NSCRLIM_def,capprox_def] 
   1.159 +      "f -- x --NSCR> L ==> f -- x --CR> L";
   1.160 +by (auto_tac (claset(),simpset() addsimps [eq_Abs_hcomplex_ALL,
   1.161 +    starfunCR,hcomplex_diff,hcomplex_of_complex_def,hypreal_diff,
   1.162 +    CInfinitesimal_hcmod_iff,hcmod,Infinitesimal_approx_minus RS sym,
   1.163 +    Infinitesimal_FreeUltrafilterNat_iff]));
   1.164 +by (EVERY1[rtac ccontr, Asm_full_simp_tac]);
   1.165 +by (fold_tac [real_le_def]);
   1.166 +by (dtac lemma_skolemize_CRLIM2 1);
   1.167 +by (Step_tac 1);
   1.168 +by (dres_inst_tac [("x","X")] spec 1);
   1.169 +by Auto_tac;
   1.170 +by (dtac (lemma_crsimp RS complex_seq_to_hcomplex_CInfinitesimal) 1);
   1.171 +by (asm_full_simp_tac (simpset() addsimps [CInfinitesimal_hcmod_iff,
   1.172 +    hcomplex_of_complex_def,Infinitesimal_FreeUltrafilterNat_iff,
   1.173 +    hcomplex_diff,hcmod]) 1);
   1.174 +by (Blast_tac 1); 
   1.175 +by (auto_tac (claset(),simpset() addsimps [hypreal_of_real_def,
   1.176 +    hypreal_diff]));
   1.177 +by (dres_inst_tac [("x","r")] spec 1);
   1.178 +by (Clarify_tac 1);
   1.179 +by (dtac FreeUltrafilterNat_all 1);
   1.180 +by (Ultra_tac 1);
   1.181 +qed "NSCRLIM_CRLIM";
   1.182 +
   1.183 +(** second key result **)
   1.184 +Goal "(f -- x --CR> L) = (f -- x --NSCR> L)";
   1.185 +by (blast_tac (claset() addIs [CRLIM_NSCRLIM,NSCRLIM_CRLIM]) 1);
   1.186 +qed "CRLIM_NSCRLIM_iff";
   1.187 +
   1.188 +(** get this result easily now **)
   1.189 +Goal "f -- a --C> L ==> (%x. Re(f x)) -- a --CR> Re(L)";
   1.190 +by (auto_tac (claset() addDs [NSCLIM_NSCRLIM_Re],simpset() 
   1.191 +    addsimps [CLIM_NSCLIM_iff,CRLIM_NSCRLIM_iff RS sym]));
   1.192 +qed "CLIM_CRLIM_Re";
   1.193 +
   1.194 +Goal "f -- a --C> L ==> (%x. Im(f x)) -- a --CR> Im(L)";
   1.195 +by (auto_tac (claset() addDs [NSCLIM_NSCRLIM_Im],simpset() 
   1.196 +    addsimps [CLIM_NSCLIM_iff,CRLIM_NSCRLIM_iff RS sym]));
   1.197 +qed "CLIM_CRLIM_Im";
   1.198 +
   1.199 +Goal "f -- a --C> L ==> (%x. cnj (f x)) -- a --C> cnj L";
   1.200 +by (auto_tac (claset(),simpset() addsimps [CLIM_def,
   1.201 +    complex_cnj_diff RS sym]));
   1.202 +qed "CLIM_cnj";
   1.203 +
   1.204 +Goal "((%x. cnj (f x)) -- a --C> cnj L) = (f -- a --C> L)";
   1.205 +by (auto_tac (claset(),simpset() addsimps [CLIM_def,
   1.206 +    complex_cnj_diff RS sym]));
   1.207 +qed "CLIM_cnj_iff";
   1.208 +
   1.209 +(*** NSLIM_add hence CLIM_add *)
   1.210 +
   1.211 +Goalw [NSCLIM_def]
   1.212 +     "[| f -- x --NSC> l; g -- x --NSC> m |] \
   1.213 +\     ==> (%x. f(x) + g(x)) -- x --NSC> (l + m)";
   1.214 +by (auto_tac (claset() addSIs [capprox_add], simpset()));
   1.215 +qed "NSCLIM_add";
   1.216 +
   1.217 +Goal "[| f -- x --C> l; g -- x --C> m |] \
   1.218 +\     ==> (%x. f(x) + g(x)) -- x --C> (l + m)";
   1.219 +by (asm_full_simp_tac (simpset() addsimps [CLIM_NSCLIM_iff, NSCLIM_add]) 1);
   1.220 +qed "CLIM_add";
   1.221 +
   1.222 +(*** NSLIM_mult hence CLIM_mult *)
   1.223 +
   1.224 +Goalw [NSCLIM_def]
   1.225 +     "[| f -- x --NSC> l; g -- x --NSC> m |] \
   1.226 +\     ==> (%x. f(x) * g(x)) -- x --NSC> (l * m)";
   1.227 +by (auto_tac (claset() addSIs [capprox_mult_CFinite],  simpset()));
   1.228 +qed "NSCLIM_mult";
   1.229 +
   1.230 +Goal "[| f -- x --C> l; g -- x --C> m |] \
   1.231 +\     ==> (%x. f(x) * g(x)) -- x --C> (l * m)";
   1.232 +by (asm_full_simp_tac (simpset() addsimps [CLIM_NSCLIM_iff, NSCLIM_mult]) 1);
   1.233 +qed "CLIM_mult";
   1.234 +
   1.235 +(*** NSCLIM_const and CLIM_const ***)
   1.236 +
   1.237 +Goalw [NSCLIM_def] "(%x. k) -- x --NSC> k";
   1.238 +by Auto_tac;
   1.239 +qed "NSCLIM_const";
   1.240 +Addsimps [NSCLIM_const];
   1.241 +
   1.242 +Goalw [CLIM_def] "(%x. k) -- x --C> k";
   1.243 +by Auto_tac;
   1.244 +qed "CLIM_const";
   1.245 +Addsimps [CLIM_const];
   1.246 +
   1.247 +(*** NSCLIM_minus and CLIM_minus ***)
   1.248 +
   1.249 +Goalw [NSCLIM_def] 
   1.250 +      "f -- a --NSC> L ==> (%x. -f(x)) -- a --NSC> -L";
   1.251 +by Auto_tac;  
   1.252 +qed "NSCLIM_minus";
   1.253 +
   1.254 +Goal "f -- a --C> L ==> (%x. -f(x)) -- a --C> -L";
   1.255 +by (asm_full_simp_tac (simpset() addsimps [CLIM_NSCLIM_iff, NSCLIM_minus]) 1);
   1.256 +qed "CLIM_minus";
   1.257 +
   1.258 +(*** NSCLIM_diff hence CLIM_diff ***)
   1.259 +
   1.260 +Goalw [complex_diff_def]
   1.261 +     "[| f -- x --NSC> l; g -- x --NSC> m |] \
   1.262 +\     ==> (%x. f(x) - g(x)) -- x --NSC> (l - m)";
   1.263 +by (auto_tac (claset(), simpset() addsimps [NSCLIM_add,NSCLIM_minus]));
   1.264 +qed "NSCLIM_diff";
   1.265 +
   1.266 +Goal "[| f -- x --C> l; g -- x --C> m |] \
   1.267 +\     ==> (%x. f(x) - g(x)) -- x --C> (l - m)";
   1.268 +by (asm_full_simp_tac (simpset() addsimps [CLIM_NSCLIM_iff, NSCLIM_diff]) 1);
   1.269 +qed "CLIM_diff";
   1.270 +
   1.271 +(*** NSCLIM_inverse and hence CLIM_inverse *)
   1.272 +
   1.273 +Goalw [NSCLIM_def] 
   1.274 +     "[| f -- a --NSC> L;  L ~= 0 |] \
   1.275 +\     ==> (%x. inverse(f(x))) -- a --NSC> (inverse L)";
   1.276 +by (Clarify_tac 1);
   1.277 +by (dtac spec 1);
   1.278 +by (auto_tac (claset(), 
   1.279 +              simpset() addsimps [hcomplex_of_complex_capprox_inverse]));  
   1.280 +qed "NSCLIM_inverse";
   1.281 +
   1.282 +Goal "[| f -- a --C> L;  L ~= 0 |] \
   1.283 +\     ==> (%x. inverse(f(x))) -- a --C> (inverse L)";
   1.284 +by (asm_full_simp_tac (simpset() addsimps [CLIM_NSCLIM_iff, NSCLIM_inverse]) 1);
   1.285 +qed "CLIM_inverse";
   1.286 +
   1.287 +(*** NSCLIM_zero, CLIM_zero, etc. ***)
   1.288 +
   1.289 +Goal "f -- a --NSC> l ==> (%x. f(x) - l) -- a --NSC> 0";
   1.290 +by (res_inst_tac [("z1","l")] (complex_add_minus_right_zero RS subst) 1);
   1.291 +by (rewtac complex_diff_def);
   1.292 +by (rtac NSCLIM_add 1 THEN Auto_tac);
   1.293 +qed "NSCLIM_zero";
   1.294 +
   1.295 +Goal "f -- a --C> l ==> (%x. f(x) - l) -- a --C> 0";
   1.296 +by (asm_full_simp_tac (simpset() addsimps [CLIM_NSCLIM_iff, NSCLIM_zero]) 1);
   1.297 +qed "CLIM_zero";
   1.298 +
   1.299 +Goal "(%x. f(x) - l) -- x --NSC> 0 ==> f -- x --NSC> l";
   1.300 +by (dres_inst_tac [("g","%x. l"),("m","l")] NSCLIM_add 1);
   1.301 +by Auto_tac;
   1.302 +qed "NSCLIM_zero_cancel";
   1.303 +
   1.304 +Goal "(%x. f(x) - l) -- x --C> 0 ==> f -- x --C> l";
   1.305 +by (dres_inst_tac [("g","%x. l"),("m","l")] CLIM_add 1);
   1.306 +by Auto_tac;
   1.307 +qed "CLIM_zero_cancel";
   1.308 +
   1.309 +(*** NSCLIM_not zero and hence CLIM_not_zero ***)
   1.310 +
   1.311 +(*not in simpset?*)
   1.312 +Addsimps [hypreal_epsilon_not_zero];
   1.313 +
   1.314 +Goalw [NSCLIM_def] "k ~= 0 ==> ~ ((%x. k) -- x --NSC> 0)";
   1.315 +by (auto_tac (claset(),simpset() delsimps [hcomplex_of_complex_zero]));
   1.316 +by (res_inst_tac [("x","hcomplex_of_complex x + hcomplex_of_hypreal epsilon")] exI 1);
   1.317 +by (auto_tac (claset() addIs [CInfinitesimal_add_capprox_self RS capprox_sym],simpset()
   1.318 +    delsimps [hcomplex_of_complex_zero]));
   1.319 +qed "NSCLIM_not_zero";
   1.320 +
   1.321 +(* [| k ~= 0; (%x. k) -- x --NSC> 0 |] ==> R *)
   1.322 +bind_thm("NSCLIM_not_zeroE", NSCLIM_not_zero RS notE);
   1.323 +
   1.324 +Goal "k ~= 0 ==> ~ ((%x. k) -- x --C> 0)";
   1.325 +by (asm_full_simp_tac (simpset() addsimps [CLIM_NSCLIM_iff, NSCLIM_not_zero]) 1);
   1.326 +qed "CLIM_not_zero";
   1.327 +
   1.328 +(*** NSCLIM_const hence CLIM_const ***)
   1.329 +
   1.330 +Goal "(%x. k) -- x --NSC> L ==> k = L";
   1.331 +by (rtac ccontr 1);
   1.332 +by (dtac NSCLIM_zero 1);
   1.333 +by (rtac NSCLIM_not_zeroE 1 THEN assume_tac 2);
   1.334 +by Auto_tac;
   1.335 +qed "NSCLIM_const_eq";
   1.336 +
   1.337 +Goal "(%x. k) -- x --C> L ==> k = L";
   1.338 +by (asm_full_simp_tac (simpset() addsimps [CLIM_NSCLIM_iff,NSCLIM_const_eq]) 1);
   1.339 +qed "CLIM_const_eq";
   1.340 +
   1.341 +(*** NSCLIM and hence CLIM are unique ***)
   1.342 +
   1.343 +Goal "[| f -- x --NSC> L; f -- x --NSC> M |] ==> L = M";
   1.344 +by (dtac NSCLIM_minus 1);
   1.345 +by (dtac NSCLIM_add 1 THEN assume_tac 1);
   1.346 +by (auto_tac (claset() addSDs [NSCLIM_const_eq RS sym], simpset()));
   1.347 +qed "NSCLIM_unique";
   1.348 +
   1.349 +Goal "[| f -- x --C> L; f -- x --C> M |] ==> L = M";
   1.350 +by (asm_full_simp_tac (simpset() addsimps [CLIM_NSCLIM_iff, NSCLIM_unique]) 1);
   1.351 +qed "CLIM_unique";
   1.352 +
   1.353 +(***  NSCLIM_mult_zero and CLIM_mult_zero ***)
   1.354 +
   1.355 +Goal "[| f -- x --NSC> 0; g -- x --NSC> 0 |] \
   1.356 +\         ==> (%x. f(x)*g(x)) -- x --NSC> 0";
   1.357 +by (dtac NSCLIM_mult 1 THEN Auto_tac);
   1.358 +qed "NSCLIM_mult_zero";
   1.359 +
   1.360 +Goal "[| f -- x --C> 0; g -- x --C> 0 |] \
   1.361 +\     ==> (%x. f(x)*g(x)) -- x --C> 0";
   1.362 +by (dtac CLIM_mult 1 THEN Auto_tac);
   1.363 +qed "CLIM_mult_zero";
   1.364 +
   1.365 +(*** NSCLIM_self hence CLIM_self ***)
   1.366 +
   1.367 +Goalw [NSCLIM_def] "(%x. x) -- a --NSC> a";
   1.368 +by (auto_tac (claset() addIs [starfunC_Idfun_capprox],simpset()));
   1.369 +qed "NSCLIM_self";
   1.370 +
   1.371 +Goal "(%x. x) -- a --C> a";
   1.372 +by (simp_tac (simpset() addsimps [CLIM_NSCLIM_iff,NSCLIM_self]) 1);
   1.373 +qed "CLIM_self";
   1.374 +
   1.375 +(** another equivalence result **)
   1.376 +Goalw [NSCLIM_def,NSCRLIM_def] 
   1.377 +   "(f -- x --NSC> L) = ((%y. cmod(f y - L)) -- x --NSCR> 0)";
   1.378 +by (auto_tac (claset(),simpset() addsimps [CInfinitesimal_capprox_minus 
   1.379 +    RS sym,CInfinitesimal_hcmod_iff]));
   1.380 +by (ALLGOALS(dtac spec) THEN Auto_tac);
   1.381 +by (ALLGOALS(res_inst_tac [("z","xa")] eq_Abs_hcomplex));
   1.382 +by (auto_tac (claset(),simpset() addsimps [hcomplex_diff,
   1.383 +    starfunC,starfunCR,hcomplex_of_complex_def,hcmod,mem_infmal_iff]));
   1.384 +qed "NSCLIM_NSCRLIM_iff";
   1.385 +
   1.386 +(** much, much easier standard proof **)
   1.387 +Goalw [CLIM_def,CRLIM_def] 
   1.388 +   "(f -- x --C> L) = ((%y. cmod(f y - L)) -- x --CR> 0)";
   1.389 +by Auto_tac;
   1.390 +qed "CLIM_CRLIM_iff";
   1.391 +
   1.392 +(* so this is nicer nonstandard proof *)
   1.393 +Goal "(f -- x --NSC> L) = ((%y. cmod(f y - L)) -- x --NSCR> 0)";
   1.394 +by (auto_tac (claset(),simpset() addsimps [CRLIM_NSCRLIM_iff RS sym,
   1.395 +    CLIM_CRLIM_iff,CLIM_NSCLIM_iff RS sym]));
   1.396 +qed "NSCLIM_NSCRLIM_iff2";
   1.397 +
   1.398 +Goal "(f -- a --NSC> L) = ((%x. Re(f x)) -- a --NSCR> Re(L) & \
   1.399 +\                           (%x. Im(f x)) -- a --NSCR> Im(L))";
   1.400 +by (auto_tac (claset() addIs [NSCLIM_NSCRLIM_Re,NSCLIM_NSCRLIM_Im],simpset()));
   1.401 +by (auto_tac (claset(),simpset() addsimps [NSCLIM_def,NSCRLIM_def]));
   1.402 +by (REPEAT(dtac spec 1) THEN Auto_tac);
   1.403 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
   1.404 +by (auto_tac (claset(),simpset() addsimps [capprox_approx_iff,starfunC,
   1.405 +    hcomplex_of_complex_def,starfunCR,hypreal_of_real_def]));
   1.406 +qed "NSCLIM_NSCRLIM_Re_Im_iff";
   1.407 +
   1.408 +Goal "(f -- a --C> L) = ((%x. Re(f x)) -- a --CR> Re(L) & \
   1.409 +\                        (%x. Im(f x)) -- a --CR> Im(L))";
   1.410 +by (auto_tac (claset(),simpset() addsimps [CLIM_NSCLIM_iff,CRLIM_NSCRLIM_iff,
   1.411 +    NSCLIM_NSCRLIM_Re_Im_iff]));
   1.412 +qed "CLIM_CRLIM_Re_Im_iff";
   1.413 +
   1.414 +
   1.415 +(*------------------------------------------------------------------------------------*)
   1.416 +(* Continuity                                                                         *)
   1.417 +(*------------------------------------------------------------------------------------*)
   1.418 +
   1.419 +Goalw [isNSContc_def] 
   1.420 +      "[| isNSContc f a; y @c= hcomplex_of_complex a |] \
   1.421 +\           ==> ( *fc* f) y @c= hcomplex_of_complex (f a)";
   1.422 +by (Blast_tac 1);
   1.423 +qed "isNSContcD";
   1.424 +
   1.425 +Goalw [isNSContc_def,NSCLIM_def] 
   1.426 +      "isNSContc f a ==> f -- a --NSC> (f a) ";
   1.427 +by (Blast_tac 1);
   1.428 +qed "isNSContc_NSCLIM";
   1.429 +
   1.430 +Goalw [isNSContc_def,NSCLIM_def] 
   1.431 +      "f -- a --NSC> (f a) ==> isNSContc f a";
   1.432 +by Auto_tac;
   1.433 +by (res_inst_tac [("Q","y = hcomplex_of_complex a")] 
   1.434 +    (excluded_middle RS disjE) 1);
   1.435 +by Auto_tac;
   1.436 +qed "NSCLIM_isNSContc";
   1.437 +
   1.438 +(*--------------------------------------------------*)
   1.439 +(* NS continuity can be defined using NS Limit in   *)
   1.440 +(* similar fashion to standard def of continuity    *)
   1.441 +(* -------------------------------------------------*)
   1.442 +
   1.443 +Goal "(isNSContc f a) = (f -- a --NSC> (f a))";
   1.444 +by (blast_tac (claset() addIs [isNSContc_NSCLIM,NSCLIM_isNSContc]) 1);
   1.445 +qed "isNSContc_NSCLIM_iff";
   1.446 +
   1.447 +Goal "(isNSContc f a) = (f -- a --C> (f a))";
   1.448 +by (asm_full_simp_tac (simpset() addsimps 
   1.449 +    [CLIM_NSCLIM_iff,isNSContc_NSCLIM_iff]) 1);
   1.450 +qed "isNSContc_CLIM_iff";
   1.451 +
   1.452 +(*** key result for continuity ***)
   1.453 +Goalw [isContc_def] "(isNSContc f a) = (isContc f a)";
   1.454 +by (rtac isNSContc_CLIM_iff 1);
   1.455 +qed "isNSContc_isContc_iff";
   1.456 +
   1.457 +Goal "isContc f a ==> isNSContc f a";
   1.458 +by (etac (isNSContc_isContc_iff RS iffD2) 1);
   1.459 +qed "isContc_isNSContc";
   1.460 +
   1.461 +Goal "isNSContc f a ==> isContc f a";
   1.462 +by (etac (isNSContc_isContc_iff RS iffD1) 1);
   1.463 +qed "isNSContc_isContc";
   1.464 +
   1.465 +(*--------------------------------------------------*)
   1.466 +(* Alternative definition of continuity             *)
   1.467 +(* -------------------------------------------------*)
   1.468 +
   1.469 +Goalw [NSCLIM_def] 
   1.470 +     "(f -- a --NSC> L) = ((%h. f(a + h)) -- 0 --NSC> L)";
   1.471 +by Auto_tac;
   1.472 +by (dres_inst_tac [("x","hcomplex_of_complex a + x")] spec 1);
   1.473 +by (dres_inst_tac [("x","- hcomplex_of_complex a + x")] spec 2);
   1.474 +by (Step_tac 1);
   1.475 +by (Asm_full_simp_tac 1);
   1.476 +by (rtac ((mem_cinfmal_iff RS iffD2) RS 
   1.477 +    (CInfinitesimal_add_capprox_self RS capprox_sym)) 1);
   1.478 +by (rtac (capprox_minus_iff2 RS iffD1) 4);
   1.479 +by (asm_full_simp_tac (simpset() addsimps [hcomplex_add_commute]) 3);
   1.480 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 2);
   1.481 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 4);
   1.482 +by (auto_tac (claset(),
   1.483 +       simpset() addsimps [starfunC, hcomplex_of_complex_def, 
   1.484 +              hcomplex_minus, hcomplex_add]));
   1.485 +qed "NSCLIM_h_iff";
   1.486 +
   1.487 +Goal "(f -- a --NSC> f a) = ((%h. f(a + h)) -- 0 --NSC> f a)";
   1.488 +by (rtac NSCLIM_h_iff 1);
   1.489 +qed "NSCLIM_isContc_iff";
   1.490 +
   1.491 +Goal "(f -- a --C> f a) = ((%h. f(a + h)) -- 0 --C> f(a))";
   1.492 +by (simp_tac (simpset() addsimps [CLIM_NSCLIM_iff, NSCLIM_isContc_iff]) 1);
   1.493 +qed "CLIM_isContc_iff";
   1.494 +
   1.495 +Goalw [isContc_def] "(isContc f x) = ((%h. f(x + h)) -- 0 --C> f(x))";
   1.496 +by (simp_tac (simpset() addsimps [CLIM_isContc_iff]) 1);
   1.497 +qed "isContc_iff";
   1.498 +
   1.499 +Goal "[| isContc f a; isContc g a |] ==> isContc (%x. f(x) + g(x)) a";
   1.500 +by (auto_tac (claset() addIs [capprox_add],
   1.501 +              simpset() addsimps [isNSContc_isContc_iff RS sym, isNSContc_def]));
   1.502 +qed "isContc_add";
   1.503 +
   1.504 +Goal "[| isContc f a; isContc g a |] ==> isContc (%x. f(x) * g(x)) a";
   1.505 +by (auto_tac (claset() addSIs [starfunC_mult_CFinite_capprox],
   1.506 +              simpset() delsimps [starfunC_mult RS sym]
   1.507 +			addsimps [isNSContc_isContc_iff RS sym, isNSContc_def]));
   1.508 +qed "isContc_mult";
   1.509 +
   1.510 +(*** more theorems: note simple proofs ***)
   1.511 +
   1.512 +Goal "[| isContc f a; isContc g (f a) |] \
   1.513 +\     ==> isContc (g o f) a";
   1.514 +by (auto_tac (claset(),simpset() addsimps [isNSContc_isContc_iff RS sym,
   1.515 +              isNSContc_def,starfunC_o RS sym]));
   1.516 +qed "isContc_o";
   1.517 +
   1.518 +Goal "[| isContc f a; isContc g (f a) |] \
   1.519 +\     ==> isContc (%x. g (f x)) a";
   1.520 +by (auto_tac (claset() addDs [isContc_o],simpset() addsimps [o_def]));
   1.521 +qed "isContc_o2";
   1.522 +
   1.523 +Goalw [isNSContc_def] "isNSContc f a ==> isNSContc (%x. - f x) a";
   1.524 +by Auto_tac; 
   1.525 +qed "isNSContc_minus";
   1.526 +
   1.527 +Goal "isContc f a ==> isContc (%x. - f x) a";
   1.528 +by (auto_tac (claset(),simpset() addsimps [isNSContc_isContc_iff RS sym,
   1.529 +              isNSContc_minus]));
   1.530 +qed "isContc_minus";
   1.531 +
   1.532 +Goalw [isContc_def]  
   1.533 +      "[| isContc f x; f x ~= 0 |] ==> isContc (%x. inverse (f x)) x";
   1.534 +by (blast_tac (claset() addIs [CLIM_inverse]) 1);
   1.535 +qed "isContc_inverse";
   1.536 +
   1.537 +Goal "[| isNSContc f x; f x ~= 0 |] ==> isNSContc (%x. inverse (f x)) x";
   1.538 +by (auto_tac (claset() addIs [isContc_inverse],simpset() addsimps 
   1.539 +    [isNSContc_isContc_iff]));
   1.540 +qed "isNSContc_inverse";
   1.541 +
   1.542 +Goalw [complex_diff_def] 
   1.543 +      "[| isContc f a; isContc g a |] ==> isContc (%x. f(x) - g(x)) a";
   1.544 +by (auto_tac (claset() addIs [isContc_add,isContc_minus],simpset()));
   1.545 +qed "isContc_diff";
   1.546 +
   1.547 +Goalw [isContc_def]  "isContc (%x. k) a";
   1.548 +by (Simp_tac 1);
   1.549 +qed "isContc_const";
   1.550 +Addsimps [isContc_const];
   1.551 +
   1.552 +Goalw [isNSContc_def]  "isNSContc (%x. k) a";
   1.553 +by (Simp_tac 1);
   1.554 +qed "isNSContc_const";
   1.555 +Addsimps [isNSContc_const];
   1.556 +
   1.557 +
   1.558 +(*------------------------------------------------------------------------------------*)
   1.559 +(* functions from complex to reals                                                    *)
   1.560 +(* -----------------------------------------------------------------------------------*)
   1.561 +
   1.562 +Goalw [isNSContCR_def] 
   1.563 +      "[| isNSContCR f a; y @c= hcomplex_of_complex a |] \
   1.564 +\           ==> ( *fcR* f) y @= hypreal_of_real (f a)";
   1.565 +by (Blast_tac 1);
   1.566 +qed "isNSContCRD";
   1.567 +
   1.568 +Goalw [isNSContCR_def,NSCRLIM_def] 
   1.569 +      "isNSContCR f a ==> f -- a --NSCR> (f a) ";
   1.570 +by (Blast_tac 1);
   1.571 +qed "isNSContCR_NSCRLIM";
   1.572 +
   1.573 +Goalw [isNSContCR_def,NSCRLIM_def] 
   1.574 +      "f -- a --NSCR> (f a) ==> isNSContCR f a";
   1.575 +by Auto_tac;
   1.576 +by (res_inst_tac [("Q","y = hcomplex_of_complex a")] 
   1.577 +    (excluded_middle RS disjE) 1);
   1.578 +by Auto_tac;
   1.579 +qed "NSCRLIM_isNSContCR";
   1.580 +
   1.581 +Goal "(isNSContCR f a) = (f -- a --NSCR> (f a))";
   1.582 +by (blast_tac (claset() addIs [isNSContCR_NSCRLIM,NSCRLIM_isNSContCR]) 1);
   1.583 +qed "isNSContCR_NSCRLIM_iff";
   1.584 +
   1.585 +Goal "(isNSContCR f a) = (f -- a --CR> (f a))";
   1.586 +by (asm_full_simp_tac (simpset() addsimps 
   1.587 +    [CRLIM_NSCRLIM_iff,isNSContCR_NSCRLIM_iff]) 1);
   1.588 +qed "isNSContCR_CRLIM_iff";
   1.589 +
   1.590 +(*** another key result for continuity ***)
   1.591 +Goalw [isContCR_def] "(isNSContCR f a) = (isContCR f a)";
   1.592 +by (rtac isNSContCR_CRLIM_iff 1);
   1.593 +qed "isNSContCR_isContCR_iff";
   1.594 +
   1.595 +Goal "isContCR f a ==> isNSContCR f a";
   1.596 +by (etac (isNSContCR_isContCR_iff RS iffD2) 1);
   1.597 +qed "isContCR_isNSContCR";
   1.598 +
   1.599 +Goal "isNSContCR f a ==> isContCR f a";
   1.600 +by (etac (isNSContCR_isContCR_iff RS iffD1) 1);
   1.601 +qed "isNSContCR_isContCR";
   1.602 +
   1.603 +Goalw [isNSContCR_def]  "isNSContCR cmod (a)";
   1.604 +by (auto_tac (claset() addIs [capprox_hcmod_approx],
   1.605 +    simpset() addsimps [starfunCR_cmod,hcmod_hcomplex_of_complex
   1.606 +    RS sym]));
   1.607 +qed "isNSContCR_cmod";    
   1.608 +Addsimps [isNSContCR_cmod];
   1.609 +
   1.610 +Goal "isContCR cmod (a)";
   1.611 +by (auto_tac (claset(),simpset() addsimps [isNSContCR_isContCR_iff RS sym]));
   1.612 +qed "isContCR_cmod";    
   1.613 +Addsimps [isContCR_cmod];
   1.614 +
   1.615 +Goalw [isContc_def,isContCR_def] 
   1.616 +  "isContc f a ==> isContCR (%x. Re (f x)) a";
   1.617 +by (etac CLIM_CRLIM_Re 1);
   1.618 +qed "isContc_isContCR_Re"; 
   1.619 +
   1.620 +Goalw [isContc_def,isContCR_def] 
   1.621 +  "isContc f a ==> isContCR (%x. Im (f x)) a";
   1.622 +by (etac CLIM_CRLIM_Im 1);
   1.623 +qed "isContc_isContCR_Im"; 
   1.624 +
   1.625 +(*------------------------------------------------------------------------------------*)
   1.626 +(* Derivatives                                                                        *)
   1.627 +(*------------------------------------------------------------------------------------*)
   1.628 +
   1.629 +Goalw [cderiv_def] 
   1.630 +      "(CDERIV f x :> D) = ((%h. (f(x + h) - f(x))/h) -- 0 --C> D)";
   1.631 +by (Blast_tac 1);        
   1.632 +qed "CDERIV_iff";
   1.633 +
   1.634 +Goalw [cderiv_def] 
   1.635 +      "(CDERIV f x :> D) = ((%h. (f(x + h) - f(x))/h) -- 0 --NSC> D)";
   1.636 +by (simp_tac (simpset() addsimps [CLIM_NSCLIM_iff]) 1);
   1.637 +qed "CDERIV_NSC_iff";
   1.638 +
   1.639 +Goalw [cderiv_def] 
   1.640 +      "CDERIV f x :> D \
   1.641 +\      ==> (%h. (f(x + h) - f(x))/h) -- 0 --C> D";
   1.642 +by (Blast_tac 1);        
   1.643 +qed "CDERIVD";
   1.644 +
   1.645 +Goalw [cderiv_def] 
   1.646 +      "CDERIV f x :> D ==> (%h. (f(x + h) - f(x))/h) -- 0 --NSC> D";
   1.647 +by (asm_full_simp_tac (simpset() addsimps [CLIM_NSCLIM_iff]) 1);
   1.648 +qed "NSC_DERIVD";
   1.649 +
   1.650 +(*** Uniqueness ***)
   1.651 +
   1.652 +Goalw [cderiv_def] 
   1.653 +      "[| CDERIV f x :> D; CDERIV f x :> E |] ==> D = E";
   1.654 +by (blast_tac (claset() addIs [CLIM_unique]) 1);
   1.655 +qed "CDERIV_unique";
   1.656 +
   1.657 +(*** uniqueness: a nonstandard proof ***)
   1.658 +Goalw [nscderiv_def] 
   1.659 +     "[| NSCDERIV f x :> D; NSCDERIV f x :> E |] ==> D = E";
   1.660 +by (auto_tac (claset() addSDs [inst "x" "hcomplex_of_hypreal epsilon" bspec] 
   1.661 +                       addSIs [inj_hcomplex_of_complex RS injD] 
   1.662 +                       addDs [capprox_trans3],
   1.663 +              simpset()));
   1.664 +qed "NSCDeriv_unique";
   1.665 +
   1.666 +
   1.667 +(*------------------------------------------------------------------------------------*)
   1.668 +(* Differentiability                                                                  *)
   1.669 +(*------------------------------------------------------------------------------------*)
   1.670 +
   1.671 +Goalw [cdifferentiable_def] 
   1.672 +      "f cdifferentiable x ==> EX D. CDERIV f x :> D";
   1.673 +by (assume_tac 1);
   1.674 +qed "cdifferentiableD";
   1.675 +
   1.676 +Goalw [cdifferentiable_def] 
   1.677 +      "CDERIV f x :> D ==> f cdifferentiable x";
   1.678 +by (Blast_tac 1);
   1.679 +qed "cdifferentiableI";
   1.680 +
   1.681 +Goalw [NSCdifferentiable_def] 
   1.682 +      "f NSCdifferentiable x ==> EX D. NSCDERIV f x :> D";
   1.683 +by (assume_tac 1);
   1.684 +qed "NSCdifferentiableD";
   1.685 +
   1.686 +Goalw [NSCdifferentiable_def] 
   1.687 +      "NSCDERIV f x :> D ==> f NSCdifferentiable x";
   1.688 +by (Blast_tac 1);
   1.689 +qed "NSCdifferentiableI";
   1.690 +
   1.691 +
   1.692 +(*------------------------------------------------------------------------------------*)
   1.693 +(* Alternative definition for differentiability                                       *)
   1.694 +(*------------------------------------------------------------------------------------*)
   1.695 +
   1.696 +Goalw [CLIM_def] 
   1.697 + "((%h. (f(a + h) - f(a))/h) -- 0 --C> D) = \
   1.698 +\ ((%x. (f(x) - f(a)) / (x - a)) -- a --C> D)";
   1.699 +by (Step_tac 1);
   1.700 +by (ALLGOALS(dtac spec));
   1.701 +by (Step_tac 1);
   1.702 +by (Blast_tac 1 THEN Blast_tac 2);
   1.703 +by (ALLGOALS(res_inst_tac [("x","s")] exI));
   1.704 +by (Step_tac 1);
   1.705 +by (dres_inst_tac [("x","x - a")] spec 1);
   1.706 +by (dres_inst_tac [("x","x + a")] spec 2);
   1.707 +by (auto_tac (claset(), simpset() addsimps complex_add_ac));
   1.708 +qed "CDERIV_CLIM_iff";
   1.709 +
   1.710 +Goalw [cderiv_def] "(CDERIV f x :> D) = \
   1.711 +\         ((%z. (f(z) - f(x)) / (z - x)) -- x --C> D)";
   1.712 +by (simp_tac (simpset() addsimps [CDERIV_CLIM_iff]) 1);
   1.713 +qed "CDERIV_iff2";
   1.714 +
   1.715 +
   1.716 +(*------------------------------------------------------------------------------------*)
   1.717 +(* Equivalence of NS and standard defs of differentiation                             *)
   1.718 +(*------------------------------------------------------------------------------------*)
   1.719 +
   1.720 +(*** first equivalence ***)
   1.721 +Goalw [nscderiv_def,NSCLIM_def] 
   1.722 +      "(NSCDERIV f x :> D) = ((%h. (f(x + h) - f(x))/h) -- 0 --NSC> D)";
   1.723 +by Auto_tac;
   1.724 +by (dres_inst_tac [("x","xa")] bspec 1);
   1.725 +by (rtac ccontr 3);
   1.726 +by (dres_inst_tac [("x","h")] spec 3);
   1.727 +by (auto_tac (claset(),
   1.728 +              simpset() addsimps [mem_cinfmal_iff, starfunC_lambda_cancel]));
   1.729 +qed "NSCDERIV_NSCLIM_iff";
   1.730 +
   1.731 +(*** 2nd equivalence ***)
   1.732 +Goal "(NSCDERIV f x :> D) = \
   1.733 +\         ((%z. (f(z) - f(x)) / (z - x)) -- x --NSC> D)";
   1.734 +by (full_simp_tac (simpset() addsimps 
   1.735 +     [NSCDERIV_NSCLIM_iff, CDERIV_CLIM_iff, CLIM_NSCLIM_iff RS sym]) 1);
   1.736 +qed "NSCDERIV_NSCLIM_iff2";
   1.737 +
   1.738 +Goal "(NSCDERIV f x :> D) = \
   1.739 +\     (ALL xa. xa ~= hcomplex_of_complex x & xa @c= hcomplex_of_complex x --> \
   1.740 +\       ( *fc* (%z. (f z - f x) / (z - x))) xa @c= hcomplex_of_complex D)";
   1.741 +by (auto_tac (claset(), simpset() addsimps [NSCDERIV_NSCLIM_iff2, NSCLIM_def]));
   1.742 +qed "NSCDERIV_iff2";
   1.743 +
   1.744 +Goalw [cderiv_def] "(NSCDERIV f x :> D) = (CDERIV f x :> D)";
   1.745 +by (simp_tac (simpset() addsimps [NSCDERIV_NSCLIM_iff,CLIM_NSCLIM_iff]) 1);
   1.746 +qed "NSCDERIV_CDERIV_iff";
   1.747 +
   1.748 +Goalw [nscderiv_def]
   1.749 +      "NSCDERIV f x :> D ==> isNSContc f x";
   1.750 +by (auto_tac (claset(),simpset() addsimps [isNSContc_NSCLIM_iff,
   1.751 +    NSCLIM_def,hcomplex_diff_def]));
   1.752 +by (dtac (capprox_minus_iff RS iffD1) 1);
   1.753 +by (dtac (CLAIM "x ~= a ==> x + - a ~= (0::hcomplex)") 1);
   1.754 +by (dres_inst_tac [("x","- hcomplex_of_complex x + xa")] bspec 1);
   1.755 +by (asm_full_simp_tac (simpset() addsimps [hcomplex_add_assoc RS sym]) 2);
   1.756 +by (auto_tac (claset(),simpset() addsimps 
   1.757 +    [mem_cinfmal_iff RS sym,hcomplex_add_commute]));
   1.758 +by (dres_inst_tac [("c","xa + - hcomplex_of_complex x")] capprox_mult1 1);
   1.759 +by (auto_tac (claset() addIs [CInfinitesimal_subset_CFinite
   1.760 +    RS subsetD],simpset() addsimps [hcomplex_mult_assoc]));
   1.761 +by (dres_inst_tac [("x3","D")] (CFinite_hcomplex_of_complex RSN
   1.762 +    (2,CInfinitesimal_CFinite_mult) RS (mem_cinfmal_iff RS iffD1)) 1);
   1.763 +by (blast_tac (claset() addIs [capprox_trans,hcomplex_mult_commute RS subst,
   1.764 +    (capprox_minus_iff RS iffD2)]) 1);
   1.765 +qed "NSCDERIV_isNSContc";
   1.766 +
   1.767 +Goal "CDERIV f x :> D ==> isContc f x";
   1.768 +by (asm_full_simp_tac (simpset() addsimps [NSCDERIV_CDERIV_iff RS sym, 
   1.769 +    isNSContc_isContc_iff RS sym,NSCDERIV_isNSContc]) 1);
   1.770 +qed "CDERIV_isContc";
   1.771 +
   1.772 +(*------------------------------------------------------------------------------------*)
   1.773 +(* Differentiation rules for combinations of functions follow from clear,             *)
   1.774 +(* straightforard, algebraic manipulations                                            *)
   1.775 +(*------------------------------------------------------------------------------------*)
   1.776 +
   1.777 +(* use simple constant nslimit theorem *)
   1.778 +Goal "(NSCDERIV (%x. k) x :> 0)";
   1.779 +by (simp_tac (simpset() addsimps [NSCDERIV_NSCLIM_iff]) 1);
   1.780 +qed "NSCDERIV_const";
   1.781 +Addsimps [NSCDERIV_const];
   1.782 +
   1.783 +Goal "(CDERIV (%x. k) x :> 0)";
   1.784 +by (simp_tac (simpset() addsimps [NSCDERIV_CDERIV_iff RS sym]) 1);
   1.785 +qed "CDERIV_const";
   1.786 +Addsimps [CDERIV_const];
   1.787 +
   1.788 +Goal "[| NSCDERIV f x :> Da;  NSCDERIV g x :> Db |] \
   1.789 +\     ==> NSCDERIV (%x. f x + g x) x :> Da + Db";
   1.790 +by (asm_full_simp_tac (simpset() addsimps [NSCDERIV_NSCLIM_iff,
   1.791 +           NSCLIM_def]) 1 THEN REPEAT(Step_tac 1));
   1.792 +by (auto_tac (claset(),
   1.793 +       simpset() addsimps [hcomplex_add_divide_distrib,hcomplex_diff_def]));
   1.794 +by (dres_inst_tac [("b","hcomplex_of_complex Da"),
   1.795 +                   ("d","hcomplex_of_complex Db")] capprox_add 1);
   1.796 +by (auto_tac (claset(), simpset() addsimps hcomplex_add_ac));
   1.797 +qed "NSCDERIV_add";
   1.798 +
   1.799 +Goal "[| CDERIV f x :> Da; CDERIV g x :> Db |] \
   1.800 +\     ==> CDERIV (%x. f x + g x) x :> Da + Db";
   1.801 +by (asm_full_simp_tac (simpset() addsimps [NSCDERIV_add,
   1.802 +                                     NSCDERIV_CDERIV_iff RS sym]) 1);
   1.803 +qed "CDERIV_add";
   1.804 +
   1.805 +(*** lemmas for multiplication ***)
   1.806 +
   1.807 +Goal "((a::hcomplex)*b) - (c*d) = (b*(a - c)) + (c*(b - d))";
   1.808 +by (simp_tac (simpset() addsimps [hcomplex_diff_mult_distrib2]) 1);
   1.809 +val lemma_nscderiv1 = result();
   1.810 +
   1.811 +Goal "[| (x + y) / z = hcomplex_of_complex D + yb; z ~= 0; \
   1.812 +\        z : CInfinitesimal; yb : CInfinitesimal |] \
   1.813 +\     ==> x + y @c= 0";
   1.814 +by (forw_inst_tac [("c1","z")] (hcomplex_mult_right_cancel RS iffD2) 1 
   1.815 +    THEN assume_tac 1);
   1.816 +by (thin_tac "(x + y) / z = hcomplex_of_complex D + yb" 1);
   1.817 +by (auto_tac (claset() addSIs [CInfinitesimal_CFinite_mult2, CFinite_add],
   1.818 +              simpset() addsimps [mem_cinfmal_iff RS sym]));
   1.819 +by (etac (CInfinitesimal_subset_CFinite RS subsetD) 1);
   1.820 +val lemma_nscderiv2 = result();
   1.821 +
   1.822 +Goal "[| NSCDERIV f x :> Da; NSCDERIV g x :> Db |] \
   1.823 +\     ==> NSCDERIV (%x. f x * g x) x :> (Da * g(x)) + (Db * f(x))";
   1.824 +by (asm_full_simp_tac (simpset() addsimps [NSCDERIV_NSCLIM_iff, NSCLIM_def]) 1 
   1.825 +    THEN REPEAT(Step_tac 1));
   1.826 +by (auto_tac (claset(),
   1.827 +       simpset() addsimps [starfunC_lambda_cancel, lemma_nscderiv1,
   1.828 +       hcomplex_of_complex_zero]));
   1.829 +by (simp_tac (simpset() addsimps [hcomplex_add_divide_distrib]) 1); 
   1.830 +by (REPEAT(dtac (bex_CInfinitesimal_iff2 RS iffD2) 1));
   1.831 +by (auto_tac (claset(),
   1.832 +        simpset() delsimps [hcomplex_times_divide1_eq]
   1.833 +		  addsimps [hcomplex_times_divide1_eq RS sym]));
   1.834 +by (rewtac hcomplex_diff_def);
   1.835 +by (dres_inst_tac [("D","Db")] lemma_nscderiv2 1);
   1.836 +by (dtac (capprox_minus_iff RS iffD2 RS (bex_CInfinitesimal_iff2 RS iffD2)) 4);
   1.837 +by (auto_tac (claset() addSIs [capprox_add_mono1],
   1.838 +      simpset() addsimps [hcomplex_add_mult_distrib, hcomplex_add_mult_distrib2, 
   1.839 +			  hcomplex_mult_commute, hcomplex_add_assoc]));
   1.840 +by (res_inst_tac [("w1","hcomplex_of_complex Db * hcomplex_of_complex (f x)")]
   1.841 +    (hcomplex_add_commute RS subst) 1);
   1.842 +by (auto_tac (claset() addSIs [CInfinitesimal_add_capprox_self2 RS capprox_sym,
   1.843 +			       CInfinitesimal_add, CInfinitesimal_mult,
   1.844 +			       CInfinitesimal_hcomplex_of_complex_mult,
   1.845 +			       CInfinitesimal_hcomplex_of_complex_mult2],
   1.846 +	      simpset() addsimps [hcomplex_add_assoc RS sym]));
   1.847 +qed "NSCDERIV_mult";
   1.848 +
   1.849 +Goal "[| CDERIV f x :> Da; CDERIV g x :> Db |] \
   1.850 +\     ==> CDERIV (%x. f x * g x) x :> (Da * g(x)) + (Db * f(x))";
   1.851 +by (asm_full_simp_tac (simpset() addsimps [NSCDERIV_mult,
   1.852 +                                           NSCDERIV_CDERIV_iff RS sym]) 1);
   1.853 +qed "CDERIV_mult";
   1.854 +
   1.855 +Goal "NSCDERIV f x :> D ==> NSCDERIV (%x. c * f x) x :> c*D";
   1.856 +by (asm_full_simp_tac 
   1.857 +    (simpset() addsimps [complex_times_divide1_eq RS sym, NSCDERIV_NSCLIM_iff,
   1.858 +                         complex_minus_mult_eq2, complex_add_mult_distrib2 RS sym,
   1.859 +                         complex_diff_def] 
   1.860 +             delsimps [complex_times_divide1_eq, complex_minus_mult_eq2 RS sym]) 1);
   1.861 +by (etac (NSCLIM_const RS NSCLIM_mult) 1);
   1.862 +qed "NSCDERIV_cmult";
   1.863 +
   1.864 +Goal "CDERIV f x :> D ==> CDERIV (%x. c * f x) x :> c*D";
   1.865 +by (auto_tac (claset(),simpset() addsimps [NSCDERIV_cmult,NSCDERIV_CDERIV_iff
   1.866 +    RS sym]));
   1.867 +qed "CDERIV_cmult";
   1.868 +
   1.869 +Goal "NSCDERIV f x :> D ==> NSCDERIV (%x. -(f x)) x :> -D";
   1.870 +by (asm_full_simp_tac (simpset() addsimps [NSCDERIV_NSCLIM_iff,complex_diff_def]) 1);
   1.871 +by (res_inst_tac [("t","f x")] (complex_minus_minus RS subst) 1);
   1.872 +by (asm_simp_tac (simpset() addsimps [complex_minus_add_distrib RS sym] 
   1.873 +                   delsimps [complex_minus_add_distrib, complex_minus_minus]) 1);
   1.874 +by (etac NSCLIM_minus 1);
   1.875 +qed "NSCDERIV_minus";
   1.876 +
   1.877 +Goal "CDERIV f x :> D ==> CDERIV (%x. -(f x)) x :> -D";
   1.878 +by (asm_full_simp_tac (simpset() addsimps [NSCDERIV_minus,NSCDERIV_CDERIV_iff RS sym]) 1);
   1.879 +qed "CDERIV_minus";
   1.880 +
   1.881 +Goal "[| NSCDERIV f x :> Da; NSCDERIV g x :> Db |] \
   1.882 +\     ==> NSCDERIV (%x. f x + -g x) x :> Da + -Db";
   1.883 +by (blast_tac (claset() addDs [NSCDERIV_add,NSCDERIV_minus]) 1);
   1.884 +qed "NSCDERIV_add_minus";
   1.885 +
   1.886 +Goal "[| CDERIV f x :> Da; CDERIV g x :> Db |] \
   1.887 +\     ==> CDERIV (%x. f x + -g x) x :> Da + -Db";
   1.888 +by (blast_tac (claset() addDs [CDERIV_add,CDERIV_minus]) 1);
   1.889 +qed "CDERIV_add_minus";
   1.890 +
   1.891 +Goalw [complex_diff_def]
   1.892 +     "[| NSCDERIV f x :> Da; NSCDERIV g x :> Db |] \
   1.893 +\     ==> NSCDERIV (%x. f x - g x) x :> Da - Db";
   1.894 +by (blast_tac (claset() addIs [NSCDERIV_add_minus]) 1);
   1.895 +qed "NSCDERIV_diff";
   1.896 +
   1.897 +Goalw [complex_diff_def]
   1.898 +     "[| CDERIV f x :> Da; CDERIV g x :> Db |] \
   1.899 +\      ==> CDERIV (%x. f x - g x) x :> Da - Db";
   1.900 +by (blast_tac (claset() addIs [CDERIV_add_minus]) 1);
   1.901 +qed "CDERIV_diff";
   1.902 +
   1.903 +
   1.904 +(*--------------------------------------------------*)
   1.905 +(* Chain rule                                       *)
   1.906 +(*--------------------------------------------------*)
   1.907 +
   1.908 +(* lemmas *)
   1.909 +Goalw [nscderiv_def] 
   1.910 +      "[| NSCDERIV g x :> D; \
   1.911 +\         ( *fc* g) (hcomplex_of_complex(x) + xa) = hcomplex_of_complex(g x);\
   1.912 +\         xa : CInfinitesimal; xa ~= 0 \
   1.913 +\      |] ==> D = 0";
   1.914 +by (dtac bspec 1);
   1.915 +by Auto_tac;
   1.916 +qed "NSCDERIV_zero";
   1.917 +
   1.918 +Goalw [nscderiv_def] 
   1.919 +     "[| NSCDERIV f x :> D;  h: CInfinitesimal;  h ~= 0 |]  \
   1.920 +\     ==> ( *fc* f) (hcomplex_of_complex(x) + h) - hcomplex_of_complex(f x) @c= 0";    
   1.921 +by (asm_full_simp_tac (simpset() addsimps [mem_cinfmal_iff RS sym]) 1);
   1.922 +by (rtac CInfinitesimal_ratio 1);
   1.923 +by (rtac capprox_hcomplex_of_complex_CFinite 3);
   1.924 +by Auto_tac;
   1.925 +qed "NSCDERIV_capprox";
   1.926 +
   1.927 +
   1.928 +(*--------------------------------------------------*)
   1.929 +(* from one version of differentiability            *)
   1.930 +(*                                                  *)                                   
   1.931 +(*   f(x) - f(a)                                    *)
   1.932 +(* --------------- @= Db                            *)
   1.933 +(*     x - a                                        *)
   1.934 +(* -------------------------------------------------*)
   1.935 +
   1.936 +Goal "[| NSCDERIV f (g x) :> Da; \
   1.937 +\        ( *fc* g) (hcomplex_of_complex(x) + xa) ~= hcomplex_of_complex (g x); \
   1.938 +\        ( *fc* g) (hcomplex_of_complex(x) + xa) @c= hcomplex_of_complex (g x) \
   1.939 +\     |] ==> (( *fc* f) (( *fc* g) (hcomplex_of_complex(x) + xa)) \
   1.940 +\                     - hcomplex_of_complex (f (g x))) \
   1.941 +\             / (( *fc* g) (hcomplex_of_complex(x) + xa) - hcomplex_of_complex (g x)) \
   1.942 +\            @c= hcomplex_of_complex (Da)";
   1.943 +by (auto_tac (claset(),simpset() addsimps [NSCDERIV_NSCLIM_iff2, NSCLIM_def]));
   1.944 +qed "NSCDERIVD1";
   1.945 +
   1.946 +(*--------------------------------------------------*)
   1.947 +(* from other version of differentiability          *)
   1.948 +(*                                                  *)
   1.949 +(*  f(x + h) - f(x)                                 *)
   1.950 +(* ----------------- @= Db                          *)
   1.951 +(*         h                                        *)
   1.952 +(*--------------------------------------------------*)
   1.953 +
   1.954 +Goal "[| NSCDERIV g x :> Db; xa: CInfinitesimal; xa ~= 0 |] \
   1.955 +\     ==> (( *fc* g) (hcomplex_of_complex(x) + xa) - hcomplex_of_complex(g x)) / xa \
   1.956 +\         @c= hcomplex_of_complex (Db)";
   1.957 +by (auto_tac (claset(),
   1.958 +    simpset() addsimps [NSCDERIV_NSCLIM_iff, NSCLIM_def, 
   1.959 +		mem_cinfmal_iff, starfunC_lambda_cancel]));
   1.960 +qed "NSCDERIVD2";
   1.961 +
   1.962 +Goal "(z::hcomplex) ~= 0 ==> x*y = (x*inverse(z))*(z*y)";
   1.963 +by Auto_tac;  
   1.964 +qed "lemma_complex_chain";
   1.965 +
   1.966 +(*** chain rule ***)
   1.967 +
   1.968 +Goal "[| NSCDERIV f (g x) :> Da; NSCDERIV g x :> Db |] \
   1.969 +\     ==> NSCDERIV (f o g) x :> Da * Db";
   1.970 +by (asm_simp_tac (simpset() addsimps [NSCDERIV_NSCLIM_iff,
   1.971 +    NSCLIM_def,mem_cinfmal_iff RS sym]) 1 THEN Step_tac 1);
   1.972 +by (forw_inst_tac [("f","g")] NSCDERIV_capprox 1);
   1.973 +by (auto_tac (claset(),
   1.974 +              simpset() addsimps [starfunC_lambda_cancel2, starfunC_o RS sym]));
   1.975 +by (case_tac "( *fc* g) (hcomplex_of_complex(x) + xa) = hcomplex_of_complex (g x)" 1);
   1.976 +by (dres_inst_tac [("g","g")] NSCDERIV_zero 1);
   1.977 +by (auto_tac (claset(),simpset() addsimps [hcomplex_divide_def]));
   1.978 +by (res_inst_tac [("z1","( *fc* g) (hcomplex_of_complex(x) + xa) - hcomplex_of_complex (g x)"),
   1.979 +    ("y1","inverse xa")] (lemma_complex_chain RS ssubst) 1);
   1.980 +by (Asm_simp_tac 1);
   1.981 +by (rtac capprox_mult_hcomplex_of_complex 1);
   1.982 +by (fold_tac [hcomplex_divide_def]);
   1.983 +by (blast_tac (claset() addIs [NSCDERIVD2]) 2);
   1.984 +by (auto_tac (claset() addSIs [NSCDERIVD1] addIs [capprox_minus_iff RS iffD2],
   1.985 +    simpset() addsimps [symmetric hcomplex_diff_def]));
   1.986 +qed "NSCDERIV_chain";
   1.987 +
   1.988 +(* standard version *)
   1.989 +Goal "[| CDERIV f (g x) :> Da; CDERIV g x :> Db |] \
   1.990 +\     ==> CDERIV (f o g) x :> Da * Db";
   1.991 +by (asm_full_simp_tac (simpset() addsimps [NSCDERIV_CDERIV_iff RS sym,
   1.992 +    NSCDERIV_chain]) 1);
   1.993 +qed "CDERIV_chain";
   1.994 +
   1.995 +Goal "[| CDERIV f (g x) :> Da; CDERIV g x :> Db |] \
   1.996 +\     ==> CDERIV (%x. f (g x)) x :> Da * Db";
   1.997 +by (auto_tac (claset() addDs [CDERIV_chain], simpset() addsimps [o_def]));
   1.998 +qed "CDERIV_chain2";
   1.999 +
  1.1000 +(*------------------------------------------------------------------------------------*)
  1.1001 +(* Differentiation of natural number powers                                           *)
  1.1002 +(*------------------------------------------------------------------------------------*)
  1.1003 +
  1.1004 +Goal "NSCDERIV (%x. x) x :> 1";
  1.1005 +by (auto_tac (claset(),
  1.1006 +     simpset() addsimps [NSCDERIV_NSCLIM_iff,NSCLIM_def]));
  1.1007 +qed "NSCDERIV_Id";
  1.1008 +Addsimps [NSCDERIV_Id];
  1.1009 +
  1.1010 +Goal "CDERIV (%x. x) x :> 1";
  1.1011 +by (simp_tac (simpset() addsimps [NSCDERIV_CDERIV_iff RS sym]) 1);
  1.1012 +qed "CDERIV_Id";
  1.1013 +Addsimps [CDERIV_Id];
  1.1014 +
  1.1015 +bind_thm ("isContc_Id", CDERIV_Id RS CDERIV_isContc);
  1.1016 +
  1.1017 +(*derivative of linear multiplication*)
  1.1018 +Goal "CDERIV (op * c) x :> c";
  1.1019 +by (cut_inst_tac [("c","c"),("x","x")] (CDERIV_Id RS CDERIV_cmult) 1);
  1.1020 +by (Asm_full_simp_tac 1);
  1.1021 +qed "CDERIV_cmult_Id";
  1.1022 +Addsimps [CDERIV_cmult_Id];
  1.1023 +
  1.1024 +Goal "NSCDERIV (op * c) x :> c";
  1.1025 +by (simp_tac (simpset() addsimps [NSCDERIV_CDERIV_iff]) 1);
  1.1026 +qed "NSCDERIV_cmult_Id";
  1.1027 +Addsimps [NSCDERIV_cmult_Id];
  1.1028 +
  1.1029 +Goal "CDERIV (%x. x ^ n) x :> (complex_of_real (real n)) * (x ^ (n - 1))";
  1.1030 +by (induct_tac "n" 1);
  1.1031 +by (dtac (CDERIV_Id RS CDERIV_mult) 2);
  1.1032 +by (auto_tac (claset(), 
  1.1033 +              simpset() addsimps [complex_of_real_add RS sym,
  1.1034 +              complex_add_mult_distrib,real_of_nat_Suc] delsimps [complex_of_real_add]));
  1.1035 +by (case_tac "n" 1);
  1.1036 +by (auto_tac (claset(), 
  1.1037 +              simpset() addsimps [complex_mult_assoc, complex_add_commute]));
  1.1038 +by (auto_tac (claset(),simpset() addsimps [complex_mult_commute]));
  1.1039 +qed "CDERIV_pow";
  1.1040 +Addsimps [CDERIV_pow,simplify (simpset()) CDERIV_pow];
  1.1041 +
  1.1042 +(* NS version *)
  1.1043 +Goal "NSCDERIV (%x. x ^ n) x :> complex_of_real (real n) * (x ^ (n - 1))";
  1.1044 +by (simp_tac (simpset() addsimps [NSCDERIV_CDERIV_iff]) 1);
  1.1045 +qed "NSCDERIV_pow";
  1.1046 +
  1.1047 +Goal "\\<lbrakk> CDERIV f x :> D; D = E \\<rbrakk> \\<Longrightarrow> CDERIV f x :> E";
  1.1048 +by Auto_tac;
  1.1049 +qed "lemma_CDERIV_subst";
  1.1050 +
  1.1051 +(*used once, in NSCDERIV_inverse*)
  1.1052 +Goal "[| h: CInfinitesimal; x ~= 0 |] ==> hcomplex_of_complex x + h ~= 0";
  1.1053 +by Auto_tac;  
  1.1054 +qed "CInfinitesimal_add_not_zero";
  1.1055 +
  1.1056 +(***
  1.1057 +Goal "[|(x::hcomplex) ~= 0;  y ~= 0 |]  \
  1.1058 +\     ==> inverse(x) + inverse(y) = (x + y)*inverse(x*y)";
  1.1059 +by (asm_full_simp_tac (simpset() addsimps [hcomplex_inverse_distrib,
  1.1060 +                    hcomplex_add_mult_distrib,hcomplex_mult_assoc RS sym]) 1);
  1.1061 +qed "hcomplex_inverse_add";
  1.1062 +***)
  1.1063 +
  1.1064 +(*Can't get rid of x ~= 0 because it isn't continuous at zero*)
  1.1065 +
  1.1066 +Goalw [nscderiv_def]
  1.1067 +     "x ~= 0 ==> NSCDERIV (%x. inverse(x)) x :> (- (inverse x ^ 2))";
  1.1068 +by (rtac ballI 1 THEN Asm_full_simp_tac 1 THEN Step_tac 1);
  1.1069 +by (forward_tac [CInfinitesimal_add_not_zero] 1);
  1.1070 +by (asm_full_simp_tac (simpset() addsimps [hcomplex_add_commute,two_eq_Suc_Suc]) 2); 
  1.1071 +by (auto_tac (claset(),
  1.1072 +     simpset() addsimps [starfunC_inverse_inverse,hcomplex_diff_def] 
  1.1073 +               delsimps [hcomplex_minus_mult_eq1 RS sym,
  1.1074 +                         hcomplex_minus_mult_eq2 RS sym]));
  1.1075 +by (asm_simp_tac
  1.1076 +     (simpset() addsimps [hcomplex_inverse_add,
  1.1077 +          hcomplex_inverse_distrib RS sym, hcomplex_minus_inverse RS sym] 
  1.1078 +          @ hcomplex_add_ac @ hcomplex_mult_ac 
  1.1079 +       delsimps [hcomplex_minus_mult_eq1 RS sym,
  1.1080 +                 hcomplex_minus_mult_eq2 RS sym] ) 1);
  1.1081 +by (asm_simp_tac (simpset() addsimps [hcomplex_mult_assoc RS sym,
  1.1082 +                                      hcomplex_add_mult_distrib2] 
  1.1083 +         delsimps [hcomplex_minus_mult_eq1 RS sym, 
  1.1084 +                   hcomplex_minus_mult_eq2 RS sym]) 1);
  1.1085 +by (res_inst_tac [("y"," inverse(- hcomplex_of_complex x * hcomplex_of_complex x)")] 
  1.1086 +                 capprox_trans 1);
  1.1087 +by (rtac inverse_add_CInfinitesimal_capprox2 1);
  1.1088 +by (auto_tac (claset() addSDs [hcomplex_of_complex_CFinite_diff_CInfinitesimal] addIs [CFinite_mult], 
  1.1089 +         simpset() addsimps [hcomplex_minus_inverse RS sym]));
  1.1090 +by (rtac CInfinitesimal_CFinite_mult2 1); 
  1.1091 +by Auto_tac;  
  1.1092 +qed "NSCDERIV_inverse";
  1.1093 +
  1.1094 +Goal "x ~= 0 ==> CDERIV (%x. inverse(x)) x :> (-(inverse x ^ 2))";
  1.1095 +by (asm_simp_tac (simpset() addsimps [NSCDERIV_inverse,
  1.1096 +         NSCDERIV_CDERIV_iff RS sym] delsimps [complexpow_Suc]) 1);
  1.1097 +qed "CDERIV_inverse";
  1.1098 +
  1.1099 +
  1.1100 +(*------------------------------------------------------------------------------------*)
  1.1101 +(* Derivative of inverse                                                              *)
  1.1102 +(*------------------------------------------------------------------------------------*)
  1.1103 +
  1.1104 +Goal "[| CDERIV f x :> d; f(x) ~= 0 |] \
  1.1105 +\     ==> CDERIV (%x. inverse(f x)) x :> (- (d * inverse(f(x) ^ 2)))";
  1.1106 +by (rtac (complex_mult_commute RS subst) 1);
  1.1107 +by (asm_simp_tac (simpset() addsimps [complex_minus_mult_eq1,
  1.1108 +    complexpow_inverse] delsimps [complexpow_Suc, 
  1.1109 +    complex_minus_mult_eq1 RS sym]) 1);
  1.1110 +by (fold_goals_tac [o_def]);
  1.1111 +by (blast_tac (claset() addSIs [CDERIV_chain,CDERIV_inverse]) 1);
  1.1112 +qed "CDERIV_inverse_fun";
  1.1113 +
  1.1114 +Goal "[| NSCDERIV f x :> d; f(x) ~= 0 |] \
  1.1115 +\     ==> NSCDERIV (%x. inverse(f x)) x :> (- (d * inverse(f(x) ^ 2)))";
  1.1116 +by (asm_full_simp_tac (simpset() addsimps [NSCDERIV_CDERIV_iff,
  1.1117 +            CDERIV_inverse_fun] delsimps [complexpow_Suc]) 1);
  1.1118 +qed "NSCDERIV_inverse_fun";
  1.1119 +
  1.1120 +(*------------------------------------------------------------------------------------*)
  1.1121 +(* Derivative of quotient                                                             *)
  1.1122 +(*------------------------------------------------------------------------------------*)
  1.1123 +
  1.1124 +
  1.1125 +Goal "x ~= (0::complex) \\<Longrightarrow> (x * inverse(x) ^ 2) = inverse x";
  1.1126 +by (auto_tac (claset(),simpset() addsimps [two_eq_Suc_Suc]));
  1.1127 +qed "lemma_complex_mult_inverse_squared";
  1.1128 +Addsimps [lemma_complex_mult_inverse_squared];
  1.1129 +
  1.1130 +Goalw [complex_diff_def] 
  1.1131 +     "[| CDERIV f x :> d; CDERIV g x :> e; g(x) ~= 0 |] \
  1.1132 +\      ==> CDERIV (%y. f(y) / (g y)) x :> (d*g(x) - (e*f(x))) / (g(x) ^ 2)";
  1.1133 +by (dres_inst_tac [("f","g")] CDERIV_inverse_fun 1);
  1.1134 +by (dtac CDERIV_mult 2);
  1.1135 +by (REPEAT(assume_tac 1));
  1.1136 +by (asm_full_simp_tac
  1.1137 +    (simpset() addsimps [complex_divide_def, complex_add_mult_distrib2,
  1.1138 +                         complexpow_inverse,complex_minus_mult_eq1] @ complex_mult_ac 
  1.1139 +       delsimps [complexpow_Suc, complex_minus_mult_eq1 RS sym,
  1.1140 +                 complex_minus_mult_eq2 RS sym]) 1);
  1.1141 +qed "CDERIV_quotient";
  1.1142 +
  1.1143 +Goal "[| NSCDERIV f x :> d; NSCDERIV g x :> e; g(x) ~= 0 |] \
  1.1144 +\      ==> NSCDERIV (%y. f(y) / (g y)) x :> (d*g(x) - (e*f(x))) / (g(x) ^ 2)";
  1.1145 +by (asm_full_simp_tac (simpset() addsimps [NSCDERIV_CDERIV_iff,
  1.1146 +            CDERIV_quotient] delsimps [complexpow_Suc]) 1);
  1.1147 +qed "NSCDERIV_quotient";
  1.1148 + 
  1.1149 +
  1.1150 +(*------------------------------------------------------------------------------------*)
  1.1151 +(* Caratheodory formulation of derivative at a point: standard proof                  *)
  1.1152 +(*------------------------------------------------------------------------------------*)
  1.1153 +
  1.1154 +
  1.1155 +Goalw [CLIM_def] 
  1.1156 +      "[| ALL x. x ~= a --> (f x = g x) |] \
  1.1157 +\           ==> (f -- a --C> l) = (g -- a --C> l)";
  1.1158 +by (auto_tac (claset(), simpset() addsimps [complex_add_minus_iff]));
  1.1159 +qed "CLIM_equal";
  1.1160 +
  1.1161 +Goal "[| (%x. f(x) + -g(x)) -- a --C> 0; \
  1.1162 +\        g -- a --C> l |] \
  1.1163 +\      ==> f -- a --C> l";
  1.1164 +by (dtac CLIM_add 1 THEN assume_tac 1);
  1.1165 +by (auto_tac (claset(), simpset() addsimps [complex_add_assoc]));
  1.1166 +qed "CLIM_trans";
  1.1167 +
  1.1168 +Goal "(CDERIV f x :> l) = \
  1.1169 +\     (EX g. (ALL z. f z - f x = g z * (z - x)) & isContc g x & g x = l)";
  1.1170 +by (Step_tac 1);
  1.1171 +by (res_inst_tac 
  1.1172 +    [("x","%z. if  z = x then l else (f(z) - f(x)) / (z - x)")] exI 1);
  1.1173 +by (auto_tac (claset(),simpset() addsimps [complex_mult_assoc,
  1.1174 +    CLAIM "z ~= x ==> z - x ~= (0::complex)"]));
  1.1175 +by (auto_tac (claset(),simpset() addsimps [isContc_iff,CDERIV_iff]));
  1.1176 +by (ALLGOALS(rtac (CLIM_equal RS iffD1)));
  1.1177 +by Auto_tac;
  1.1178 +qed "CARAT_CDERIV";
  1.1179 +
  1.1180 +Goal "NSCDERIV f x :> l ==> \
  1.1181 +\     EX g. (ALL z. f z - f x = g z * (z - x)) & isNSContc g x & g x = l";
  1.1182 +by (auto_tac (claset(),simpset() addsimps [NSCDERIV_CDERIV_iff,
  1.1183 +    isNSContc_isContc_iff,CARAT_CDERIV]));
  1.1184 +qed "CARAT_NSCDERIV";
  1.1185 +
  1.1186 +(* How about a NS proof? *)
  1.1187 +Goal "(ALL z. f z - f x = g z * (z - x)) & isNSContc g x & g x = l \
  1.1188 +\     ==> NSCDERIV f x :> l";
  1.1189 +by (auto_tac (claset(), 
  1.1190 +              simpset() delsimprocs complex_cancel_factor
  1.1191 +                        addsimps [NSCDERIV_iff2]));
  1.1192 +by (asm_full_simp_tac (simpset() addsimps [isNSContc_def]) 1);
  1.1193 +qed "CARAT_CDERIVD";
  1.1194 + 
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/src/HOL/Complex/CLim.thy	Mon May 05 18:22:31 2003 +0200
     2.3 @@ -0,0 +1,82 @@
     2.4 +(*  Title       : CLim.thy
     2.5 +    Author      : Jacques D. Fleuriot
     2.6 +    Copyright   : 2001 University of Edinburgh
     2.7 +    Description : A first theory of limits, continuity and 
     2.8 +                  differentiation for complex functions
     2.9 +*)
    2.10 +
    2.11 +CLim = CSeries + 
    2.12 +
    2.13 +constdefs
    2.14 +
    2.15 +  CLIM :: [complex=>complex,complex,complex] => bool
    2.16 +				("((_)/ -- (_)/ --C> (_))" [60, 0, 60] 60)
    2.17 +  "f -- a --C> L ==
    2.18 +     ALL r. 0 < r --> 
    2.19 +	     (EX s. 0 < s & (ALL x. (x ~= a & (cmod(x - a) < s)
    2.20 +			  --> cmod(f x - L) < r)))"
    2.21 +
    2.22 +  NSCLIM :: [complex=>complex,complex,complex] => bool
    2.23 +			      ("((_)/ -- (_)/ --NSC> (_))" [60, 0, 60] 60)
    2.24 +  "f -- a --NSC> L == (ALL x. (x ~= hcomplex_of_complex a & 
    2.25 +           		         x @c= hcomplex_of_complex a 
    2.26 +                                   --> ( *fc* f) x @c= hcomplex_of_complex L))"   
    2.27 +
    2.28 +  (* f: C --> R *)
    2.29 +  CRLIM :: [complex=>real,complex,real] => bool
    2.30 +				("((_)/ -- (_)/ --CR> (_))" [60, 0, 60] 60)
    2.31 +  "f -- a --CR> L ==
    2.32 +     ALL r. 0 < r --> 
    2.33 +	     (EX s. 0 < s & (ALL x. (x ~= a & (cmod(x - a) < s)
    2.34 +			  --> abs(f x - L) < r)))"
    2.35 +
    2.36 +  NSCRLIM :: [complex=>real,complex,real] => bool
    2.37 +			      ("((_)/ -- (_)/ --NSCR> (_))" [60, 0, 60] 60)
    2.38 +  "f -- a --NSCR> L == (ALL x. (x ~= hcomplex_of_complex a & 
    2.39 +           		         x @c= hcomplex_of_complex a 
    2.40 +                                   --> ( *fcR* f) x @= hypreal_of_real L))"   
    2.41 +
    2.42 +
    2.43 +  isContc :: [complex=>complex,complex] => bool
    2.44 +  "isContc f a == (f -- a --C> (f a))"        
    2.45 +
    2.46 +  (* NS definition dispenses with limit notions *)
    2.47 +  isNSContc :: [complex=>complex,complex] => bool
    2.48 +  "isNSContc f a == (ALL y. y @c= hcomplex_of_complex a --> 
    2.49 +			   ( *fc* f) y @c= hcomplex_of_complex (f a))"
    2.50 +
    2.51 +  isContCR :: [complex=>real,complex] => bool
    2.52 +  "isContCR f a == (f -- a --CR> (f a))"        
    2.53 +
    2.54 +  (* NS definition dispenses with limit notions *)
    2.55 +  isNSContCR :: [complex=>real,complex] => bool
    2.56 +  "isNSContCR f a == (ALL y. y @c= hcomplex_of_complex a --> 
    2.57 +			   ( *fcR* f) y @= hypreal_of_real (f a))"
    2.58 +
    2.59 +  (* differentiation: D is derivative of function f at x *)
    2.60 +  cderiv:: [complex=>complex,complex,complex] => bool
    2.61 +			    ("(CDERIV (_)/ (_)/ :> (_))" [60, 0, 60] 60)
    2.62 +  "CDERIV f x :> D == ((%h. (f(x + h) - f(x))/h) -- 0 --C> D)"
    2.63 +
    2.64 +  nscderiv :: [complex=>complex,complex,complex] => bool
    2.65 +			    ("(NSCDERIV (_)/ (_)/ :> (_))" [60, 0, 60] 60)
    2.66 +  "NSCDERIV f x :> D == (ALL h: CInfinitesimal - {0}. 
    2.67 +			      (( *fc* f)(hcomplex_of_complex x + h)
    2.68 +        			 - hcomplex_of_complex (f x))/h @c= hcomplex_of_complex D)"
    2.69 +
    2.70 +  cdifferentiable :: [complex=>complex,complex] => bool   (infixl 60)
    2.71 +  "f cdifferentiable x == (EX D. CDERIV f x :> D)"
    2.72 +
    2.73 +  NSCdifferentiable :: [complex=>complex,complex] => bool   (infixl 60)
    2.74 +  "f NSCdifferentiable x == (EX D. NSCDERIV f x :> D)"
    2.75 +
    2.76 +
    2.77 +  isUContc :: (complex=>complex) => bool
    2.78 +  "isUContc f ==  (ALL r. 0 < r --> 
    2.79 +		      (EX s. 0 < s & (ALL x y. cmod(x - y) < s
    2.80 +			    --> cmod(f x - f y) < r)))"
    2.81 +
    2.82 +  isNSUContc :: (complex=>complex) => bool
    2.83 +  "isNSUContc f == (ALL x y. x @c= y --> ( *fc* f) x @c= ( *fc* f) y)"
    2.84 +
    2.85 +end 
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/src/HOL/Complex/CSeries.ML	Mon May 05 18:22:31 2003 +0200
     3.3 @@ -0,0 +1,210 @@
     3.4 +(*  Title       : CSeries.ML
     3.5 +    Author      : Jacques D. Fleuriot
     3.6 +    Copyright   : 2002  University of Edinburgh
     3.7 +    Description : Finite summation and infinite series for complex numbers
     3.8 +*)
     3.9 +
    3.10 +
    3.11 +Goal "sumc (Suc n) n f = 0";
    3.12 +by (induct_tac "n" 1);
    3.13 +by (Auto_tac);
    3.14 +qed "sumc_Suc_zero";
    3.15 +Addsimps [sumc_Suc_zero];
    3.16 +
    3.17 +Goal "sumc m m f = 0";
    3.18 +by (induct_tac "m" 1);
    3.19 +by (Auto_tac);
    3.20 +qed "sumc_eq_bounds";
    3.21 +Addsimps [sumc_eq_bounds];
    3.22 +
    3.23 +Goal "sumc m (Suc m) f = f(m)";
    3.24 +by (Auto_tac);
    3.25 +qed "sumc_Suc_eq";
    3.26 +Addsimps [sumc_Suc_eq];
    3.27 +
    3.28 +Goal "sumc (m+k) k f = 0";
    3.29 +by (induct_tac "k" 1);
    3.30 +by (Auto_tac);
    3.31 +qed "sumc_add_lbound_zero";
    3.32 +Addsimps [sumc_add_lbound_zero];
    3.33 +
    3.34 +Goal "sumc m n f + sumc m n g = sumc m n (%n. f n + g n)";
    3.35 +by (induct_tac "n" 1);
    3.36 +by (auto_tac (claset(),simpset() addsimps real_add_ac));
    3.37 +qed "sumc_add";
    3.38 +
    3.39 +Goal "r * sumc m n f = sumc m n (%n. r * f n)";
    3.40 +by (induct_tac "n" 1);
    3.41 +by (Auto_tac);
    3.42 +by (auto_tac (claset(),simpset() addsimps 
    3.43 +    [complex_add_mult_distrib2]));
    3.44 +qed "sumc_mult";
    3.45 +
    3.46 +Goal "n < p --> sumc 0 n f + sumc n p f = sumc 0 p f";
    3.47 +by (induct_tac "p" 1);
    3.48 +by (auto_tac (claset() addSDs [CLAIM "n < Suc na ==> n <= na",
    3.49 +    leI] addDs [le_anti_sym], simpset()));
    3.50 +qed_spec_mp "sumc_split_add";
    3.51 +
    3.52 +Goal "n < p ==> sumc 0 p f + \
    3.53 +\                - sumc 0 n f = sumc n p f";
    3.54 +by (dres_inst_tac [("f1","f")] (sumc_split_add RS sym) 1);
    3.55 +by (asm_simp_tac (simpset() addsimps complex_add_ac) 1);
    3.56 +qed "sumc_split_add_minus";
    3.57 +
    3.58 +Goal "cmod(sumc m n f) <= sumr m n (%i. cmod(f i))";
    3.59 +by (induct_tac "n" 1);
    3.60 +by (auto_tac (claset() addIs [complex_mod_triangle_ineq RS order_trans], 
    3.61 +              simpset()));
    3.62 +qed "sumc_cmod";
    3.63 +
    3.64 +Goal "!!f g. (ALL r. m <= r & r < n --> f r = g r) \
    3.65 +\                --> sumc m n f = sumc m n g";
    3.66 +by (induct_tac "n" 1);
    3.67 +by (Auto_tac);
    3.68 +qed_spec_mp "sumc_fun_eq";
    3.69 +
    3.70 +Goal "sumc 0 n (%i. r) = complex_of_real (real n) * r";
    3.71 +by (induct_tac "n" 1);
    3.72 +by (auto_tac (claset(),
    3.73 +              simpset() addsimps [complex_add_mult_distrib,
    3.74 +                                  complex_of_real_add RS sym,
    3.75 +                                  real_of_nat_Suc]));
    3.76 +qed "sumc_const";
    3.77 +Addsimps [sumc_const];
    3.78 +
    3.79 +Goal "sumc 0 n f + -(complex_of_real(real n) * r) = sumc 0 n (%i. f i + -r)";
    3.80 +by (full_simp_tac (simpset() addsimps [sumc_add RS sym]) 1);
    3.81 +qed "sumc_add_mult_const";
    3.82 +
    3.83 +Goalw [complex_diff_def] 
    3.84 +     "sumc 0 n f - (complex_of_real(real n)*r) = sumc 0 n (%i. f i - r)";
    3.85 +by (full_simp_tac (simpset() addsimps [sumc_add_mult_const]) 1);
    3.86 +qed "sumc_diff_mult_const";
    3.87 +
    3.88 +Goal "n < m --> sumc m n f = 0";
    3.89 +by (induct_tac "n" 1);
    3.90 +by Auto_tac;
    3.91 +qed_spec_mp "sumc_less_bounds_zero";
    3.92 +Addsimps [sumc_less_bounds_zero];
    3.93 +
    3.94 +Goal "sumc m n (%i. - f i) = - sumc m n f";
    3.95 +by (induct_tac "n" 1);
    3.96 +by Auto_tac;
    3.97 +qed "sumc_minus";
    3.98 +
    3.99 +Goal "sumc (m+k) (n+k) f = sumc m n (%i. f(i + k))";
   3.100 +by (induct_tac "n" 1);
   3.101 +by (Auto_tac);
   3.102 +qed "sumc_shift_bounds";
   3.103 +
   3.104 +Goal "sumc 0 (2*n) (%i. (-1) ^ Suc i) = 0";
   3.105 +by (induct_tac "n" 1);
   3.106 +by (Auto_tac);
   3.107 +qed "sumc_minus_one_complexpow_zero";
   3.108 +Addsimps [sumc_minus_one_complexpow_zero];
   3.109 +
   3.110 +Goal "(ALL n. m <= Suc n --> f n = r) & m <= na \
   3.111 +\                --> sumc m na f = (complex_of_real(real (na - m)) * r)";
   3.112 +by (induct_tac "na" 1);
   3.113 +by (auto_tac (claset(),simpset() addsimps [real_add_mult_distrib, Suc_diff_n,
   3.114 +                                      real_of_nat_Suc,complex_of_real_add RS sym,
   3.115 +                                      complex_add_mult_distrib]));
   3.116 +qed_spec_mp "sumc_interval_const";
   3.117 +
   3.118 +Goal "(ALL n. m <= n --> f n = r) & m <= na \
   3.119 +\     --> sumc m na f = (complex_of_real(real (na - m)) * r)";
   3.120 +by (induct_tac "na" 1);
   3.121 +by (auto_tac (claset(),simpset() addsimps [real_add_mult_distrib, Suc_diff_n,
   3.122 +                                      real_of_nat_Suc,complex_of_real_add RS sym,
   3.123 +                                      complex_add_mult_distrib]));
   3.124 +qed_spec_mp "sumc_interval_const2";
   3.125 +
   3.126 +(*** 
   3.127 +Goal "(ALL n. m <= n --> 0 <= cmod(f n)) & m < k --> cmod(sumc 0 m f) <= cmod(sumc 0 k f)";
   3.128 +by (induct_tac "k" 1);
   3.129 +by (Step_tac 1);
   3.130 +by (ALLGOALS(asm_full_simp_tac (simpset() addsimps [less_Suc_eq_le])));
   3.131 +by (ALLGOALS(dres_inst_tac [("x","n")] spec));
   3.132 +by (Step_tac 1);
   3.133 +by (dtac le_imp_less_or_eq 1 THEN Step_tac 1);
   3.134 +by (dtac real_add_le_mono 2);
   3.135 +by (dres_inst_tac [("i","sumr 0 m f")] (order_refl RS real_add_le_mono) 1);
   3.136 +by (Auto_tac);
   3.137 +qed_spec_mp "sumc_le";
   3.138 +
   3.139 +Goal "!!f g. (ALL r. m <= r & r < n --> f r <= g r) \
   3.140 +\                --> sumc m n f <= sumc m n g";
   3.141 +by (induct_tac "n" 1);
   3.142 +by (auto_tac (claset() addIs [real_add_le_mono],
   3.143 +    simpset() addsimps [le_def]));
   3.144 +qed_spec_mp "sumc_le2";
   3.145 +
   3.146 +Goal "(ALL n. 0 <= f n) --> 0 <= sumc m n f";
   3.147 +by (induct_tac "n" 1);
   3.148 +by Auto_tac;
   3.149 +by (dres_inst_tac [("x","n")] spec 1);
   3.150 +by (arith_tac 1);
   3.151 +qed_spec_mp "sumc_ge_zero";
   3.152 +
   3.153 +Goal "(ALL n. m <= n --> 0 <= f n) --> 0 <= sumc m n f";
   3.154 +by (induct_tac "n" 1);
   3.155 +by Auto_tac;
   3.156 +by (dres_inst_tac [("x","n")] spec 1);
   3.157 +by (arith_tac 1);
   3.158 +qed_spec_mp "sumc_ge_zero2";
   3.159 +***)
   3.160 +
   3.161 +Goal "0 <= sumr m n (%n. cmod (f n))";
   3.162 +by (induct_tac "n" 1);
   3.163 +by Auto_tac;
   3.164 +by (res_inst_tac [("j","0")] real_le_trans 1);
   3.165 +by Auto_tac;
   3.166 +qed "sumr_cmod_ge_zero";
   3.167 +Addsimps [sumr_cmod_ge_zero];
   3.168 +AddSIs [sumr_cmod_ge_zero]; 
   3.169 +
   3.170 +Goal "abs (sumr m n (%n. cmod (f n))) = (sumr m n (%n. cmod (f n)))";
   3.171 +by (rtac (abs_eqI1 RS ssubst) 1 THEN Auto_tac);
   3.172 +qed "rabs_sumc_cmod_cancel";
   3.173 +Addsimps [rabs_sumc_cmod_cancel];
   3.174 +
   3.175 +Goal "ALL n. N <= n --> f n = 0 \
   3.176 +\     ==> ALL m n. N <= m --> sumc m n f = 0";   
   3.177 +by (Step_tac 1);
   3.178 +by (induct_tac "n" 1);
   3.179 +by (Auto_tac);
   3.180 +qed "sumc_zero";
   3.181 +
   3.182 +Goal "ALL n. N <= n --> f (Suc n) = 0 \
   3.183 +\     ==> ALL m n. Suc N <= m --> sumc m n f = 0";   
   3.184 +by (rtac sumc_zero 1 THEN Step_tac 1);
   3.185 +by (dres_inst_tac [("x","n - 1")] spec 1);
   3.186 +by Auto_tac;
   3.187 +by (arith_tac 1);
   3.188 +qed "fun_zero_sumc_zero";
   3.189 +
   3.190 +Goal "sumc 1 n (%n. f(n) * 0 ^ n) = 0";
   3.191 +by (induct_tac "n" 1);
   3.192 +by (case_tac "n" 2);
   3.193 +by Auto_tac;
   3.194 +qed "sumc_one_lb_complexpow_zero";
   3.195 +Addsimps [sumc_one_lb_complexpow_zero];
   3.196 +
   3.197 +Goalw [complex_diff_def] "sumc m n f - sumc m n g = sumc m n (%n. f n - g n)";
   3.198 +by (simp_tac (simpset() addsimps [sumc_add RS sym,sumc_minus]) 1);
   3.199 +qed "sumc_diff";
   3.200 +
   3.201 +Goal "(ALL p. (m <= p & p < m + n --> (f p = g p))) --> sumc m n f = sumc m n g";
   3.202 +by (induct_tac "n" 1);
   3.203 +by (Auto_tac);
   3.204 +qed_spec_mp "sumc_subst";
   3.205 +
   3.206 +Goal "sumc 0 n (%m. sumc (m * k) (m*k + k) f) = sumc 0 (n * k) f";
   3.207 +by (subgoal_tac "k = 0 | 0 < k" 1);
   3.208 +by (Auto_tac);
   3.209 +by (induct_tac "n" 1);
   3.210 +by (auto_tac (claset(),simpset() addsimps [sumc_split_add,add_commute]));
   3.211 +qed "sumc_group";
   3.212 +Addsimps [sumc_group];
   3.213 +
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/src/HOL/Complex/CSeries.thy	Mon May 05 18:22:31 2003 +0200
     4.3 @@ -0,0 +1,30 @@
     4.4 +(*  Title       : CSeries.thy
     4.5 +    Author      : Jacques D. Fleuriot
     4.6 +    Copyright   : 2002  University of Edinburgh
     4.7 +    Description : Finite summation and infinite series for complex numbers
     4.8 +*)
     4.9 +
    4.10 +CSeries = CStar +
    4.11 +
    4.12 +consts sumc :: "[nat,nat,(nat=>complex)] => complex"
    4.13 +primrec
    4.14 +   sumc_0   "sumc m 0 f = 0"
    4.15 +   sumc_Suc "sumc m (Suc n) f = (if n < m then 0 else sumc m n f + f(n))"
    4.16 +
    4.17 +(*  
    4.18 +constdefs
    4.19 +
    4.20 +   needs convergence of complex sequences  
    4.21 +
    4.22 +  csums  :: [nat=>complex,complex] => bool     (infixr 80)
    4.23 +   "f sums s  == (%n. sumr 0 n f) ----C> s"
    4.24 +  
    4.25 +   csummable :: (nat=>complex) => bool
    4.26 +   "csummable f == (EX s. f csums s)"
    4.27 +
    4.28 +   csuminf   :: (nat=>complex) => complex
    4.29 +   "csuminf f == (@s. f csums s)"
    4.30 +*)
    4.31 +
    4.32 +end
    4.33 +
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/src/HOL/Complex/CStar.ML	Mon May 05 18:22:31 2003 +0200
     5.3 @@ -0,0 +1,630 @@
     5.4 +(*  Title       : CStar.ML
     5.5 +    Author      : Jacques D. Fleuriot
     5.6 +    Copyright   : 2001 University of Edinburgh
     5.7 +    Description : defining *-transforms in NSA which extends sets of complex numbers, 
     5.8 +                  and complex functions
     5.9 +*)
    5.10 +
    5.11 +
    5.12 +
    5.13 +(*-----------------------------------------------------------------------------------*)
    5.14 +(*    Properties of the *-transform applied to sets of reals                         *)
    5.15 +(* ----------------------------------------------------------------------------------*)
    5.16 +
    5.17 +Goalw [starsetC_def] "*sc*(UNIV::complex set) = (UNIV::hcomplex set)";
    5.18 +by (Auto_tac);
    5.19 +qed "STARC_complex_set";
    5.20 +Addsimps [STARC_complex_set];
    5.21 +
    5.22 +Goalw [starsetC_def] "*sc* {} = {}";
    5.23 +by (Auto_tac);
    5.24 +qed "STARC_empty_set";
    5.25 +Addsimps [STARC_empty_set];
    5.26 +
    5.27 +Goalw [starsetC_def] "*sc* (A Un B) = *sc* A Un *sc* B";
    5.28 +by (Auto_tac);
    5.29 +by (REPEAT(blast_tac (claset() addIs [FreeUltrafilterNat_subset]) 2));
    5.30 +by (dtac bspec 1 THEN assume_tac 1);
    5.31 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
    5.32 +by (Auto_tac);
    5.33 +by (Ultra_tac 1);
    5.34 +qed "STARC_Un";
    5.35 +
    5.36 +Goalw [starsetC_n_def] 
    5.37 +      "*scn* (%n. (A n) Un (B n)) = *scn* A Un *scn* B";
    5.38 +by Auto_tac;
    5.39 +by (dres_inst_tac [("x","Xa")] bspec 1);
    5.40 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 2);
    5.41 +by (auto_tac (claset() addSDs [bspec], simpset()));
    5.42 +by (TRYALL(Ultra_tac));
    5.43 +qed "starsetC_n_Un";
    5.44 +
    5.45 +Goalw [InternalCSets_def]
    5.46 +     "[| X : InternalCSets; Y : InternalCSets |] \
    5.47 +\     ==> (X Un Y) : InternalCSets";
    5.48 +by (auto_tac (claset(),
    5.49 +         simpset() addsimps [starsetC_n_Un RS sym]));
    5.50 +qed "InternalCSets_Un";
    5.51 +
    5.52 +Goalw [starsetC_def] "*sc* (A Int B) = *sc* A Int *sc* B";
    5.53 +by (Auto_tac);
    5.54 +by (blast_tac (claset() addIs [FreeUltrafilterNat_Int,
    5.55 +               FreeUltrafilterNat_subset]) 3);
    5.56 +by (REPEAT(blast_tac (claset() addIs [FreeUltrafilterNat_subset]) 1));
    5.57 +qed "STARC_Int";
    5.58 +
    5.59 +Goalw [starsetC_n_def] 
    5.60 +      "*scn* (%n. (A n) Int (B n)) = *scn* A Int *scn* B";
    5.61 +by (Auto_tac);
    5.62 +by (auto_tac (claset() addSDs [bspec],simpset()));
    5.63 +by (TRYALL(Ultra_tac));
    5.64 +qed "starsetC_n_Int";
    5.65 +
    5.66 +Goalw [InternalCSets_def]
    5.67 +     "[| X : InternalCSets; Y : InternalCSets |] \
    5.68 +\     ==> (X Int Y) : InternalCSets";
    5.69 +by (auto_tac (claset(),
    5.70 +         simpset() addsimps [starsetC_n_Int RS sym]));
    5.71 +qed "InternalCSets_Int";
    5.72 +
    5.73 +Goalw [starsetC_def] "*sc* -A = -( *sc* A)";
    5.74 +by (Auto_tac);
    5.75 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
    5.76 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 2);
    5.77 +by (REPEAT(Step_tac 1) THEN Auto_tac);
    5.78 +by (ALLGOALS(Ultra_tac));
    5.79 +qed "STARC_Compl";
    5.80 +
    5.81 +Goalw [starsetC_n_def] "*scn* ((%n. - A n)) = -( *scn* A)";
    5.82 +by (Auto_tac);
    5.83 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
    5.84 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 2);
    5.85 +by (REPEAT(Step_tac 1) THEN Auto_tac);
    5.86 +by (TRYALL(Ultra_tac));
    5.87 +qed "starsetC_n_Compl";
    5.88 +
    5.89 +Goalw [InternalCSets_def]
    5.90 +     "X :InternalCSets ==> -X : InternalCSets";
    5.91 +by (auto_tac (claset(),
    5.92 +         simpset() addsimps [starsetC_n_Compl RS sym]));
    5.93 +qed "InternalCSets_Compl";
    5.94 +
    5.95 +Goal "x ~: *sc* F ==> x : *sc* (- F)";
    5.96 +by (auto_tac (claset(),simpset() addsimps [STARC_Compl]));
    5.97 +qed "STARC_mem_Compl";
    5.98 +
    5.99 +Goal "*sc* (A - B) = *sc* A - *sc* B";
   5.100 +by (auto_tac (claset(),simpset() addsimps 
   5.101 +         [set_diff_iff2,STARC_Int,STARC_Compl]));
   5.102 +qed "STARC_diff";
   5.103 +
   5.104 +Goalw [starsetC_n_def] 
   5.105 +      "*scn* (%n. (A n) - (B n)) = *scn* A - *scn* B";
   5.106 +by (Auto_tac);
   5.107 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 2);
   5.108 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 3);
   5.109 +by (auto_tac (claset() addSDs [bspec], simpset()));
   5.110 +by (TRYALL(Ultra_tac));
   5.111 +qed "starsetC_n_diff";
   5.112 +
   5.113 +Goalw [InternalCSets_def]
   5.114 +     "[| X : InternalCSets; Y : InternalCSets |] \
   5.115 +\     ==> (X - Y) : InternalCSets";
   5.116 +by (auto_tac (claset(), simpset() addsimps [starsetC_n_diff RS sym]));
   5.117 +qed "InternalCSets_diff";
   5.118 +
   5.119 +Goalw [starsetC_def] "A <= B ==> *sc* A <= *sc* B";
   5.120 +by (REPEAT(blast_tac (claset() addIs [FreeUltrafilterNat_subset]) 1));
   5.121 +qed "STARC_subset";
   5.122 +
   5.123 +Goalw [starsetC_def,hcomplex_of_complex_def] 
   5.124 +          "a : A ==> hcomplex_of_complex a : *sc* A";
   5.125 +by (auto_tac (claset() addIs [FreeUltrafilterNat_subset],
   5.126 +         simpset()));
   5.127 +qed "STARC_mem";
   5.128 +
   5.129 +Goalw [starsetC_def] "hcomplex_of_complex ` A <= *sc* A";
   5.130 +by (auto_tac (claset(), simpset() addsimps [hcomplex_of_complex_def]));
   5.131 +by (blast_tac (claset() addIs [FreeUltrafilterNat_subset]) 1);
   5.132 +qed "STARC_hcomplex_of_complex_image_subset";
   5.133 +
   5.134 +Goal "SComplex <= *sc* (UNIV:: complex set)";
   5.135 +by Auto_tac;
   5.136 +qed "STARC_SComplex_subset";
   5.137 +
   5.138 +Goalw [starsetC_def] 
   5.139 +     "*sc* X Int SComplex = hcomplex_of_complex ` X";
   5.140 +by (auto_tac (claset(),
   5.141 +         simpset() addsimps 
   5.142 +           [hcomplex_of_complex_def,SComplex_def]));
   5.143 +by (fold_tac [hcomplex_of_complex_def]);
   5.144 +by (rtac imageI 1 THEN rtac ccontr 1);
   5.145 +by (dtac bspec 1);
   5.146 +by (rtac lemma_hcomplexrel_refl 1);
   5.147 +by (blast_tac (claset() addIs [FreeUltrafilterNat_subset]) 2);
   5.148 +by (Auto_tac);
   5.149 +qed "STARC_hcomplex_of_complex_Int";
   5.150 +
   5.151 +Goal "x ~: hcomplex_of_complex ` A ==> ALL y: A. x ~= hcomplex_of_complex y";
   5.152 +by (Auto_tac);
   5.153 +qed "lemma_not_hcomplexA";
   5.154 +
   5.155 +Goalw [starsetC_n_def,starsetC_def] "*sc* X = *scn* (%n. X)";
   5.156 +by Auto_tac;
   5.157 +qed "starsetC_starsetC_n_eq";
   5.158 +
   5.159 +Goalw [InternalCSets_def] "( *sc* X) : InternalCSets";
   5.160 +by (auto_tac (claset(),
   5.161 +         simpset() addsimps [starsetC_starsetC_n_eq]));
   5.162 +qed "InternalCSets_starsetC_n";
   5.163 +Addsimps [InternalCSets_starsetC_n];
   5.164 +
   5.165 +Goal "X : InternalCSets ==> UNIV - X : InternalCSets";
   5.166 +by (auto_tac (claset() addIs [InternalCSets_Compl], simpset()));
   5.167 +qed "InternalCSets_UNIV_diff";
   5.168 +
   5.169 +(*-----------------------------------------------------------------------------------*)
   5.170 +(* Nonstandard extension of a set (defined using a constant sequence) as a special   *)
   5.171 +(* case of an internal set                                                           *)
   5.172 +(*-----------------------------------------------------------------------------------*)
   5.173 +
   5.174 +Goalw [starsetC_n_def,starsetC_def] 
   5.175 +     "ALL n. (As n = A) ==> *scn* As = *sc* A";
   5.176 +by (Auto_tac);
   5.177 +qed "starsetC_n_starsetC";
   5.178 +
   5.179 +(*-----------------------------------------------------------------------------------*)
   5.180 +(* Theorems about nonstandard extensions of functions                                *)   
   5.181 +(*-----------------------------------------------------------------------------------*)
   5.182 +
   5.183 +Goalw [starfunC_n_def,starfunC_def] 
   5.184 +     "ALL n. (F n = f) ==> *fcn* F = *fc* f";
   5.185 +by (Auto_tac);
   5.186 +qed "starfunC_n_starfunC";
   5.187 +
   5.188 +Goalw [starfunRC_n_def,starfunRC_def] 
   5.189 +     "ALL n. (F n = f) ==> *fRcn* F = *fRc* f";
   5.190 +by (Auto_tac);
   5.191 +qed "starfunRC_n_starfunRC";
   5.192 +
   5.193 +Goalw [starfunCR_n_def,starfunCR_def] 
   5.194 +     "ALL n. (F n = f) ==> *fcRn* F = *fcR* f";
   5.195 +by (Auto_tac);
   5.196 +qed "starfunCR_n_starfunCR";
   5.197 +
   5.198 +Goalw [congruent_def] 
   5.199 +      "congruent hcomplexrel (%X. hcomplexrel``{%n. f (X n)})";
   5.200 +by (safe_tac (claset()));
   5.201 +by (ALLGOALS(Ultra_tac));
   5.202 +qed "starfunC_congruent";
   5.203 +
   5.204 +(* f::complex => complex *)
   5.205 +Goalw [starfunC_def]
   5.206 +      "( *fc* f) (Abs_hcomplex(hcomplexrel``{%n. X n})) = \
   5.207 +\      Abs_hcomplex(hcomplexrel `` {%n. f (X n)})";
   5.208 +by (res_inst_tac [("f","Abs_hcomplex")] arg_cong 1);
   5.209 +by Auto_tac;
   5.210 +by (Ultra_tac 1);
   5.211 +qed "starfunC";
   5.212 +
   5.213 +Goalw [starfunRC_def]
   5.214 +      "( *fRc* f) (Abs_hypreal(hyprel``{%n. X n})) = \
   5.215 +\      Abs_hcomplex(hcomplexrel `` {%n. f (X n)})";
   5.216 +by (res_inst_tac [("f","Abs_hcomplex")] arg_cong 1);
   5.217 +by Auto_tac;
   5.218 +by (Ultra_tac 1);
   5.219 +qed "starfunRC";
   5.220 +
   5.221 +Goalw [starfunCR_def]
   5.222 +      "( *fcR* f) (Abs_hcomplex(hcomplexrel``{%n. X n})) = \
   5.223 +\      Abs_hypreal(hyprel `` {%n. f (X n)})";
   5.224 +by (res_inst_tac [("f","Abs_hypreal")] arg_cong 1);
   5.225 +by Auto_tac;
   5.226 +by (Ultra_tac 1);
   5.227 +qed "starfunCR";
   5.228 +
   5.229 +(**  multiplication: ( *f ) x ( *g ) = *(f x g) **)
   5.230 +
   5.231 +Goal "( *fc* f) z * ( *fc* g) z = ( *fc* (%x. f x * g x)) z";
   5.232 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
   5.233 +by (auto_tac (claset(), simpset() addsimps [starfunC,hcomplex_mult]));
   5.234 +qed "starfunC_mult";
   5.235 +Addsimps [starfunC_mult RS sym];
   5.236 +
   5.237 +Goal "( *fRc* f) z * ( *fRc* g) z = ( *fRc* (%x. f x * g x)) z";
   5.238 +by (res_inst_tac [("z","z")] eq_Abs_hypreal 1);
   5.239 +by (auto_tac (claset(), simpset() addsimps [starfunRC,hcomplex_mult]));
   5.240 +qed "starfunRC_mult";
   5.241 +Addsimps [starfunRC_mult RS sym];
   5.242 +
   5.243 +Goal "( *fcR* f) z * ( *fcR* g) z = ( *fcR* (%x. f x * g x)) z";
   5.244 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
   5.245 +by (auto_tac (claset(), simpset() addsimps [starfunCR,hypreal_mult]));
   5.246 +qed "starfunCR_mult";
   5.247 +Addsimps [starfunCR_mult RS sym];
   5.248 +
   5.249 +(**  addition: ( *f ) + ( *g ) = *(f + g)  **)
   5.250 +
   5.251 +Goal "( *fc* f) z + ( *fc* g) z = ( *fc* (%x. f x + g x)) z";
   5.252 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
   5.253 +by (auto_tac (claset(), simpset() addsimps [starfunC,hcomplex_add]));
   5.254 +qed "starfunC_add";
   5.255 +Addsimps [starfunC_add RS sym];
   5.256 +
   5.257 +Goal "( *fRc* f) z + ( *fRc* g) z = ( *fRc* (%x. f x + g x)) z";
   5.258 +by (res_inst_tac [("z","z")] eq_Abs_hypreal 1);
   5.259 +by (auto_tac (claset(), simpset() addsimps [starfunRC,hcomplex_add]));
   5.260 +qed "starfunRC_add";
   5.261 +Addsimps [starfunRC_add RS sym];
   5.262 +
   5.263 +Goal "( *fcR* f) z + ( *fcR* g) z = ( *fcR* (%x. f x + g x)) z";
   5.264 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
   5.265 +by (auto_tac (claset(), simpset() addsimps [starfunCR,hypreal_add]));
   5.266 +qed "starfunCR_add";
   5.267 +Addsimps [starfunCR_add RS sym];
   5.268 +
   5.269 +(**  uminus **)
   5.270 +Goal "( *fc* (%x. - f x)) x = - ( *fc* f) x";
   5.271 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
   5.272 +by (auto_tac (claset(),simpset() addsimps [starfunC, hcomplex_minus]));
   5.273 +qed "starfunC_minus";
   5.274 +Addsimps [starfunC_minus];
   5.275 +
   5.276 +Goal "( *fRc* (%x. - f x)) x = - ( *fRc* f) x";
   5.277 +by (res_inst_tac [("z","x")] eq_Abs_hypreal 1);
   5.278 +by (auto_tac (claset(),simpset() addsimps [starfunRC, hcomplex_minus]));
   5.279 +qed "starfunRC_minus";
   5.280 +Addsimps [starfunRC_minus];
   5.281 +
   5.282 +Goal "( *fcR* (%x. - f x)) x = - ( *fcR* f) x";
   5.283 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
   5.284 +by (auto_tac (claset(),simpset() addsimps [starfunCR, hypreal_minus]));
   5.285 +qed "starfunCR_minus";
   5.286 +Addsimps [starfunCR_minus];
   5.287 +
   5.288 +(**  addition: ( *f ) - ( *g ) = *(f - g)  **)
   5.289 +
   5.290 +Goalw [hcomplex_diff_def,complex_diff_def]
   5.291 +  "( *fc* f) xa  - ( *fc* g) xa = ( *fc* (%x. f x - g x)) xa";
   5.292 +by (auto_tac (claset(),simpset() addsimps [starfunC_minus,starfunC_add RS sym]));
   5.293 +qed "starfunC_diff";
   5.294 +Addsimps [starfunC_diff RS sym];
   5.295 +
   5.296 +Goalw [hcomplex_diff_def,complex_diff_def]
   5.297 +  "( *fRc* f) xa  - ( *fRc* g) xa = ( *fRc* (%x. f x - g x)) xa";
   5.298 +by (auto_tac (claset(),simpset() addsimps [starfunRC_minus,starfunRC_add RS sym]));
   5.299 +qed "starfunRC_diff";
   5.300 +Addsimps [starfunRC_diff RS sym];
   5.301 +
   5.302 +Goalw [hypreal_diff_def,real_diff_def]
   5.303 +  "( *fcR* f) xa  - ( *fcR* g) xa = ( *fcR* (%x. f x - g x)) xa";
   5.304 +by (auto_tac (claset(),simpset() addsimps [starfunCR_minus,starfunCR_add RS sym]));
   5.305 +qed "starfunCR_diff";
   5.306 +Addsimps [starfunCR_diff RS sym];
   5.307 +
   5.308 +(**  composition: ( *f ) o ( *g ) = *(f o g) **)
   5.309 +
   5.310 +Goal "(%x. ( *fc* f) (( *fc* g) x)) = *fc* (%x. f (g x))"; 
   5.311 +by (rtac ext 1);
   5.312 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
   5.313 +by (auto_tac (claset(),simpset() addsimps [starfunC]));
   5.314 +qed "starfunC_o2";
   5.315 +
   5.316 +Goalw [o_def] "( *fc* f) o ( *fc* g) = ( *fc* (f o g))";
   5.317 +by (simp_tac (simpset() addsimps [starfunC_o2]) 1);
   5.318 +qed "starfunC_o";
   5.319 +
   5.320 +Goal "(%x. ( *fc* f) (( *fRc* g) x)) = *fRc* (%x. f (g x))"; 
   5.321 +by (rtac ext 1);
   5.322 +by (res_inst_tac [("z","x")] eq_Abs_hypreal 1);
   5.323 +by (auto_tac (claset(),simpset() addsimps [starfunRC,starfunC]));
   5.324 +qed "starfunC_starfunRC_o2";
   5.325 +
   5.326 +Goal "(%x. ( *f* f) (( *fcR* g) x)) = *fcR* (%x. f (g x))"; 
   5.327 +by (rtac ext 1);
   5.328 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
   5.329 +by (auto_tac (claset(),simpset() addsimps [starfunCR,starfun]));
   5.330 +qed "starfun_starfunCR_o2";
   5.331 +
   5.332 +Goalw [o_def] "( *fc* f) o ( *fRc* g) = ( *fRc* (f o g))";
   5.333 +by (simp_tac (simpset() addsimps [starfunC_starfunRC_o2]) 1);
   5.334 +qed "starfunC_starfunRC_o";
   5.335 +
   5.336 +Goalw [o_def] "( *f* f) o ( *fcR* g) = ( *fcR* (f o g))";
   5.337 +by (simp_tac (simpset() addsimps [starfun_starfunCR_o2]) 1);
   5.338 +qed "starfun_starfunCR_o";
   5.339 +
   5.340 +Goal "( *fc* (%x. k)) z = hcomplex_of_complex k";
   5.341 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
   5.342 +by (auto_tac (claset(), simpset() addsimps [starfunC, hcomplex_of_complex_def]));
   5.343 +qed "starfunC_const_fun";
   5.344 +Addsimps [starfunC_const_fun];
   5.345 +
   5.346 +Goal "( *fRc* (%x. k)) z = hcomplex_of_complex k";
   5.347 +by (res_inst_tac [("z","z")] eq_Abs_hypreal 1);
   5.348 +by (auto_tac (claset(), simpset() addsimps [starfunRC, hcomplex_of_complex_def]));
   5.349 +qed "starfunRC_const_fun";
   5.350 +Addsimps [starfunRC_const_fun];
   5.351 +
   5.352 +Goal "( *fcR* (%x. k)) z = hypreal_of_real k";
   5.353 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
   5.354 +by (auto_tac (claset(), simpset() addsimps [starfunCR, hypreal_of_real_def]));
   5.355 +qed "starfunCR_const_fun";
   5.356 +Addsimps [starfunCR_const_fun];
   5.357 +
   5.358 +Goal "inverse (( *fc* f) x) = ( *fc* (%x. inverse (f x))) x";
   5.359 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
   5.360 +by (auto_tac (claset(), simpset() addsimps [starfunC, hcomplex_inverse]));
   5.361 +qed "starfunC_inverse";
   5.362 +Addsimps [starfunC_inverse RS sym];
   5.363 +
   5.364 +Goal "inverse (( *fRc* f) x) = ( *fRc* (%x. inverse (f x))) x";
   5.365 +by (res_inst_tac [("z","x")] eq_Abs_hypreal 1);
   5.366 +by (auto_tac (claset(), simpset() addsimps [starfunRC, hcomplex_inverse]));
   5.367 +qed "starfunRC_inverse";
   5.368 +Addsimps [starfunRC_inverse RS sym];
   5.369 +
   5.370 +Goal "inverse (( *fcR* f) x) = ( *fcR* (%x. inverse (f x))) x";
   5.371 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
   5.372 +by (auto_tac (claset(), simpset() addsimps [starfunCR, hypreal_inverse]));
   5.373 +qed "starfunCR_inverse";
   5.374 +Addsimps [starfunCR_inverse RS sym];
   5.375 +
   5.376 +Goal "( *fc* f) (hcomplex_of_complex a) = hcomplex_of_complex (f a)";
   5.377 +by (auto_tac (claset(),
   5.378 +      simpset() addsimps [starfunC,hcomplex_of_complex_def]));
   5.379 +qed "starfunC_eq";
   5.380 +Addsimps [starfunC_eq];
   5.381 +
   5.382 +Goal "( *fRc* f) (hypreal_of_real a) = hcomplex_of_complex (f a)";
   5.383 +by (auto_tac (claset(),
   5.384 +      simpset() addsimps [starfunRC,hcomplex_of_complex_def,hypreal_of_real_def]));
   5.385 +qed "starfunRC_eq";
   5.386 +Addsimps [starfunRC_eq];
   5.387 +
   5.388 +Goal "( *fcR* f) (hcomplex_of_complex a) = hypreal_of_real (f a)";
   5.389 +by (auto_tac (claset(),
   5.390 +      simpset() addsimps [starfunCR,hcomplex_of_complex_def,hypreal_of_real_def]));
   5.391 +qed "starfunCR_eq";
   5.392 +Addsimps [starfunCR_eq];
   5.393 +
   5.394 +Goal "( *fc* f) (hcomplex_of_complex a) @c= hcomplex_of_complex (f a)";
   5.395 +by (Auto_tac);
   5.396 +qed "starfunC_capprox";
   5.397 +
   5.398 +Goal "( *fRc* f) (hypreal_of_real a) @c= hcomplex_of_complex (f a)";
   5.399 +by (Auto_tac);
   5.400 +qed "starfunRC_capprox";
   5.401 +
   5.402 +Goal "( *fcR* f) (hcomplex_of_complex a) @= hypreal_of_real (f a)";
   5.403 +by (Auto_tac);
   5.404 +qed "starfunCR_approx";
   5.405 +
   5.406 +(*
   5.407 +Goal "( *fcNat* (%n. z ^ n)) N = (hcomplex_of_complex z) hcpow N";
   5.408 +*)
   5.409 +
   5.410 +Goalw [hypnat_of_nat_def] 
   5.411 +   "( *fc* (%z. z ^ n)) Z = Z hcpow hypnat_of_nat n";
   5.412 +by (res_inst_tac [("z","Z")] eq_Abs_hcomplex 1);
   5.413 +by (auto_tac (claset(), simpset() addsimps [hcpow,starfunC]));
   5.414 +qed "starfunC_hcpow";
   5.415 +
   5.416 +Goal "( *fc* (%h. f (x + h))) xa  = ( *fc* f) (hcomplex_of_complex  x + xa)";
   5.417 +by (res_inst_tac [("z","xa")] eq_Abs_hcomplex 1);
   5.418 +by (auto_tac (claset(),simpset() addsimps [starfunC,
   5.419 +    hcomplex_of_complex_def,hcomplex_add]));
   5.420 +qed "starfunC_lambda_cancel";
   5.421 +
   5.422 +Goal "( *fcR* (%h. f (x + h))) xa  = ( *fcR* f) (hcomplex_of_complex  x + xa)";
   5.423 +by (res_inst_tac [("z","xa")] eq_Abs_hcomplex 1);
   5.424 +by (auto_tac (claset(),simpset() addsimps [starfunCR,
   5.425 +    hcomplex_of_complex_def,hcomplex_add]));
   5.426 +qed "starfunCR_lambda_cancel";
   5.427 +
   5.428 +Goal "( *fRc* (%h. f (x + h))) xa  = ( *fRc* f) (hypreal_of_real x + xa)";
   5.429 +by (res_inst_tac [("z","xa")] eq_Abs_hypreal 1);
   5.430 +by (auto_tac (claset(),simpset() addsimps [starfunRC,
   5.431 +    hypreal_of_real_def,hypreal_add]));
   5.432 +qed "starfunRC_lambda_cancel";
   5.433 +
   5.434 +Goal "( *fc* (%h. f(g(x + h)))) xa = ( *fc* (f o g)) (hcomplex_of_complex x + xa)";
   5.435 +by (res_inst_tac [("z","xa")] eq_Abs_hcomplex 1);
   5.436 +by (auto_tac (claset(),simpset() addsimps [starfunC,
   5.437 +    hcomplex_of_complex_def,hcomplex_add]));
   5.438 +qed "starfunC_lambda_cancel2";
   5.439 +
   5.440 +Goal "( *fcR* (%h. f(g(x + h)))) xa = ( *fcR* (f o g)) (hcomplex_of_complex x + xa)";
   5.441 +by (res_inst_tac [("z","xa")] eq_Abs_hcomplex 1);
   5.442 +by (auto_tac (claset(),simpset() addsimps [starfunCR,
   5.443 +    hcomplex_of_complex_def,hcomplex_add]));
   5.444 +qed "starfunCR_lambda_cancel2";
   5.445 +
   5.446 +Goal "( *fRc* (%h. f(g(x + h)))) xa = ( *fRc* (f o g)) (hypreal_of_real x + xa)";
   5.447 +by (res_inst_tac [("z","xa")] eq_Abs_hypreal 1);
   5.448 +by (auto_tac (claset(),simpset() addsimps [starfunRC,
   5.449 +    hypreal_of_real_def,hypreal_add]));
   5.450 +qed "starfunRC_lambda_cancel2";
   5.451 +
   5.452 +Goal "[| ( *fc* f) xa @c= l; ( *fc* g) xa @c= m; \
   5.453 +\                 l: CFinite; m: CFinite  \
   5.454 +\              |] ==>  ( *fc* (%x. f x * g x)) xa @c= l * m";
   5.455 +by (dtac capprox_mult_CFinite 1);
   5.456 +by (REPEAT(assume_tac 1));
   5.457 +by (auto_tac (claset() addIs [capprox_sym RSN (2,capprox_CFinite)],
   5.458 +              simpset()));
   5.459 +qed "starfunC_mult_CFinite_capprox";
   5.460 +
   5.461 +Goal "[| ( *fcR* f) xa @= l; ( *fcR* g) xa @= m; \
   5.462 +\                 l: HFinite; m: HFinite  \
   5.463 +\              |] ==>  ( *fcR* (%x. f x * g x)) xa @= l * m";
   5.464 +by (dtac approx_mult_HFinite 1);
   5.465 +by (REPEAT(assume_tac 1));
   5.466 +by (auto_tac (claset() addIs [approx_sym RSN (2,approx_HFinite)],
   5.467 +              simpset()));
   5.468 +qed "starfunCR_mult_HFinite_capprox";
   5.469 +
   5.470 +Goal "[| ( *fRc* f) xa @c= l; ( *fRc* g) xa @c= m; \
   5.471 +\                 l: CFinite; m: CFinite  \
   5.472 +\              |] ==>  ( *fRc* (%x. f x * g x)) xa @c= l * m";
   5.473 +by (dtac capprox_mult_CFinite 1);
   5.474 +by (REPEAT(assume_tac 1));
   5.475 +by (auto_tac (claset() addIs [capprox_sym RSN (2,capprox_CFinite)],
   5.476 +              simpset()));
   5.477 +qed "starfunRC_mult_CFinite_capprox";
   5.478 +
   5.479 +Goal "[| ( *fc* f) xa @c= l; ( *fc* g) xa @c= m \
   5.480 +\              |] ==>  ( *fc* (%x. f x + g x)) xa @c= l + m";
   5.481 +by (auto_tac (claset() addIs [capprox_add], simpset()));
   5.482 +qed "starfunC_add_capprox";
   5.483 +
   5.484 +Goal "[| ( *fRc* f) xa @c= l; ( *fRc* g) xa @c= m \
   5.485 +\              |] ==>  ( *fRc* (%x. f x + g x)) xa @c= l + m";
   5.486 +by (auto_tac (claset() addIs [capprox_add], simpset()));
   5.487 +qed "starfunRC_add_capprox";
   5.488 +
   5.489 +Goal "[| ( *fcR* f) xa @= l; ( *fcR* g) xa @= m \
   5.490 +\              |] ==>  ( *fcR* (%x. f x + g x)) xa @= l + m";
   5.491 +by (auto_tac (claset() addIs [approx_add], simpset()));
   5.492 +qed "starfunCR_add_approx";
   5.493 +
   5.494 +Goal "*fcR* cmod = hcmod";
   5.495 +by (rtac ext 1);
   5.496 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
   5.497 +by (auto_tac (claset(),simpset() addsimps [starfunCR,hcmod]));
   5.498 +qed "starfunCR_cmod";
   5.499 +
   5.500 +Goal "( *fc* inverse) x = inverse(x)";
   5.501 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
   5.502 +by (auto_tac (claset(),simpset() addsimps [starfunC,hcomplex_inverse]));
   5.503 +qed "starfunC_inverse_inverse";
   5.504 +
   5.505 +Goalw [hcomplex_divide_def,complex_divide_def]
   5.506 +  "( *fc* f) xa  / ( *fc* g) xa = ( *fc* (%x. f x / g x)) xa";
   5.507 +by Auto_tac;
   5.508 +qed "starfunC_divide";
   5.509 +Addsimps [starfunC_divide RS sym];
   5.510 +
   5.511 +Goalw [hypreal_divide_def,real_divide_def]
   5.512 +  "( *fcR* f) xa  / ( *fcR* g) xa = ( *fcR* (%x. f x / g x)) xa";
   5.513 +by Auto_tac;
   5.514 +qed "starfunCR_divide";
   5.515 +Addsimps [starfunCR_divide RS sym];
   5.516 +
   5.517 +Goalw [hcomplex_divide_def,complex_divide_def]
   5.518 +  "( *fRc* f) xa  / ( *fRc* g) xa = ( *fRc* (%x. f x / g x)) xa";
   5.519 +by Auto_tac;
   5.520 +qed "starfunRC_divide";
   5.521 +Addsimps [starfunRC_divide RS sym];
   5.522 +
   5.523 +(*-----------------------------------------------------------------------------------*)
   5.524 +(* Internal functions - some redundancy with *fc* now                                *)
   5.525 +(*-----------------------------------------------------------------------------------*)
   5.526 +
   5.527 +Goalw [congruent_def] 
   5.528 +      "congruent hcomplexrel (%X. hcomplexrel``{%n. f n (X n)})";
   5.529 +by (safe_tac (claset()));
   5.530 +by (ALLGOALS(Fuf_tac));
   5.531 +qed "starfunC_n_congruent";
   5.532 +
   5.533 +Goalw [starfunC_n_def]
   5.534 +     "( *fcn* f) (Abs_hcomplex(hcomplexrel``{%n. X n})) = \
   5.535 +\     Abs_hcomplex(hcomplexrel `` {%n. f n (X n)})";
   5.536 +by (res_inst_tac [("f","Abs_hcomplex")] arg_cong 1);
   5.537 +by Auto_tac;
   5.538 +by (Ultra_tac 1);
   5.539 +qed "starfunC_n";
   5.540 +
   5.541 +(**  multiplication: ( *fn ) x ( *gn ) = *(fn x gn) **)
   5.542 +
   5.543 +Goal "( *fcn* f) z * ( *fcn* g) z = ( *fcn* (% i x. f i x * g i x)) z";
   5.544 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
   5.545 +by (auto_tac (claset(), simpset() addsimps [starfunC_n,hcomplex_mult]));
   5.546 +qed "starfunC_n_mult";
   5.547 +
   5.548 +(**  addition: ( *fn ) + ( *gn ) = *(fn + gn) **)
   5.549 +
   5.550 +Goal "( *fcn* f) z + ( *fcn* g) z = ( *fcn* (%i x. f i x + g i x)) z";
   5.551 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
   5.552 +by (auto_tac (claset(), simpset() addsimps [starfunC_n,hcomplex_add]));
   5.553 +qed "starfunC_n_add";
   5.554 +
   5.555 +(** uminus **)
   5.556 +
   5.557 +Goal "- ( *fcn* g) z = ( *fcn* (%i x. - g i x)) z";
   5.558 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
   5.559 +by (auto_tac (claset(), simpset() addsimps [starfunC_n,hcomplex_minus]));
   5.560 +qed "starfunC_n_minus";
   5.561 +
   5.562 +(** subtraction: ( *fn ) - ( *gn ) = *(fn - gn) **)
   5.563 +
   5.564 +Goalw [hcomplex_diff_def,complex_diff_def] 
   5.565 +   "( *fcn* f) z - ( *fcn* g) z = ( *fcn* (%i x. f i x - g i x)) z";
   5.566 +by (auto_tac (claset(), 
   5.567 +          simpset() addsimps [starfunC_n_add,starfunC_n_minus]));
   5.568 +qed "starfunNat_n_diff";
   5.569 +
   5.570 +(** composition: ( *fn ) o ( *gn ) = *(fn o gn) **)
   5.571 + 
   5.572 +Goal "( *fcn* (%i x. k)) z = hcomplex_of_complex  k";
   5.573 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
   5.574 +by (auto_tac (claset(), 
   5.575 +       simpset() addsimps [starfunC_n, hcomplex_of_complex_def]));
   5.576 +qed "starfunC_n_const_fun";
   5.577 +Addsimps [starfunC_n_const_fun];
   5.578 +
   5.579 +Goal "( *fcn* f) (hcomplex_of_complex n) = Abs_hcomplex(hcomplexrel `` {%i. f i n})";
   5.580 +by (auto_tac (claset(), simpset() addsimps [starfunC_n,hcomplex_of_complex_def]));
   5.581 +qed "starfunC_n_eq";
   5.582 +Addsimps [starfunC_n_eq];
   5.583 +
   5.584 +Goal "(( *fc* f) = ( *fc* g)) = (f = g)";
   5.585 +by Auto_tac;
   5.586 +by (rtac ext 1 THEN rtac ccontr 1);
   5.587 +by (dres_inst_tac [("x","hcomplex_of_complex(x)")] fun_cong 1);
   5.588 +by (auto_tac (claset(), simpset() addsimps [starfunC,hcomplex_of_complex_def]));
   5.589 +qed "starfunC_eq_iff";
   5.590 +
   5.591 +Goal "(( *fRc* f) = ( *fRc* g)) = (f = g)";
   5.592 +by Auto_tac;
   5.593 +by (rtac ext 1 THEN rtac ccontr 1);
   5.594 +by (dres_inst_tac [("x","hypreal_of_real(x)")] fun_cong 1);
   5.595 +by Auto_tac;
   5.596 +qed "starfunRC_eq_iff";
   5.597 +
   5.598 +Goal "(( *fcR* f) = ( *fcR* g)) = (f = g)";
   5.599 +by Auto_tac;
   5.600 +by (rtac ext 1 THEN rtac ccontr 1);
   5.601 +by (dres_inst_tac [("x","hcomplex_of_complex(x)")] fun_cong 1);
   5.602 +by Auto_tac;
   5.603 +qed "starfunCR_eq_iff";
   5.604 +
   5.605 +(*** more theorems ***)
   5.606 +
   5.607 +Goal "(( *fc* f) x = z) = ((( *fcR* (%x. Re(f x))) x = hRe (z)) & \
   5.608 +\                         (( *fcR* (%x. Im(f x))) x = hIm (z)))";
   5.609 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
   5.610 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
   5.611 +by (auto_tac (claset(),simpset() addsimps [starfunCR,starfunC,
   5.612 +    hIm,hRe,complex_Re_Im_cancel_iff]));
   5.613 +by (ALLGOALS(Ultra_tac));
   5.614 +qed "starfunC_eq_Re_Im_iff";
   5.615 +
   5.616 +Goal "(( *fc* f) x @c= z) = ((( *fcR* (%x. Re(f x))) x @= hRe (z)) & \
   5.617 +\                           (( *fcR* (%x. Im(f x))) x @= hIm (z)))";
   5.618 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
   5.619 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
   5.620 +by (auto_tac (claset(),simpset() addsimps [starfunCR,starfunC,
   5.621 +    hIm,hRe,capprox_approx_iff]));
   5.622 +qed "starfunC_approx_Re_Im_iff";
   5.623 +
   5.624 +Goal "x @c= hcomplex_of_complex a ==> ( *fc* (%x. x)) x @c= hcomplex_of_complex  a";
   5.625 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
   5.626 +by (auto_tac (claset(),simpset() addsimps [starfunC]));
   5.627 +qed "starfunC_Idfun_capprox";
   5.628 +
   5.629 +Goal "( *fc* (%x. x)) x = x";
   5.630 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
   5.631 +by (auto_tac (claset(),simpset() addsimps [starfunC]));
   5.632 +qed "starfunC_Id";
   5.633 +Addsimps [starfunC_Id];  
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/src/HOL/Complex/CStar.thy	Mon May 05 18:22:31 2003 +0200
     6.3 @@ -0,0 +1,57 @@
     6.4 +(*  Title       : CStar.thy
     6.5 +    Author      : Jacques D. Fleuriot
     6.6 +    Copyright   : 2001 University of Edinburgh
     6.7 +    Description : defining *-transforms in NSA which extends sets of complex numbers, 
     6.8 +                  and complex functions
     6.9 +*)
    6.10 +
    6.11 +CStar = NSCA + 
    6.12 +
    6.13 +constdefs
    6.14 +
    6.15 +    (* nonstandard extension of sets *)
    6.16 +    starsetC :: complex set => hcomplex set          ("*sc* _" [80] 80)
    6.17 +    "*sc* A  == {x. ALL X: Rep_hcomplex(x). {n::nat. X n : A}: FreeUltrafilterNat}"
    6.18 +
    6.19 +    (* internal sets *)
    6.20 +    starsetC_n :: (nat => complex set) => hcomplex set        ("*scn* _" [80] 80)
    6.21 +    "*scn* As  == {x. ALL X: Rep_hcomplex(x). {n::nat. X n : (As n)}: FreeUltrafilterNat}"   
    6.22 +    
    6.23 +    InternalCSets :: "hcomplex set set"
    6.24 +    "InternalCSets == {X. EX As. X = *scn* As}"
    6.25 +
    6.26 +    (* star transform of functions f: Complex --> Complex *)
    6.27 +
    6.28 +    starfunC :: (complex => complex) => hcomplex => hcomplex        ("*fc* _" [80] 80)
    6.29 +    "*fc* f  == (%x. Abs_hcomplex(UN X: Rep_hcomplex(x). hcomplexrel``{%n. f (X n)}))" 
    6.30 +
    6.31 +    starfunC_n :: (nat => (complex => complex)) => hcomplex => hcomplex  ("*fcn* _" [80] 80)
    6.32 +    "*fcn* F  == (%x. Abs_hcomplex(UN X: Rep_hcomplex(x). hcomplexrel``{%n. (F n)(X n)}))" 
    6.33 +
    6.34 +    InternalCFuns :: (hcomplex => hcomplex) set
    6.35 +    "InternalCFuns == {X. EX F. X = *fcn* F}"
    6.36 +
    6.37 +
    6.38 +    (* star transform of functions f: Real --> Complex *)
    6.39 +
    6.40 +    starfunRC :: (real => complex) => hypreal => hcomplex        ("*fRc* _" [80] 80)
    6.41 +    "*fRc* f  == (%x. Abs_hcomplex(UN X: Rep_hypreal(x). hcomplexrel``{%n. f (X n)}))" 
    6.42 +
    6.43 +    starfunRC_n :: (nat => (real => complex)) => hypreal => hcomplex  ("*fRcn* _" [80] 80)
    6.44 +    "*fRcn* F  == (%x. Abs_hcomplex(UN X: Rep_hypreal(x). hcomplexrel``{%n. (F n)(X n)}))" 
    6.45 +
    6.46 +    InternalRCFuns :: (hypreal => hcomplex) set
    6.47 +    "InternalRCFuns == {X. EX F. X = *fRcn* F}"
    6.48 +
    6.49 +    (* star transform of functions f: Complex --> Real; needed for Re and Im parts *)
    6.50 +
    6.51 +    starfunCR :: (complex => real) => hcomplex => hypreal        ("*fcR* _" [80] 80)
    6.52 +    "*fcR* f  == (%x. Abs_hypreal(UN X: Rep_hcomplex(x). hyprel``{%n. f (X n)}))" 
    6.53 +
    6.54 +    starfunCR_n :: (nat => (complex => real)) => hcomplex => hypreal  ("*fcRn* _" [80] 80)
    6.55 +    "*fcRn* F  == (%x. Abs_hypreal(UN X: Rep_hcomplex(x). hyprel``{%n. (F n)(X n)}))" 
    6.56 +
    6.57 +    InternalCRFuns :: (hcomplex => hypreal) set
    6.58 +    "InternalCRFuns == {X. EX F. X = *fcRn* F}"
    6.59 +
    6.60 +end
    6.61 \ No newline at end of file
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/src/HOL/Complex/Complex.ML	Mon May 05 18:22:31 2003 +0200
     7.3 @@ -0,0 +1,1588 @@
     7.4 +(*  Title:       Complex.ML
     7.5 +    Author:      Jacques D. Fleuriot
     7.6 +    Copyright:   2001  University of Edinburgh
     7.7 +    Description: Complex numbers
     7.8 +*)
     7.9 +
    7.10 +Goal "inj Rep_complex";
    7.11 +by (rtac inj_inverseI 1);
    7.12 +by (rtac Rep_complex_inverse 1);
    7.13 +qed "inj_Rep_complex";
    7.14 +
    7.15 +Goal "inj Abs_complex";
    7.16 +by (rtac inj_inverseI 1);
    7.17 +by (rtac Abs_complex_inverse 1);
    7.18 +by (simp_tac (simpset() addsimps [complex_def]) 1);
    7.19 +qed "inj_Abs_complex";
    7.20 +Addsimps [inj_Abs_complex RS injD];
    7.21 +
    7.22 +Goal "(Abs_complex x = Abs_complex y) = (x = y)";
    7.23 +by (auto_tac (claset() addDs [inj_Abs_complex RS injD],simpset()));
    7.24 +qed "Abs_complex_cancel_iff";
    7.25 +Addsimps [Abs_complex_cancel_iff]; 
    7.26 +
    7.27 +Goalw [complex_def] "(x,y) : complex";
    7.28 +by (Auto_tac);
    7.29 +qed "pair_mem_complex";
    7.30 +Addsimps [pair_mem_complex];
    7.31 +
    7.32 +Goal "Rep_complex (Abs_complex (x,y)) = (x,y)";
    7.33 +by (simp_tac (simpset() addsimps [Abs_complex_inverse]) 1);
    7.34 +qed "Abs_complex_inverse2";
    7.35 +Addsimps [Abs_complex_inverse2];
    7.36 +
    7.37 +val [prem] = goal Complex.thy
    7.38 +    "(!!x y. z = Abs_complex(x,y) ==> P) ==> P";
    7.39 +by (res_inst_tac [("p","Rep_complex z")] PairE 1);
    7.40 +by (dres_inst_tac [("f","Abs_complex")] arg_cong 1);
    7.41 +by (res_inst_tac [("x","x"),("y","y")] prem 1);
    7.42 +by (asm_full_simp_tac (simpset() addsimps [Rep_complex_inverse]) 1);
    7.43 +qed "eq_Abs_complex";
    7.44 +
    7.45 +Goalw [Re_def] "Re(Abs_complex(x,y)) = x";
    7.46 +by (Simp_tac 1);
    7.47 +qed "Re";
    7.48 +Addsimps [Re];
    7.49 +
    7.50 +Goalw [Im_def] "Im(Abs_complex(x,y)) = y";
    7.51 +by (Simp_tac 1);
    7.52 +qed "Im";
    7.53 +Addsimps [Im];
    7.54 +
    7.55 +Goal "Abs_complex(Re(z),Im(z)) = z";
    7.56 +by (res_inst_tac [("z","z")] eq_Abs_complex 1);
    7.57 +by (Asm_simp_tac 1);
    7.58 +qed "Abs_complex_cancel";
    7.59 +Addsimps [Abs_complex_cancel];
    7.60 +
    7.61 +Goal "(w=z) = (Re(w) = Re(z) & Im(w) = Im(z))";
    7.62 +by (res_inst_tac [("z","w")] eq_Abs_complex 1);
    7.63 +by (res_inst_tac [("z","z")] eq_Abs_complex 1);
    7.64 +by (auto_tac (claset() addDs [inj_Abs_complex RS injD],simpset()));
    7.65 +qed "complex_Re_Im_cancel_iff";
    7.66 +
    7.67 +Goalw [complex_zero_def] "Re 0 = 0";
    7.68 +by (Simp_tac 1);
    7.69 +qed "complex_Re_zero";
    7.70 +
    7.71 +Goalw [complex_zero_def] "Im 0 = 0";
    7.72 +by (Simp_tac 1);
    7.73 +qed "complex_Im_zero";
    7.74 +Addsimps [complex_Re_zero,complex_Im_zero];
    7.75 +
    7.76 +Goalw [complex_one_def] "Re 1 = 1";
    7.77 +by (Simp_tac 1);
    7.78 +qed "complex_Re_one";
    7.79 +Addsimps [complex_Re_one];
    7.80 +
    7.81 +Goalw [complex_one_def] "Im 1 = 0";
    7.82 +by (Simp_tac 1);
    7.83 +qed "complex_Im_one";
    7.84 +Addsimps [complex_Im_one];
    7.85 +
    7.86 +Goalw [i_def] "Re(ii) = 0";
    7.87 +by Auto_tac;
    7.88 +qed "complex_Re_i";
    7.89 +Addsimps [complex_Re_i];
    7.90 +
    7.91 +Goalw [i_def] "Im(ii) = 1";
    7.92 +by Auto_tac;
    7.93 +qed "complex_Im_i";
    7.94 +Addsimps [complex_Im_i];
    7.95 +
    7.96 +Goalw [complex_of_real_def] "Re(complex_of_real 0) = 0";
    7.97 +by (Simp_tac 1);
    7.98 +qed "Re_complex_of_real_zero";
    7.99 +Addsimps [Re_complex_of_real_zero];
   7.100 +
   7.101 +Goalw [complex_of_real_def] "Im(complex_of_real 0) = 0";
   7.102 +by (Simp_tac 1);
   7.103 +qed "Im_complex_of_real_zero";
   7.104 +Addsimps [Im_complex_of_real_zero];
   7.105 +
   7.106 +Goalw [complex_of_real_def] "Re(complex_of_real 1) = 1";
   7.107 +by (Simp_tac 1);
   7.108 +qed "Re_complex_of_real_one";
   7.109 +Addsimps [Re_complex_of_real_one];
   7.110 +
   7.111 +Goalw [complex_of_real_def] "Im(complex_of_real 1) = 0";
   7.112 +by (Simp_tac 1);
   7.113 +qed "Im_complex_of_real_one";
   7.114 +Addsimps [Im_complex_of_real_one];
   7.115 +
   7.116 +Goalw [complex_of_real_def] "Re(complex_of_real z) = z";
   7.117 +by Auto_tac;
   7.118 +qed "Re_complex_of_real";
   7.119 +Addsimps [Re_complex_of_real];
   7.120 +
   7.121 +Goalw [complex_of_real_def] "Im(complex_of_real z) = 0";
   7.122 +by Auto_tac;
   7.123 +qed "Im_complex_of_real";
   7.124 +Addsimps [Im_complex_of_real];
   7.125 +
   7.126 +(*** negation ***)
   7.127 +
   7.128 +Goalw [complex_minus_def] "- Abs_complex(x,y) = Abs_complex(-x,-y)";
   7.129 +by (Simp_tac 1);
   7.130 +qed "complex_minus";
   7.131 +
   7.132 +Goalw [Re_def] "Re (-z) = - Re z";
   7.133 +by (res_inst_tac [("z","z")] eq_Abs_complex 1);
   7.134 +by (auto_tac (claset(),simpset() addsimps [complex_minus]));
   7.135 +qed "complex_Re_minus";
   7.136 +
   7.137 +Goalw [Im_def] "Im (-z) = - Im z";
   7.138 +by (res_inst_tac [("z","z")] eq_Abs_complex 1);
   7.139 +by (auto_tac (claset(),simpset() addsimps [complex_minus]));
   7.140 +qed "complex_Im_minus";
   7.141 +
   7.142 +Goalw [complex_minus_def] "- (- z) = (z::complex)";
   7.143 +by (Simp_tac 1);
   7.144 +qed "complex_minus_minus";
   7.145 +Addsimps [complex_minus_minus];
   7.146 +
   7.147 +Goal "inj(%r::complex. -r)";
   7.148 +by (rtac injI 1);
   7.149 +by (dres_inst_tac [("f","uminus")] arg_cong 1);
   7.150 +by (Asm_full_simp_tac 1);
   7.151 +qed "inj_complex_minus";
   7.152 +
   7.153 +Goalw [complex_zero_def] "-(0::complex) = 0";
   7.154 +by (simp_tac (simpset() addsimps [complex_minus]) 1);
   7.155 +qed "complex_minus_zero";
   7.156 +Addsimps [complex_minus_zero];
   7.157 +
   7.158 +Goal "(-x = 0) = (x = (0::complex))"; 
   7.159 +by (res_inst_tac [("z","x")] eq_Abs_complex 1);
   7.160 +by (auto_tac (claset() addDs [inj_Abs_complex RS injD],simpset() 
   7.161 +    addsimps [complex_zero_def,complex_minus]));
   7.162 +qed "complex_minus_zero_iff";
   7.163 +Addsimps [complex_minus_zero_iff];
   7.164 +
   7.165 +Goal "(0 = -x) = (x = (0::real))"; 
   7.166 +by (auto_tac (claset() addDs [sym],simpset()));
   7.167 +qed "complex_minus_zero_iff2";
   7.168 +Addsimps [complex_minus_zero_iff2];
   7.169 +
   7.170 +Goal "(-x ~= 0) = (x ~= (0::complex))"; 
   7.171 +by Auto_tac;
   7.172 +qed "complex_minus_not_zero_iff";
   7.173 +
   7.174 +(*** addition ***)
   7.175 +
   7.176 +Goalw [complex_add_def]
   7.177 +      "Abs_complex(x1,y1) + Abs_complex(x2,y2) = Abs_complex(x1+x2,y1+y2)";
   7.178 +by (Simp_tac 1);
   7.179 +qed "complex_add";
   7.180 +
   7.181 +Goalw [Re_def] "Re(x + y) = Re(x) + Re(y)";
   7.182 +by (res_inst_tac [("z","x")] eq_Abs_complex 1);
   7.183 +by (res_inst_tac [("z","y")] eq_Abs_complex 1);
   7.184 +by (auto_tac (claset(),simpset() addsimps [complex_add]));
   7.185 +qed "complex_Re_add";
   7.186 +
   7.187 +Goalw [Im_def] "Im(x + y) = Im(x) + Im(y)";
   7.188 +by (res_inst_tac [("z","x")] eq_Abs_complex 1);
   7.189 +by (res_inst_tac [("z","y")] eq_Abs_complex 1);
   7.190 +by (auto_tac (claset(),simpset() addsimps [complex_add]));
   7.191 +qed "complex_Im_add";
   7.192 +
   7.193 +Goalw [complex_add_def] "(u::complex) + v = v + u";
   7.194 +by (simp_tac (simpset() addsimps [real_add_commute]) 1);
   7.195 +qed "complex_add_commute";
   7.196 +
   7.197 +Goalw [complex_add_def] "((u::complex) + v) + w = u + (v + w)";
   7.198 +by (simp_tac (simpset() addsimps [real_add_assoc]) 1);
   7.199 +qed "complex_add_assoc";
   7.200 +
   7.201 +Goalw [complex_add_def] "(x::complex) + (y + z) = y + (x + z)";
   7.202 +by (simp_tac (simpset() addsimps [real_add_left_commute]) 1);
   7.203 +qed "complex_add_left_commute";
   7.204 +
   7.205 +val complex_add_ac = [complex_add_assoc,complex_add_commute,
   7.206 +                      complex_add_left_commute];
   7.207 +
   7.208 +Goalw [complex_add_def,complex_zero_def] "(0::complex) + z = z";
   7.209 +by (Simp_tac 1);
   7.210 +qed "complex_add_zero_left";
   7.211 +Addsimps [complex_add_zero_left];
   7.212 +
   7.213 +Goalw [complex_add_def,complex_zero_def] "z + (0::complex) = z";
   7.214 +by (Simp_tac 1);
   7.215 +qed "complex_add_zero_right";
   7.216 +Addsimps [complex_add_zero_right];
   7.217 +
   7.218 +Goalw [complex_add_def,complex_minus_def,complex_zero_def] 
   7.219 +      "z + -z = (0::complex)";
   7.220 +by (Simp_tac 1);
   7.221 +qed "complex_add_minus_right_zero";
   7.222 +Addsimps [complex_add_minus_right_zero];
   7.223 +
   7.224 +Goalw [complex_add_def,complex_minus_def,complex_zero_def] 
   7.225 +      "-z + z = (0::complex)";
   7.226 +by (Simp_tac 1);
   7.227 +qed "complex_add_minus_left_zero";
   7.228 +Addsimps [complex_add_minus_left_zero];
   7.229 +
   7.230 +Goal "z + (- z + w) = (w::complex)";
   7.231 +by (simp_tac (simpset() addsimps [complex_add_assoc RS sym]) 1);
   7.232 +qed "complex_add_minus_cancel";
   7.233 +
   7.234 +Goal "(-z) + (z + w) = (w::complex)";
   7.235 +by (simp_tac (simpset() addsimps [complex_add_assoc RS sym]) 1);
   7.236 +qed "complex_minus_add_cancel";
   7.237 +
   7.238 +Addsimps [complex_add_minus_cancel, complex_minus_add_cancel];
   7.239 +
   7.240 +Goal "x + y = (0::complex) ==> x = -y";
   7.241 +by (auto_tac (claset(),simpset() addsimps [complex_Re_Im_cancel_iff,
   7.242 +    complex_Re_add,complex_Im_add,complex_Re_minus,complex_Im_minus]));
   7.243 +qed "complex_add_minus_eq_minus";
   7.244 +
   7.245 +Goal "-(x + y) = -x + -(y::complex)";
   7.246 +by (res_inst_tac [("z","x")] eq_Abs_complex 1);
   7.247 +by (res_inst_tac [("z","y")] eq_Abs_complex 1);
   7.248 +by (auto_tac (claset(),simpset() addsimps [complex_minus,complex_add]));
   7.249 +qed "complex_minus_add_distrib";
   7.250 +Addsimps [complex_minus_add_distrib];
   7.251 +
   7.252 +Goal "((x::complex) + y = x + z) = (y = z)";
   7.253 +by (Step_tac 1);
   7.254 +by (dres_inst_tac [("f","%t.-x + t")] arg_cong 1);
   7.255 +by (asm_full_simp_tac (simpset() addsimps [complex_add_assoc RS sym]) 1);
   7.256 +qed "complex_add_left_cancel";
   7.257 +AddIffs [complex_add_left_cancel];
   7.258 +
   7.259 +Goal "(y + (x::complex)= z + x) = (y = z)";
   7.260 +by (simp_tac (simpset() addsimps [complex_add_commute]) 1);
   7.261 +qed "complex_add_right_cancel";
   7.262 +Addsimps [complex_add_right_cancel];
   7.263 +
   7.264 +Goal "((x::complex) = y) = (0 = x + - y)";
   7.265 +by (Step_tac 1);
   7.266 +by (res_inst_tac [("x1","-y")] 
   7.267 +      (complex_add_right_cancel RS iffD1) 2);
   7.268 +by (Auto_tac);
   7.269 +qed "complex_eq_minus_iff"; 
   7.270 +
   7.271 +Goal "((x::complex) = y) = (x + - y = 0)";
   7.272 +by (Step_tac 1);
   7.273 +by (res_inst_tac [("x1","-y")] 
   7.274 +      (complex_add_right_cancel RS iffD1) 2);
   7.275 +by (Auto_tac);
   7.276 +qed "complex_eq_minus_iff2"; 
   7.277 +
   7.278 +Goal "(0::complex) - x = -x";
   7.279 +by (simp_tac (simpset() addsimps [complex_diff_def]) 1);
   7.280 +qed "complex_diff_0";
   7.281 +
   7.282 +Goal "x - (0::complex) = x";
   7.283 +by (simp_tac (simpset() addsimps [complex_diff_def]) 1);
   7.284 +qed "complex_diff_0_right";
   7.285 +
   7.286 +Goal "x - x = (0::complex)";
   7.287 +by (simp_tac (simpset() addsimps [complex_diff_def]) 1);
   7.288 +qed "complex_diff_self";
   7.289 +
   7.290 +Addsimps [complex_diff_0, complex_diff_0_right, complex_diff_self];
   7.291 +
   7.292 +Goalw [complex_diff_def]
   7.293 +      "Abs_complex(x1,y1) - Abs_complex(x2,y2) = Abs_complex(x1-x2,y1-y2)";
   7.294 +by (simp_tac (simpset() addsimps [complex_add,complex_minus]) 1);
   7.295 +qed "complex_diff";
   7.296 +
   7.297 +Goal "((x::complex) - y = z) = (x = z + y)";
   7.298 +by (auto_tac (claset(),simpset() addsimps [complex_diff_def,complex_add_assoc]));
   7.299 +qed "complex_diff_eq_eq";
   7.300 +
   7.301 +(*** complex multiplication ***)
   7.302 +
   7.303 +Goalw [complex_mult_def]
   7.304 +      "Abs_complex(x1,y1) * Abs_complex(x2,y2) = \
   7.305 +\      Abs_complex(x1*x2 - y1*y2,x1*y2 + y1*x2)";
   7.306 +by (Simp_tac 1);
   7.307 +qed "complex_mult";
   7.308 +
   7.309 +Goalw [complex_mult_def] "(w::complex) * z = z * w";
   7.310 +by (simp_tac (simpset() addsimps [real_mult_commute,real_add_commute]) 1);
   7.311 +qed "complex_mult_commute";
   7.312 +
   7.313 +Goalw [complex_mult_def] "((u::complex) * v) * w = u * (v * w)";
   7.314 +by (simp_tac (simpset() addsimps [complex_Re_Im_cancel_iff,
   7.315 +    real_mult_assoc,real_diff_mult_distrib2,
   7.316 +    real_add_mult_distrib2,real_diff_mult_distrib,
   7.317 +    real_add_mult_distrib,real_mult_left_commute]) 1);
   7.318 +qed "complex_mult_assoc";
   7.319 +
   7.320 +Goalw [complex_mult_def] "(x::complex) * (y * z) = y * (x * z)";
   7.321 +by (simp_tac (simpset() addsimps [complex_Re_Im_cancel_iff,
   7.322 +    real_mult_left_commute,real_diff_mult_distrib2,
   7.323 +    real_add_mult_distrib2]) 1);
   7.324 +qed "complex_mult_left_commute";
   7.325 +
   7.326 +val complex_mult_ac = [complex_mult_assoc,complex_mult_commute,
   7.327 +                      complex_mult_left_commute];
   7.328 +
   7.329 +Goalw [complex_one_def] "(1::complex) * z = z";
   7.330 +by (res_inst_tac [("z","z")] eq_Abs_complex 1);
   7.331 +by (asm_simp_tac (simpset() addsimps [complex_mult]) 1);
   7.332 +qed "complex_mult_one_left";
   7.333 +Addsimps [complex_mult_one_left];
   7.334 +
   7.335 +Goal "z * (1::complex) = z";
   7.336 +by (simp_tac (simpset() addsimps [complex_mult_commute]) 1);
   7.337 +qed "complex_mult_one_right";
   7.338 +Addsimps [complex_mult_one_right];
   7.339 +
   7.340 +Goalw [complex_zero_def] "(0::complex) * z = 0";
   7.341 +by (res_inst_tac [("z","z")] eq_Abs_complex 1);
   7.342 +by (asm_simp_tac (simpset() addsimps [complex_mult]) 1);
   7.343 +qed "complex_mult_zero_left";
   7.344 +Addsimps [complex_mult_zero_left];
   7.345 +
   7.346 +Goal "z * 0 = (0::complex)";
   7.347 +by (simp_tac (simpset() addsimps [complex_mult_commute]) 1);
   7.348 +qed "complex_mult_zero_right";
   7.349 +Addsimps [complex_mult_zero_right];
   7.350 +
   7.351 +Goalw [complex_divide_def] "0 / z = (0::complex)";
   7.352 +by Auto_tac;
   7.353 +qed "complex_divide_zero";
   7.354 +Addsimps [complex_divide_zero];
   7.355 +
   7.356 +Goal "-(x * y) = -x * (y::complex)";
   7.357 +by (res_inst_tac [("z","x")] eq_Abs_complex 1);
   7.358 +by (res_inst_tac [("z","y")] eq_Abs_complex 1);
   7.359 +by (auto_tac (claset(),simpset() addsimps [complex_mult,complex_minus,
   7.360 +    real_diff_def]));
   7.361 +qed "complex_minus_mult_eq1";
   7.362 +
   7.363 +Goal "-(x * y) = x * -(y::complex)";
   7.364 +by (res_inst_tac [("z","x")] eq_Abs_complex 1);
   7.365 +by (res_inst_tac [("z","y")] eq_Abs_complex 1);
   7.366 +by (auto_tac (claset(),simpset() addsimps [complex_mult,complex_minus,
   7.367 +    real_diff_def]));
   7.368 +qed "complex_minus_mult_eq2";
   7.369 +
   7.370 +Addsimps [ complex_minus_mult_eq1 RS sym, complex_minus_mult_eq2 RS sym];
   7.371 +
   7.372 +Goal "-(1::complex) * z = -z";
   7.373 +by (Simp_tac 1);
   7.374 +qed "complex_mult_minus_one";
   7.375 +Addsimps [complex_mult_minus_one];
   7.376 +
   7.377 +Goal "z * -(1::complex) = -z";
   7.378 +by (stac complex_mult_commute 1);
   7.379 +by (Simp_tac 1);
   7.380 +qed "complex_mult_minus_one_right";
   7.381 +Addsimps [complex_mult_minus_one_right];
   7.382 +
   7.383 +Goal "-x * -y = x * (y::complex)";
   7.384 +by (Simp_tac 1);
   7.385 +qed "complex_minus_mult_cancel";
   7.386 +Addsimps [complex_minus_mult_cancel];
   7.387 +
   7.388 +Goal "-x * y = x * -(y::complex)";
   7.389 +by (Simp_tac 1);
   7.390 +qed "complex_minus_mult_commute";
   7.391 +
   7.392 +qed_goal "complex_add_assoc_cong" thy
   7.393 +    "!!z. (z::complex) + v = z' + v' ==> z + (v + w) = z' + (v' + w)"
   7.394 + (fn _ => [(asm_simp_tac (simpset() addsimps [complex_add_assoc RS sym]) 1)]);
   7.395 +
   7.396 +qed_goal "complex_add_assoc_swap" thy "(z::complex) + (v + w) = v + (z + w)"
   7.397 + (fn _ => [(REPEAT (ares_tac [complex_add_commute RS complex_add_assoc_cong] 1))]);
   7.398 +
   7.399 +Goal "((z1::complex) + z2) * w = (z1 * w) + (z2 * w)";
   7.400 +by (res_inst_tac [("z","z1")] eq_Abs_complex 1);
   7.401 +by (res_inst_tac [("z","z2")] eq_Abs_complex 1);
   7.402 +by (res_inst_tac [("z","w")] eq_Abs_complex 1);
   7.403 +by (auto_tac (claset(),simpset() addsimps [complex_mult,complex_add,
   7.404 +    real_add_mult_distrib,real_diff_def] @ real_add_ac));
   7.405 +qed "complex_add_mult_distrib";
   7.406 +
   7.407 +Goal "(w::complex) * (z1 + z2) = (w * z1) + (w * z2)";
   7.408 +by (res_inst_tac [("z1","z1 + z2")] (complex_mult_commute RS ssubst) 1);
   7.409 +by (simp_tac (simpset() addsimps [complex_add_mult_distrib]) 1);
   7.410 +by (simp_tac (simpset() addsimps [complex_mult_commute]) 1);
   7.411 +qed "complex_add_mult_distrib2";
   7.412 +
   7.413 +Goalw [complex_zero_def,complex_one_def] "(0::complex) ~= 1";
   7.414 +by (simp_tac (simpset() addsimps [complex_Re_Im_cancel_iff]) 1);
   7.415 +qed "complex_zero_not_eq_one";
   7.416 +Addsimps [complex_zero_not_eq_one];
   7.417 +Addsimps [complex_zero_not_eq_one RS not_sym];
   7.418 +
   7.419 +(*** inverse ***)
   7.420 +Goalw [complex_inverse_def] "inverse (Abs_complex(x,y)) = \
   7.421 +\    Abs_complex(x/(x ^ 2 + y ^ 2),-y/(x ^ 2 + y ^ 2))";
   7.422 +by (Simp_tac 1);
   7.423 +qed "complex_inverse";
   7.424 +
   7.425 +Goalw [complex_inverse_def,complex_zero_def] "inverse 0 = (0::complex)";
   7.426 +by Auto_tac;
   7.427 +qed "COMPLEX_INVERSE_ZERO";
   7.428 +
   7.429 +Goal "a / (0::complex) = 0";
   7.430 +by (simp_tac (simpset() addsimps [complex_divide_def, COMPLEX_INVERSE_ZERO]) 1);
   7.431 +qed "COMPLEX_DIVISION_BY_ZERO";  (*NOT for adding to default simpset*)
   7.432 +
   7.433 +fun complex_div_undefined_case_tac s i =
   7.434 +  case_tac s i THEN 
   7.435 +  asm_simp_tac (simpset() addsimps [COMPLEX_DIVISION_BY_ZERO, COMPLEX_INVERSE_ZERO]) i;
   7.436 +
   7.437 +(*REMOVE?:
   7.438 +lemmas:replace previous versions to accommodate new behaviour of simplification
   7.439 +Goal "x ^ 2 + y ^ 2 = 0 ==> x = (0::real)";
   7.440 +by (auto_tac (claset() addIs [real_sum_squares_cancel],
   7.441 +    simpset() addsimps [CLAIM "2 = Suc(Suc 0)"]));
   7.442 +qed "real_sum_squares_cancel";
   7.443 +
   7.444 +Goal "x ^ 2 + y ^ 2 = 0 ==> y = (0::real)";
   7.445 +by (auto_tac (claset() addIs [real_sum_squares_cancel2],
   7.446 +    simpset() addsimps [CLAIM "2 = Suc(Suc 0)"]));
   7.447 +qed "real_sum_squares_cancel2";
   7.448 +*)
   7.449 +
   7.450 +Goal "z ~= (0::complex) ==> inverse(z) * z = 1";
   7.451 +by (res_inst_tac [("z","z")] eq_Abs_complex 1);
   7.452 +by (auto_tac (claset(),simpset() addsimps [complex_mult,complex_inverse,
   7.453 +    complex_one_def,complex_zero_def,real_add_divide_distrib RS sym,
   7.454 +    realpow_two_eq_mult] @ real_mult_ac));
   7.455 +by (dres_inst_tac [("y","y")] real_sum_squares_not_zero 1);
   7.456 +by (dres_inst_tac [("x","x")] real_sum_squares_not_zero2 2);
   7.457 +by Auto_tac;
   7.458 +qed "complex_mult_inv_left";
   7.459 +Addsimps [complex_mult_inv_left];
   7.460 +
   7.461 +Goal "z ~= (0::complex) ==> z * inverse(z) = 1";
   7.462 +by (auto_tac (claset() addIs [complex_mult_commute RS subst],simpset()));
   7.463 +qed "complex_mult_inv_right";
   7.464 +Addsimps [complex_mult_inv_right];
   7.465 +
   7.466 +Goal "(c::complex) ~= 0 ==> (c*a=c*b) = (a=b)";
   7.467 +by Auto_tac;
   7.468 +by (dres_inst_tac [("f","%x. x*inverse c")] arg_cong 1);
   7.469 +by (asm_full_simp_tac (simpset() addsimps complex_mult_ac)  1);
   7.470 +qed "complex_mult_left_cancel";
   7.471 +    
   7.472 +Goal "(c::complex) ~= 0 ==> (a*c=b*c) = (a=b)";
   7.473 +by (Step_tac 1);
   7.474 +by (dres_inst_tac [("f","%x. x*inverse c")] arg_cong 1);
   7.475 +by (asm_full_simp_tac (simpset() addsimps complex_mult_ac)  1);
   7.476 +qed "complex_mult_right_cancel";
   7.477 +
   7.478 +Goal "z ~= 0 ==> inverse(z::complex) ~= 0";
   7.479 +by (Step_tac 1);
   7.480 +by (ftac (complex_mult_right_cancel RS iffD2) 1);
   7.481 +by (thin_tac "inverse z = 0" 2);
   7.482 +by (assume_tac 1 THEN Auto_tac);
   7.483 +qed "complex_inverse_not_zero";
   7.484 +Addsimps [complex_inverse_not_zero];
   7.485 +
   7.486 +Goal "!!x. [| x ~= 0; y ~= (0::complex) |] ==> x * y ~= 0";
   7.487 +by (Step_tac 1);
   7.488 +by (dres_inst_tac [("f","%z. inverse x*z")] arg_cong 1);
   7.489 +by (asm_full_simp_tac (simpset() addsimps [complex_mult_assoc RS sym]) 1);
   7.490 +qed "complex_mult_not_zero";
   7.491 +
   7.492 +bind_thm ("complex_mult_not_zeroE",complex_mult_not_zero RS notE);
   7.493 +
   7.494 +Goal "inverse(inverse (x::complex)) = x";
   7.495 +by (complex_div_undefined_case_tac "x = 0" 1);
   7.496 +by (res_inst_tac [("c1","inverse x")] (complex_mult_right_cancel RS iffD1) 1);
   7.497 +by (etac complex_inverse_not_zero 1);
   7.498 +by (auto_tac (claset() addDs [complex_inverse_not_zero],simpset()));
   7.499 +qed "complex_inverse_inverse";
   7.500 +Addsimps [complex_inverse_inverse];
   7.501 +
   7.502 +Goalw [complex_one_def] "inverse(1::complex) = 1";
   7.503 +by (simp_tac (simpset() addsimps [complex_inverse,realpow_num_two]) 1);
   7.504 +qed "complex_inverse_one";
   7.505 +Addsimps [complex_inverse_one];
   7.506 +
   7.507 +Goal "inverse(-x) = -inverse(x::complex)";
   7.508 +by (complex_div_undefined_case_tac "x = 0" 1);
   7.509 +by (res_inst_tac [("c1","-x")] (complex_mult_right_cancel RS iffD1) 1);
   7.510 +by (stac complex_mult_inv_left 2);
   7.511 +by Auto_tac;
   7.512 +qed "complex_minus_inverse";
   7.513 +
   7.514 +Goal "inverse(x*y) = inverse x * inverse (y::complex)";
   7.515 +by (complex_div_undefined_case_tac "x = 0" 1);
   7.516 +by (complex_div_undefined_case_tac "y = 0" 1);
   7.517 +by (res_inst_tac [("c1","x*y")] (complex_mult_left_cancel RS iffD1) 1);
   7.518 +by (auto_tac (claset(),simpset() addsimps [complex_mult_not_zero]
   7.519 +    @ complex_mult_ac));
   7.520 +by (auto_tac (claset(),simpset() addsimps [complex_mult_not_zero,
   7.521 +    complex_mult_assoc RS sym]));
   7.522 +qed "complex_inverse_distrib";
   7.523 +
   7.524 +
   7.525 +(*** division ***)
   7.526 +
   7.527 +(*adding some of these theorems to simpset as for reals: 
   7.528 +  not 100% convinced for some*)
   7.529 +
   7.530 +Goal "(x::complex) * (y/z) = (x*y)/z";
   7.531 +by (simp_tac (simpset() addsimps [complex_divide_def, complex_mult_assoc]) 1); 
   7.532 +qed "complex_times_divide1_eq";
   7.533 +
   7.534 +Goal "(y/z) * (x::complex) = (y*x)/z";
   7.535 +by (simp_tac (simpset() addsimps [complex_divide_def]@complex_mult_ac) 1); 
   7.536 +qed "complex_times_divide2_eq";
   7.537 +
   7.538 +Addsimps [complex_times_divide1_eq, complex_times_divide2_eq];
   7.539 +
   7.540 +Goal "(x::complex) / (y/z) = (x*z)/y";
   7.541 +by (simp_tac (simpset() addsimps [complex_divide_def, complex_inverse_distrib]@
   7.542 +                                  complex_mult_ac) 1); 
   7.543 +qed "complex_divide_divide1_eq";
   7.544 +
   7.545 +Goal "((x::complex) / y) / z = x/(y*z)";
   7.546 +by (simp_tac (simpset() addsimps [complex_divide_def, complex_inverse_distrib, 
   7.547 +                                  complex_mult_assoc]) 1); 
   7.548 +qed "complex_divide_divide2_eq";
   7.549 +
   7.550 +Addsimps [complex_divide_divide1_eq, complex_divide_divide2_eq];
   7.551 +
   7.552 +(** As with multiplication, pull minus signs OUT of the / operator **)
   7.553 +
   7.554 +Goal "(-x) / (y::complex) = - (x/y)";
   7.555 +by (simp_tac (simpset() addsimps [complex_divide_def]) 1); 
   7.556 +qed "complex_minus_divide_eq";
   7.557 +Addsimps [complex_minus_divide_eq];
   7.558 +
   7.559 +Goal "(x / -(y::complex)) = - (x/y)";
   7.560 +by (simp_tac (simpset() addsimps [complex_divide_def, complex_minus_inverse]) 1); 
   7.561 +qed "complex_divide_minus_eq";
   7.562 +Addsimps [complex_divide_minus_eq];
   7.563 +
   7.564 +Goal "(x+y)/(z::complex) = x/z + y/z";
   7.565 +by (simp_tac (simpset() addsimps [complex_divide_def, complex_add_mult_distrib]) 1); 
   7.566 +qed "complex_add_divide_distrib";
   7.567 +
   7.568 +(*---------------------------------------------------------------------------*)
   7.569 +(*          Embedding properties for complex_of_real map                     *)
   7.570 +(*---------------------------------------------------------------------------*)
   7.571 +
   7.572 +Goal "inj complex_of_real";
   7.573 +by (rtac injI 1);
   7.574 +by (auto_tac (claset() addDs [inj_Abs_complex RS injD],
   7.575 +    simpset() addsimps [complex_of_real_def]));
   7.576 +qed "inj_complex_of_real";
   7.577 +
   7.578 +Goalw [complex_one_def,complex_of_real_def]
   7.579 +      "complex_of_real 1 = 1";
   7.580 +by (rtac refl 1);
   7.581 +qed "complex_of_real_one";
   7.582 +Addsimps [complex_of_real_one];
   7.583 +
   7.584 +Goalw [complex_zero_def,complex_of_real_def]
   7.585 +      "complex_of_real 0 = 0";
   7.586 +by (rtac refl 1);
   7.587 +qed "complex_of_real_zero";
   7.588 +Addsimps [complex_of_real_zero];
   7.589 +
   7.590 +Goal "(complex_of_real x = complex_of_real y) = (x = y)";
   7.591 +by (auto_tac (claset() addDs [inj_complex_of_real RS injD],simpset()));
   7.592 +qed "complex_of_real_eq_iff";
   7.593 +AddIffs [complex_of_real_eq_iff];
   7.594 +
   7.595 +Goal "complex_of_real(-x) = - complex_of_real x";
   7.596 +by (simp_tac (simpset() addsimps [complex_of_real_def,complex_minus]) 1);
   7.597 +qed "complex_of_real_minus";
   7.598 +
   7.599 +Goal "complex_of_real(inverse x) = inverse(complex_of_real x)";
   7.600 +by (real_div_undefined_case_tac "x=0" 1);
   7.601 +by (simp_tac (simpset() addsimps [DIVISION_BY_ZERO,COMPLEX_INVERSE_ZERO]) 1);
   7.602 +by (auto_tac (claset(),simpset() addsimps [complex_inverse,
   7.603 +    complex_of_real_def,realpow_num_two,real_divide_def,
   7.604 +    real_inverse_distrib]));
   7.605 +qed "complex_of_real_inverse";
   7.606 +
   7.607 +Goal "complex_of_real x + complex_of_real y = complex_of_real (x + y)";
   7.608 +by (simp_tac (simpset() addsimps [complex_add,complex_of_real_def]) 1);
   7.609 +qed "complex_of_real_add";
   7.610 +
   7.611 +Goal "complex_of_real x - complex_of_real y = complex_of_real (x - y)";
   7.612 +by (simp_tac (simpset() addsimps [complex_of_real_minus RS sym,
   7.613 +    complex_diff_def,complex_of_real_add]) 1);
   7.614 +qed "complex_of_real_diff";
   7.615 +
   7.616 +Goal "complex_of_real x * complex_of_real y = complex_of_real (x * y)";
   7.617 +by (simp_tac (simpset() addsimps [complex_mult,complex_of_real_def]) 1);
   7.618 +qed "complex_of_real_mult";
   7.619 +
   7.620 +Goalw [complex_divide_def] 
   7.621 +      "complex_of_real x / complex_of_real y = complex_of_real(x/y)";
   7.622 +by (real_div_undefined_case_tac "y=0" 1);
   7.623 +by (simp_tac (simpset() addsimps [rename_numerals DIVISION_BY_ZERO,
   7.624 +    COMPLEX_INVERSE_ZERO]) 1);
   7.625 +by (asm_simp_tac (simpset() addsimps [complex_of_real_mult RS sym,
   7.626 +    complex_of_real_inverse,real_divide_def]) 1);
   7.627 +qed "complex_of_real_divide";
   7.628 +
   7.629 +Goal "complex_of_real (x ^ n) = (complex_of_real x) ^ n";
   7.630 +by (induct_tac "n" 1);
   7.631 +by (auto_tac (claset(),simpset() addsimps [complex_of_real_mult RS sym]));
   7.632 +qed "complex_of_real_pow";
   7.633 +
   7.634 +Goalw [cmod_def] "cmod (Abs_complex(x,y)) = sqrt(x ^ 2 + y ^ 2)";
   7.635 +by (Simp_tac 1);
   7.636 +qed "complex_mod";
   7.637 +
   7.638 +Goalw [cmod_def] "cmod(0) = 0";
   7.639 +by (Simp_tac 1);
   7.640 +qed "complex_mod_zero";
   7.641 +Addsimps [complex_mod_zero];
   7.642 +
   7.643 +Goalw [cmod_def] "cmod(1) = 1";
   7.644 +by (simp_tac (simpset() addsimps [realpow_num_two]) 1);
   7.645 +qed "complex_mod_one";
   7.646 +Addsimps [complex_mod_one];
   7.647 +
   7.648 +Goalw [complex_of_real_def] "cmod(complex_of_real x) = abs x";
   7.649 +by (simp_tac (simpset() addsimps [complex_mod,realpow_num_two]) 1);
   7.650 +qed "complex_mod_complex_of_real";
   7.651 +Addsimps [complex_mod_complex_of_real];
   7.652 +
   7.653 +Goal "complex_of_real (abs x) = complex_of_real(cmod(complex_of_real x))";
   7.654 +by (Simp_tac 1);
   7.655 +qed "complex_of_real_abs";
   7.656 +
   7.657 +(*---------------------------------------------------------------------------*)
   7.658 +(*                   conjugation is an automorphism                          *)
   7.659 +(*---------------------------------------------------------------------------*)
   7.660 +
   7.661 +Goalw [cnj_def] "cnj (Abs_complex(x,y)) = Abs_complex(x,-y)";
   7.662 +by (Simp_tac 1);
   7.663 +qed "complex_cnj";
   7.664 +
   7.665 +Goal "inj cnj";
   7.666 +by (rtac injI 1);
   7.667 +by (auto_tac (claset(),simpset() addsimps [cnj_def,
   7.668 +    Abs_complex_cancel_iff,complex_Re_Im_cancel_iff]));
   7.669 +qed "inj_cnj";
   7.670 +
   7.671 +Goal "(cnj x = cnj y) = (x = y)";
   7.672 +by (auto_tac (claset() addDs [inj_cnj RS injD],simpset()));
   7.673 +qed "complex_cnj_cancel_iff";
   7.674 +Addsimps [complex_cnj_cancel_iff];
   7.675 +
   7.676 +Goalw [cnj_def] "cnj (cnj z) = z";
   7.677 +by (Simp_tac 1);
   7.678 +qed "complex_cnj_cnj";
   7.679 +Addsimps [complex_cnj_cnj];
   7.680 +
   7.681 +Goalw [complex_of_real_def] "cnj (complex_of_real x) = complex_of_real x";
   7.682 +by (simp_tac (simpset() addsimps [complex_cnj]) 1);
   7.683 +qed "complex_cnj_complex_of_real";
   7.684 +Addsimps [complex_cnj_complex_of_real];
   7.685 +
   7.686 +Goal "cmod (cnj z) = cmod z";
   7.687 +by (res_inst_tac [("z","z")] eq_Abs_complex 1);
   7.688 +by (asm_simp_tac (simpset() addsimps [complex_cnj,complex_mod,realpow_num_two]) 1);
   7.689 +qed "complex_mod_cnj";
   7.690 +Addsimps [complex_mod_cnj];
   7.691 +
   7.692 +Goalw [cnj_def] "cnj (-z) = - cnj z";
   7.693 +by (simp_tac (simpset() addsimps [complex_minus,
   7.694 +    complex_Re_minus,complex_Im_minus]) 1);
   7.695 +qed "complex_cnj_minus";
   7.696 +
   7.697 +Goal "cnj(inverse z) = inverse(cnj z)";
   7.698 +by (res_inst_tac [("z","z")] eq_Abs_complex 1);
   7.699 +by (asm_simp_tac (simpset() addsimps [complex_cnj,complex_inverse,
   7.700 +    realpow_num_two]) 1);
   7.701 +qed "complex_cnj_inverse";
   7.702 +
   7.703 +Goal "cnj(w + z) = cnj(w) + cnj(z)";
   7.704 +by (res_inst_tac [("z","w")] eq_Abs_complex 1);
   7.705 +by (res_inst_tac [("z","z")] eq_Abs_complex 1);
   7.706 +by (asm_simp_tac (simpset() addsimps [complex_cnj,complex_add]) 1);
   7.707 +qed "complex_cnj_add";
   7.708 +
   7.709 +Goalw [complex_diff_def] "cnj(w - z) = cnj(w) - cnj(z)";
   7.710 +by (simp_tac (simpset() addsimps [complex_cnj_add,complex_cnj_minus]) 1);
   7.711 +qed "complex_cnj_diff";
   7.712 +
   7.713 +Goal "cnj(w * z) = cnj(w) * cnj(z)";
   7.714 +by (res_inst_tac [("z","w")] eq_Abs_complex 1);
   7.715 +by (res_inst_tac [("z","z")] eq_Abs_complex 1);
   7.716 +by (asm_simp_tac (simpset() addsimps [complex_cnj,complex_mult]) 1);
   7.717 +qed "complex_cnj_mult";
   7.718 +
   7.719 +Goalw [complex_divide_def] "cnj(w / z) = (cnj w)/(cnj z)";
   7.720 +by (simp_tac (simpset() addsimps [complex_cnj_mult,complex_cnj_inverse]) 1);
   7.721 +qed "complex_cnj_divide";
   7.722 +
   7.723 +Goalw [cnj_def,complex_one_def] "cnj 1 = 1";
   7.724 +by (Simp_tac 1);
   7.725 +qed "complex_cnj_one";
   7.726 +Addsimps [complex_cnj_one];
   7.727 +
   7.728 +Goal "cnj(z ^ n) = cnj(z) ^ n";
   7.729 +by (induct_tac "n" 1);
   7.730 +by (auto_tac (claset(),simpset() addsimps [complex_cnj_mult]));
   7.731 +qed "complex_cnj_pow";
   7.732 +
   7.733 +Goal "z + cnj z = complex_of_real (2 * Re(z))";
   7.734 +by (res_inst_tac [("z","z")] eq_Abs_complex 1);
   7.735 +by (asm_simp_tac (simpset() addsimps [complex_add,complex_cnj,
   7.736 +    complex_of_real_def]) 1);
   7.737 +qed "complex_add_cnj";
   7.738 +
   7.739 +Goal "z - cnj z = complex_of_real (2 * Im(z)) * ii";
   7.740 +by (res_inst_tac [("z","z")] eq_Abs_complex 1);
   7.741 +by (asm_simp_tac (simpset() addsimps [complex_add,complex_cnj,
   7.742 +    complex_of_real_def,complex_diff_def,complex_minus,
   7.743 +    i_def,complex_mult]) 1);
   7.744 +qed "complex_diff_cnj";
   7.745 +
   7.746 +goalw Complex.thy  [cnj_def,complex_zero_def] 
   7.747 +      "cnj 0 = 0";
   7.748 +by Auto_tac;
   7.749 +qed "complex_cnj_zero";
   7.750 +Addsimps [complex_cnj_zero];
   7.751 +
   7.752 +goal Complex.thy "(cnj z = 0) = (z = 0)";
   7.753 +by (res_inst_tac [("z","z")] eq_Abs_complex 1);
   7.754 +by (auto_tac (claset(),simpset() addsimps [complex_zero_def,
   7.755 +    complex_cnj]));
   7.756 +qed "complex_cnj_zero_iff";
   7.757 +AddIffs [complex_cnj_zero_iff];
   7.758 +
   7.759 +Goal "z * cnj z = complex_of_real (Re(z) ^ 2 + Im(z) ^ 2)";
   7.760 +by (res_inst_tac [("z","z")] eq_Abs_complex 1);
   7.761 +by (auto_tac (claset(),simpset() addsimps [complex_cnj,complex_mult,
   7.762 +    complex_of_real_def,realpow_num_two]));
   7.763 +qed "complex_mult_cnj";
   7.764 +
   7.765 +(*---------------------------------------------------------------------------*)
   7.766 +(*                              algebra                                      *)
   7.767 +(*---------------------------------------------------------------------------*)
   7.768 +
   7.769 +Goal "(x*y = (0::complex)) = (x = 0 | y = 0)";
   7.770 +by Auto_tac;
   7.771 +by (auto_tac (claset() addIs [ccontr] addDs 
   7.772 +    [complex_mult_not_zero],simpset()));
   7.773 +qed "complex_mult_zero_iff";
   7.774 +AddIffs [complex_mult_zero_iff];
   7.775 +
   7.776 +Goalw [complex_zero_def] "(x + y = x) = (y = (0::complex))";
   7.777 +by (res_inst_tac [("z","x")] eq_Abs_complex 1);
   7.778 +by (res_inst_tac [("z","y")] eq_Abs_complex 1);
   7.779 +by (auto_tac (claset(),simpset() addsimps [complex_add]));
   7.780 +qed "complex_add_left_cancel_zero";
   7.781 +Addsimps [complex_add_left_cancel_zero];
   7.782 +
   7.783 +Goalw [complex_diff_def] 
   7.784 +      "((z1::complex) - z2) * w = (z1 * w) - (z2 * w)";
   7.785 +by (simp_tac (simpset() addsimps [complex_add_mult_distrib]) 1);
   7.786 +qed "complex_diff_mult_distrib";
   7.787 +
   7.788 +Goalw [complex_diff_def]
   7.789 +      "(w::complex) * (z1 - z2) = (w * z1) - (w * z2)";
   7.790 +by (simp_tac (simpset() addsimps [complex_add_mult_distrib2]) 1);
   7.791 +qed "complex_diff_mult_distrib2";
   7.792 +
   7.793 +(*---------------------------------------------------------------------------*)
   7.794 +(*                               modulus                                     *)
   7.795 +(*---------------------------------------------------------------------------*)
   7.796 +
   7.797 +(*
   7.798 +Goal "[| sqrt(x) = 0; 0 <= x |] ==> x = 0";
   7.799 +by (auto_tac (claset() addIs [real_sqrt_eq_zero_cancel],
   7.800 +    simpset()));
   7.801 +qed "real_sqrt_eq_zero_cancel2";
   7.802 +*)
   7.803 +
   7.804 +Goal "(cmod x = 0) = (x = 0)";
   7.805 +by (res_inst_tac [("z","x")] eq_Abs_complex 1);
   7.806 +by (auto_tac (claset() addIs
   7.807 +    [real_sum_squares_cancel,real_sum_squares_cancel2],
   7.808 +    simpset() addsimps [complex_mod,complex_zero_def,
   7.809 +    realpow_num_two]));
   7.810 +qed "complex_mod_eq_zero_cancel";
   7.811 +Addsimps [complex_mod_eq_zero_cancel];
   7.812 +
   7.813 +Goal "cmod (complex_of_real(real (n::nat))) = real n";
   7.814 +by (Simp_tac 1);
   7.815 +qed "complex_mod_complex_of_real_of_nat";
   7.816 +Addsimps [complex_mod_complex_of_real_of_nat];
   7.817 +
   7.818 +Goal "cmod (-x) = cmod(x)";
   7.819 +by (res_inst_tac [("z","x")] eq_Abs_complex 1);
   7.820 +by (asm_simp_tac (simpset() addsimps [complex_mod,complex_minus,
   7.821 +    realpow_num_two]) 1);
   7.822 +qed "complex_mod_minus";
   7.823 +Addsimps [complex_mod_minus];
   7.824 +
   7.825 +Goal "cmod(z * cnj(z)) = cmod(z) ^ 2";
   7.826 +by (res_inst_tac [("z","z")] eq_Abs_complex 1);
   7.827 +by (asm_simp_tac (simpset() addsimps [complex_mod,complex_cnj,
   7.828 +    complex_mult, CLAIM "0 ^ 2 = (0::real)"]) 1);
   7.829 +by (simp_tac (simpset() addsimps [realpow_two_eq_mult]) 1);
   7.830 +qed "complex_mod_mult_cnj";
   7.831 +
   7.832 +Goalw [cmod_def] "cmod(Abs_complex(x,y)) ^ 2 = x ^ 2 + y ^ 2";
   7.833 +by Auto_tac;
   7.834 +qed "complex_mod_squared";
   7.835 +
   7.836 +Goalw [cmod_def]  "0 <= cmod x";
   7.837 +by (auto_tac (claset() addIs [real_sqrt_ge_zero],simpset()));
   7.838 +qed "complex_mod_ge_zero";
   7.839 +Addsimps [complex_mod_ge_zero];
   7.840 +
   7.841 +Goal "abs(cmod x) = cmod x";
   7.842 +by (auto_tac (claset() addIs [abs_eqI1],simpset()));
   7.843 +qed "abs_cmod_cancel";
   7.844 +Addsimps [abs_cmod_cancel];
   7.845 +
   7.846 +Goal "cmod(x*y) = cmod(x) * cmod(y)";
   7.847 +by (res_inst_tac [("z","x")] eq_Abs_complex 1);
   7.848 +by (res_inst_tac [("z","y")] eq_Abs_complex 1);
   7.849 +by (auto_tac (claset(),simpset() addsimps [complex_mult,
   7.850 +    complex_mod,real_sqrt_mult_distrib2 RS sym] delsimps [realpow_Suc]));
   7.851 +by (res_inst_tac [("n","1")] realpow_Suc_cancel_eq 1);
   7.852 +by (auto_tac (claset(),simpset() addsimps [realpow_num_two RS sym] 
   7.853 +    delsimps [realpow_Suc]));
   7.854 +by (auto_tac (claset(),simpset() addsimps [real_diff_def,realpow_num_two,
   7.855 +    real_add_mult_distrib2,real_add_mult_distrib] @ real_add_ac @ 
   7.856 +    real_mult_ac));
   7.857 +qed "complex_mod_mult";
   7.858 +
   7.859 +Goal "cmod(x + y) ^ 2 = cmod(x) ^ 2 + cmod(y) ^ 2 + 2 * Re(x * cnj y)";
   7.860 +by (res_inst_tac [("z","x")] eq_Abs_complex 1);
   7.861 +by (res_inst_tac [("z","y")] eq_Abs_complex 1);
   7.862 +by (auto_tac (claset(),simpset() addsimps [complex_add,
   7.863 +    complex_mod_squared,complex_mult,complex_cnj,real_diff_def] 
   7.864 +    delsimps [realpow_Suc]));
   7.865 +by (auto_tac (claset(),simpset() addsimps [real_add_mult_distrib2,
   7.866 +    real_add_mult_distrib,realpow_num_two] @ real_mult_ac @ real_add_ac));
   7.867 +qed "complex_mod_add_squared_eq";
   7.868 +
   7.869 +Goal "Re(x * cnj y) <= cmod(x * cnj y)";
   7.870 +by (res_inst_tac [("z","x")] eq_Abs_complex 1);
   7.871 +by (res_inst_tac [("z","y")] eq_Abs_complex 1);
   7.872 +by (auto_tac (claset(),simpset() addsimps [complex_mod,
   7.873 +    complex_mult,complex_cnj,real_diff_def] delsimps [realpow_Suc]));
   7.874 +qed "complex_Re_mult_cnj_le_cmod";
   7.875 +Addsimps [complex_Re_mult_cnj_le_cmod];
   7.876 +
   7.877 +Goal "Re(x * cnj y) <= cmod(x * y)";
   7.878 +by (cut_inst_tac [("x","x"),("y","y")] complex_Re_mult_cnj_le_cmod 1);
   7.879 +by (asm_full_simp_tac (simpset() addsimps [complex_mod_mult]) 1);
   7.880 +qed "complex_Re_mult_cnj_le_cmod2";
   7.881 +Addsimps [complex_Re_mult_cnj_le_cmod2];
   7.882 +
   7.883 +Goal "((x::real) + y) ^ 2 = x ^ 2 + y ^ 2 + 2 * x * y";
   7.884 +by (simp_tac (simpset() addsimps [real_add_mult_distrib,
   7.885 +    real_add_mult_distrib2,realpow_num_two]) 1);
   7.886 +qed "real_sum_squared_expand";
   7.887 +
   7.888 +Goal "cmod (x + y) ^ 2 <= (cmod(x) + cmod(y)) ^ 2";
   7.889 +by (simp_tac (simpset() addsimps [real_sum_squared_expand,
   7.890 +    complex_mod_add_squared_eq,real_mult_assoc,complex_mod_mult RS sym]) 1);
   7.891 +qed "complex_mod_triangle_squared";
   7.892 +Addsimps [complex_mod_triangle_squared];
   7.893 +
   7.894 +Goal "- cmod x <= cmod x";
   7.895 +by (rtac (complex_mod_ge_zero RSN (2,real_le_trans)) 1);
   7.896 +by (Simp_tac 1);
   7.897 +qed "complex_mod_minus_le_complex_mod";
   7.898 +Addsimps [complex_mod_minus_le_complex_mod];
   7.899 +
   7.900 +Goal "cmod (x + y) <= cmod(x) + cmod(y)";
   7.901 +by (res_inst_tac [("n","1")] realpow_increasing 1);
   7.902 +by (auto_tac (claset() addIs [(complex_mod_ge_zero RSN (2,real_le_trans))],
   7.903 +    simpset() addsimps [realpow_num_two RS sym]));
   7.904 +qed "complex_mod_triangle_ineq";
   7.905 +Addsimps [complex_mod_triangle_ineq];
   7.906 +
   7.907 +Goal "cmod(b + a) - cmod b <= cmod a";
   7.908 +by (cut_inst_tac [("x1","b"),("y1","a"),("z","-cmod b")]
   7.909 +   (complex_mod_triangle_ineq RS real_add_le_mono1) 1);
   7.910 +by (Simp_tac 1);
   7.911 +qed "complex_mod_triangle_ineq2";
   7.912 +Addsimps [complex_mod_triangle_ineq2];
   7.913 +
   7.914 +Goal "cmod (x - y) = cmod (y - x)";
   7.915 +by (res_inst_tac [("z","x")] eq_Abs_complex 1);
   7.916 +by (res_inst_tac [("z","y")] eq_Abs_complex 1);
   7.917 +by (auto_tac (claset(),simpset() addsimps [complex_diff,
   7.918 +    complex_mod,real_diff_mult_distrib2,realpow_num_two,
   7.919 +    real_diff_mult_distrib] @ real_add_ac @ real_mult_ac));
   7.920 +qed "complex_mod_diff_commute";
   7.921 +
   7.922 +Goal "[| cmod x < r; cmod y < s |] ==> cmod (x + y) < r + s";
   7.923 +by (auto_tac (claset() addIs [order_le_less_trans,
   7.924 +    complex_mod_triangle_ineq],simpset()));
   7.925 +qed "complex_mod_add_less";
   7.926 +
   7.927 +Goal "[| cmod x < r; cmod y < s |] ==> cmod (x * y) < r * s";
   7.928 +by (auto_tac (claset() addIs [real_mult_less_mono'],simpset()     
   7.929 +    addsimps [complex_mod_mult]));
   7.930 +qed "complex_mod_mult_less";
   7.931 +
   7.932 +goal Complex.thy "cmod(a) - cmod(b) <= cmod(a + b)";
   7.933 +by (res_inst_tac [("R1.0","cmod(a)"),("R2.0","cmod(b)")]
   7.934 +    real_linear_less2 1);
   7.935 +by Auto_tac;
   7.936 +by (dtac (ARITH_PROVE "a < b ==> a - (b::real) < 0") 1);
   7.937 +by (rtac real_le_trans 1 THEN rtac order_less_imp_le 1);
   7.938 +by Auto_tac;
   7.939 +by (dtac (ARITH_PROVE "a < b ==> 0 < (b::real) - a") 1);
   7.940 +by (rtac (ARITH_PROVE "a  <= b + c ==> a - c <= (b::real)") 1);
   7.941 +by (rtac (complex_mod_minus RS subst) 1);
   7.942 +by (rtac real_le_trans 1);
   7.943 +by (rtac complex_mod_triangle_ineq 2);
   7.944 +by (auto_tac (claset(),simpset() addsimps complex_add_ac));
   7.945 +qed "complex_mod_diff_ineq";
   7.946 +Addsimps [complex_mod_diff_ineq];
   7.947 +
   7.948 +Goal "Re z <= cmod z";
   7.949 +by (res_inst_tac [("z","z")] eq_Abs_complex 1);
   7.950 +by (auto_tac (claset(),simpset() addsimps [complex_mod]
   7.951 +    delsimps [realpow_Suc]));
   7.952 +qed "complex_Re_le_cmod";
   7.953 +Addsimps [complex_Re_le_cmod];
   7.954 +
   7.955 +Goal "z ~= 0 ==> 0 < cmod z";
   7.956 +by (cut_inst_tac [("x","z")] complex_mod_ge_zero 1);
   7.957 +by (dtac order_le_imp_less_or_eq 1);
   7.958 +by Auto_tac;
   7.959 +qed "complex_mod_gt_zero";
   7.960 +
   7.961 +
   7.962 +(*---------------------------------------------------------------------------*)
   7.963 +(*                       a few more theorems                                 *)
   7.964 +(*---------------------------------------------------------------------------*)
   7.965 +
   7.966 +Goal "cmod(x ^ n) = cmod(x) ^ n";
   7.967 +by (induct_tac "n" 1);
   7.968 +by (auto_tac (claset(),simpset() addsimps [complex_mod_mult]));
   7.969 +qed "complex_mod_complexpow";
   7.970 +
   7.971 +Goal "(-x::complex) ^ n = (if even n then (x ^ n) else -(x ^ n))";
   7.972 +by (induct_tac "n" 1);
   7.973 +by Auto_tac;
   7.974 +qed "complexpow_minus";
   7.975 +
   7.976 +Goal "inverse (-x) = - inverse (x::complex)";
   7.977 +by (res_inst_tac [("z","x")] eq_Abs_complex 1);
   7.978 +by (asm_simp_tac (simpset() addsimps [complex_inverse,complex_minus,
   7.979 +    realpow_num_two]) 1);
   7.980 +qed "complex_inverse_minus";
   7.981 +
   7.982 +Goalw [complex_divide_def] "x / (1::complex) = x";
   7.983 +by (Simp_tac 1);
   7.984 +qed "complex_divide_one";
   7.985 +Addsimps [complex_divide_one];
   7.986 +
   7.987 +Goal "cmod(inverse x) = inverse(cmod x)";
   7.988 +by (complex_div_undefined_case_tac "x=0" 1);
   7.989 +by (res_inst_tac [("c1","cmod x")] (real_mult_left_cancel RS iffD1) 1);
   7.990 +by (auto_tac (claset(),simpset() addsimps [complex_mod_mult RS sym]));
   7.991 +qed "complex_mod_inverse";
   7.992 +
   7.993 +Goalw [complex_divide_def,real_divide_def]
   7.994 +      "cmod(x/y) = cmod(x)/(cmod y)";
   7.995 +by (auto_tac (claset(),simpset() addsimps [complex_mod_mult,
   7.996 +    complex_mod_inverse]));
   7.997 +qed "complex_mod_divide";
   7.998 +
   7.999 +Goalw [complex_divide_def]  
  7.1000 +      "inverse(x/y) = y/(x::complex)";
  7.1001 +by (auto_tac (claset(),simpset() addsimps [complex_inverse_distrib,
  7.1002 +    complex_mult_commute]));
  7.1003 +qed "complex_inverse_divide";
  7.1004 +Addsimps [complex_inverse_divide];
  7.1005 +
  7.1006 +Goal "((r::complex) * s) ^ n = (r ^ n) * (s ^ n)";
  7.1007 +by (induct_tac "n" 1);
  7.1008 +by (auto_tac (claset(),simpset() addsimps complex_mult_ac));
  7.1009 +qed "complexpow_mult";
  7.1010 +
  7.1011 +(*---------------------------------------------------------------------------*)
  7.1012 +(*                       More exponentiation                                 *)
  7.1013 +(*---------------------------------------------------------------------------*)
  7.1014 +
  7.1015 +Goal "(0::complex) ^ (Suc n) = 0";
  7.1016 +by (Auto_tac);
  7.1017 +qed "complexpow_zero";
  7.1018 +Addsimps [complexpow_zero];
  7.1019 +
  7.1020 +Goal "r ~= (0::complex) --> r ^ n ~= 0";
  7.1021 +by (induct_tac "n" 1);
  7.1022 +by (auto_tac (claset(),simpset() addsimps [complex_mult_not_zero]));
  7.1023 +qed_spec_mp "complexpow_not_zero";
  7.1024 +Addsimps [complexpow_not_zero];
  7.1025 +AddIs [complexpow_not_zero];
  7.1026 +
  7.1027 +Goal "r ^ n = (0::complex) ==> r = 0";
  7.1028 +by (blast_tac (claset() addIs [ccontr] 
  7.1029 +    addDs [complexpow_not_zero]) 1);
  7.1030 +qed "complexpow_zero_zero";
  7.1031 +
  7.1032 +Goalw [i_def] "ii ^ 2 = -(1::complex)";
  7.1033 +by (auto_tac (claset(),simpset() addsimps 
  7.1034 +    [complex_mult,complex_one_def,complex_minus,realpow_num_two]));
  7.1035 +qed "complexpow_i_squared";
  7.1036 +Addsimps [complexpow_i_squared];
  7.1037 +
  7.1038 +Goalw [i_def,complex_zero_def] "ii ~= 0";
  7.1039 +by Auto_tac;
  7.1040 +qed "complex_i_not_zero";
  7.1041 +Addsimps [complex_i_not_zero];
  7.1042 +
  7.1043 +Goal "x * y ~= (0::complex) ==> x ~= 0";
  7.1044 +by Auto_tac;
  7.1045 +qed "complex_mult_eq_zero_cancel1";
  7.1046 +
  7.1047 +Goal "x * y ~= 0 ==> y ~= (0::complex)";
  7.1048 +by Auto_tac;
  7.1049 +qed "complex_mult_eq_zero_cancel2";
  7.1050 +
  7.1051 +Goal "(x * y ~= 0) = (x ~= 0 & y ~= (0::complex))";
  7.1052 +by Auto_tac;
  7.1053 +qed "complex_mult_not_eq_zero_iff";
  7.1054 +AddIffs [complex_mult_not_eq_zero_iff];
  7.1055 +
  7.1056 +Goal "inverse ((r::complex) ^ n) = (inverse r) ^ n";
  7.1057 +by (induct_tac "n" 1);
  7.1058 +by (auto_tac (claset(), simpset() addsimps [complex_inverse_distrib]));
  7.1059 +qed "complexpow_inverse";
  7.1060 +
  7.1061 +(*---------------------------------------------------------------------------*)
  7.1062 +(* sgn                                                                       *)
  7.1063 +(*---------------------------------------------------------------------------*)
  7.1064 +
  7.1065 +Goalw [sgn_def] "sgn 0 = 0";
  7.1066 +by (Simp_tac 1);
  7.1067 +qed "sgn_zero";
  7.1068 +Addsimps[sgn_zero];
  7.1069 +
  7.1070 +Goalw [sgn_def] "sgn 1 = 1";
  7.1071 +by (Simp_tac 1);
  7.1072 +qed "sgn_one";
  7.1073 +Addsimps [sgn_one];
  7.1074 +
  7.1075 +Goalw [sgn_def] "sgn (-z) = - sgn(z)";
  7.1076 +by Auto_tac;
  7.1077 +qed "sgn_minus";
  7.1078 +
  7.1079 +Goalw [sgn_def] 
  7.1080 +    "sgn z = z / complex_of_real (cmod z)";
  7.1081 +by (Simp_tac 1);
  7.1082 +qed "sgn_eq";
  7.1083 +
  7.1084 +Goal "EX x y. z = complex_of_real(x) + ii * complex_of_real(y)";
  7.1085 +by (res_inst_tac [("z","z")] eq_Abs_complex 1);
  7.1086 +by (auto_tac (claset(),simpset() addsimps [complex_of_real_def,
  7.1087 +    i_def,complex_mult,complex_add]));
  7.1088 +qed "complex_split";
  7.1089 +
  7.1090 +Goal "Re(complex_of_real(x) + ii * complex_of_real(y)) = x";
  7.1091 +by (auto_tac (claset(),simpset() addsimps [complex_of_real_def,
  7.1092 +    i_def,complex_mult,complex_add]));
  7.1093 +qed "Re_complex_i";
  7.1094 +Addsimps [Re_complex_i];
  7.1095 +
  7.1096 +Goal "Im(complex_of_real(x) + ii * complex_of_real(y)) = y";
  7.1097 +by (auto_tac (claset(),simpset() addsimps [complex_of_real_def,
  7.1098 +    i_def,complex_mult,complex_add]));
  7.1099 +qed "Im_complex_i";
  7.1100 +Addsimps [Im_complex_i];
  7.1101 +
  7.1102 +Goalw [i_def,complex_of_real_def] "ii * ii = complex_of_real (-1)";
  7.1103 +by (auto_tac (claset(),simpset() addsimps [complex_mult,complex_add]));
  7.1104 +qed "i_mult_eq";
  7.1105 +
  7.1106 +Goalw [i_def,complex_one_def] "ii * ii = -(1::complex)";
  7.1107 +by (simp_tac (simpset() addsimps [complex_mult,complex_minus]) 1);
  7.1108 +qed "i_mult_eq2";
  7.1109 +Addsimps [i_mult_eq2];
  7.1110 +
  7.1111 +Goal "cmod (complex_of_real(x) + ii * complex_of_real(y)) = \
  7.1112 +\     sqrt (x ^ 2 + y ^ 2)";
  7.1113 +by (auto_tac (claset(),simpset() addsimps [complex_mult,complex_add,
  7.1114 +    i_def,complex_of_real_def,cmod_def]));
  7.1115 +qed "cmod_i";
  7.1116 +
  7.1117 +Goalw [complex_of_real_def,i_def] 
  7.1118 +     "complex_of_real xa + ii * complex_of_real ya = \
  7.1119 +\     complex_of_real xb + ii * complex_of_real yb \
  7.1120 +\      ==> xa = xb";
  7.1121 +by (auto_tac (claset(),simpset() addsimps [complex_mult,complex_add]));
  7.1122 +qed "complex_eq_Re_eq";
  7.1123 +
  7.1124 +Goalw [complex_of_real_def,i_def] 
  7.1125 +     "complex_of_real xa + ii * complex_of_real ya = \
  7.1126 +\     complex_of_real xb + ii * complex_of_real yb \
  7.1127 +\      ==> ya = yb";
  7.1128 +by (auto_tac (claset(),simpset() addsimps [complex_mult,complex_add]));
  7.1129 +qed "complex_eq_Im_eq";
  7.1130 +
  7.1131 +Goal "(complex_of_real xa + ii * complex_of_real ya = \
  7.1132 +\      complex_of_real xb + ii * complex_of_real yb) = ((xa = xb) & (ya = yb))";
  7.1133 +by (auto_tac (claset() addIs [complex_eq_Im_eq,complex_eq_Re_eq],simpset()));
  7.1134 +qed "complex_eq_cancel_iff";
  7.1135 +AddIffs [complex_eq_cancel_iff];
  7.1136 +
  7.1137 +Goal "(complex_of_real xa + complex_of_real ya * ii = \
  7.1138 +\      complex_of_real xb + complex_of_real yb * ii ) = ((xa = xb) & (ya = yb))";
  7.1139 +by (auto_tac (claset(),simpset() addsimps [complex_mult_commute]));
  7.1140 +qed "complex_eq_cancel_iffA";
  7.1141 +AddIffs [complex_eq_cancel_iffA];
  7.1142 +
  7.1143 +Goal "(complex_of_real xa + complex_of_real ya * ii = \
  7.1144 +\      complex_of_real xb + ii * complex_of_real yb) = ((xa = xb) & (ya = yb))";
  7.1145 +by (auto_tac (claset(),simpset() addsimps [complex_mult_commute]));
  7.1146 +qed "complex_eq_cancel_iffB";
  7.1147 +AddIffs [complex_eq_cancel_iffB];
  7.1148 +
  7.1149 +Goal "(complex_of_real xa + ii * complex_of_real ya  = \
  7.1150 +\      complex_of_real xb + complex_of_real yb * ii) = ((xa = xb) & (ya = yb))";
  7.1151 +by (auto_tac (claset(),simpset() addsimps [complex_mult_commute]));
  7.1152 +qed "complex_eq_cancel_iffC";
  7.1153 +AddIffs [complex_eq_cancel_iffC];
  7.1154 +
  7.1155 +Goal"(complex_of_real x + ii * complex_of_real y = \
  7.1156 +\     complex_of_real xa) = (x = xa & y = 0)";
  7.1157 +by (cut_inst_tac [("xa","x"),("ya","y"),("xb","xa"),("yb","0")]  
  7.1158 +    complex_eq_cancel_iff 1);
  7.1159 +by (asm_full_simp_tac (simpset() delsimps [complex_eq_cancel_iff]) 1);
  7.1160 +qed "complex_eq_cancel_iff2";
  7.1161 +Addsimps [complex_eq_cancel_iff2];
  7.1162 +
  7.1163 +Goal"(complex_of_real x + complex_of_real y * ii = \
  7.1164 +\     complex_of_real xa) = (x = xa & y = 0)";
  7.1165 +by (auto_tac (claset(),simpset() addsimps [complex_mult_commute]));
  7.1166 +qed "complex_eq_cancel_iff2a";
  7.1167 +Addsimps [complex_eq_cancel_iff2a];
  7.1168 +
  7.1169 +Goal "(complex_of_real x + ii * complex_of_real y = \
  7.1170 +\     ii * complex_of_real ya) = (x = 0 & y = ya)";
  7.1171 +by (cut_inst_tac [("xa","x"),("ya","y"),("xb","0"),("yb","ya")]  
  7.1172 +    complex_eq_cancel_iff 1);
  7.1173 +by (asm_full_simp_tac (simpset() delsimps [complex_eq_cancel_iff]) 1);
  7.1174 +qed "complex_eq_cancel_iff3";
  7.1175 +Addsimps [complex_eq_cancel_iff3];
  7.1176 +
  7.1177 +Goal "(complex_of_real x + complex_of_real y * ii = \
  7.1178 +\     ii * complex_of_real ya) = (x = 0 & y = ya)";
  7.1179 +by (auto_tac (claset(),simpset() addsimps [complex_mult_commute]));
  7.1180 +qed "complex_eq_cancel_iff3a";
  7.1181 +Addsimps [complex_eq_cancel_iff3a];
  7.1182 +
  7.1183 +Goalw [complex_of_real_def,i_def,complex_zero_def] 
  7.1184 +     "complex_of_real x + ii * complex_of_real y = 0 \
  7.1185 +\     ==> x = 0";
  7.1186 +by (auto_tac (claset(),simpset() addsimps [complex_mult,complex_add]));
  7.1187 +qed "complex_split_Re_zero";
  7.1188 +
  7.1189 +Goalw [complex_of_real_def,i_def,complex_zero_def] 
  7.1190 +     "complex_of_real x + ii * complex_of_real y = 0 \
  7.1191 +\     ==> y = 0";
  7.1192 +by (auto_tac (claset(),simpset() addsimps [complex_mult,complex_add]));
  7.1193 +qed "complex_split_Im_zero";
  7.1194 +
  7.1195 +Goalw [sgn_def,complex_divide_def] 
  7.1196 +      "Re(sgn z) = Re(z)/cmod z";
  7.1197 +by (res_inst_tac [("z","z")] eq_Abs_complex 1);
  7.1198 +by (auto_tac (claset(),simpset() addsimps [complex_of_real_inverse RS sym]));
  7.1199 +by (auto_tac (claset(),simpset() addsimps [complex_of_real_def,
  7.1200 +    complex_mult,real_divide_def]));
  7.1201 +qed "Re_sgn";
  7.1202 +Addsimps [Re_sgn];
  7.1203 +
  7.1204 +Goalw [sgn_def,complex_divide_def] 
  7.1205 +      "Im(sgn z) = Im(z)/cmod z";
  7.1206 +by (res_inst_tac [("z","z")] eq_Abs_complex 1);
  7.1207 +by (auto_tac (claset(),simpset() addsimps [complex_of_real_inverse RS sym]));
  7.1208 +by (auto_tac (claset(),simpset() addsimps [complex_of_real_def,
  7.1209 +    complex_mult,real_divide_def]));
  7.1210 +qed "Im_sgn";
  7.1211 +Addsimps [Im_sgn];
  7.1212 +
  7.1213 +Goalw [complex_of_real_def,i_def] 
  7.1214 +     "inverse(complex_of_real x + ii * complex_of_real y) = \
  7.1215 +\     complex_of_real(x/(x ^ 2 + y ^ 2)) - \
  7.1216 +\     ii * complex_of_real(y/(x ^ 2 + y ^ 2))";
  7.1217 +by (auto_tac (claset(),simpset() addsimps [complex_mult,complex_add,
  7.1218 +    complex_diff_def,complex_minus,complex_inverse,real_divide_def]));
  7.1219 +qed "complex_inverse_complex_split";
  7.1220 +
  7.1221 +(*----------------------------------------------------------------------------*)
  7.1222 +(* Many of the theorems below need to be moved elsewhere e.g. Transc.ML. Also *)
  7.1223 +(* many of the theorems are not used - so should they be kept?                *)
  7.1224 +(*----------------------------------------------------------------------------*)
  7.1225 +
  7.1226 +Goalw [i_def,complex_of_real_def]
  7.1227 +    "Re (ii * complex_of_real y) = 0";
  7.1228 +by (auto_tac (claset(),simpset() addsimps [complex_mult]));
  7.1229 +qed "Re_mult_i_eq";
  7.1230 +Addsimps [Re_mult_i_eq];
  7.1231 +
  7.1232 +Goalw [i_def,complex_of_real_def]
  7.1233 +    "Im (ii * complex_of_real y) = y";
  7.1234 +by (auto_tac (claset(),simpset() addsimps [complex_mult]));
  7.1235 +qed "Im_mult_i_eq";
  7.1236 +Addsimps [Im_mult_i_eq];
  7.1237 +
  7.1238 +Goalw [i_def,complex_of_real_def]
  7.1239 +    "cmod (ii * complex_of_real y) = abs y";
  7.1240 +by (auto_tac (claset(),simpset() addsimps [complex_mult,
  7.1241 +    complex_mod,realpow_num_two]));
  7.1242 +qed "complex_mod_mult_i";
  7.1243 +Addsimps [complex_mod_mult_i];
  7.1244 +
  7.1245 +Goalw [arg_def] 
  7.1246 +   "0 < y ==> cos (arg(ii * complex_of_real y)) = 0";
  7.1247 +by (auto_tac (claset(),simpset() addsimps [abs_eqI2]));
  7.1248 +by (res_inst_tac [("a","pi/2")] someI2 1);
  7.1249 +by Auto_tac;
  7.1250 +by (res_inst_tac [("R2.0","0")] real_less_trans 1);
  7.1251 +by Auto_tac;
  7.1252 +qed "cos_arg_i_mult_zero";
  7.1253 +Addsimps [cos_arg_i_mult_zero];
  7.1254 +
  7.1255 +Goalw [arg_def] 
  7.1256 +   "y < 0 ==> cos (arg(ii * complex_of_real y)) = 0";
  7.1257 +by (auto_tac (claset(),simpset() addsimps [abs_minus_eqI2]));
  7.1258 +by (res_inst_tac [("a","- pi/2")] someI2 1);
  7.1259 +by Auto_tac;
  7.1260 +by (res_inst_tac [("j","0")] real_le_trans 1);
  7.1261 +by Auto_tac;
  7.1262 +qed "cos_arg_i_mult_zero2";
  7.1263 +Addsimps [cos_arg_i_mult_zero2];
  7.1264 +
  7.1265 +Goalw [complex_zero_def,complex_of_real_def] 
  7.1266 +      "(complex_of_real y ~= 0) = (y ~= 0)";
  7.1267 +by Auto_tac;
  7.1268 +qed "complex_of_real_not_zero_iff";
  7.1269 +Addsimps [complex_of_real_not_zero_iff];
  7.1270 +
  7.1271 +Goal "(complex_of_real y = 0) = (y = 0)";
  7.1272 +by Auto_tac;
  7.1273 +by (rtac ccontr 1 THEN dtac (complex_of_real_not_zero_iff RS iffD2) 1);
  7.1274 +by (Asm_full_simp_tac 1);
  7.1275 +qed "complex_of_real_zero_iff";
  7.1276 +Addsimps [complex_of_real_zero_iff];
  7.1277 +
  7.1278 +Goal "y ~= 0 ==> cos (arg(ii * complex_of_real y)) = 0";
  7.1279 +by (cut_inst_tac [("R1.0","y"),("R2.0","0")] real_linear 1);
  7.1280 +by Auto_tac;
  7.1281 +qed "cos_arg_i_mult_zero3";
  7.1282 +Addsimps [cos_arg_i_mult_zero3];
  7.1283 +
  7.1284 +(*---------------------------------------------------------------------------*)
  7.1285 +(* Finally! Polar form for complex numbers                                   *) 
  7.1286 +(*---------------------------------------------------------------------------*)
  7.1287 +
  7.1288 +Goal "EX r a. z = complex_of_real r * \
  7.1289 +\     (complex_of_real(cos a) + ii * complex_of_real(sin a))";
  7.1290 +by (cut_inst_tac [("z","z")] complex_split 1);
  7.1291 +by (auto_tac (claset(),simpset() addsimps [polar_Ex,
  7.1292 +    complex_add_mult_distrib2,complex_of_real_mult] @ complex_mult_ac));
  7.1293 +qed "complex_split_polar";
  7.1294 +
  7.1295 +Goalw [rcis_def,cis_def] "EX r a. z = rcis r a";
  7.1296 +by (rtac complex_split_polar 1);
  7.1297 +qed "rcis_Ex";
  7.1298 +
  7.1299 +Goal "Re(complex_of_real r * \
  7.1300 +\     (complex_of_real(cos a) + ii * complex_of_real(sin a))) = r * cos a";
  7.1301 +by (auto_tac (claset(),simpset() addsimps [complex_add_mult_distrib2,
  7.1302 +    complex_of_real_mult] @ complex_mult_ac));
  7.1303 +qed "Re_complex_polar";
  7.1304 +Addsimps [Re_complex_polar];
  7.1305 +
  7.1306 +Goalw [rcis_def,cis_def] "Re(rcis r a) = r * cos a";
  7.1307 +by Auto_tac;
  7.1308 +qed "Re_rcis";
  7.1309 +Addsimps [Re_rcis];
  7.1310 +
  7.1311 +Goal "Im(complex_of_real r * \
  7.1312 +\     (complex_of_real(cos a) + ii * complex_of_real(sin a))) = r * sin a";
  7.1313 +by (auto_tac (claset(),simpset() addsimps [complex_add_mult_distrib2,
  7.1314 +    complex_of_real_mult] @ complex_mult_ac));
  7.1315 +qed "Im_complex_polar";
  7.1316 +Addsimps [Im_complex_polar];
  7.1317 +
  7.1318 +Goalw [rcis_def,cis_def] "Im(rcis r a) = r * sin a";
  7.1319 +by Auto_tac;
  7.1320 +qed "Im_rcis";
  7.1321 +Addsimps [Im_rcis];
  7.1322 +
  7.1323 +Goal "cmod (complex_of_real r * \
  7.1324 +\     (complex_of_real(cos a) + ii * complex_of_real(sin a))) = abs r";
  7.1325 +by (auto_tac (claset(),simpset() addsimps [complex_add_mult_distrib2,
  7.1326 +    cmod_i,complex_of_real_mult,real_add_mult_distrib2
  7.1327 +    RS sym,realpow_mult]  @ complex_mult_ac@ real_mult_ac 
  7.1328 +    delsimps [realpow_Suc]));
  7.1329 +qed "complex_mod_complex_polar";
  7.1330 +Addsimps [complex_mod_complex_polar];
  7.1331 +
  7.1332 +Goalw [rcis_def,cis_def] "cmod(rcis r a) = abs r";
  7.1333 +by Auto_tac;
  7.1334 +qed "complex_mod_rcis";
  7.1335 +Addsimps [complex_mod_rcis];
  7.1336 +
  7.1337 +Goalw [cmod_def] "cmod z = sqrt (Re (z * cnj z))";
  7.1338 +by (rtac (real_sqrt_eq_iff RS iffD2) 1);
  7.1339 +by (auto_tac (claset(),simpset() addsimps [complex_mult_cnj]));
  7.1340 +qed "complex_mod_sqrt_Re_mult_cnj";
  7.1341 +
  7.1342 +Goal "Re(cnj z) = Re z";
  7.1343 +by (res_inst_tac [("z","z")] eq_Abs_complex 1);
  7.1344 +by (auto_tac (claset(),simpset() addsimps [complex_cnj]));
  7.1345 +qed "complex_Re_cnj";
  7.1346 +Addsimps [complex_Re_cnj];
  7.1347 +
  7.1348 +Goal "Im(cnj z) = - Im z";
  7.1349 +by (res_inst_tac [("z","z")] eq_Abs_complex 1);
  7.1350 +by (auto_tac (claset(),simpset() addsimps [complex_cnj]));
  7.1351 +qed "complex_Im_cnj";
  7.1352 +Addsimps [complex_Im_cnj];
  7.1353 +
  7.1354 +Goal "Im (z * cnj z) = 0";
  7.1355 +by (res_inst_tac [("z","z")] eq_Abs_complex 1);
  7.1356 +by (auto_tac (claset(),simpset() addsimps [complex_cnj,complex_mult]));
  7.1357 +qed "complex_In_mult_cnj_zero";
  7.1358 +Addsimps [complex_In_mult_cnj_zero];
  7.1359 +
  7.1360 +Goal "[| Im w = 0; Im z = 0 |] ==> Re(w * z) = Re(w) * Re(z)";
  7.1361 +by (res_inst_tac [("z","z")] eq_Abs_complex 1);
  7.1362 +by (res_inst_tac [("z","w")] eq_Abs_complex 1);
  7.1363 +by (auto_tac (claset(),simpset() addsimps [complex_mult]));
  7.1364 +qed "complex_Re_mult";
  7.1365 +
  7.1366 +Goalw [complex_of_real_def] "Re (z * complex_of_real c) = Re(z) * c";
  7.1367 +by (res_inst_tac [("z","z")] eq_Abs_complex 1);
  7.1368 +by (auto_tac (claset(),simpset() addsimps [complex_mult]));
  7.1369 +qed "complex_Re_mult_complex_of_real";
  7.1370 +Addsimps [complex_Re_mult_complex_of_real];
  7.1371 +
  7.1372 +Goalw [complex_of_real_def] "Im (z * complex_of_real c) = Im(z) * c";
  7.1373 +by (res_inst_tac [("z","z")] eq_Abs_complex 1);
  7.1374 +by (auto_tac (claset(),simpset() addsimps [complex_mult]));
  7.1375 +qed "complex_Im_mult_complex_of_real";
  7.1376 +Addsimps [complex_Im_mult_complex_of_real];
  7.1377 +
  7.1378 +Goalw [complex_of_real_def] "Re (complex_of_real c * z) = c * Re(z)";
  7.1379 +by (res_inst_tac [("z","z")] eq_Abs_complex 1);
  7.1380 +by (auto_tac (claset(),simpset() addsimps [complex_mult]));
  7.1381 +qed "complex_Re_mult_complex_of_real2";
  7.1382 +Addsimps [complex_Re_mult_complex_of_real2];
  7.1383 +
  7.1384 +Goalw [complex_of_real_def] "Im (complex_of_real c * z) = c * Im(z)";
  7.1385 +by (res_inst_tac [("z","z")] eq_Abs_complex 1);
  7.1386 +by (auto_tac (claset(),simpset() addsimps [complex_mult]));
  7.1387 +qed "complex_Im_mult_complex_of_real2";
  7.1388 +Addsimps [complex_Im_mult_complex_of_real2];
  7.1389 +
  7.1390 +(*---------------------------------------------------------------------------*)
  7.1391 +(*  (r1 * cis a) * (r2 * cis b) = r1 * r2 * cis (a + b)                      *) 
  7.1392 +(*---------------------------------------------------------------------------*)
  7.1393 +
  7.1394 +Goalw [rcis_def] "cis a = rcis 1 a";
  7.1395 +by (Simp_tac 1);
  7.1396 +qed "cis_rcis_eq";
  7.1397 +
  7.1398 +Goalw [rcis_def,cis_def] 
  7.1399 +  "rcis r1 a * rcis r2 b = rcis (r1*r2) (a + b)";
  7.1400 +by (auto_tac (claset(),simpset() addsimps [cos_add,sin_add,
  7.1401 +    complex_add_mult_distrib2,complex_add_mult_distrib]
  7.1402 +     @ complex_mult_ac @ complex_add_ac));
  7.1403 +by (auto_tac (claset(),simpset() addsimps [complex_add_mult_distrib2 RS sym,
  7.1404 +    complex_mult_assoc RS sym,complex_of_real_mult,complex_of_real_add,
  7.1405 +    complex_add_assoc RS sym,i_mult_eq] delsimps [i_mult_eq2]));
  7.1406 +by (auto_tac (claset(),simpset() addsimps complex_add_ac));
  7.1407 +by (auto_tac (claset(),simpset() addsimps [complex_add_assoc RS sym,
  7.1408 +    complex_of_real_add,real_add_mult_distrib2,
  7.1409 +    real_diff_def] @ real_mult_ac @ real_add_ac));
  7.1410 +qed "rcis_mult";
  7.1411 +
  7.1412 +Goal "cis a * cis b = cis (a + b)";
  7.1413 +by (simp_tac (simpset() addsimps [cis_rcis_eq,rcis_mult]) 1);
  7.1414 +qed "cis_mult";
  7.1415 +
  7.1416 +Goalw [cis_def] "cis 0 = 1";
  7.1417 +by Auto_tac;
  7.1418 +qed "cis_zero";
  7.1419 +Addsimps [cis_zero];
  7.1420 +
  7.1421 +Goalw [cis_def] "cis 0 = complex_of_real 1";
  7.1422 +by Auto_tac;
  7.1423 +qed "cis_zero2";
  7.1424 +Addsimps [cis_zero2];
  7.1425 +
  7.1426 +Goalw [rcis_def] "rcis 0 a = 0";
  7.1427 +by (Simp_tac 1);
  7.1428 +qed "rcis_zero_mod";
  7.1429 +Addsimps [rcis_zero_mod];
  7.1430 +
  7.1431 +Goalw [rcis_def] "rcis r 0 = complex_of_real r";
  7.1432 +by (Simp_tac 1);
  7.1433 +qed "rcis_zero_arg";
  7.1434 +Addsimps [rcis_zero_arg];
  7.1435 +
  7.1436 +Goalw [complex_of_real_def,complex_one_def] 
  7.1437 +   "complex_of_real (-(1::real)) = -(1::complex)";
  7.1438 +by (simp_tac (simpset() addsimps [complex_minus]) 1);
  7.1439 +qed "complex_of_real_minus_one";
  7.1440 +
  7.1441 +Goal "ii * (ii * x) = - x";
  7.1442 +by (simp_tac (simpset() addsimps [complex_mult_assoc RS sym]) 1);
  7.1443 +qed "complex_i_mult_minus";
  7.1444 +Addsimps [complex_i_mult_minus];
  7.1445 +
  7.1446 +Goal "ii * ii * x = - x";
  7.1447 +by (Simp_tac 1);
  7.1448 +qed "complex_i_mult_minus2";
  7.1449 +Addsimps [complex_i_mult_minus2];
  7.1450 +
  7.1451 +Goalw [cis_def] 
  7.1452 +   "cis (real (Suc n) * a) = cis a * cis (real n * a)";
  7.1453 +by (auto_tac (claset(),simpset() addsimps [real_of_nat_Suc,
  7.1454 +    real_add_mult_distrib,cos_add,sin_add,complex_add_mult_distrib,
  7.1455 +    complex_add_mult_distrib2,complex_of_real_add,complex_of_real_mult] 
  7.1456 +    @ complex_mult_ac @ complex_add_ac));
  7.1457 +by (auto_tac (claset(),simpset() addsimps [complex_add_mult_distrib2 RS sym,
  7.1458 +    complex_mult_assoc RS sym,i_mult_eq,complex_of_real_mult,
  7.1459 +    complex_of_real_add,complex_add_assoc RS sym,complex_of_real_minus
  7.1460 +    RS sym,real_diff_def] @ real_mult_ac delsimps [i_mult_eq2]));
  7.1461 +qed "cis_real_of_nat_Suc_mult";
  7.1462 +
  7.1463 +Goal "(cis a) ^ n = cis (real n * a)";
  7.1464 +by (induct_tac "n" 1);
  7.1465 +by (auto_tac (claset(),simpset() addsimps [cis_real_of_nat_Suc_mult]));
  7.1466 +qed "DeMoivre";
  7.1467 +
  7.1468 +Goalw [rcis_def] 
  7.1469 +   "(rcis r a) ^ n = rcis (r ^ n) (real n * a)";
  7.1470 +by (auto_tac (claset(),simpset() addsimps [complexpow_mult,
  7.1471 +    DeMoivre,complex_of_real_pow]));
  7.1472 +qed "DeMoivre2";
  7.1473 +
  7.1474 +Goalw [cis_def] "inverse(cis a) = cis (-a)";
  7.1475 +by (auto_tac (claset(),simpset() addsimps [complex_inverse_complex_split,
  7.1476 +    complex_of_real_minus,complex_diff_def]));
  7.1477 +qed "cis_inverse";
  7.1478 +Addsimps [cis_inverse];
  7.1479 +
  7.1480 +Goal "inverse(rcis r a) = rcis (1/r) (-a)";
  7.1481 +by (real_div_undefined_case_tac "r=0" 1);
  7.1482 +by (simp_tac (simpset() addsimps [rename_numerals DIVISION_BY_ZERO,
  7.1483 +    COMPLEX_INVERSE_ZERO]) 1);
  7.1484 +by (auto_tac (claset(),simpset() addsimps [complex_inverse_complex_split,
  7.1485 +    complex_add_mult_distrib2,complex_of_real_mult,rcis_def,cis_def,
  7.1486 +    realpow_num_two] @ complex_mult_ac @ real_mult_ac));
  7.1487 +by (auto_tac (claset(),simpset() addsimps [real_add_mult_distrib2 RS sym,
  7.1488 +    complex_of_real_minus,complex_diff_def]));
  7.1489 +qed "rcis_inverse";
  7.1490 +
  7.1491 +Goalw [complex_divide_def] "cis a / cis b = cis (a - b)";
  7.1492 +by (auto_tac (claset(),simpset() addsimps [cis_mult,real_diff_def]));
  7.1493 +qed "cis_divide";
  7.1494 +
  7.1495 +Goalw [complex_divide_def]
  7.1496 + "rcis r1 a / rcis r2 b = rcis (r1/r2) (a - b)";
  7.1497 +by (real_div_undefined_case_tac "r2=0" 1);
  7.1498 +by (simp_tac (simpset() addsimps [rename_numerals DIVISION_BY_ZERO,
  7.1499 +    COMPLEX_INVERSE_ZERO]) 1);
  7.1500 +by (auto_tac (claset(),simpset() addsimps [rcis_inverse,rcis_mult,
  7.1501 +    real_diff_def]));
  7.1502 +qed "rcis_divide";
  7.1503 +
  7.1504 +Goalw [cis_def] "Re(cis a) = cos a";
  7.1505 +by Auto_tac;
  7.1506 +qed "Re_cis";
  7.1507 +Addsimps [Re_cis];
  7.1508 +
  7.1509 +Goalw [cis_def] "Im(cis a) = sin a";
  7.1510 +by Auto_tac;
  7.1511 +qed "Im_cis";
  7.1512 +Addsimps [Im_cis];
  7.1513 +
  7.1514 +Goal "cos (real n * a) = Re(cis a ^ n)";
  7.1515 +by (auto_tac (claset(),simpset() addsimps [DeMoivre]));
  7.1516 +qed "cos_n_Re_cis_pow_n";
  7.1517 + 
  7.1518 +Goal "sin (real n * a) = Im(cis a ^ n)";
  7.1519 +by (auto_tac (claset(),simpset() addsimps [DeMoivre]));
  7.1520 +qed "sin_n_Im_cis_pow_n";
  7.1521 +
  7.1522 +Goalw [expi_def,cis_def]
  7.1523 +    "expi (ii * complex_of_real y) = \
  7.1524 +\    complex_of_real (cos y) + ii * complex_of_real (sin y)";
  7.1525 +by Auto_tac;
  7.1526 +qed "expi_Im_split";
  7.1527 +
  7.1528 +Goalw [expi_def]
  7.1529 +    "expi (ii * complex_of_real y) = cis y";
  7.1530 +by Auto_tac;
  7.1531 +qed "expi_Im_cis";
  7.1532 +
  7.1533 +Goalw [expi_def] "expi(a + b) = expi(a) * expi(b)";
  7.1534 +by (auto_tac (claset(),simpset() addsimps [complex_Re_add,exp_add,
  7.1535 +    complex_Im_add,cis_mult RS sym,complex_of_real_mult] @
  7.1536 +    complex_mult_ac));
  7.1537 +qed "expi_add";
  7.1538 +
  7.1539 +Goalw [expi_def] 
  7.1540 +     "expi(complex_of_real x + ii * complex_of_real y) = \
  7.1541 +\     complex_of_real (exp(x)) * cis y";
  7.1542 +by Auto_tac;
  7.1543 +qed "expi_complex_split";
  7.1544 +
  7.1545 +Goalw [expi_def] "expi (0::complex) = 1";
  7.1546 +by Auto_tac;
  7.1547 +qed "expi_zero";
  7.1548 +Addsimps [expi_zero];
  7.1549 +
  7.1550 +goal Complex.thy 
  7.1551 +     "Re (w * z) = Re w * Re z - Im w * Im z";
  7.1552 +by (res_inst_tac [("z","z")] eq_Abs_complex 1);
  7.1553 +by (res_inst_tac [("z","w")] eq_Abs_complex 1);
  7.1554 +by (auto_tac (claset(),simpset() addsimps [complex_mult]));
  7.1555 +qed "complex_Re_mult_eq";
  7.1556 +
  7.1557 +goal Complex.thy 
  7.1558 +     "Im (w * z) = Re w * Im z + Im w * Re z";
  7.1559 +by (res_inst_tac [("z","z")] eq_Abs_complex 1);
  7.1560 +by (res_inst_tac [("z","w")] eq_Abs_complex 1);
  7.1561 +by (auto_tac (claset(),simpset() addsimps [complex_mult]));
  7.1562 +qed "complex_Im_mult_eq";
  7.1563 +
  7.1564 +goal Complex.thy 
  7.1565 +   "EX a r. z = complex_of_real r * expi a";
  7.1566 +by (cut_inst_tac [("z","z")] rcis_Ex 1);
  7.1567 +by (auto_tac (claset(),simpset() addsimps [expi_def,rcis_def,
  7.1568 +    complex_mult_assoc RS sym,complex_of_real_mult]));
  7.1569 +by (res_inst_tac [("x","ii * complex_of_real a")] exI 1);
  7.1570 +by Auto_tac;
  7.1571 +qed "complex_expi_Ex";
  7.1572 +
  7.1573 +
  7.1574 +(****
  7.1575 +Goal "[| - pi < a; a <= pi |] ==> (-pi < a & a <= 0) | (0 <= a & a <= pi)";
  7.1576 +by Auto_tac;
  7.1577 +qed "lemma_split_interval";
  7.1578 +
  7.1579 +Goalw [arg_def] 
  7.1580 +  "[| r ~= 0; - pi < a; a <= pi |] \
  7.1581 +\  ==> arg(complex_of_real r * \
  7.1582 +\      (complex_of_real(cos a) + ii * complex_of_real(sin a))) = a";
  7.1583 +by Auto_tac;
  7.1584 +by (cut_inst_tac [("R1.0","0"),("R2.0","r")] real_linear 1);
  7.1585 +by (auto_tac (claset(),simpset() addsimps (map (full_rename_numerals thy)
  7.1586 +    [rabs_eqI2,rabs_minus_eqI2,real_minus_rinv]) @ [real_divide_def,
  7.1587 +    real_minus_mult_eq2 RS sym] @ real_mult_ac));
  7.1588 +by (auto_tac (claset(),simpset() addsimps [real_mult_assoc RS sym]));
  7.1589 +by (dtac lemma_split_interval 1 THEN Step_tac 1);
  7.1590 +****)
  7.1591 +
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/src/HOL/Complex/Complex.thy	Mon May 05 18:22:31 2003 +0200
     8.3 @@ -0,0 +1,111 @@
     8.4 +(*  Title:       Complex.thy
     8.5 +    Author:      Jacques D. Fleuriot
     8.6 +    Copyright:   2001 University of Edinburgh
     8.7 +    Description: Complex numbers
     8.8 +*)
     8.9 +
    8.10 +Complex = HLog + 
    8.11 +
    8.12 +typedef complex = "{p::(real*real). True}"
    8.13 +
    8.14 +instance
    8.15 +  complex :: {ord,zero,one,plus,minus,times,power,inverse}
    8.16 +
    8.17 +consts
    8.18 +  "ii"    :: complex        ("ii") 
    8.19 +
    8.20 +constdefs
    8.21 +
    8.22 +  (*--- real and Imaginary parts ---*)
    8.23 +  
    8.24 +  Re :: complex => real
    8.25 +  "Re(z) == fst(Rep_complex z)"
    8.26 +
    8.27 +  Im :: complex => real
    8.28 +  "Im(z) == snd(Rep_complex z)"
    8.29 +
    8.30 +  (*----------- modulus ------------*)
    8.31 +
    8.32 +  cmod :: complex => real
    8.33 +  "cmod z == sqrt(Re(z) ^ 2 + Im(z) ^ 2)"			      
    8.34 +
    8.35 +  (*----- injection from reals -----*)			   
    8.36 + 
    8.37 +  complex_of_real :: real => complex
    8.38 +  "complex_of_real r == Abs_complex(r,0::real)"
    8.39 +				    
    8.40 +  (*------- complex conjugate ------*)
    8.41 +
    8.42 +  cnj :: complex => complex
    8.43 +  "cnj z == Abs_complex(Re z, -Im z)"
    8.44 +
    8.45 +  (*------------ Argand -------------*)		       
    8.46 +
    8.47 +  sgn :: complex => complex
    8.48 +  "sgn z == z / complex_of_real(cmod z)"
    8.49 +
    8.50 +  arg :: complex => real
    8.51 +  "arg z == @a. Re(sgn z) = cos a & Im(sgn z) = sin a & -pi < a & a <= pi"
    8.52 +									  
    8.53 +defs
    8.54 +
    8.55 +  complex_zero_def
    8.56 +  "0 == Abs_complex(0::real,0)"
    8.57 +
    8.58 +  complex_one_def
    8.59 +  "1 == Abs_complex(1,0::real)"
    8.60 +
    8.61 +  (*------ imaginary unit ----------*)					 
    8.62 +			      
    8.63 +  i_def 
    8.64 +  "ii == Abs_complex(0::real,1)"
    8.65 +
    8.66 +  (*----------- negation -----------*)
    8.67 +				     
    8.68 +  complex_minus_def
    8.69 +  "- (z::complex) == Abs_complex(-Re z, -Im z)"				     
    8.70 +
    8.71 +  
    8.72 +  (*----------- inverse -----------*)
    8.73 +  complex_inverse_def
    8.74 +  "inverse (z::complex) == Abs_complex(Re(z)/(Re(z) ^ 2 + Im(z) ^ 2),
    8.75 +                            -Im(z)/(Re(z) ^ 2 + Im(z) ^ 2))"
    8.76 +
    8.77 +  complex_add_def
    8.78 +  "w + (z::complex) == Abs_complex(Re(w) + Re(z),Im(w) + Im(z))"
    8.79 +
    8.80 +  complex_diff_def
    8.81 +  "w - (z::complex) == w + -(z::complex)"
    8.82 +
    8.83 +  complex_mult_def
    8.84 +  "w * (z::complex) == Abs_complex(Re(w) * Re(z) - Im(w) * Im(z),
    8.85 +			Re(w) * Im(z) + Im(w) * Re(z))"
    8.86 +
    8.87 +
    8.88 +  (*----------- division ----------*)
    8.89 +  complex_divide_def
    8.90 +  "w / (z::complex) == w * inverse z"
    8.91 +  
    8.92 +
    8.93 +primrec
    8.94 +     complexpow_0   "z ^ 0       = complex_of_real 1"
    8.95 +     complexpow_Suc "z ^ (Suc n) = (z::complex) * (z ^ n)"
    8.96 +
    8.97 +
    8.98 +constdefs
    8.99 +
   8.100 +  (* abbreviation for (cos a + i sin a) *)
   8.101 +  cis :: real => complex
   8.102 +  "cis a == complex_of_real(cos a) + ii * complex_of_real(sin a)"
   8.103 +
   8.104 +  (* abbreviation for r*(cos a + i sin a) *)
   8.105 +  rcis :: [real, real] => complex
   8.106 +  "rcis r a == complex_of_real r * cis a"
   8.107 +
   8.108 +  (* e ^ (x + iy) *)
   8.109 +  expi :: complex => complex
   8.110 +  "expi z == complex_of_real(exp (Re z)) * cis (Im z)"
   8.111 +   
   8.112 +end
   8.113 +
   8.114 +
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/src/HOL/Complex/ComplexArith0.ML	Mon May 05 18:22:31 2003 +0200
     9.3 @@ -0,0 +1,321 @@
     9.4 +(*  Title:       ComplexArith0.ML
     9.5 +    Author:      Jacques D. Fleuriot
     9.6 +    Copyright:   2001  University of Edinburgh
     9.7 +    Description: Assorted facts that need binary literals 
     9.8 +		 Also, common factor cancellation (see e.g. HyperArith0)
     9.9 +*)
    9.10 +
    9.11 +Goal "x - - y = x + (y::complex)";
    9.12 +by (Simp_tac 1);
    9.13 +qed "real_diff_minus_eq";
    9.14 +Addsimps [real_diff_minus_eq];
    9.15 +
    9.16 +(** Division and inverse **)
    9.17 +
    9.18 +Goal "0/x = (0::complex)";
    9.19 +by (simp_tac (simpset() addsimps [complex_divide_def]) 1); 
    9.20 +qed "complex_0_divide";
    9.21 +Addsimps [complex_0_divide];
    9.22 +
    9.23 +Goalw [complex_divide_def] "x/(0::complex) = 0";
    9.24 +by (stac COMPLEX_INVERSE_ZERO 1); 
    9.25 +by (Simp_tac 1); 
    9.26 +qed "COMPLEX_DIVIDE_ZERO";
    9.27 +
    9.28 +Goal "inverse (x::complex) = 1/x";
    9.29 +by (simp_tac (simpset() addsimps [complex_divide_def]) 1); 
    9.30 +qed "complex_inverse_eq_divide";
    9.31 +
    9.32 +Goal "(inverse(x::complex) = 0) = (x = 0)";
    9.33 +by (auto_tac (claset(), 
    9.34 +              simpset() addsimps [COMPLEX_INVERSE_ZERO]));  
    9.35 +by (rtac ccontr 1); 
    9.36 +by (blast_tac (claset() addDs [complex_inverse_not_zero]) 1); 
    9.37 +qed "complex_inverse_zero_iff";
    9.38 +Addsimps [complex_inverse_zero_iff];
    9.39 +
    9.40 +Goal "(x/y = 0) = (x=0 | y=(0::complex))";
    9.41 +by (auto_tac (claset(), simpset() addsimps [complex_divide_def]));  
    9.42 +qed "complex_divide_eq_0_iff";
    9.43 +Addsimps [complex_divide_eq_0_iff];
    9.44 +
    9.45 +Goal "h ~= (0::complex) ==> h/h = 1";
    9.46 +by (asm_simp_tac 
    9.47 +    (simpset() addsimps [complex_divide_def]) 1);
    9.48 +qed "complex_divide_self_eq"; 
    9.49 +Addsimps [complex_divide_self_eq];
    9.50 +
    9.51 +bind_thm ("complex_mult_minus_right", complex_minus_mult_eq2 RS sym);
    9.52 +
    9.53 +Goal "!!k::complex. (k*m = k*n) = (k = 0 | m=n)";
    9.54 +by (case_tac "k=0" 1);
    9.55 +by (auto_tac (claset(), simpset() addsimps [complex_mult_left_cancel]));  
    9.56 +qed "complex_mult_eq_cancel1";
    9.57 +
    9.58 +Goal "!!k::complex. (m*k = n*k) = (k = 0 | m=n)";
    9.59 +by (case_tac "k=0" 1);
    9.60 +by (auto_tac (claset(), simpset() addsimps [complex_mult_right_cancel]));  
    9.61 +qed "complex_mult_eq_cancel2";
    9.62 +
    9.63 +Goal "!!k::complex. k~=0 ==> (k*m) / (k*n) = (m/n)";
    9.64 +by (asm_simp_tac
    9.65 +    (simpset() addsimps [complex_divide_def, complex_inverse_distrib]) 1); 
    9.66 +by (subgoal_tac "k * m * (inverse k * inverse n) = \
    9.67 +\                (k * inverse k) * (m * inverse n)" 1);
    9.68 +by (Asm_full_simp_tac 1);
    9.69 +by (asm_full_simp_tac (HOL_ss addsimps complex_mult_ac) 1); 
    9.70 +qed "complex_mult_div_cancel1";
    9.71 +
    9.72 +(*For ExtractCommonTerm*)
    9.73 +Goal "(k*m) / (k*n) = (if k = (0::complex) then 0 else m/n)";
    9.74 +by (simp_tac (simpset() addsimps [complex_mult_div_cancel1]) 1); 
    9.75 +qed "complex_mult_div_cancel_disj";
    9.76 +
    9.77 +
    9.78 +local
    9.79 +  open Complex_Numeral_Simprocs
    9.80 +in
    9.81 +
    9.82 +val rel_complex_number_of = [eq_complex_number_of];
    9.83 +
    9.84 +
    9.85 +structure CancelNumeralFactorCommon =
    9.86 +  struct
    9.87 +  val mk_coeff		= mk_coeff
    9.88 +  val dest_coeff	= dest_coeff 1
    9.89 +  val trans_tac         = Real_Numeral_Simprocs.trans_tac
    9.90 +  val norm_tac =  ALLGOALS (simp_tac (HOL_ss addsimps complex_minus_from_mult_simps @ mult_1s)) 
    9.91 +                  THEN ALLGOALS (simp_tac (HOL_ss addsimps bin_simps@complex_mult_minus_simps))
    9.92 +                  THEN ALLGOALS (simp_tac (HOL_ss addsimps complex_mult_ac))
    9.93 +  val numeral_simp_tac	=  ALLGOALS (simp_tac (HOL_ss addsimps rel_complex_number_of@bin_simps))
    9.94 +  val simplify_meta_eq  = simplify_meta_eq
    9.95 +  end
    9.96 +
    9.97 +
    9.98 +structure DivCancelNumeralFactor = CancelNumeralFactorFun
    9.99 + (open CancelNumeralFactorCommon
   9.100 +  val prove_conv = Bin_Simprocs.prove_conv
   9.101 +  val mk_bal   = HOLogic.mk_binop "HOL.divide"
   9.102 +  val dest_bal = HOLogic.dest_bin "HOL.divide" complexT
   9.103 +  val cancel = complex_mult_div_cancel1 RS trans
   9.104 +  val neg_exchanges = false
   9.105 +)
   9.106 +
   9.107 +
   9.108 +structure EqCancelNumeralFactor = CancelNumeralFactorFun
   9.109 + (open CancelNumeralFactorCommon
   9.110 +  val prove_conv = Bin_Simprocs.prove_conv
   9.111 +  val mk_bal   = HOLogic.mk_eq
   9.112 +  val dest_bal = HOLogic.dest_bin "op =" complexT
   9.113 +  val cancel = complex_mult_eq_cancel1 RS trans
   9.114 +  val neg_exchanges = false
   9.115 +)
   9.116 +
   9.117 +val complex_cancel_numeral_factors_relations = 
   9.118 +  map prep_simproc
   9.119 +   [("complexeq_cancel_numeral_factor",
   9.120 +     ["(l::complex) * m = n", "(l::complex) = m * n"], 
   9.121 +     EqCancelNumeralFactor.proc)];
   9.122 +
   9.123 +val complex_cancel_numeral_factors_divide = prep_simproc
   9.124 +	("complexdiv_cancel_numeral_factor", 
   9.125 +	 ["((l::complex) * m) / n", "(l::complex) / (m * n)", 
   9.126 +                     "((number_of v)::complex) / (number_of w)"], 
   9.127 +	 DivCancelNumeralFactor.proc);
   9.128 +
   9.129 +val complex_cancel_numeral_factors = 
   9.130 +    complex_cancel_numeral_factors_relations @ 
   9.131 +    [complex_cancel_numeral_factors_divide];
   9.132 +
   9.133 +end;
   9.134 +
   9.135 +
   9.136 +Addsimprocs complex_cancel_numeral_factors;
   9.137 +
   9.138 +
   9.139 +(*examples:
   9.140 +print_depth 22;
   9.141 +set timing;
   9.142 +set trace_simp;
   9.143 +fun test s = (Goal s; by (Simp_tac 1)); 
   9.144 +
   9.145 +
   9.146 +test "9*x = 12 * (y::complex)";
   9.147 +test "(9*x) / (12 * (y::complex)) = z";
   9.148 +
   9.149 +test "-99*x = 132 * (y::complex)";
   9.150 +
   9.151 +test "999*x = -396 * (y::complex)";
   9.152 +test "(999*x) / (-396 * (y::complex)) = z";
   9.153 +
   9.154 +test "-99*x = -81 * (y::complex)";
   9.155 +test "(-99*x) / (-81 * (y::complex)) = z";
   9.156 +
   9.157 +test "-2 * x = -1 * (y::complex)";
   9.158 +test "-2 * x = -(y::complex)";
   9.159 +test "(-2 * x) / (-1 * (y::complex)) = z";
   9.160 +
   9.161 +*)
   9.162 +
   9.163 +
   9.164 +(** Declarations for ExtractCommonTerm **)
   9.165 +
   9.166 +local
   9.167 +  open Complex_Numeral_Simprocs
   9.168 +in
   9.169 +
   9.170 +structure CancelFactorCommon =
   9.171 +  struct
   9.172 +  val mk_sum    	= long_mk_prod
   9.173 +  val dest_sum		= dest_prod
   9.174 +  val mk_coeff		= mk_coeff
   9.175 +  val dest_coeff	= dest_coeff
   9.176 +  val find_first	= find_first []
   9.177 +  val trans_tac         = Real_Numeral_Simprocs.trans_tac
   9.178 +  val norm_tac = ALLGOALS (simp_tac (HOL_ss addsimps mult_1s@complex_mult_ac))
   9.179 +  end;
   9.180 +
   9.181 +
   9.182 +structure EqCancelFactor = ExtractCommonTermFun
   9.183 + (open CancelFactorCommon
   9.184 +  val prove_conv = Bin_Simprocs.prove_conv
   9.185 +  val mk_bal   = HOLogic.mk_eq
   9.186 +  val dest_bal = HOLogic.dest_bin "op =" complexT
   9.187 +  val simplify_meta_eq  = cancel_simplify_meta_eq complex_mult_eq_cancel1
   9.188 +);
   9.189 +
   9.190 +
   9.191 +structure DivideCancelFactor = ExtractCommonTermFun
   9.192 + (open CancelFactorCommon
   9.193 +  val prove_conv = Bin_Simprocs.prove_conv
   9.194 +  val mk_bal   = HOLogic.mk_binop "HOL.divide"
   9.195 +  val dest_bal = HOLogic.dest_bin "HOL.divide" complexT
   9.196 +  val simplify_meta_eq  = cancel_simplify_meta_eq complex_mult_div_cancel_disj
   9.197 +);
   9.198 +
   9.199 +val complex_cancel_factor = 
   9.200 +  map prep_simproc
   9.201 +   [("complex_eq_cancel_factor", ["(l::complex) * m = n", "(l::complex) = m * n"], 
   9.202 +     EqCancelFactor.proc),
   9.203 +    ("complex_divide_cancel_factor", ["((l::complex) * m) / n", "(l::complex) / (m * n)"], 
   9.204 +     DivideCancelFactor.proc)];
   9.205 +
   9.206 +end;
   9.207 +
   9.208 +Addsimprocs complex_cancel_factor;
   9.209 +
   9.210 +
   9.211 +(*examples:
   9.212 +print_depth 22;
   9.213 +set timing;
   9.214 +set trace_simp;
   9.215 +fun test s = (Goal s; by (Asm_simp_tac 1)); 
   9.216 +
   9.217 +test "x*k = k*(y::complex)";
   9.218 +test "k = k*(y::complex)"; 
   9.219 +test "a*(b*c) = (b::complex)";
   9.220 +test "a*(b*c) = d*(b::complex)*(x*a)";
   9.221 +
   9.222 +
   9.223 +test "(x*k) / (k*(y::complex)) = (uu::complex)";
   9.224 +test "(k) / (k*(y::complex)) = (uu::complex)"; 
   9.225 +test "(a*(b*c)) / ((b::complex)) = (uu::complex)";
   9.226 +test "(a*(b*c)) / (d*(b::complex)*(x*a)) = (uu::complex)";
   9.227 +
   9.228 +(*FIXME: what do we do about this?*)
   9.229 +test "a*(b*c)/(y*z) = d*(b::complex)*(x*a)/z";
   9.230 +*)
   9.231 +
   9.232 +
   9.233 +Goal "z~=0 ==> ((x::complex) = y/z) = (x*z = y)";
   9.234 +by (subgoal_tac "(x*z = y) = (x*z = (y/z)*z)" 1);
   9.235 +by (asm_simp_tac (simpset() addsimps [complex_divide_def, complex_mult_assoc]) 2); 
   9.236 +by (etac ssubst 1);
   9.237 +by (stac complex_mult_eq_cancel2 1); 
   9.238 +by (Asm_simp_tac 1); 
   9.239 +qed "complex_eq_divide_eq";
   9.240 +Addsimps [inst "z" "number_of ?w" complex_eq_divide_eq];
   9.241 +
   9.242 +Goal "z~=0 ==> (y/z = (x::complex)) = (y = x*z)";
   9.243 +by (subgoal_tac "(y = x*z) = ((y/z)*z = x*z)" 1);
   9.244 +by (asm_simp_tac (simpset() addsimps [complex_divide_def, complex_mult_assoc]) 2); 
   9.245 +by (etac ssubst 1);
   9.246 +by (stac complex_mult_eq_cancel2 1); 
   9.247 +by (Asm_simp_tac 1); 
   9.248 +qed "complex_divide_eq_eq";
   9.249 +Addsimps [inst "z" "number_of ?w" complex_divide_eq_eq];
   9.250 +
   9.251 +Goal "(m/k = n/k) = (k = 0 | m = (n::complex))";
   9.252 +by (case_tac "k=0" 1);
   9.253 +by (asm_simp_tac (simpset() addsimps [COMPLEX_DIVIDE_ZERO]) 1); 
   9.254 +by (asm_simp_tac (simpset() addsimps [complex_divide_eq_eq, complex_eq_divide_eq, 
   9.255 +                                      complex_mult_eq_cancel2]) 1); 
   9.256 +qed "complex_divide_eq_cancel2";
   9.257 +
   9.258 +Goal "(k/m = k/n) = (k = 0 | m = (n::complex))";
   9.259 +by (case_tac "m=0 | n = 0" 1);
   9.260 +by (auto_tac (claset(), 
   9.261 +              simpset() addsimps [COMPLEX_DIVIDE_ZERO, complex_divide_eq_eq, 
   9.262 +                                  complex_eq_divide_eq, complex_mult_eq_cancel1]));  
   9.263 +qed "complex_divide_eq_cancel1";
   9.264 +
   9.265 +(** Division by 1, -1 **)
   9.266 +
   9.267 +Goal "(x::complex)/1 = x";
   9.268 +by (simp_tac (simpset() addsimps [complex_divide_def]) 1); 
   9.269 +qed "complex_divide_1";
   9.270 +Addsimps [complex_divide_1];
   9.271 +
   9.272 +Goal "x/-1 = -(x::complex)";
   9.273 +by (Simp_tac 1); 
   9.274 +qed "complex_divide_minus1";
   9.275 +Addsimps [complex_divide_minus1];
   9.276 +
   9.277 +Goal "-1/(x::complex) = - (1/x)";
   9.278 +by (simp_tac (simpset() addsimps [complex_divide_def, complex_minus_inverse]) 1); 
   9.279 +qed "complex_minus1_divide";
   9.280 +Addsimps [complex_minus1_divide];
   9.281 +
   9.282 +
   9.283 +Goal "(x = - y) = (y = - (x::complex))";
   9.284 +by Auto_tac;
   9.285 +qed "complex_equation_minus";
   9.286 +
   9.287 +Goal "(- x = y) = (- (y::complex) = x)";
   9.288 +by Auto_tac;
   9.289 +qed "complex_minus_equation";
   9.290 +
   9.291 +Goal "(x + - a = (0::complex)) = (x=a)";
   9.292 +by (simp_tac (simpset() addsimps [complex_diff_eq_eq,symmetric complex_diff_def]) 1);
   9.293 +qed "complex_add_minus_iff";
   9.294 +Addsimps [complex_add_minus_iff];
   9.295 +
   9.296 +Goal "(-b = -a) = (b = (a::complex))";
   9.297 +by Auto_tac;
   9.298 +by (etac ( inj_complex_minus RS injD) 1);
   9.299 +qed "complex_minus_eq_cancel";
   9.300 +Addsimps [complex_minus_eq_cancel];
   9.301 +
   9.302 +(*Distributive laws for literals*)
   9.303 +Addsimps (map (inst "w" "number_of ?v")
   9.304 +	  [complex_add_mult_distrib, complex_add_mult_distrib2,
   9.305 +	   complex_diff_mult_distrib, complex_diff_mult_distrib2]);
   9.306 +
   9.307 +Addsimps [inst "x" "number_of ?v" complex_equation_minus];
   9.308 +
   9.309 +Addsimps [inst "y" "number_of ?v" complex_minus_equation];
   9.310 +
   9.311 +Goal "(x+y = (0::complex)) = (y = -x)";
   9.312 +by Auto_tac;
   9.313 +by (dtac (sym RS (complex_diff_eq_eq RS iffD2)) 1);
   9.314 +by Auto_tac;  
   9.315 +qed "complex_add_eq_0_iff";
   9.316 +AddIffs [complex_add_eq_0_iff];
   9.317 +
   9.318 +Goalw [complex_diff_def]"-(x-y) = y - (x::complex)";
   9.319 +by (auto_tac (claset(),simpset() addsimps [complex_add_commute]));
   9.320 +qed "complex_minus_diff_eq";
   9.321 +Addsimps [complex_minus_diff_eq];
   9.322 +
   9.323 +Addsimps [inst "x" "number_of ?w" complex_inverse_eq_divide];
   9.324 +
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/src/HOL/Complex/ComplexArith0.thy	Mon May 05 18:22:31 2003 +0200
    10.3 @@ -0,0 +1,2 @@
    10.4 +ComplexArith0 = ComplexBin
    10.5 +
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/src/HOL/Complex/ComplexBin.ML	Mon May 05 18:22:31 2003 +0200
    11.3 @@ -0,0 +1,609 @@
    11.4 +(*  Title:      ComplexBin.ML
    11.5 +    Author:     Jacques D. Fleuriot
    11.6 +    Copyright:  2001 University of Edinburgh
    11.7 +    Descrition: Binary arithmetic for the complex numbers
    11.8 +*)
    11.9 +
   11.10 +(** complex_of_real (coercion from real to complex) **)
   11.11 +
   11.12 +Goal "complex_of_real (number_of w) = number_of w";
   11.13 +by (simp_tac (simpset() addsimps [complex_number_of_def]) 1);
   11.14 +qed "complex_number_of";
   11.15 +Addsimps [complex_number_of];
   11.16 + 
   11.17 +Goalw [complex_number_of_def] "Numeral0 = (0::complex)";
   11.18 +by (Simp_tac 1);
   11.19 +qed "complex_numeral_0_eq_0";
   11.20 + 
   11.21 +Goalw [complex_number_of_def] "Numeral1 = (1::complex)";
   11.22 +by (Simp_tac 1);
   11.23 +qed "complex_numeral_1_eq_1";
   11.24 +
   11.25 +(** Addition **)
   11.26 +
   11.27 +Goal "(number_of v :: complex) + number_of v' = number_of (bin_add v v')";
   11.28 +by (simp_tac
   11.29 +    (HOL_ss addsimps [complex_number_of_def, 
   11.30 +                      complex_of_real_add, add_real_number_of]) 1);
   11.31 +qed "add_complex_number_of";
   11.32 +Addsimps [add_complex_number_of];
   11.33 +
   11.34 +
   11.35 +(** Subtraction **)
   11.36 +
   11.37 +Goalw [complex_number_of_def]
   11.38 +     "- (number_of w :: complex) = number_of (bin_minus w)";
   11.39 +by (simp_tac
   11.40 +    (HOL_ss addsimps [minus_real_number_of, complex_of_real_minus RS sym]) 1);
   11.41 +qed "minus_complex_number_of";
   11.42 +Addsimps [minus_complex_number_of];
   11.43 +
   11.44 +Goalw [complex_number_of_def, complex_diff_def]
   11.45 +     "(number_of v :: complex) - number_of w = number_of (bin_add v (bin_minus w))";
   11.46 +by (Simp_tac 1); 
   11.47 +qed "diff_complex_number_of";
   11.48 +Addsimps [diff_complex_number_of];
   11.49 +
   11.50 +
   11.51 +(** Multiplication **)
   11.52 +
   11.53 +Goal "(number_of v :: complex) * number_of v' = number_of (bin_mult v v')";
   11.54 +by (simp_tac
   11.55 +    (HOL_ss addsimps [complex_number_of_def, 
   11.56 +	              complex_of_real_mult, mult_real_number_of]) 1);
   11.57 +qed "mult_complex_number_of";
   11.58 +Addsimps [mult_complex_number_of];
   11.59 +
   11.60 +Goal "(2::complex) = 1 + 1";
   11.61 +by (simp_tac (simpset() addsimps [complex_numeral_1_eq_1 RS sym]) 1);
   11.62 +val lemma = result();
   11.63 +
   11.64 +(*For specialist use: NOT as default simprules*)
   11.65 +Goal "2 * z = (z+z::complex)";
   11.66 +by (simp_tac (simpset () addsimps [lemma, complex_add_mult_distrib]) 1);
   11.67 +qed "complex_mult_2";
   11.68 +
   11.69 +Goal "z * 2 = (z+z::complex)";
   11.70 +by (stac complex_mult_commute 1 THEN rtac complex_mult_2 1);
   11.71 +qed "complex_mult_2_right";
   11.72 +
   11.73 +(** Equals (=) **)
   11.74 +
   11.75 +Goal "((number_of v :: complex) = number_of v') = \
   11.76 +\     iszero (number_of (bin_add v (bin_minus v')))";
   11.77 +by (simp_tac
   11.78 +    (HOL_ss addsimps [complex_number_of_def, 
   11.79 +	              complex_of_real_eq_iff, eq_real_number_of]) 1);
   11.80 +qed "eq_complex_number_of";
   11.81 +Addsimps [eq_complex_number_of];
   11.82 +
   11.83 +(*** New versions of existing theorems involving 0, 1 ***)
   11.84 +
   11.85 +Goal "- 1 = (-1::complex)";
   11.86 +by (simp_tac (simpset() addsimps [complex_numeral_1_eq_1 RS sym]) 1);
   11.87 +qed "complex_minus_1_eq_m1";
   11.88 +
   11.89 +Goal "-1 * z = -(z::complex)";
   11.90 +by (simp_tac (simpset() addsimps [complex_minus_1_eq_m1 RS sym]) 1);
   11.91 +qed "complex_mult_minus1";
   11.92 +
   11.93 +Goal "z * -1 = -(z::complex)";
   11.94 +by (stac complex_mult_commute 1 THEN rtac complex_mult_minus1 1);
   11.95 +qed "complex_mult_minus1_right";
   11.96 +
   11.97 +Addsimps [complex_mult_minus1,complex_mult_minus1_right];
   11.98 +
   11.99 +
  11.100 +(*Maps 0 to Numeral0 and 1 to Numeral1 and -Numeral1 to -1*)
  11.101 +val complex_numeral_ss = 
  11.102 +    hypreal_numeral_ss addsimps [complex_numeral_0_eq_0 RS sym, complex_numeral_1_eq_1 RS sym, 
  11.103 +		                 complex_minus_1_eq_m1];
  11.104 +
  11.105 +fun rename_numerals th = 
  11.106 +    asm_full_simplify complex_numeral_ss (Thm.transfer (the_context ()) th);
  11.107 +
  11.108 +(*Now insert some identities previously stated for 0 and 1c*)
  11.109 +
  11.110 +Addsimps [complex_numeral_0_eq_0,complex_numeral_1_eq_1];
  11.111 +
  11.112 +Goal "number_of v + (number_of w + z) = (number_of(bin_add v w) + z::complex)";
  11.113 +by (auto_tac (claset(),simpset() addsimps [complex_add_assoc RS sym]));
  11.114 +qed "complex_add_number_of_left";
  11.115 +
  11.116 +Goal "number_of v *(number_of w * z) = (number_of(bin_mult v w) * z::complex)";
  11.117 +by (simp_tac (simpset() addsimps [complex_mult_assoc RS sym]) 1);
  11.118 +qed "complex_mult_number_of_left";
  11.119 +
  11.120 +Goalw [complex_diff_def]
  11.121 +    "number_of v + (number_of w - c) = number_of(bin_add v w) - (c::complex)";
  11.122 +by (rtac complex_add_number_of_left 1);
  11.123 +qed "complex_add_number_of_diff1";
  11.124 +
  11.125 +Goal "number_of v + (c - number_of w) = \
  11.126 +\     number_of (bin_add v (bin_minus w)) + (c::complex)";
  11.127 +by (auto_tac (claset(),simpset() addsimps [complex_diff_def]@ complex_add_ac));
  11.128 +qed "complex_add_number_of_diff2";
  11.129 +
  11.130 +Addsimps [complex_add_number_of_left, complex_mult_number_of_left,
  11.131 +	  complex_add_number_of_diff1, complex_add_number_of_diff2]; 
  11.132 +
  11.133 +
  11.134 +(**** Simprocs for numeric literals ****)
  11.135 +
  11.136 +(** Combining of literal coefficients in sums of products **)
  11.137 +
  11.138 +Goal "(x = y) = (x-y = (0::complex))";
  11.139 +by (simp_tac (simpset() addsimps [complex_diff_eq_eq]) 1);   
  11.140 +qed "complex_eq_iff_diff_eq_0";
  11.141 +
  11.142 +(** For combine_numerals **)
  11.143 +
  11.144 +Goal "i*u + (j*u + k) = (i+j)*u + (k::complex)";
  11.145 +by (asm_simp_tac (simpset() addsimps [complex_add_mult_distrib]
  11.146 +    @ complex_add_ac) 1);
  11.147 +qed "left_complex_add_mult_distrib";
  11.148 +
  11.149 +(** For cancel_numerals **)
  11.150 +
  11.151 +Goal "((x::complex) = u + v) = (x - (u + v) = 0)";
  11.152 +by (auto_tac (claset(),simpset() addsimps [complex_diff_eq_eq]));
  11.153 +qed "complex_eq_add_diff_eq_0";
  11.154 +
  11.155 +Goal "((x::complex) = n) = (x - n = 0)";
  11.156 +by (auto_tac (claset(),simpset() addsimps [complex_diff_eq_eq]));
  11.157 +qed "complex_eq_diff_eq_0";
  11.158 +
  11.159 +val complex_rel_iff_rel_0_rls = [complex_eq_diff_eq_0,complex_eq_add_diff_eq_0];
  11.160 +
  11.161 +Goal "!!i::complex. (i*u + m = j*u + n) = ((i-j)*u + m = n)";
  11.162 +by (auto_tac (claset(), simpset() addsimps [complex_add_mult_distrib,
  11.163 +    complex_diff_def] @ complex_add_ac));
  11.164 +by (asm_simp_tac (simpset() addsimps [complex_add_assoc RS sym]) 1);
  11.165 +by (simp_tac (simpset() addsimps [complex_add_assoc]) 1);
  11.166 +qed "complex_eq_add_iff1";
  11.167 +
  11.168 +Goal "!!i::complex. (i*u + m = j*u + n) = (m = (j-i)*u + n)";
  11.169 +by (simp_tac (simpset() addsimps [ complex_eq_add_iff1]) 1);
  11.170 +by (auto_tac (claset(), simpset() addsimps [complex_diff_def, 
  11.171 +    complex_add_mult_distrib]@ complex_add_ac));
  11.172 +qed "complex_eq_add_iff2";
  11.173 +
  11.174 +structure Complex_Numeral_Simprocs =
  11.175 +struct
  11.176 +
  11.177 +(*Maps 0 to Numeral0 and 1 to Numeral1 so that arithmetic in simprocs
  11.178 +  isn't complicated by the abstract 0 and 1.*)
  11.179 +val numeral_syms = [complex_numeral_0_eq_0 RS sym, complex_numeral_1_eq_1 RS sym];
  11.180 +
  11.181 +
  11.182 +(*Utilities*)
  11.183 +
  11.184 +val complexT = Type("Complex.complex",[]);
  11.185 +
  11.186 +fun mk_numeral n = HOLogic.number_of_const complexT $ HOLogic.mk_bin n;
  11.187 +
  11.188 +val dest_numeral = Real_Numeral_Simprocs.dest_numeral;
  11.189 +val find_first_numeral = Real_Numeral_Simprocs.find_first_numeral;
  11.190 +
  11.191 +val zero = mk_numeral 0;
  11.192 +val mk_plus = HOLogic.mk_binop "op +";
  11.193 +
  11.194 +val uminus_const = Const ("uminus", complexT --> complexT);
  11.195 +
  11.196 +(*Thus mk_sum[t] yields t+0; longer sums don't have a trailing zero*)
  11.197 +fun mk_sum []        = zero
  11.198 +  | mk_sum [t,u]     = mk_plus (t, u)
  11.199 +  | mk_sum (t :: ts) = mk_plus (t, mk_sum ts);
  11.200 +
  11.201 +(*this version ALWAYS includes a trailing zero*)
  11.202 +fun long_mk_sum []        = zero
  11.203 +  | long_mk_sum (t :: ts) = mk_plus (t, mk_sum ts);
  11.204 +
  11.205 +val dest_plus = HOLogic.dest_bin "op +" complexT;
  11.206 +
  11.207 +(*decompose additions AND subtractions as a sum*)
  11.208 +fun dest_summing (pos, Const ("op +", _) $ t $ u, ts) =
  11.209 +        dest_summing (pos, t, dest_summing (pos, u, ts))
  11.210 +  | dest_summing (pos, Const ("op -", _) $ t $ u, ts) =
  11.211 +        dest_summing (pos, t, dest_summing (not pos, u, ts))
  11.212 +  | dest_summing (pos, t, ts) =
  11.213 +	if pos then t::ts else uminus_const$t :: ts;
  11.214 +
  11.215 +fun dest_sum t = dest_summing (true, t, []);
  11.216 +
  11.217 +val mk_diff = HOLogic.mk_binop "op -";
  11.218 +val dest_diff = HOLogic.dest_bin "op -" complexT;
  11.219 +
  11.220 +val one = mk_numeral 1;
  11.221 +val mk_times = HOLogic.mk_binop "op *";
  11.222 +
  11.223 +fun mk_prod [] = one
  11.224 +  | mk_prod [t] = t
  11.225 +  | mk_prod (t :: ts) = if t = one then mk_prod ts
  11.226 +                        else mk_times (t, mk_prod ts);
  11.227 +
  11.228 +val dest_times = HOLogic.dest_bin "op *" complexT;
  11.229 +
  11.230 +fun dest_prod t =
  11.231 +      let val (t,u) = dest_times t 
  11.232 +      in  dest_prod t @ dest_prod u  end
  11.233 +      handle TERM _ => [t];
  11.234 +
  11.235 +(*DON'T do the obvious simplifications; that would create special cases*) 
  11.236 +fun mk_coeff (k, ts) = mk_times (mk_numeral k, ts);
  11.237 +
  11.238 +(*Express t as a product of (possibly) a numeral with other sorted terms*)
  11.239 +fun dest_coeff sign (Const ("uminus", _) $ t) = dest_coeff (~sign) t
  11.240 +  | dest_coeff sign t =
  11.241 +    let val ts = sort Term.term_ord (dest_prod t)
  11.242 +	val (n, ts') = find_first_numeral [] ts
  11.243 +                          handle TERM _ => (1, ts)
  11.244 +    in (sign*n, mk_prod ts') end;
  11.245 +
  11.246 +(*Find first coefficient-term THAT MATCHES u*)
  11.247 +fun find_first_coeff past u [] = raise TERM("find_first_coeff", []) 
  11.248 +  | find_first_coeff past u (t::terms) =
  11.249 +	let val (n,u') = dest_coeff 1 t
  11.250 +	in  if u aconv u' then (n, rev past @ terms)
  11.251 +			  else find_first_coeff (t::past) u terms
  11.252 +	end
  11.253 +	handle TERM _ => find_first_coeff (t::past) u terms;
  11.254 +
  11.255 +
  11.256 +(*Simplify Numeral0+n, n+Numeral0, Numeral1*n, n*Numeral1*)
  11.257 +val add_0s = map rename_numerals [complex_add_zero_left, complex_add_zero_right];
  11.258 +val mult_plus_1s = map rename_numerals [complex_mult_one_left, complex_mult_one_right];
  11.259 +val mult_minus_1s = map rename_numerals
  11.260 +                      [complex_mult_minus1, complex_mult_minus1_right];
  11.261 +val mult_1s = mult_plus_1s @ mult_minus_1s;
  11.262 +
  11.263 +(*To perform binary arithmetic*)
  11.264 +val bin_simps =
  11.265 +    [complex_numeral_0_eq_0 RS sym, complex_numeral_1_eq_1 RS sym,
  11.266 +     add_complex_number_of, complex_add_number_of_left, 
  11.267 +     minus_complex_number_of, diff_complex_number_of, mult_complex_number_of, 
  11.268 +     complex_mult_number_of_left] @ bin_arith_simps @ bin_rel_simps;
  11.269 +
  11.270 +(*To evaluate binary negations of coefficients*)
  11.271 +val complex_minus_simps = NCons_simps @
  11.272 +                   [complex_minus_1_eq_m1,minus_complex_number_of, 
  11.273 +		    bin_minus_1, bin_minus_0, bin_minus_Pls, bin_minus_Min,
  11.274 +		    bin_pred_1, bin_pred_0, bin_pred_Pls, bin_pred_Min];
  11.275 +
  11.276 +(*To let us treat subtraction as addition*)
  11.277 +val diff_simps = [complex_diff_def, complex_minus_add_distrib, 
  11.278 +                  complex_minus_minus];
  11.279 +
  11.280 +(* push the unary minus down: - x * y = x * - y *)
  11.281 +val complex_minus_mult_eq_1_to_2 = 
  11.282 +    [complex_minus_mult_eq1 RS sym, complex_minus_mult_eq2] MRS trans 
  11.283 +    |> standard;
  11.284 +
  11.285 +(*to extract again any uncancelled minuses*)
  11.286 +val complex_minus_from_mult_simps = 
  11.287 +    [complex_minus_minus, complex_minus_mult_eq1 RS sym, 
  11.288 +     complex_minus_mult_eq2 RS sym];
  11.289 +
  11.290 +(*combine unary minus with numeric literals, however nested within a product*)
  11.291 +val complex_mult_minus_simps =
  11.292 +    [complex_mult_assoc, complex_minus_mult_eq1, complex_minus_mult_eq_1_to_2];
  11.293 +
  11.294 +(*Final simplification: cancel + and *  *)
  11.295 +val simplify_meta_eq = 
  11.296 +    Int_Numeral_Simprocs.simplify_meta_eq
  11.297 +         [complex_add_zero_left, complex_add_zero_right,
  11.298 + 	  complex_mult_zero_left, complex_mult_zero_right, complex_mult_one_left, 
  11.299 +          complex_mult_one_right];
  11.300 +
  11.301 +val prep_simproc = Real_Numeral_Simprocs.prep_simproc;
  11.302 +
  11.303 +
  11.304 +structure CancelNumeralsCommon =
  11.305 +  struct
  11.306 +  val mk_sum    	= mk_sum
  11.307 +  val dest_sum		= dest_sum
  11.308 +  val mk_coeff		= mk_coeff
  11.309 +  val dest_coeff	= dest_coeff 1
  11.310 +  val find_first_coeff	= find_first_coeff []
  11.311 +  val trans_tac         = Real_Numeral_Simprocs.trans_tac
  11.312 +  val norm_tac = 
  11.313 +     ALLGOALS (simp_tac (HOL_ss addsimps add_0s@mult_1s@diff_simps@
  11.314 +                                         complex_minus_simps@complex_add_ac))
  11.315 +     THEN ALLGOALS (simp_tac (HOL_ss addsimps bin_simps@complex_mult_minus_simps))
  11.316 +     THEN ALLGOALS
  11.317 +              (simp_tac (HOL_ss addsimps complex_minus_from_mult_simps@
  11.318 +                                         complex_add_ac@complex_mult_ac))
  11.319 +  val numeral_simp_tac	= ALLGOALS (simp_tac (HOL_ss addsimps add_0s@bin_simps))
  11.320 +  val simplify_meta_eq  = simplify_meta_eq
  11.321 +  end;
  11.322 +
  11.323 +
  11.324 +structure EqCancelNumerals = CancelNumeralsFun
  11.325 + (open CancelNumeralsCommon
  11.326 +  val prove_conv = Bin_Simprocs.prove_conv
  11.327 +  val mk_bal   = HOLogic.mk_eq
  11.328 +  val dest_bal = HOLogic.dest_bin "op =" complexT
  11.329 +  val bal_add1 = complex_eq_add_iff1 RS trans
  11.330 +  val bal_add2 = complex_eq_add_iff2 RS trans
  11.331 +);
  11.332 +
  11.333 +
  11.334 +val cancel_numerals = 
  11.335 +  map prep_simproc
  11.336 +   [("complexeq_cancel_numerals",
  11.337 +               ["(l::complex) + m = n", "(l::complex) = m + n", 
  11.338 +		"(l::complex) - m = n", "(l::complex) = m - n", 
  11.339 +		"(l::complex) * m = n", "(l::complex) = m * n"], 
  11.340 +     EqCancelNumerals.proc)];
  11.341 +
  11.342 +structure CombineNumeralsData =
  11.343 +  struct
  11.344 +  val add		= op + : int*int -> int 
  11.345 +  val mk_sum    	= long_mk_sum    (*to work for e.g. #2*x + #3*x *)
  11.346 +  val dest_sum		= dest_sum
  11.347 +  val mk_coeff		= mk_coeff
  11.348 +  val dest_coeff	= dest_coeff 1
  11.349 +  val left_distrib	= left_complex_add_mult_distrib RS trans
  11.350 +  val prove_conv	= Bin_Simprocs.prove_conv_nohyps
  11.351 +  val trans_tac         = Real_Numeral_Simprocs.trans_tac
  11.352 +  val norm_tac = 
  11.353 +     ALLGOALS (simp_tac (HOL_ss addsimps add_0s@mult_1s@diff_simps@
  11.354 +                                         complex_minus_simps@complex_add_ac))
  11.355 +     THEN ALLGOALS (simp_tac (HOL_ss addsimps bin_simps@complex_mult_minus_simps))
  11.356 +     THEN ALLGOALS (simp_tac (HOL_ss addsimps complex_minus_from_mult_simps@
  11.357 +                                              complex_add_ac@complex_mult_ac))
  11.358 +  val numeral_simp_tac	= ALLGOALS 
  11.359 +                    (simp_tac (HOL_ss addsimps add_0s@bin_simps))
  11.360 +  val simplify_meta_eq  = simplify_meta_eq
  11.361 +  end;
  11.362 +
  11.363 +structure CombineNumerals = CombineNumeralsFun(CombineNumeralsData);
  11.364 +
  11.365 +val combine_numerals = 
  11.366 +    prep_simproc ("complex_combine_numerals",
  11.367 +		  ["(i::complex) + j", "(i::complex) - j"],
  11.368 +		  CombineNumerals.proc);
  11.369 +
  11.370 +
  11.371 +(** Declarations for ExtractCommonTerm **)
  11.372 +
  11.373 +(*this version ALWAYS includes a trailing one*)
  11.374 +fun long_mk_prod []        = one
  11.375 +  | long_mk_prod (t :: ts) = mk_times (t, mk_prod ts);
  11.376 +
  11.377 +(*Find first term that matches u*)
  11.378 +fun find_first past u []         = raise TERM("find_first", []) 
  11.379 +  | find_first past u (t::terms) =
  11.380 +	if u aconv t then (rev past @ terms)
  11.381 +        else find_first (t::past) u terms
  11.382 +	handle TERM _ => find_first (t::past) u terms;
  11.383 +
  11.384 +(*Final simplification: cancel + and *  *)
  11.385 +fun cancel_simplify_meta_eq cancel_th th = 
  11.386 +    Int_Numeral_Simprocs.simplify_meta_eq 
  11.387 +        [complex_mult_one_left, complex_mult_one_right] 
  11.388 +        (([th, cancel_th]) MRS trans);
  11.389 +
  11.390 +(*** Making constant folding work for 0 and 1 too ***)
  11.391 +
  11.392 +structure ComplexAbstractNumeralsData =
  11.393 +  struct
  11.394 +  val dest_eq         = HOLogic.dest_eq o HOLogic.dest_Trueprop o concl_of
  11.395 +  val is_numeral      = Bin_Simprocs.is_numeral
  11.396 +  val numeral_0_eq_0  = complex_numeral_0_eq_0
  11.397 +  val numeral_1_eq_1  = complex_numeral_1_eq_1
  11.398 +  val prove_conv      = Bin_Simprocs.prove_conv_nohyps_novars
  11.399 +  fun norm_tac simps  = ALLGOALS (simp_tac (HOL_ss addsimps simps))
  11.400 +  val simplify_meta_eq = Bin_Simprocs.simplify_meta_eq
  11.401 +  end
  11.402 +
  11.403 +structure ComplexAbstractNumerals = AbstractNumeralsFun (ComplexAbstractNumeralsData)
  11.404 +
  11.405 +(*For addition, we already have rules for the operand 0.
  11.406 +  Multiplication is omitted because there are already special rules for
  11.407 +  both 0 and 1 as operands.  Unary minus is trivial, just have - 1 = -1.
  11.408 +  For the others, having three patterns is a compromise between just having
  11.409 +  one (many spurious calls) and having nine (just too many!) *)
  11.410 +val eval_numerals =
  11.411 +  map prep_simproc
  11.412 +   [("complex_add_eval_numerals",
  11.413 +     ["(m::complex) + 1", "(m::complex) + number_of v"],
  11.414 +     ComplexAbstractNumerals.proc add_complex_number_of),
  11.415 +    ("complex_diff_eval_numerals",
  11.416 +     ["(m::complex) - 1", "(m::complex) - number_of v"],
  11.417 +     ComplexAbstractNumerals.proc diff_complex_number_of),
  11.418 +    ("complex_eq_eval_numerals",
  11.419 +     ["(m::complex) = 0", "(m::complex) = 1", "(m::complex) = number_of v"],
  11.420 +     ComplexAbstractNumerals.proc eq_complex_number_of)]
  11.421 +
  11.422 +end;
  11.423 +
  11.424 +Addsimprocs Complex_Numeral_Simprocs.eval_numerals;
  11.425 +Addsimprocs Complex_Numeral_Simprocs.cancel_numerals;
  11.426 +Addsimprocs [Complex_Numeral_Simprocs.combine_numerals];
  11.427 +
  11.428 +(*The Abel_Cancel simprocs are now obsolete
  11.429 +Delsimprocs [Complex_Cancel.sum_conv, Complex_Cancel.rel_conv];
  11.430 +*)
  11.431 +
  11.432 +(*examples:
  11.433 +print_depth 22;
  11.434 +set timing;
  11.435 +set trace_simp;
  11.436 +fun test s = (Goal s, by (Simp_tac 1)); 
  11.437 +
  11.438 +test "l +  2 +  2 +  2 + (l +  2) + (oo +  2) = (uu::complex)";
  11.439 +test " 2*u = (u::complex)";
  11.440 +test "(i + j +  12 + (k::complex)) -  15 = y";
  11.441 +test "(i + j +  12 + (k::complex)) -  5 = y";
  11.442 +
  11.443 +test "( 2*x - (u*v) + y) - v* 3*u = (w::complex)";
  11.444 +test "( 2*x*u*v + (u*v)* 4 + y) - v*u* 4 = (w::complex)";
  11.445 +test "( 2*x*u*v + (u*v)* 4 + y) - v*u = (w::complex)";
  11.446 +test "u*v - (x*u*v + (u*v)* 4 + y) = (w::complex)";
  11.447 +
  11.448 +test "(i + j +  12 + (k::complex)) = u +  15 + y";
  11.449 +test "(i + j* 2 +  12 + (k::complex)) = j +  5 + y";
  11.450 +
  11.451 +test " 2*y +  3*z +  6*w +  2*y +  3*z +  2*u =  2*y' +  3*z' +  6*w' +  2*y' +  3*z' + u + (vv::complex)";
  11.452 +
  11.453 +test "a + -(b+c) + b = (d::complex)";
  11.454 +test "a + -(b+c) - b = (d::complex)";
  11.455 +
  11.456 +(*negative numerals*)
  11.457 +test "(i + j +  -2 + (k::complex)) - (u +  5 + y) = zz";
  11.458 +
  11.459 +test "(i + j +  -12 + (k::complex)) -  15 = y";
  11.460 +test "(i + j +  12 + (k::complex)) -  -15 = y";
  11.461 +test "(i + j +  -12 + (k::complex)) -  -15 = y";
  11.462 +
  11.463 +*)
  11.464 +
  11.465 +
  11.466 +(** Constant folding for complex plus and times **)
  11.467 +
  11.468 +structure Complex_Times_Assoc_Data : ASSOC_FOLD_DATA =
  11.469 +struct
  11.470 +  val ss		= HOL_ss
  11.471 +  val eq_reflection	= eq_reflection
  11.472 +  val sg_ref    = Sign.self_ref (Theory.sign_of (the_context ()))
  11.473 +  val T	     = Complex_Numeral_Simprocs.complexT
  11.474 +  val plus   = Const ("op *", [T,T] ---> T)
  11.475 +  val add_ac = complex_mult_ac
  11.476 +end;
  11.477 +
  11.478 +structure Complex_Times_Assoc = Assoc_Fold (Complex_Times_Assoc_Data);
  11.479 +
  11.480 +Addsimprocs [Complex_Times_Assoc.conv];
  11.481 +
  11.482 +Addsimps [complex_of_real_zero_iff];
  11.483 +
  11.484 +(*Simplification of  x-y = 0 *)
  11.485 +
  11.486 +AddIffs [complex_eq_iff_diff_eq_0 RS sym];
  11.487 +
  11.488 +(*** Real and imaginary stuff ***)
  11.489 +
  11.490 +Goalw [complex_number_of_def] 
  11.491 +  "((number_of xa :: complex) + ii * number_of ya = \
  11.492 +\       number_of xb + ii * number_of yb) = \
  11.493 +\  (((number_of xa :: complex) = number_of xb) & \
  11.494 +\   ((number_of ya :: complex) = number_of yb))";
  11.495 +by (auto_tac (claset(), HOL_ss addsimps [complex_eq_cancel_iff]));
  11.496 +qed "complex_number_of_eq_cancel_iff";
  11.497 +Addsimps [complex_number_of_eq_cancel_iff];
  11.498 +
  11.499 +Goalw [complex_number_of_def] 
  11.500 +  "((number_of xa :: complex) + number_of ya * ii = \
  11.501 +\       number_of xb + number_of yb * ii) = \
  11.502 +\  (((number_of xa :: complex) = number_of xb) & \
  11.503 +\   ((number_of ya :: complex) = number_of yb))";
  11.504 +by (auto_tac (claset(), HOL_ss addsimps [complex_eq_cancel_iffA]));
  11.505 +qed "complex_number_of_eq_cancel_iffA";
  11.506 +Addsimps [complex_number_of_eq_cancel_iffA];
  11.507 +
  11.508 +Goalw [complex_number_of_def] 
  11.509 +  "((number_of xa :: complex) + number_of ya * ii = \
  11.510 +\       number_of xb + ii * number_of yb) = \
  11.511 +\  (((number_of xa :: complex) = number_of xb) & \
  11.512 +\   ((number_of ya :: complex) = number_of yb))";
  11.513 +by (auto_tac (claset(), HOL_ss addsimps [complex_eq_cancel_iffB]));
  11.514 +qed "complex_number_of_eq_cancel_iffB";
  11.515 +Addsimps [complex_number_of_eq_cancel_iffB];
  11.516 +
  11.517 +Goalw [complex_number_of_def] 
  11.518 +  "((number_of xa :: complex) + ii * number_of ya = \
  11.519 +\       number_of xb + number_of yb * ii) = \
  11.520 +\  (((number_of xa :: complex) = number_of xb) & \
  11.521 +\   ((number_of ya :: complex) = number_of yb))";
  11.522 +by (auto_tac (claset(), HOL_ss addsimps [complex_eq_cancel_iffC]));
  11.523 +qed "complex_number_of_eq_cancel_iffC";
  11.524 +Addsimps [complex_number_of_eq_cancel_iffC];
  11.525 +
  11.526 +Goalw [complex_number_of_def] 
  11.527 +  "((number_of xa :: complex) + ii * number_of ya = \
  11.528 +\       number_of xb) = \
  11.529 +\  (((number_of xa :: complex) = number_of xb) & \
  11.530 +\   ((number_of ya :: complex) = 0))";
  11.531 +by (auto_tac (claset(), HOL_ss addsimps [complex_eq_cancel_iff2,
  11.532 +    complex_of_real_zero_iff]));
  11.533 +qed "complex_number_of_eq_cancel_iff2";
  11.534 +Addsimps [complex_number_of_eq_cancel_iff2];
  11.535 +
  11.536 +Goalw [complex_number_of_def] 
  11.537 +  "((number_of xa :: complex) + number_of ya * ii = \
  11.538 +\       number_of xb) = \
  11.539 +\  (((number_of xa :: complex) = number_of xb) & \
  11.540 +\   ((number_of ya :: complex) = 0))";
  11.541 +by (auto_tac (claset(), HOL_ss addsimps [complex_eq_cancel_iff2a,
  11.542 +    complex_of_real_zero_iff]));
  11.543 +qed "complex_number_of_eq_cancel_iff2a";
  11.544 +Addsimps [complex_number_of_eq_cancel_iff2a];
  11.545 +
  11.546 +Goalw [complex_number_of_def] 
  11.547 +  "((number_of xa :: complex) + ii * number_of ya = \
  11.548 +\    ii * number_of yb) = \
  11.549 +\  (((number_of xa :: complex) = 0) & \
  11.550 +\   ((number_of ya :: complex) = number_of yb))";
  11.551 +by (auto_tac (claset(), HOL_ss addsimps [complex_eq_cancel_iff3,
  11.552 +    complex_of_real_zero_iff]));
  11.553 +qed "complex_number_of_eq_cancel_iff3";
  11.554 +Addsimps [complex_number_of_eq_cancel_iff3];
  11.555 +
  11.556 +Goalw [complex_number_of_def] 
  11.557 +  "((number_of xa :: complex) + number_of ya * ii= \
  11.558 +\    ii * number_of yb) = \
  11.559 +\  (((number_of xa :: complex) = 0) & \
  11.560 +\   ((number_of ya :: complex) = number_of yb))";
  11.561 +by (auto_tac (claset(), HOL_ss addsimps [complex_eq_cancel_iff3a,
  11.562 +    complex_of_real_zero_iff]));
  11.563 +qed "complex_number_of_eq_cancel_iff3a";
  11.564 +Addsimps [complex_number_of_eq_cancel_iff3a];
  11.565 +
  11.566 +Goalw [complex_number_of_def] "cnj (number_of v :: complex) = number_of v";
  11.567 +by (rtac complex_cnj_complex_of_real 1);
  11.568 +qed "complex_number_of_cnj";
  11.569 +Addsimps [complex_number_of_cnj];
  11.570 +
  11.571 +Goalw [complex_number_of_def] 
  11.572 +      "cmod(number_of v :: complex) = abs (number_of v :: real)";
  11.573 +by (auto_tac (claset(), HOL_ss addsimps [complex_mod_complex_of_real]));
  11.574 +qed "complex_number_of_cmod";
  11.575 +Addsimps [complex_number_of_cmod];
  11.576 +
  11.577 +Goalw [complex_number_of_def] 
  11.578 +      "Re(number_of v :: complex) = number_of v";
  11.579 +by (auto_tac (claset(), HOL_ss addsimps [Re_complex_of_real]));
  11.580 +qed "complex_number_of_Re";
  11.581 +Addsimps [complex_number_of_Re];
  11.582 +
  11.583 +Goalw [complex_number_of_def] 
  11.584 +      "Im(number_of v :: complex) = 0";
  11.585 +by (auto_tac (claset(), HOL_ss addsimps [Im_complex_of_real]));
  11.586 +qed "complex_number_of_Im";
  11.587 +Addsimps [complex_number_of_Im];
  11.588 +
  11.589 +Goalw [expi_def] 
  11.590 +   "expi((2::complex) * complex_of_real pi * ii) = 1";
  11.591 +by (auto_tac (claset(),simpset() addsimps [complex_Re_mult_eq,
  11.592 +    complex_Im_mult_eq,cis_def]));
  11.593 +qed "expi_two_pi_i";
  11.594 +Addsimps [expi_two_pi_i];
  11.595 +
  11.596 +(*examples:
  11.597 +print_depth 22;
  11.598 +set timing;
  11.599 +set trace_simp;
  11.600 +fun test s = (Goal s, by (Simp_tac 1)); 
  11.601 +
  11.602 +test "23 * ii + 45 * ii= (x::complex)";
  11.603 +
  11.604 +test "5 * ii + 12 - 45 * ii= (x::complex)";
  11.605 +test "5 * ii + 40 - 12 * ii + 9 = (x::complex) + 89 * ii";
  11.606 +test "5 * ii + 40 - 12 * ii + 9 - 78 = (x::complex) + 89 * ii";
  11.607 +
  11.608 +test "l + 10 * ii + 90 + 3*l +  9 + 45 * ii= (x::complex)";
  11.609 +test "87 + 10 * ii + 90 + 3*7 +  9 + 45 * ii= (x::complex)";
  11.610 +
  11.611 +
  11.612 +*)
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/src/HOL/Complex/ComplexBin.thy	Mon May 05 18:22:31 2003 +0200
    12.3 @@ -0,0 +1,22 @@
    12.4 +(*  Title:      ComplexBin.thy
    12.5 +    Author:     Jacques D. Fleuriot
    12.6 +    Copyright:  2001 University of Edinburgh
    12.7 +    Descrition: Binary arithmetic for the complex numbers
    12.8 +                This case is reduced to that for the reals.
    12.9 +*)
   12.10 +
   12.11 +ComplexBin = Complex + 
   12.12 +
   12.13 +
   12.14 +instance
   12.15 +  complex :: number 
   12.16 +
   12.17 +instance complex :: plus_ac0(complex_add_commute,complex_add_assoc,complex_add_zero_left)
   12.18 +
   12.19 +
   12.20 +defs
   12.21 +  complex_number_of_def
   12.22 +    "number_of v == complex_of_real (number_of v)"
   12.23 +     (*::bin=>complex               ::bin=>complex*)
   12.24 +
   12.25 +end
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/src/HOL/Complex/NSCA.ML	Mon May 05 18:22:31 2003 +0200
    13.3 @@ -0,0 +1,1451 @@
    13.4 +(*  Title       : NSCA.ML
    13.5 +    Author      : Jacques D. Fleuriot
    13.6 +    Copyright   : 2001,2002 University of Edinburgh
    13.7 +    Description : Infinite, infinitesimal complex number etc! 
    13.8 +*)
    13.9 +
   13.10 +(*--------------------------------------------------------------------------------------*)
   13.11 +(* Closure laws for members of (embedded) set standard complex SComplex                 *)
   13.12 +(* -------------------------------------------------------------------------------------*)
   13.13 +
   13.14 +Goalw [SComplex_def] "[| (x::hcomplex): SComplex; y: SComplex |] ==> x + y: SComplex";
   13.15 +by (Step_tac 1);
   13.16 +by (res_inst_tac [("x","r + ra")] exI 1);
   13.17 +by (Simp_tac 1);
   13.18 +qed "SComplex_add";
   13.19 +
   13.20 +Goalw [SComplex_def] "[| (x::hcomplex): SComplex; y: SComplex |] ==> x * y: SComplex";
   13.21 +by (Step_tac 1);
   13.22 +by (res_inst_tac [("x","r * ra")] exI 1);
   13.23 +by (Simp_tac 1);
   13.24 +qed "SComplex_mult";
   13.25 +
   13.26 +Goalw [SComplex_def] "x: SComplex ==> inverse x : SComplex";
   13.27 +by (blast_tac (claset() addIs [hcomplex_of_complex_inverse RS sym]) 1); 
   13.28 +qed "SComplex_inverse";
   13.29 +
   13.30 +Goal "[| x: SComplex;  y: SComplex |] ==> x/y: SComplex";
   13.31 +by (asm_simp_tac (simpset() addsimps [SComplex_mult,SComplex_inverse,
   13.32 +                                      hcomplex_divide_def]) 1); 
   13.33 +qed "SComplex_divide";
   13.34 +
   13.35 +Goalw [SComplex_def] "x: SComplex ==> -x : SComplex";
   13.36 +by (blast_tac (claset() addIs [hcomplex_of_complex_minus RS sym]) 1); 
   13.37 +qed "SComplex_minus";
   13.38 +
   13.39 +Goal "(-x : SComplex) = (x: SComplex)";
   13.40 +by Auto_tac;  
   13.41 +by (etac SComplex_minus 2); 
   13.42 +by (dtac SComplex_minus 1); 
   13.43 +by Auto_tac;  
   13.44 +qed "SComplex_minus_iff";
   13.45 +Addsimps [SComplex_minus_iff]; 
   13.46 +
   13.47 +Goal "[| x + y : SComplex; y: SComplex |] ==> x: SComplex";
   13.48 +by (dres_inst_tac [("x","y")] SComplex_minus 1);
   13.49 +by (dtac SComplex_add 1);
   13.50 +by (assume_tac 1); 
   13.51 +by Auto_tac;  
   13.52 +qed "SComplex_add_cancel";
   13.53 +
   13.54 +Goalw [hcomplex_of_complex_def]
   13.55 +     "hcmod (hcomplex_of_complex r) : Reals";
   13.56 +by (simp_tac (simpset() addsimps [hcmod,SReal_def,
   13.57 +    hypreal_of_real_def]) 1);
   13.58 +qed "SReal_hcmod_hcomplex_of_complex";
   13.59 +Addsimps [SReal_hcmod_hcomplex_of_complex];
   13.60 +
   13.61 +Goalw [hcomplex_number_of_def]
   13.62 +    "hcmod (number_of w ::hcomplex) : Reals";
   13.63 +by (rtac SReal_hcmod_hcomplex_of_complex 1);
   13.64 +qed "SReal_hcmod_number_of";
   13.65 +Addsimps [SReal_hcmod_number_of];
   13.66 +
   13.67 +Goalw [SComplex_def] "x: SComplex ==> hcmod x : Reals";
   13.68 +by Auto_tac;
   13.69 +qed "SReal_hcmod_SComplex";
   13.70 +
   13.71 +Goalw [SComplex_def] "hcomplex_of_complex x: SComplex";
   13.72 +by (Blast_tac 1);
   13.73 +qed "SComplex_hcomplex_of_complex";
   13.74 +Addsimps [SComplex_hcomplex_of_complex];
   13.75 +
   13.76 +Goalw [hcomplex_number_of_def] "(number_of w ::hcomplex) : SComplex";
   13.77 +by (rtac SComplex_hcomplex_of_complex 1);
   13.78 +qed "SComplex_number_of";
   13.79 +Addsimps [SComplex_number_of];
   13.80 +
   13.81 +Goalw [hcomplex_divide_def] "r : SComplex ==> r/(number_of w::hcomplex) : SComplex";
   13.82 +by (blast_tac (claset() addSIs [SComplex_number_of, SComplex_mult, 
   13.83 +                                SComplex_inverse]) 1);
   13.84 +qed "SComplex_divide_number_of";
   13.85 +
   13.86 +Goalw [SComplex_def] "{x. hcomplex_of_complex x : SComplex} = (UNIV::complex set)";
   13.87 +by Auto_tac;
   13.88 +qed "SComplex_UNIV_complex";
   13.89 +
   13.90 +Goalw [SComplex_def] "(x: SComplex) = (EX y. x = hcomplex_of_complex y)";
   13.91 +by Auto_tac;
   13.92 +qed "SComplex_iff";
   13.93 +
   13.94 +Goalw [SComplex_def] "hcomplex_of_complex `(UNIV::complex set) = SComplex";
   13.95 +by Auto_tac;
   13.96 +qed "hcomplex_of_complex_image";
   13.97 +
   13.98 +Goalw [SComplex_def] "inv hcomplex_of_complex `SComplex = (UNIV::complex set)";
   13.99 +by Auto_tac;
  13.100 +by (rtac (inj_hcomplex_of_complex RS inv_f_f RS subst) 1);
  13.101 +by (Blast_tac 1);
  13.102 +qed "inv_hcomplex_of_complex_image";
  13.103 +
  13.104 +Goalw [SComplex_def] 
  13.105 +      "[| EX x. x: P; P <= SComplex |] ==> EX Q. P = hcomplex_of_complex ` Q";
  13.106 +by (Best_tac 1); 
  13.107 +qed "SComplex_hcomplex_of_complex_image";
  13.108 +
  13.109 +Goal "[| (x::hcomplex): SComplex; y: SComplex; hcmod x < hcmod y \
  13.110 +\     |] ==> EX r: Reals. hcmod x< r & r < hcmod y";
  13.111 +by (auto_tac (claset() addIs [SReal_dense], simpset() 
  13.112 +    addsimps [SReal_hcmod_SComplex]));
  13.113 +qed "SComplex_SReal_dense";
  13.114 +
  13.115 +Goalw [SComplex_def,SReal_def] 
  13.116 +      "z : SComplex ==> hcmod z : Reals";
  13.117 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
  13.118 +by (auto_tac (claset(),simpset() addsimps [hcmod,hypreal_of_real_def,
  13.119 +    hcomplex_of_complex_def,cmod_def]));
  13.120 +by (res_inst_tac [("x","cmod r")] exI 1);
  13.121 +by (ultra_tac (claset(),simpset() addsimps [cmod_def]) 1);
  13.122 +qed "SComplex_hcmod_SReal";
  13.123 +
  13.124 +Goal "0 : SComplex";
  13.125 +by (auto_tac (claset(),simpset() addsimps [SComplex_def]));
  13.126 +qed "SComplex_zero";
  13.127 +Addsimps [SComplex_zero];
  13.128 +
  13.129 +Goal "1 : SComplex";
  13.130 +by (auto_tac (claset(),simpset() addsimps [SComplex_def,hcomplex_of_complex_def,
  13.131 +    hcomplex_one_def]));
  13.132 +qed "SComplex_one";
  13.133 +Addsimps [SComplex_one];
  13.134 +
  13.135 +(*
  13.136 +Goalw [SComplex_def,SReal_def] "hcmod z : Reals ==> z : SComplex";
  13.137 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
  13.138 +by (auto_tac (claset(),simpset() addsimps [hcmod,hypreal_of_real_def,
  13.139 +    hcomplex_of_complex_def,cmod_def]));
  13.140 +*)
  13.141 +
  13.142 +(*--------------------------------------------------------------------------------------------*)
  13.143 +(*        Set of finite elements is a subring of the extended complex numbers                 *)
  13.144 +(* -------------------------------------------------------------------------------------------*)
  13.145 +
  13.146 +Goalw [CFinite_def] "[|x : CFinite; y : CFinite|] ==> (x+y) : CFinite";
  13.147 +by (blast_tac (claset() addSIs [SReal_add,hcmod_add_less]) 1);
  13.148 +qed "CFinite_add";
  13.149 +
  13.150 +Goalw [CFinite_def] "[|x : CFinite; y : CFinite|] ==> x*y : CFinite";
  13.151 +by (blast_tac (claset() addSIs [SReal_mult,hcmod_mult_less]) 1);
  13.152 +qed "CFinite_mult";
  13.153 +
  13.154 +Goalw [CFinite_def] "(-x : CFinite) = (x : CFinite)";
  13.155 +by (Simp_tac 1);
  13.156 +qed "CFinite_minus_iff";
  13.157 +Addsimps [CFinite_minus_iff];
  13.158 +
  13.159 +Goalw [SComplex_def,CFinite_def] "SComplex <= CFinite";
  13.160 +by Auto_tac;
  13.161 +by (res_inst_tac [("x","1 + hcmod(hcomplex_of_complex r)")] bexI 1);
  13.162 +by (auto_tac (claset() addIs [SReal_add],simpset()));
  13.163 +qed "SComplex_subset_CFinite";
  13.164 +Addsimps [ SComplex_subset_CFinite];
  13.165 +
  13.166 +Goal "hcmod (hcomplex_of_complex r) : HFinite";
  13.167 +by (auto_tac (claset() addSIs [ SReal_subset_HFinite RS subsetD],simpset()));
  13.168 +qed "HFinite_hcmod_hcomplex_of_complex";
  13.169 +Addsimps [HFinite_hcmod_hcomplex_of_complex];
  13.170 +
  13.171 +Goal "hcomplex_of_complex x: CFinite";
  13.172 +by (auto_tac (claset() addSIs [ SComplex_subset_CFinite RS subsetD],simpset()));
  13.173 +qed "CFinite_hcomplex_of_complex";
  13.174 +Addsimps [CFinite_hcomplex_of_complex];
  13.175 +
  13.176 +Goalw [CFinite_def] "x : CFinite ==> EX t: Reals. hcmod x < t";
  13.177 +by Auto_tac;
  13.178 +qed "CFiniteD";
  13.179 +
  13.180 +Goalw [CFinite_def] "(x : CFinite) = (hcmod x : HFinite)";
  13.181 +by (auto_tac (claset(), simpset() addsimps [HFinite_def]));
  13.182 +qed "CFinite_hcmod_iff";
  13.183 +
  13.184 +Goal "number_of w : CFinite";
  13.185 +by (rtac (SComplex_number_of RS (SComplex_subset_CFinite RS subsetD)) 1);
  13.186 +qed "CFinite_number_of";
  13.187 +Addsimps [CFinite_number_of];
  13.188 +
  13.189 +Goal "[|x : CFinite; y <= hcmod x; 0 <= y |] ==> y: HFinite";
  13.190 +by (auto_tac (claset() addIs [HFinite_bounded],simpset() addsimps 
  13.191 +    [CFinite_hcmod_iff]));
  13.192 +qed "CFinite_bounded";
  13.193 +
  13.194 +(*--------------------------------------------------------------------------------------*)
  13.195 +(* Set of complex infinitesimals is a subring of the nonstandard complex numbers        *) 
  13.196 +(*--------------------------------------------------------------------------------------*)
  13.197 +	 
  13.198 +Goalw [CInfinitesimal_def]
  13.199 +      "x : CInfinitesimal ==> ALL r: Reals. 0 < r --> hcmod x < r";
  13.200 +by Auto_tac;
  13.201 +qed "CInfinitesimalD";
  13.202 +
  13.203 +Goalw [CInfinitesimal_def] "0 : CInfinitesimal";
  13.204 +by Auto_tac;
  13.205 +qed "CInfinitesimal_zero";
  13.206 +AddIffs [CInfinitesimal_zero];
  13.207 +
  13.208 +Goal "x/(2::hcomplex) + x/(2::hcomplex) = x";
  13.209 +by Auto_tac;  
  13.210 +qed "hcomplex_sum_of_halves";
  13.211 +
  13.212 +Goalw [CInfinitesimal_def,Infinitesimal_def] 
  13.213 +   "(z : CInfinitesimal) = (hcmod z : Infinitesimal)";
  13.214 +by Auto_tac;
  13.215 +qed "CInfinitesimal_hcmod_iff";
  13.216 +
  13.217 +Goal "1 ~: CInfinitesimal";
  13.218 +by (simp_tac (simpset() addsimps [CInfinitesimal_hcmod_iff]) 1);
  13.219 +qed "one_not_CInfinitesimal";
  13.220 +Addsimps [one_not_CInfinitesimal];
  13.221 +
  13.222 +Goal "[| x : CInfinitesimal; y : CInfinitesimal |] ==> (x+y) : CInfinitesimal";
  13.223 +by (auto_tac (claset(),simpset() addsimps [CInfinitesimal_hcmod_iff]));
  13.224 +by (rtac hrabs_le_Infinitesimal 1);
  13.225 +by (res_inst_tac [("y","hcmod y")] Infinitesimal_add 1);
  13.226 +by Auto_tac;
  13.227 +qed "CInfinitesimal_add";
  13.228 +
  13.229 +Goalw [CInfinitesimal_def] "(-x:CInfinitesimal) = (x:CInfinitesimal)";
  13.230 +by (Full_simp_tac 1);
  13.231 +qed "CInfinitesimal_minus_iff";
  13.232 +Addsimps [CInfinitesimal_minus_iff];
  13.233 +
  13.234 +Goal "[| x : CInfinitesimal;  y : CInfinitesimal |] ==> x-y : CInfinitesimal";
  13.235 +by (asm_simp_tac
  13.236 +    (simpset() addsimps [hcomplex_diff_def, CInfinitesimal_add]) 1);
  13.237 +qed "CInfinitesimal_diff";
  13.238 +
  13.239 +Goal "[| x : CInfinitesimal; y : CInfinitesimal |] ==> (x * y) : CInfinitesimal";
  13.240 +by (auto_tac (claset() addIs [Infinitesimal_mult],simpset() addsimps 
  13.241 +    [CInfinitesimal_hcmod_iff,hcmod_mult]));
  13.242 +qed "CInfinitesimal_mult";
  13.243 +
  13.244 +Goal "[| x : CInfinitesimal; y : CFinite |] ==> (x * y) : CInfinitesimal";
  13.245 +by (auto_tac (claset() addIs [Infinitesimal_HFinite_mult],simpset() 
  13.246 +    addsimps [CInfinitesimal_hcmod_iff,CFinite_hcmod_iff,hcmod_mult]));
  13.247 +qed "CInfinitesimal_CFinite_mult";
  13.248 +
  13.249 +Goal "[| x : CInfinitesimal; y : CFinite |] ==> (y * x) : CInfinitesimal";
  13.250 +by (auto_tac (claset() addDs [CInfinitesimal_CFinite_mult],
  13.251 +              simpset() addsimps [hcomplex_mult_commute]));
  13.252 +qed "CInfinitesimal_CFinite_mult2";
  13.253 +
  13.254 +Goalw [CInfinite_def,HInfinite_def] 
  13.255 +   "(z : CInfinite) = (hcmod z : HInfinite)";
  13.256 +by Auto_tac;
  13.257 +qed "CInfinite_hcmod_iff";
  13.258 +
  13.259 +Goal "x: CInfinite ==> inverse x: CInfinitesimal";
  13.260 +by (auto_tac (claset() addIs [HInfinite_inverse_Infinitesimal],
  13.261 +    simpset() addsimps [CInfinitesimal_hcmod_iff,
  13.262 +    CInfinite_hcmod_iff,hcmod_hcomplex_inverse]));
  13.263 +qed "CInfinite_inverse_CInfinitesimal";
  13.264 +
  13.265 +Goal "[|x: CInfinite; y: CInfinite|] ==> (x*y): CInfinite";
  13.266 +by (auto_tac (claset() addIs [HInfinite_mult],simpset() addsimps 
  13.267 +    [CInfinite_hcmod_iff,hcmod_mult]));
  13.268 +qed "CInfinite_mult";
  13.269 +
  13.270 +Goalw [CInfinite_def] "(-x : CInfinite) = (x : CInfinite)";
  13.271 +by (Simp_tac 1);
  13.272 +qed "CInfinite_minus_iff";
  13.273 +Addsimps [CInfinite_minus_iff];
  13.274 +
  13.275 +Goal "[|a: CFinite; b: CFinite; c: CFinite|] \ 
  13.276 +\     ==> a*a + b*b + c*c : CFinite";
  13.277 +by (auto_tac (claset() addIs [CFinite_mult,CFinite_add], simpset()));
  13.278 +qed "CFinite_sum_squares";
  13.279 +
  13.280 +Goal "x ~: CInfinitesimal ==> x ~= 0";
  13.281 +by Auto_tac;
  13.282 +qed "not_CInfinitesimal_not_zero";
  13.283 +
  13.284 +Goal "x: CFinite - CInfinitesimal ==> x ~= 0";
  13.285 +by Auto_tac;
  13.286 +qed "not_CInfinitesimal_not_zero2";
  13.287 +
  13.288 +Goal "x : CFinite - CInfinitesimal ==> hcmod x : HFinite - Infinitesimal";
  13.289 +by (auto_tac (claset(),simpset() addsimps [CFinite_hcmod_iff,CInfinitesimal_hcmod_iff]));
  13.290 +qed "CFinite_diff_CInfinitesimal_hcmod";
  13.291 +
  13.292 +Goal "[| e : CInfinitesimal; hcmod x < hcmod e |] ==> x : CInfinitesimal";
  13.293 +by (auto_tac (claset() addIs [hrabs_less_Infinitesimal],simpset() 
  13.294 +    addsimps [CInfinitesimal_hcmod_iff]));
  13.295 +qed "hcmod_less_CInfinitesimal";
  13.296 +
  13.297 +Goal "[| e : CInfinitesimal; hcmod x <= hcmod e |] ==> x : CInfinitesimal";
  13.298 +by (auto_tac (claset() addIs [hrabs_le_Infinitesimal],simpset() 
  13.299 +    addsimps [CInfinitesimal_hcmod_iff]));
  13.300 +qed "hcmod_le_CInfinitesimal";
  13.301 +
  13.302 +Goal  "[| e : CInfinitesimal; \
  13.303 +\         e' : CInfinitesimal; \
  13.304 +\         hcmod e' < hcmod x ; hcmod x < hcmod e \
  13.305 +\      |] ==> x : CInfinitesimal";
  13.306 +by (auto_tac (claset() addIs [Infinitesimal_interval],simpset() 
  13.307 +    addsimps [CInfinitesimal_hcmod_iff]));
  13.308 +qed "CInfinitesimal_interval";
  13.309 +
  13.310 +Goal "[| e : CInfinitesimal; \
  13.311 +\        e' : CInfinitesimal; \
  13.312 +\        hcmod e' <= hcmod x ; hcmod x <= hcmod e \
  13.313 +\     |] ==> x : CInfinitesimal";
  13.314 +by (auto_tac (claset() addIs [Infinitesimal_interval2],simpset() 
  13.315 +    addsimps [CInfinitesimal_hcmod_iff]));
  13.316 +qed "CInfinitesimal_interval2";
  13.317 +
  13.318 +Goal "[| x ~: CInfinitesimal;  y ~: CInfinitesimal|] ==> (x*y) ~: CInfinitesimal";
  13.319 +by (auto_tac (claset(),simpset() addsimps [CInfinitesimal_hcmod_iff,hcmod_mult]));
  13.320 +by (dtac not_Infinitesimal_mult 1);
  13.321 +by Auto_tac;
  13.322 +qed "not_CInfinitesimal_mult";
  13.323 +
  13.324 +Goal "x*y : CInfinitesimal ==> x : CInfinitesimal | y : CInfinitesimal";
  13.325 +by (auto_tac (claset() addDs [Infinitesimal_mult_disj],simpset() addsimps 
  13.326 +    [CInfinitesimal_hcmod_iff,hcmod_mult]));
  13.327 +qed "CInfinitesimal_mult_disj";
  13.328 +
  13.329 +Goal "[| x : CFinite - CInfinitesimal; \
  13.330 +\                  y : CFinite - CInfinitesimal \
  13.331 +\               |] ==> (x*y) : CFinite - CInfinitesimal";
  13.332 +by (Clarify_tac 1);
  13.333 +by (blast_tac (claset() addDs [CFinite_mult,not_CInfinitesimal_mult]) 1);
  13.334 +qed "CFinite_CInfinitesimal_diff_mult";
  13.335 +
  13.336 +Goal "CInfinitesimal <= CFinite";
  13.337 +by (auto_tac (claset() addIs [Infinitesimal_subset_HFinite RS subsetD],
  13.338 +    simpset() addsimps [CInfinitesimal_hcmod_iff,CFinite_hcmod_iff]));
  13.339 +qed "CInfinitesimal_subset_CFinite";
  13.340 +
  13.341 +Goal "x: CInfinitesimal ==> x * hcomplex_of_complex r : CInfinitesimal";
  13.342 +by (auto_tac (claset() addSIs [Infinitesimal_HFinite_mult],
  13.343 +    simpset() addsimps [CInfinitesimal_hcmod_iff,hcmod_mult]));
  13.344 +qed "CInfinitesimal_hcomplex_of_complex_mult";
  13.345 +
  13.346 +Goal "x: CInfinitesimal ==> hcomplex_of_complex r * x: CInfinitesimal";
  13.347 +by (auto_tac (claset() addSIs [Infinitesimal_HFinite_mult2],
  13.348 +    simpset() addsimps [CInfinitesimal_hcmod_iff,hcmod_mult]));
  13.349 +qed "CInfinitesimal_hcomplex_of_complex_mult2";
  13.350 +
  13.351 +
  13.352 +(*--------------------------------------------------------------------------------------*)
  13.353 +(* Infinitely close relation @c=                                                        *)
  13.354 +(* -------------------------------------------------------------------------------------*)
  13.355 +
  13.356 +(*
  13.357 +Goalw [capprox_def,approx_def] "(z @c= w) = (hcmod z @= hcmod w)";
  13.358 +by (auto_tac (claset(),simpset() addsimps [CInfinitesimal_hcmod_iff]));
  13.359 +*)
  13.360 +
  13.361 +Goal "x:CInfinitesimal = (x @c= 0)";
  13.362 +by (simp_tac (simpset() addsimps [CInfinitesimal_hcmod_iff,
  13.363 +    capprox_def]) 1);
  13.364 +qed "mem_cinfmal_iff";
  13.365 +
  13.366 +Goalw [capprox_def,hcomplex_diff_def]
  13.367 +      " (x @c= y) = (x + -y @c= 0)";
  13.368 +by (Simp_tac 1);
  13.369 +qed "capprox_minus_iff";
  13.370 +
  13.371 +Goalw [capprox_def,hcomplex_diff_def]
  13.372 +      " (x @c= y) = (-y + x @c= 0)";
  13.373 +by (simp_tac (simpset() addsimps [hcomplex_add_commute]) 1);
  13.374 +qed "capprox_minus_iff2";
  13.375 +
  13.376 +Goalw [capprox_def] "x @c= x";
  13.377 +by (Simp_tac 1);
  13.378 +qed "capprox_refl";
  13.379 +Addsimps [capprox_refl];
  13.380 +
  13.381 +Goalw [capprox_def,CInfinitesimal_def]  
  13.382 +     "x @c= y ==> y @c= x";
  13.383 +by (auto_tac (claset() addSDs [bspec],simpset() addsimps 
  13.384 +    [hcmod_diff_commute]));
  13.385 +qed "capprox_sym";
  13.386 +
  13.387 +Goalw [capprox_def]  "[| x @c= y; y @c= z |] ==> x @c= z";
  13.388 +by (dtac CInfinitesimal_add 1); 
  13.389 +by (assume_tac 1); 
  13.390 +by (auto_tac (claset(),simpset() addsimps [hcomplex_diff_def]));
  13.391 +qed "capprox_trans";
  13.392 +
  13.393 +Goal "[| r @c= x; s @c= x |] ==> r @c= s";
  13.394 +by (blast_tac (claset() addIs [capprox_sym, capprox_trans]) 1); 
  13.395 +qed "capprox_trans2";
  13.396 +
  13.397 +Goal "[| x @c= r; x @c= s|] ==> r @c= s";
  13.398 +by (blast_tac (claset() addIs [capprox_sym, capprox_trans]) 1); 
  13.399 +qed "capprox_trans3";
  13.400 +
  13.401 +Goal "(number_of w @c= x) = (x @c= number_of w)";
  13.402 +by (blast_tac (claset() addIs [capprox_sym]) 1); 
  13.403 +qed "number_of_capprox_reorient";
  13.404 +Addsimps [number_of_capprox_reorient];
  13.405 +
  13.406 +Goal "(x-y : CInfinitesimal) = (x @c= y)";
  13.407 +by (auto_tac (claset(),
  13.408 +              simpset() addsimps [hcomplex_diff_def, capprox_minus_iff RS sym,
  13.409 +                                  mem_cinfmal_iff]));
  13.410 +qed "CInfinitesimal_capprox_minus";
  13.411 +
  13.412 +Goalw [cmonad_def] "(x @c= y) = (cmonad(x)=cmonad(y))";
  13.413 +by (auto_tac (claset() addDs [capprox_sym] 
  13.414 +                       addSEs [capprox_trans,equalityCE],
  13.415 +              simpset()));
  13.416 +qed "capprox_monad_iff";
  13.417 +
  13.418 +Goal "[| x: CInfinitesimal; y: CInfinitesimal |] ==> x @c= y";
  13.419 +by (asm_full_simp_tac (simpset() addsimps [mem_cinfmal_iff]) 1);
  13.420 +by (blast_tac (claset() addIs [capprox_trans, capprox_sym]) 1); 
  13.421 +qed "Infinitesimal_capprox";
  13.422 +
  13.423 +val prem1::prem2::rest = 
  13.424 +goalw thy [capprox_def,hcomplex_diff_def] 
  13.425 +     "[| a @c= b; c @c= d |] ==> a+c @c= b+d";
  13.426 +by (rtac (hcomplex_minus_add_distrib RS ssubst) 1);
  13.427 +by (rtac (hcomplex_add_assoc RS ssubst) 1);
  13.428 +by (res_inst_tac [("y1","c")] (hcomplex_add_left_commute RS subst) 1);
  13.429 +by (rtac (hcomplex_add_assoc RS subst) 1);
  13.430 +by (rtac ([prem1,prem2] MRS CInfinitesimal_add) 1);
  13.431 +qed "capprox_add";
  13.432 +
  13.433 +Goal "a @c= b ==> -a @c= -b";
  13.434 +by (rtac ((capprox_minus_iff RS iffD2) RS capprox_sym) 1);
  13.435 +by (dtac (capprox_minus_iff RS iffD1) 1);
  13.436 +by (simp_tac (simpset() addsimps [hcomplex_add_commute]) 1);
  13.437 +qed "capprox_minus";
  13.438 +
  13.439 +Goal "-a @c= -b ==> a @c= b";
  13.440 +by (auto_tac (claset() addDs [capprox_minus], simpset()));
  13.441 +qed "capprox_minus2";
  13.442 +
  13.443 +Goal "(-a @c= -b) = (a @c= b)";
  13.444 +by (blast_tac (claset() addIs [capprox_minus,capprox_minus2]) 1);
  13.445 +qed "capprox_minus_cancel";
  13.446 +Addsimps [capprox_minus_cancel];
  13.447 +
  13.448 +Goal "[| a @c= b; c @c= d |] ==> a + -c @c= b + -d";
  13.449 +by (blast_tac (claset() addSIs [capprox_add,capprox_minus]) 1);
  13.450 +qed "capprox_add_minus";
  13.451 +
  13.452 +Goalw [capprox_def,hcomplex_diff_def] 
  13.453 +      "[| a @c= b; c: CFinite|] ==> a*c @c= b*c"; 
  13.454 +by (asm_full_simp_tac (simpset() addsimps [CInfinitesimal_CFinite_mult,
  13.455 +    hcomplex_minus_mult_eq1,hcomplex_add_mult_distrib RS sym] 
  13.456 +    delsimps [hcomplex_minus_mult_eq1 RS sym]) 1);
  13.457 +qed "capprox_mult1";
  13.458 +
  13.459 +Goal "[|a @c= b; c: CFinite|] ==> c*a @c= c*b"; 
  13.460 +by (asm_simp_tac (simpset() addsimps [capprox_mult1,hcomplex_mult_commute]) 1);
  13.461 +qed "capprox_mult2";
  13.462 +
  13.463 +Goal "[|u @c= v*x; x @c= y; v: CFinite|] ==> u @c= v*y";
  13.464 +by (fast_tac (claset() addIs [capprox_mult2,capprox_trans]) 1);
  13.465 +qed "capprox_mult_subst";
  13.466 +
  13.467 +Goal "[| u @c= x*v; x @c= y; v: CFinite |] ==> u @c= y*v";
  13.468 +by (fast_tac (claset() addIs [capprox_mult1,capprox_trans]) 1);
  13.469 +qed "capprox_mult_subst2";
  13.470 +
  13.471 +Goal "[| u @c= x*hcomplex_of_complex v; x @c= y |] ==> u @c= y*hcomplex_of_complex v";
  13.472 +by (auto_tac (claset() addIs [capprox_mult_subst2], simpset()));
  13.473 +qed "capprox_mult_subst_SComplex";
  13.474 +
  13.475 +Goalw [capprox_def]  "a = b ==> a @c= b";
  13.476 +by (Asm_simp_tac 1);
  13.477 +qed "capprox_eq_imp";
  13.478 +
  13.479 +Goal "x: CInfinitesimal ==> -x @c= x"; 
  13.480 +by (fast_tac (HOL_cs addIs [CInfinitesimal_minus_iff RS iffD2,
  13.481 +    mem_cinfmal_iff RS iffD1,capprox_trans2]) 1);
  13.482 +qed "CInfinitesimal_minus_capprox";
  13.483 +
  13.484 +Goalw [capprox_def]  
  13.485 +     "(EX y: CInfinitesimal. x - z = y) = (x @c= z)";
  13.486 +by (Blast_tac 1);
  13.487 +qed "bex_CInfinitesimal_iff";
  13.488 +
  13.489 +Goal "(EX y: CInfinitesimal. x = z + y) = (x @c= z)";
  13.490 +by (asm_full_simp_tac (simpset() addsimps [bex_CInfinitesimal_iff RS sym]) 1);
  13.491 +by (Force_tac 1);
  13.492 +qed "bex_CInfinitesimal_iff2";
  13.493 +
  13.494 +Goal "[| y: CInfinitesimal; x + y = z |] ==> x @c= z";
  13.495 +by (rtac (bex_CInfinitesimal_iff RS iffD1) 1);
  13.496 +by (dtac (CInfinitesimal_minus_iff RS iffD2) 1);
  13.497 +by (auto_tac (claset(), simpset() addsimps [hcomplex_add_assoc RS sym]));
  13.498 +qed "CInfinitesimal_add_capprox";
  13.499 +
  13.500 +Goal "y: CInfinitesimal ==> x @c= x + y";
  13.501 +by (rtac (bex_CInfinitesimal_iff RS iffD1) 1);
  13.502 +by (dtac (CInfinitesimal_minus_iff RS iffD2) 1);
  13.503 +by (auto_tac (claset(), simpset() addsimps [hcomplex_add_assoc RS sym]));
  13.504 +qed "CInfinitesimal_add_capprox_self";
  13.505 +
  13.506 +Goal "y: CInfinitesimal ==> x @c= y + x";
  13.507 +by (auto_tac (claset() addDs [CInfinitesimal_add_capprox_self],
  13.508 +    simpset() addsimps [hcomplex_add_commute]));
  13.509 +qed "CInfinitesimal_add_capprox_self2";
  13.510 +
  13.511 +Goal "y: CInfinitesimal ==> x @c= x + -y";
  13.512 +by (blast_tac (claset() addSIs [CInfinitesimal_add_capprox_self,
  13.513 +                                CInfinitesimal_minus_iff RS iffD2]) 1);
  13.514 +qed "CInfinitesimal_add_minus_capprox_self";
  13.515 +
  13.516 +Goal "[| y: CInfinitesimal; x+y @c= z|] ==> x @c= z";
  13.517 +by (dres_inst_tac [("x","x")] (CInfinitesimal_add_capprox_self RS capprox_sym) 1);
  13.518 +by (etac (capprox_trans3 RS capprox_sym) 1);
  13.519 +by (assume_tac 1);
  13.520 +qed "CInfinitesimal_add_cancel";
  13.521 +
  13.522 +Goal "[| y: CInfinitesimal; x @c= z + y|] ==> x @c= z";
  13.523 +by (dres_inst_tac [("x","z")] (CInfinitesimal_add_capprox_self2  RS capprox_sym) 1);
  13.524 +by (etac (capprox_trans3 RS capprox_sym) 1);
  13.525 +by (asm_full_simp_tac (simpset() addsimps [hcomplex_add_commute]) 1);
  13.526 +by (etac capprox_sym 1);
  13.527 +qed "CInfinitesimal_add_right_cancel";
  13.528 +
  13.529 +Goal "d + b  @c= d + c ==> b @c= c";
  13.530 +by (dtac (capprox_minus_iff RS iffD1) 1);
  13.531 +by (asm_full_simp_tac (simpset() addsimps 
  13.532 +    [hcomplex_minus_add_distrib,capprox_minus_iff RS sym] 
  13.533 +    @ hcomplex_add_ac) 1);
  13.534 +qed "capprox_add_left_cancel";
  13.535 +
  13.536 +Goal "b + d @c= c + d ==> b @c= c";
  13.537 +by (rtac capprox_add_left_cancel 1);
  13.538 +by (asm_full_simp_tac (simpset() addsimps 
  13.539 +    [hcomplex_add_commute]) 1);
  13.540 +qed "capprox_add_right_cancel";
  13.541 +
  13.542 +Goal "b @c= c ==> d + b @c= d + c";
  13.543 +by (rtac (capprox_minus_iff RS iffD2) 1);
  13.544 +by (asm_full_simp_tac (simpset() addsimps 
  13.545 +    [capprox_minus_iff RS sym] @ hcomplex_add_ac) 1);
  13.546 +qed "capprox_add_mono1";
  13.547 +
  13.548 +Goal "b @c= c ==> b + a @c= c + a";
  13.549 +by (asm_simp_tac (simpset() addsimps 
  13.550 +    [hcomplex_add_commute,capprox_add_mono1]) 1);
  13.551 +qed "capprox_add_mono2";
  13.552 +
  13.553 +Goal "(a + b @c= a + c) = (b @c= c)";
  13.554 +by (fast_tac (claset() addEs [capprox_add_left_cancel,
  13.555 +    capprox_add_mono1]) 1);
  13.556 +qed "capprox_add_left_iff";
  13.557 +
  13.558 +AddIffs [capprox_add_left_iff];
  13.559 +
  13.560 +
  13.561 +Goal "(b + a @c= c + a) = (b @c= c)";
  13.562 +by (simp_tac (simpset() addsimps [hcomplex_add_commute]) 1);
  13.563 +qed "capprox_add_right_iff";
  13.564 +
  13.565 +AddIffs [capprox_add_right_iff];
  13.566 +
  13.567 +Goal "[| x: CFinite; x @c= y |] ==> y: CFinite";
  13.568 +by (dtac (bex_CInfinitesimal_iff2 RS iffD2) 1);
  13.569 +by (Step_tac 1);
  13.570 +by (dtac (CInfinitesimal_subset_CFinite RS subsetD 
  13.571 +          RS (CFinite_minus_iff RS iffD2)) 1);
  13.572 +by (dtac CFinite_add 1);
  13.573 +by (assume_tac 1 THEN Auto_tac);
  13.574 +qed "capprox_CFinite";
  13.575 +
  13.576 +Goal "x @c= hcomplex_of_complex D ==> x: CFinite";
  13.577 +by (rtac (capprox_sym RSN (2,capprox_CFinite)) 1);
  13.578 +by Auto_tac;
  13.579 +qed "capprox_hcomplex_of_complex_CFinite";
  13.580 +
  13.581 +Goal "[|a @c= b; c @c= d; b: CFinite; d: CFinite|] ==> a*c @c= b*d";
  13.582 +by (rtac capprox_trans 1); 
  13.583 +by (rtac capprox_mult2 2); 
  13.584 +by (rtac capprox_mult1 1);
  13.585 +by (blast_tac (claset() addIs [capprox_CFinite, capprox_sym]) 2);  
  13.586 +by Auto_tac;  
  13.587 +qed "capprox_mult_CFinite";
  13.588 +
  13.589 +Goal "[|a @c= hcomplex_of_complex b; c @c= hcomplex_of_complex d |] \
  13.590 +\     ==> a*c @c= hcomplex_of_complex b * hcomplex_of_complex d";
  13.591 +by (blast_tac (claset() addSIs [capprox_mult_CFinite,
  13.592 +            capprox_hcomplex_of_complex_CFinite,CFinite_hcomplex_of_complex]) 1);
  13.593 +qed "capprox_mult_hcomplex_of_complex";
  13.594 +
  13.595 +Goal "[| a: SComplex; a ~= 0; a*x @c= 0 |] ==> x @c= 0";
  13.596 +by (dtac (SComplex_inverse RS (SComplex_subset_CFinite RS subsetD)) 1);
  13.597 +by (auto_tac (claset() addDs [capprox_mult2],
  13.598 +    simpset() addsimps [hcomplex_mult_assoc RS sym]));
  13.599 +qed "capprox_SComplex_mult_cancel_zero";
  13.600 +
  13.601 +Goal "[| a: SComplex; x @c= 0 |] ==> x*a @c= 0";
  13.602 +by (auto_tac (claset() addDs [(SComplex_subset_CFinite RS subsetD),
  13.603 +              capprox_mult1], simpset()));
  13.604 +qed "capprox_mult_SComplex1";
  13.605 +
  13.606 +Goal "[| a: SComplex; x @c= 0 |] ==> a*x @c= 0";
  13.607 +by (auto_tac (claset() addDs [(SComplex_subset_CFinite RS subsetD),
  13.608 +              capprox_mult2], simpset()));
  13.609 +qed "capprox_mult_SComplex2";
  13.610 +
  13.611 +Goal "[|a : SComplex; a ~= 0 |] ==> (a*x @c= 0) = (x @c= 0)";
  13.612 +by (blast_tac (claset() addIs [capprox_SComplex_mult_cancel_zero,
  13.613 +    capprox_mult_SComplex2]) 1);
  13.614 +qed "capprox_mult_SComplex_zero_cancel_iff";
  13.615 +Addsimps [capprox_mult_SComplex_zero_cancel_iff];
  13.616 +
  13.617 +Goal "[| a: SComplex; a ~= 0; a* w @c= a*z |] ==> w @c= z";
  13.618 +by (dtac (SComplex_inverse RS (SComplex_subset_CFinite RS subsetD)) 1);
  13.619 +by (auto_tac (claset() addDs [capprox_mult2],
  13.620 +    simpset() addsimps [hcomplex_mult_assoc RS sym]));
  13.621 +qed "capprox_SComplex_mult_cancel";
  13.622 +
  13.623 +Goal "[| a: SComplex; a ~= 0|] ==> (a* w @c= a*z) = (w @c= z)";
  13.624 +by (auto_tac (claset() addSIs [capprox_mult2,SComplex_subset_CFinite RS subsetD] 
  13.625 +    addIs [capprox_SComplex_mult_cancel], simpset()));
  13.626 +qed "capprox_SComplex_mult_cancel_iff1";
  13.627 +Addsimps [capprox_SComplex_mult_cancel_iff1];
  13.628 +
  13.629 +Goal "(x @c= y) = (hcmod (y - x) @= 0)";
  13.630 +by (rtac (capprox_minus_iff RS ssubst) 1);
  13.631 +by (auto_tac (claset(),simpset() addsimps [capprox_def,
  13.632 +    CInfinitesimal_hcmod_iff,mem_infmal_iff,symmetric hcomplex_diff_def,
  13.633 +    hcmod_diff_commute]));
  13.634 +qed "capprox_hcmod_approx_zero";
  13.635 +
  13.636 +Goal "(x @c= 0) = (hcmod x @= 0)";
  13.637 +by (auto_tac (claset(),simpset() addsimps 
  13.638 +    [capprox_hcmod_approx_zero]));
  13.639 +qed "capprox_approx_zero_iff";
  13.640 +
  13.641 +Goal "(-x @c= 0) = (x @c= 0)";
  13.642 +by (auto_tac (claset(),simpset() addsimps 
  13.643 +    [capprox_hcmod_approx_zero]));
  13.644 +qed "capprox_minus_zero_cancel_iff";
  13.645 +Addsimps [capprox_minus_zero_cancel_iff];
  13.646 +
  13.647 +Goal "u @c= 0 ==> hcmod(x + u) - hcmod x : Infinitesimal";
  13.648 +by (res_inst_tac [("e","hcmod u"),("e'","- hcmod u")] Infinitesimal_interval2 1);
  13.649 +by (auto_tac (claset() addDs [capprox_approx_zero_iff RS iffD1], 
  13.650 +    simpset() addsimps [mem_infmal_iff RS sym,hypreal_diff_def]));
  13.651 +by (res_inst_tac [("C","hcmod x")] hypreal_le_add_left_cancel 1);
  13.652 +by (auto_tac (claset(),simpset() addsimps [symmetric hypreal_diff_def]));
  13.653 +qed "Infinitesimal_hcmod_add_diff";
  13.654 +
  13.655 +Goal "u @c= 0 ==> hcmod(x + u) @= hcmod x";
  13.656 +by (rtac (approx_minus_iff RS iffD2) 1);
  13.657 +by (auto_tac (claset() addIs [Infinitesimal_hcmod_add_diff],
  13.658 +    simpset() addsimps [mem_infmal_iff RS sym,symmetric hypreal_diff_def]));
  13.659 +qed "approx_hcmod_add_hcmod";
  13.660 +
  13.661 +Goal "x @c= y ==> hcmod x @= hcmod y";
  13.662 +by (auto_tac (claset() addIs [approx_hcmod_add_hcmod] 
  13.663 +    addSDs [bex_CInfinitesimal_iff2 RS iffD2],simpset() addsimps [mem_cinfmal_iff]));
  13.664 +qed "capprox_hcmod_approx";
  13.665 +
  13.666 +(*--------------------------------------------------------------------------------------*)
  13.667 +(* zero is the only complex number that is also infinitesimal                           *)
  13.668 +(*--------------------------------------------------------------------------------------*)
  13.669 +
  13.670 +Goal "[| x: SComplex; y: CInfinitesimal; 0 < hcmod x |] ==> hcmod y < hcmod x";
  13.671 +by (auto_tac (claset() addSIs [Infinitesimal_less_SReal,SComplex_hcmod_SReal],
  13.672 +    simpset() addsimps [CInfinitesimal_hcmod_iff]));
  13.673 +qed "CInfinitesimal_less_SComplex";
  13.674 +
  13.675 +Goal "y: CInfinitesimal ==> ALL r: SComplex. 0 < hcmod r --> hcmod y < hcmod r";
  13.676 +by (blast_tac (claset() addIs [CInfinitesimal_less_SComplex]) 1);
  13.677 +qed "CInfinitesimal_less_SComplex2";
  13.678 +
  13.679 +Goal "SComplex Int CInfinitesimal = {0}";
  13.680 +by (auto_tac (claset(),simpset() addsimps [SComplex_def,CInfinitesimal_hcmod_iff]));
  13.681 +by (cut_inst_tac [("r","r")] SReal_hcmod_hcomplex_of_complex 1);
  13.682 +by (dres_inst_tac [("A","Reals")] IntI 1 THEN assume_tac 1);
  13.683 +by (subgoal_tac "hcmod (hcomplex_of_complex r) = 0" 1);
  13.684 +by (Asm_full_simp_tac 1);
  13.685 +by (cut_facts_tac [SReal_Int_Infinitesimal_zero] 1);
  13.686 +by (rotate_tac 2 1);
  13.687 +by (Asm_full_simp_tac 1);
  13.688 +qed "SComplex_Int_CInfinitesimal_zero";
  13.689 +
  13.690 +Goal "[| x: SComplex; x: CInfinitesimal|] ==> x = 0";
  13.691 +by (cut_facts_tac [SComplex_Int_CInfinitesimal_zero] 1);
  13.692 +by (Blast_tac 1);
  13.693 +qed "SComplex_CInfinitesimal_zero";
  13.694 +
  13.695 +Goal "[| x : SComplex; x ~= 0 |] ==> x : CFinite - CInfinitesimal";
  13.696 +by (auto_tac (claset() addDs [SComplex_CInfinitesimal_zero,
  13.697 +                              SComplex_subset_CFinite RS subsetD], 
  13.698 +              simpset()));
  13.699 +qed "SComplex_CFinite_diff_CInfinitesimal";
  13.700 +
  13.701 +Goal "hcomplex_of_complex x ~= 0 ==> hcomplex_of_complex x : CFinite - CInfinitesimal";
  13.702 +by (rtac SComplex_CFinite_diff_CInfinitesimal 1);
  13.703 +by Auto_tac;
  13.704 +qed "hcomplex_of_complex_CFinite_diff_CInfinitesimal";
  13.705 +
  13.706 +Goal "(hcomplex_of_complex x : CInfinitesimal) = (x=0)";
  13.707 +by (auto_tac (claset(), simpset() addsimps [hcomplex_of_complex_zero]));  
  13.708 +by (rtac ccontr 1); 
  13.709 +by (rtac (hcomplex_of_complex_CFinite_diff_CInfinitesimal RS DiffD2) 1); 
  13.710 +by Auto_tac;  
  13.711 +qed "hcomplex_of_complex_CInfinitesimal_iff_0";
  13.712 +AddIffs [hcomplex_of_complex_CInfinitesimal_iff_0];
  13.713 +
  13.714 +Goal "number_of w ~= (0::hcomplex) ==> number_of w ~: CInfinitesimal";
  13.715 +by (fast_tac (claset() addDs [SComplex_number_of RS SComplex_CInfinitesimal_zero]) 1);
  13.716 +qed "number_of_not_CInfinitesimal";
  13.717 +Addsimps [number_of_not_CInfinitesimal];
  13.718 +
  13.719 +Goal "[| y: SComplex; x @c= y; y~= 0 |] ==> x ~= 0";
  13.720 +by (auto_tac (claset() addDs [SComplex_CInfinitesimal_zero,
  13.721 +    capprox_sym RS (mem_cinfmal_iff RS iffD2)],simpset()));
  13.722 +qed "capprox_SComplex_not_zero";
  13.723 +
  13.724 +Goal "[| x @c= y; y : CFinite - CInfinitesimal |] \
  13.725 +\     ==> x : CFinite - CInfinitesimal";
  13.726 +by (auto_tac (claset() addIs [capprox_sym RSN (2,capprox_CFinite)],
  13.727 +              simpset() addsimps [mem_cinfmal_iff]));
  13.728 +by (dtac capprox_trans3 1 THEN assume_tac 1);
  13.729 +by (blast_tac (claset() addDs [capprox_sym]) 1);
  13.730 +qed "CFinite_diff_CInfinitesimal_capprox";
  13.731 +
  13.732 +Goal "[| y ~= 0;  y: CInfinitesimal;  x/y : CFinite |] ==> x : CInfinitesimal";
  13.733 +by (dtac CInfinitesimal_CFinite_mult2 1);
  13.734 +by (assume_tac 1);
  13.735 +by (asm_full_simp_tac 
  13.736 +    (simpset() addsimps [hcomplex_divide_def, hcomplex_mult_assoc]) 1);
  13.737 +qed "CInfinitesimal_ratio";
  13.738 +
  13.739 +Goal "[|x: SComplex; y: SComplex|] ==> (x @c= y) = (x = y)"; 
  13.740 +by Auto_tac;
  13.741 +by (rewrite_goals_tac [capprox_def]);
  13.742 +by (dres_inst_tac [("x","y")] SComplex_minus 1);
  13.743 +by (dtac SComplex_add 1 THEN assume_tac 1);
  13.744 +by (rtac (CLAIM "x - y = 0 ==> x = (y::hcomplex)") 1);
  13.745 +by (rtac SComplex_CInfinitesimal_zero 1);
  13.746 +by (auto_tac (claset(),simpset() addsimps [hcomplex_diff_def]));
  13.747 +qed "SComplex_capprox_iff";
  13.748 +
  13.749 +Goal "(number_of v @c= number_of w) = (number_of v = (number_of w :: hcomplex))";
  13.750 +by (rtac SComplex_capprox_iff 1); 
  13.751 +by Auto_tac;  
  13.752 +qed "number_of_capprox_iff";
  13.753 +Addsimps [number_of_capprox_iff];
  13.754 +
  13.755 +Goal "(number_of w : CInfinitesimal) = (number_of w = (0::hcomplex))";
  13.756 +by (rtac iffI 1);
  13.757 +by (fast_tac (claset() addDs [SComplex_number_of RS SComplex_CInfinitesimal_zero]) 1);
  13.758 +by (Asm_simp_tac 1);
  13.759 +qed "number_of_CInfinitesimal_iff";
  13.760 +Addsimps [number_of_CInfinitesimal_iff];
  13.761 +
  13.762 +Goal "(hcomplex_of_complex k @c= hcomplex_of_complex m) = (k = m)";
  13.763 +by Auto_tac;  
  13.764 +by (rtac (inj_hcomplex_of_complex RS injD) 1); 
  13.765 +by (rtac (SComplex_capprox_iff RS iffD1) 1); 
  13.766 +by Auto_tac;  
  13.767 +qed "hcomplex_of_complex_approx_iff";
  13.768 +Addsimps [hcomplex_of_complex_approx_iff];
  13.769 +
  13.770 +Goal "(hcomplex_of_complex k @c= number_of w) = (k = number_of w)";
  13.771 +by (stac (hcomplex_of_complex_approx_iff RS sym) 1); 
  13.772 +by Auto_tac;  
  13.773 +qed "hcomplex_of_complex_capprox_number_of_iff";
  13.774 +Addsimps [hcomplex_of_complex_capprox_number_of_iff];
  13.775 +
  13.776 +Goal "[| r: SComplex; s: SComplex; r @c= x; s @c= x|] ==> r = s";
  13.777 +by (blast_tac (claset() addIs [(SComplex_capprox_iff RS iffD1),
  13.778 +               capprox_trans2]) 1);
  13.779 +qed "capprox_unique_complex";
  13.780 +
  13.781 +Goal "Abs_hcomplex(hcomplexrel ``{%n. X n}) @c= Abs_hcomplex(hcomplexrel``{%n. Y n}) \
  13.782 +\     ==> Abs_hypreal(hyprel `` {%n. Re(X n)}) @= \
  13.783 +\         Abs_hypreal(hyprel `` {%n. Re(Y n)})";
  13.784 +by (auto_tac (claset(),simpset() addsimps [approx_FreeUltrafilterNat_iff]));
  13.785 +by (dtac (capprox_minus_iff RS iffD1) 1);
  13.786 +by (auto_tac (claset(),simpset() addsimps [hcomplex_minus,hcomplex_add,
  13.787 +    mem_cinfmal_iff RS sym,CInfinitesimal_hcmod_iff,hcmod,
  13.788 +    Infinitesimal_FreeUltrafilterNat_iff2]));
  13.789 +by (dres_inst_tac [("x","m")] spec 1);
  13.790 +by (Ultra_tac 1);
  13.791 +by (res_inst_tac [("z","X x")] eq_Abs_complex 1);
  13.792 +by (res_inst_tac [("z","Y x")] eq_Abs_complex 1);
  13.793 +by (auto_tac (claset(),simpset() addsimps [complex_minus,complex_add,
  13.794 +    complex_mod] delsimps [realpow_Suc]));
  13.795 +by (rtac order_le_less_trans 1 THEN assume_tac 2);
  13.796 +by (dres_inst_tac [("t","Ya x")] sym 1);
  13.797 +by (auto_tac (claset(),simpset() addsimps [abs_eqI1] delsimps [realpow_Suc]));
  13.798 +qed "hcomplex_capproxD1";
  13.799 +
  13.800 +(* same proof *)
  13.801 +Goal "Abs_hcomplex(hcomplexrel ``{%n. X n}) @c= Abs_hcomplex(hcomplexrel``{%n. Y n}) \
  13.802 +\     ==> Abs_hypreal(hyprel `` {%n. Im(X n)}) @= \
  13.803 +\         Abs_hypreal(hyprel `` {%n. Im(Y n)})";
  13.804 +by (auto_tac (claset(),simpset() addsimps [approx_FreeUltrafilterNat_iff]));
  13.805 +by (dtac (capprox_minus_iff RS iffD1) 1);
  13.806 +by (auto_tac (claset(),simpset() addsimps [hcomplex_minus,hcomplex_add,
  13.807 +    mem_cinfmal_iff RS sym,CInfinitesimal_hcmod_iff,hcmod,
  13.808 +    Infinitesimal_FreeUltrafilterNat_iff2]));
  13.809 +by (dres_inst_tac [("x","m")] spec 1);
  13.810 +by (Ultra_tac 1);
  13.811 +by (res_inst_tac [("z","X x")] eq_Abs_complex 1);
  13.812 +by (res_inst_tac [("z","Y x")] eq_Abs_complex 1);
  13.813 +by (auto_tac (claset(),simpset() addsimps [complex_minus,complex_add,
  13.814 +    complex_mod] delsimps [realpow_Suc]));
  13.815 +by (rtac order_le_less_trans 1 THEN assume_tac 2);
  13.816 +by (dres_inst_tac [("t","Ya x")] sym 1);
  13.817 +by (auto_tac (claset(),simpset() addsimps [abs_eqI1] delsimps [realpow_Suc]));
  13.818 +qed "hcomplex_capproxD2";
  13.819 +
  13.820 +Goal "[| Abs_hypreal(hyprel `` {%n. Re(X n)}) @= \
  13.821 +\        Abs_hypreal(hyprel `` {%n. Re(Y n)}); \
  13.822 +\        Abs_hypreal(hyprel `` {%n. Im(X n)}) @= \
  13.823 +\        Abs_hypreal(hyprel `` {%n. Im(Y n)}) \
  13.824 +\     |] ==> Abs_hcomplex(hcomplexrel ``{%n. X n}) @c= Abs_hcomplex(hcomplexrel``{%n. Y n})";
  13.825 +by (dtac (approx_minus_iff RS iffD1) 1);
  13.826 +by (dtac (approx_minus_iff RS iffD1) 1);
  13.827 +by (rtac (capprox_minus_iff RS iffD2) 1);
  13.828 +by (auto_tac (claset(),simpset() addsimps [mem_cinfmal_iff RS sym,
  13.829 +    mem_infmal_iff RS sym,hypreal_minus,hypreal_add,hcomplex_minus,
  13.830 +    hcomplex_add,CInfinitesimal_hcmod_iff,hcmod,Infinitesimal_FreeUltrafilterNat_iff]));
  13.831 +by (rtac bexI 1 THEN rtac lemma_hyprel_refl 2);
  13.832 +by Auto_tac;
  13.833 +by (dres_inst_tac [("x","u/2")] spec 1);
  13.834 +by (dres_inst_tac [("x","u/2")] spec 1);
  13.835 +by (Step_tac 1);
  13.836 +by (TRYALL(Force_tac));
  13.837 +by (ultra_tac (claset(),HOL_ss) 1);
  13.838 +by (dtac sym 1 THEN dtac sym 1);
  13.839 +by (res_inst_tac [("z","X x")] eq_Abs_complex 1);
  13.840 +by (res_inst_tac [("z","Y x")] eq_Abs_complex 1);
  13.841 +by (auto_tac (claset(),HOL_ss addsimps [complex_minus,complex_add,
  13.842 +    complex_mod,pair_mem_complex RS Abs_complex_inverse,snd_conv,
  13.843 +    fst_conv,two_eq_Suc_Suc]));
  13.844 +by (rtac (realpow_two_abs RS subst) 1);
  13.845 +by (res_inst_tac [("x1","xa + - xb")] (realpow_two_abs RS subst) 1);
  13.846 +by (simp_tac (simpset() addsimps [two_eq_Suc_Suc RS sym]) 1);
  13.847 +by (rtac lemma_sqrt_hcomplex_capprox 1);
  13.848 +by Auto_tac;
  13.849 +qed "hcomplex_capproxI";
  13.850 +
  13.851 +Goal "(Abs_hcomplex(hcomplexrel ``{%n. X n}) @c= Abs_hcomplex(hcomplexrel``{%n. Y n})) =\
  13.852 +\      (Abs_hypreal(hyprel `` {%n. Re(X n)}) @= Abs_hypreal(hyprel `` {%n. Re(Y n)}) & \
  13.853 +\       Abs_hypreal(hyprel `` {%n. Im(X n)}) @= Abs_hypreal(hyprel `` {%n. Im(Y n)}))";
  13.854 +by (blast_tac (claset() addIs [hcomplex_capproxI,hcomplex_capproxD1,hcomplex_capproxD2]) 1);
  13.855 +qed "capprox_approx_iff";
  13.856 +
  13.857 +Goal "(hcomplex_of_hypreal x @c= hcomplex_of_hypreal z) = (x @= z)";
  13.858 +by (res_inst_tac [("z","x")] eq_Abs_hypreal 1);
  13.859 +by (res_inst_tac [("z","z")] eq_Abs_hypreal 1);
  13.860 +by (auto_tac (claset(),simpset() addsimps [hcomplex_of_hypreal,
  13.861 +    capprox_approx_iff]));
  13.862 +qed "hcomplex_of_hypreal_capprox_iff";
  13.863 +Addsimps [hcomplex_of_hypreal_capprox_iff];
  13.864 +
  13.865 +Goal "Abs_hcomplex(hcomplexrel ``{%n. X n}) : CFinite \
  13.866 +\     ==> Abs_hypreal(hyprel `` {%n. Re(X n)}) : HFinite";
  13.867 +by (auto_tac (claset(),simpset() addsimps [CFinite_hcmod_iff,
  13.868 +    hcmod,HFinite_FreeUltrafilterNat_iff]));
  13.869 +by (rtac bexI 1 THEN rtac lemma_hyprel_refl 2);
  13.870 +by (res_inst_tac [("x","u")] exI 1 THEN Auto_tac);
  13.871 +by (Ultra_tac 1);
  13.872 +by (dtac sym 1 THEN res_inst_tac [("z","X x")] eq_Abs_complex 1);
  13.873 +by (auto_tac (claset(),simpset() addsimps [complex_mod,two_eq_Suc_Suc] delsimps [realpow_Suc]));
  13.874 +by (rtac ccontr 1 THEN dtac real_leI 1);
  13.875 +by (dtac order_less_le_trans 1 THEN assume_tac 1);
  13.876 +by (dtac (real_sqrt_ge_abs1 RSN (2,order_less_le_trans)) 1);
  13.877 +by (auto_tac (claset(),simpset() addsimps [two_eq_Suc_Suc RS sym]));
  13.878 +qed "CFinite_HFinite_Re";
  13.879 +
  13.880 +Goal "Abs_hcomplex(hcomplexrel ``{%n. X n}) : CFinite \
  13.881 +\     ==> Abs_hypreal(hyprel `` {%n. Im(X n)}) : HFinite";
  13.882 +by (auto_tac (claset(),simpset() addsimps [CFinite_hcmod_iff,
  13.883 +    hcmod,HFinite_FreeUltrafilterNat_iff]));
  13.884 +by (rtac bexI 1 THEN rtac lemma_hyprel_refl 2);
  13.885 +by (res_inst_tac [("x","u")] exI 1 THEN Auto_tac);
  13.886 +by (Ultra_tac 1);
  13.887 +by (dtac sym 1 THEN res_inst_tac [("z","X x")] eq_Abs_complex 1);
  13.888 +by (auto_tac (claset(),simpset() addsimps [complex_mod] delsimps [realpow_Suc]));
  13.889 +by (rtac ccontr 1 THEN dtac real_leI 1);
  13.890 +by (dtac order_less_le_trans 1 THEN assume_tac 1);
  13.891 +by (dtac (real_sqrt_ge_abs2 RSN (2,order_less_le_trans)) 1);
  13.892 +by Auto_tac;
  13.893 +qed "CFinite_HFinite_Im";
  13.894 +
  13.895 +Goal "[| Abs_hypreal(hyprel `` {%n. Re(X n)}) : HFinite; \
  13.896 +\        Abs_hypreal(hyprel `` {%n. Im(X n)}) : HFinite \
  13.897 +\     |] ==> Abs_hcomplex(hcomplexrel ``{%n. X n}) : CFinite";
  13.898 +by (auto_tac (claset(),simpset() addsimps [CFinite_hcmod_iff,
  13.899 +    hcmod,HFinite_FreeUltrafilterNat_iff]));
  13.900 +by (rtac bexI 1 THEN rtac lemma_hyprel_refl 2);
  13.901 +by (res_inst_tac [("x","2*(u + ua)")] exI 1);
  13.902 +by (Ultra_tac 1);
  13.903 +by (dtac sym 1 THEN res_inst_tac [("z","X x")] eq_Abs_complex 1);
  13.904 +by (auto_tac (claset(),simpset() addsimps [complex_mod,two_eq_Suc_Suc] delsimps [realpow_Suc]));
  13.905 +by (subgoal_tac "0 < u" 1 THEN arith_tac 2);
  13.906 +by (subgoal_tac "0 < ua" 1 THEN arith_tac 2);
  13.907 +by (rtac (realpow_two_abs RS subst) 1);
  13.908 +by (res_inst_tac [("x1","Y x")] (realpow_two_abs RS subst) 1);
  13.909 +by (simp_tac (simpset() addsimps [two_eq_Suc_Suc RS sym]) 1);
  13.910 +by (rtac lemma_sqrt_hcomplex_capprox 1);
  13.911 +by Auto_tac;
  13.912 +qed "HFinite_Re_Im_CFinite";
  13.913 +
  13.914 +Goal "(Abs_hcomplex(hcomplexrel ``{%n. X n}) : CFinite) = \
  13.915 +\     (Abs_hypreal(hyprel `` {%n. Re(X n)}) : HFinite & \
  13.916 +\      Abs_hypreal(hyprel `` {%n. Im(X n)}) : HFinite)";
  13.917 +by (blast_tac (claset() addIs [HFinite_Re_Im_CFinite,CFinite_HFinite_Im,
  13.918 +    CFinite_HFinite_Re]) 1);
  13.919 +qed "CFinite_HFinite_iff";
  13.920 +
  13.921 +Goal "Abs_hcomplex(hcomplexrel ``{%n. X n}) : SComplex \
  13.922 +\     ==> Abs_hypreal(hyprel `` {%n. Re(X n)}) : Reals";
  13.923 +by (auto_tac (claset(),simpset() addsimps [SComplex_def,
  13.924 +    hcomplex_of_complex_def,SReal_def,hypreal_of_real_def]));
  13.925 +by (res_inst_tac [("x","Re r")] exI 1);
  13.926 +by (Ultra_tac 1);
  13.927 +qed "SComplex_Re_SReal";
  13.928 +
  13.929 +Goal "Abs_hcomplex(hcomplexrel ``{%n. X n}) : SComplex \
  13.930 +\     ==> Abs_hypreal(hyprel `` {%n. Im(X n)}) : Reals";
  13.931 +by (auto_tac (claset(),simpset() addsimps [SComplex_def,
  13.932 +    hcomplex_of_complex_def,SReal_def,hypreal_of_real_def]));
  13.933 +by (res_inst_tac [("x","Im r")] exI 1);
  13.934 +by (Ultra_tac 1);
  13.935 +qed "SComplex_Im_SReal";
  13.936 +
  13.937 +Goal "[| Abs_hypreal(hyprel `` {%n. Re(X n)}) : Reals; \
  13.938 +\        Abs_hypreal(hyprel `` {%n. Im(X n)}) : Reals \
  13.939 +\     |] ==> Abs_hcomplex(hcomplexrel ``{%n. X n}) : SComplex";
  13.940 +by (auto_tac (claset(),simpset() addsimps [SComplex_def,
  13.941 +    hcomplex_of_complex_def,SReal_def,hypreal_of_real_def]));
  13.942 +by (res_inst_tac [("x","complex_of_real r + ii  * complex_of_real ra")] exI 1);
  13.943 +by (Ultra_tac 1);
  13.944 +by (res_inst_tac [("z","X x")] eq_Abs_complex 1);
  13.945 +by (auto_tac (claset(),simpset() addsimps [complex_of_real_def,i_def,
  13.946 +    complex_add,complex_mult]));
  13.947 +qed "Reals_Re_Im_SComplex";
  13.948 +
  13.949 +Goal "(Abs_hcomplex(hcomplexrel ``{%n. X n}) : SComplex) = \
  13.950 +\     (Abs_hypreal(hyprel `` {%n. Re(X n)}) : Reals & \
  13.951 +\      Abs_hypreal(hyprel `` {%n. Im(X n)}) : Reals)";
  13.952 +by (blast_tac (claset() addIs [SComplex_Re_SReal,SComplex_Im_SReal,
  13.953 +    Reals_Re_Im_SComplex]) 1);
  13.954 +qed "SComplex_SReal_iff";
  13.955 +
  13.956 +Goal "(Abs_hcomplex(hcomplexrel ``{%n. X n}) : CInfinitesimal) = \
  13.957 +\     (Abs_hypreal(hyprel `` {%n. Re(X n)}) : Infinitesimal & \
  13.958 +\      Abs_hypreal(hyprel `` {%n. Im(X n)}) : Infinitesimal)";
  13.959 +by (auto_tac (claset(),simpset() addsimps [mem_cinfmal_iff,
  13.960 +    mem_infmal_iff,hcomplex_zero_num,hypreal_zero_num,capprox_approx_iff]));
  13.961 +qed "CInfinitesimal_Infinitesimal_iff";
  13.962 +
  13.963 +(*** more lemmas ****)
  13.964 +Goal "(EX t. P t) = (EX X. P (Abs_hcomplex(hcomplexrel `` {X})))";
  13.965 +by Auto_tac;
  13.966 +by (res_inst_tac [("z","t")] eq_Abs_hcomplex 1);
  13.967 +by Auto_tac;
  13.968 +qed "eq_Abs_hcomplex_EX";
  13.969 +
  13.970 +Goal "(EX t : A. P t) = (EX X. (Abs_hcomplex(hcomplexrel `` {X})) : A & \
  13.971 +\                        P (Abs_hcomplex(hcomplexrel `` {X})))";
  13.972 +by Auto_tac;
  13.973 +by (res_inst_tac [("z","t")] eq_Abs_hcomplex 1);
  13.974 +by Auto_tac;
  13.975 +qed "eq_Abs_hcomplex_Bex";
  13.976 +
  13.977 +(* Here we go - easy proof now!! *)
  13.978 +Goal "x:CFinite ==> EX t: SComplex. x @c= t";
  13.979 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
  13.980 +by (auto_tac (claset(),simpset() addsimps [CFinite_HFinite_iff,
  13.981 +    eq_Abs_hcomplex_Bex,SComplex_SReal_iff,capprox_approx_iff]));
  13.982 +by (REPEAT(dtac st_part_Ex 1 THEN Step_tac 1));
  13.983 +by (res_inst_tac [("z","t")] eq_Abs_hypreal 1);
  13.984 +by (res_inst_tac [("z","ta")] eq_Abs_hypreal 1);
  13.985 +by Auto_tac;
  13.986 +by (res_inst_tac [("x","%n. complex_of_real (xa n) + ii * complex_of_real (xb n)")]
  13.987 +    exI 1);
  13.988 +by Auto_tac;
  13.989 +qed "stc_part_Ex";
  13.990 +
  13.991 +Goal "x:CFinite ==> EX! t. t : SComplex &  x @c= t";
  13.992 +by (dtac stc_part_Ex 1 THEN Step_tac 1);
  13.993 +by (dtac capprox_sym 2 THEN dtac capprox_sym 2 
  13.994 +    THEN dtac capprox_sym 2);
  13.995 +by (auto_tac (claset() addSIs [capprox_unique_complex], simpset()));
  13.996 +qed "stc_part_Ex1";
  13.997 +
  13.998 +Goalw [CFinite_def,CInfinite_def] "CFinite Int CInfinite = {}";
  13.999 +by Auto_tac;
 13.1000 +qed "CFinite_Int_CInfinite_empty";
 13.1001 +Addsimps [CFinite_Int_CInfinite_empty];
 13.1002 +
 13.1003 +Goal "x: CFinite ==> x ~: CInfinite";
 13.1004 +by (EVERY1[Step_tac, dtac IntI, assume_tac]);
 13.1005 +by Auto_tac;
 13.1006 +qed "CFinite_not_CInfinite";
 13.1007 +
 13.1008 +Goal "x~: CFinite ==> x: CInfinite";
 13.1009 +by (auto_tac (claset() addIs [not_HFinite_HInfinite],
 13.1010 +    simpset() addsimps [CFinite_hcmod_iff,CInfinite_hcmod_iff]));
 13.1011 +qed "not_CFinite_CInfinite";
 13.1012 +
 13.1013 +Goal "x : CInfinite | x : CFinite";
 13.1014 +by (blast_tac (claset() addIs [not_CFinite_CInfinite]) 1);
 13.1015 +qed "CInfinite_CFinite_disj";
 13.1016 +
 13.1017 +Goal "(x : CInfinite) = (x ~: CFinite)";
 13.1018 +by (blast_tac (claset() addDs [CFinite_not_CInfinite,
 13.1019 +               not_CFinite_CInfinite]) 1);
 13.1020 +qed "CInfinite_CFinite_iff";
 13.1021 +
 13.1022 +Goal "(x : CFinite) = (x ~: CInfinite)";
 13.1023 +by (simp_tac (simpset() addsimps [CInfinite_CFinite_iff]) 1);
 13.1024 +qed "CFinite_CInfinite_iff";
 13.1025 +
 13.1026 +Goal "x ~: CInfinitesimal ==> x : CInfinite | x : CFinite - CInfinitesimal";
 13.1027 +by (fast_tac (claset() addIs [not_CFinite_CInfinite]) 1);
 13.1028 +qed "CInfinite_diff_CFinite_CInfinitesimal_disj";
 13.1029 +
 13.1030 +Goal "[| x : CFinite; x ~: CInfinitesimal |] ==> inverse x : CFinite";
 13.1031 +by (cut_inst_tac [("x","inverse x")] CInfinite_CFinite_disj 1);
 13.1032 +by (auto_tac (claset() addSDs [CInfinite_inverse_CInfinitesimal], simpset()));
 13.1033 +qed "CFinite_inverse";
 13.1034 +
 13.1035 +Goal "x : CFinite - CInfinitesimal ==> inverse x : CFinite";
 13.1036 +by (blast_tac (claset() addIs [CFinite_inverse]) 1);
 13.1037 +qed "CFinite_inverse2";
 13.1038 +
 13.1039 +Goal "x ~: CInfinitesimal ==> inverse(x) : CFinite";
 13.1040 +by (dtac CInfinite_diff_CFinite_CInfinitesimal_disj 1);
 13.1041 +by (blast_tac (claset() addIs [CFinite_inverse,
 13.1042 +                 CInfinite_inverse_CInfinitesimal,
 13.1043 +                 CInfinitesimal_subset_CFinite RS subsetD]) 1);
 13.1044 +qed "CInfinitesimal_inverse_CFinite";
 13.1045 +
 13.1046 +
 13.1047 +Goal "x : CFinite - CInfinitesimal ==> inverse x : CFinite - CInfinitesimal";
 13.1048 +by (auto_tac (claset() addIs [CInfinitesimal_inverse_CFinite], simpset()));
 13.1049 +by (dtac CInfinitesimal_CFinite_mult2 1);
 13.1050 +by (assume_tac 1);
 13.1051 +by (asm_full_simp_tac (simpset() addsimps [not_CInfinitesimal_not_zero]) 1); 
 13.1052 +qed "CFinite_not_CInfinitesimal_inverse";
 13.1053 +
 13.1054 +Goal "[| x @c= y; y :  CFinite - CInfinitesimal |] \
 13.1055 +\     ==> inverse x @c= inverse y";
 13.1056 +by (forward_tac [CFinite_diff_CInfinitesimal_capprox] 1);
 13.1057 +by (assume_tac 1);
 13.1058 +by (forward_tac [not_CInfinitesimal_not_zero2] 1);
 13.1059 +by (forw_inst_tac [("x","x")] not_CInfinitesimal_not_zero2 1);
 13.1060 +by (REPEAT(dtac CFinite_inverse2 1));
 13.1061 +by (dtac capprox_mult2 1 THEN assume_tac 1);
 13.1062 +by Auto_tac;
 13.1063 +by (dres_inst_tac [("c","inverse x")] capprox_mult1 1 
 13.1064 +    THEN assume_tac 1);
 13.1065 +by (auto_tac (claset() addIs [capprox_sym],
 13.1066 +    simpset() addsimps [hcomplex_mult_assoc]));
 13.1067 +qed "capprox_inverse";
 13.1068 +
 13.1069 +bind_thm ("hcomplex_of_complex_capprox_inverse",
 13.1070 +       hcomplex_of_complex_CFinite_diff_CInfinitesimal RSN (2, capprox_inverse));
 13.1071 +
 13.1072 +Goal "[| x: CFinite - CInfinitesimal; \
 13.1073 +\        h : CInfinitesimal |] ==> inverse(x + h) @c= inverse x";
 13.1074 +by (auto_tac (claset() addIs [capprox_inverse, capprox_sym, 
 13.1075 +                              CInfinitesimal_add_capprox_self], 
 13.1076 +              simpset()));
 13.1077 +qed "inverse_add_CInfinitesimal_capprox";
 13.1078 +
 13.1079 +Goal "[| x: CFinite - CInfinitesimal; \
 13.1080 +\        h : CInfinitesimal |] ==> inverse(h + x) @c= inverse x";
 13.1081 +by (rtac (hcomplex_add_commute RS subst) 1);
 13.1082 +by (blast_tac (claset() addIs [inverse_add_CInfinitesimal_capprox]) 1);
 13.1083 +qed "inverse_add_CInfinitesimal_capprox2";
 13.1084 +
 13.1085 +Goal "[| x : CFinite - CInfinitesimal; \
 13.1086 +\        h : CInfinitesimal |] ==> inverse(x + h) - inverse x @c= h"; 
 13.1087 +by (rtac capprox_trans2 1);
 13.1088 +by (auto_tac (claset() addIs [inverse_add_CInfinitesimal_capprox],
 13.1089 +              simpset() addsimps [mem_cinfmal_iff,hcomplex_diff_def,
 13.1090 +                                  capprox_minus_iff RS sym]));
 13.1091 +qed "inverse_add_CInfinitesimal_approx_CInfinitesimal";
 13.1092 +
 13.1093 +Goal "(x*x : CInfinitesimal) = (x : CInfinitesimal)";
 13.1094 +by (auto_tac (claset(), simpset() addsimps [CInfinitesimal_hcmod_iff,
 13.1095 +    hcmod_mult]));
 13.1096 +qed "CInfinitesimal_square_iff";
 13.1097 +AddIffs [CInfinitesimal_square_iff];
 13.1098 +
 13.1099 +Goal "[| a: CFinite-CInfinitesimal; a*w @c= a*z |] ==> w @c= z";
 13.1100 +by (Step_tac 1);
 13.1101 +by (ftac CFinite_inverse 1 THEN assume_tac 1);
 13.1102 +by (dtac not_CInfinitesimal_not_zero 1);
 13.1103 +by (auto_tac (claset() addDs [capprox_mult2],
 13.1104 +    simpset() addsimps [hcomplex_mult_assoc RS sym]));
 13.1105 +qed "capprox_CFinite_mult_cancel";
 13.1106 +
 13.1107 +Goal "a: CFinite-CInfinitesimal ==> (a * w @c= a * z) = (w @c= z)";
 13.1108 +by (auto_tac (claset() addIs [capprox_mult2,
 13.1109 +    capprox_CFinite_mult_cancel], simpset()));
 13.1110 +qed "capprox_CFinite_mult_cancel_iff1";
 13.1111 +
 13.1112 +
 13.1113 +(*---------------------------------------------------------------------------*)
 13.1114 +(* Theorems about monads                                                     *)
 13.1115 +(*---------------------------------------------------------------------------*)
 13.1116 +
 13.1117 +Goalw [cmonad_def] "(x @c= y) = (cmonad(x)=cmonad(y))";
 13.1118 +by (auto_tac (claset() addDs [capprox_sym] 
 13.1119 +                       addSEs [capprox_trans,equalityCE],
 13.1120 +              simpset()));
 13.1121 +qed "capprox_cmonad_iff";
 13.1122 +
 13.1123 +Goal "e : CInfinitesimal ==> cmonad (x+e) = cmonad x";
 13.1124 +by (fast_tac (claset() addSIs [CInfinitesimal_add_capprox_self RS capprox_sym,
 13.1125 +    capprox_cmonad_iff RS iffD1]) 1);
 13.1126 +qed "CInfinitesimal_cmonad_eq";
 13.1127 +
 13.1128 +Goalw [cmonad_def] "(u:cmonad x) = (-u:cmonad (-x))";
 13.1129 +by Auto_tac;
 13.1130 +qed "mem_cmonad_iff";
 13.1131 +
 13.1132 +Goalw [cmonad_def] "(x:CInfinitesimal) = (x:cmonad 0)";
 13.1133 +by (auto_tac (claset() addIs [capprox_sym],
 13.1134 +    simpset() addsimps [mem_cinfmal_iff]));
 13.1135 +qed "CInfinitesimal_cmonad_zero_iff";
 13.1136 +
 13.1137 +Goal "(x:cmonad 0) = (-x:cmonad 0)";
 13.1138 +by (simp_tac (simpset() addsimps [CInfinitesimal_cmonad_zero_iff RS sym]) 1);
 13.1139 +qed "cmonad_zero_minus_iff";
 13.1140 +
 13.1141 +Goal "(x:cmonad 0) = (hcmod x:monad 0)";
 13.1142 +by (auto_tac (claset(), simpset() addsimps 
 13.1143 +    [CInfinitesimal_cmonad_zero_iff RS sym,
 13.1144 +     CInfinitesimal_hcmod_iff,Infinitesimal_monad_zero_iff RS sym]));
 13.1145 +qed "cmonad_zero_hcmod_iff";
 13.1146 +
 13.1147 +Goalw [cmonad_def] "x:cmonad x";
 13.1148 +by (Simp_tac 1);
 13.1149 +qed "mem_cmonad_self";
 13.1150 +Addsimps [mem_cmonad_self];
 13.1151 +
 13.1152 +(*---------------------------------------------------------------------------*)
 13.1153 +(* Theorems about standard part                                              *)
 13.1154 +(*---------------------------------------------------------------------------*)
 13.1155 +Goalw [stc_def] "x: CFinite ==> stc x @c= x";
 13.1156 +by (forward_tac [stc_part_Ex] 1 THEN Step_tac 1);
 13.1157 +by (rtac someI2 1);
 13.1158 +by (auto_tac (claset() addIs [capprox_sym], simpset()));
 13.1159 +qed "stc_capprox_self";
 13.1160 +
 13.1161 +Goalw [stc_def] "x: CFinite ==> stc x: SComplex";
 13.1162 +by (forward_tac [stc_part_Ex] 1 THEN Step_tac 1);
 13.1163 +by (rtac someI2 1);
 13.1164 +by (auto_tac (claset() addIs [capprox_sym], simpset()));
 13.1165 +qed "stc_SComplex";
 13.1166 +
 13.1167 +Goal "x: CFinite ==> stc x: CFinite";
 13.1168 +by (etac (stc_SComplex RS (SComplex_subset_CFinite RS subsetD)) 1);
 13.1169 +qed "stc_CFinite";
 13.1170 +
 13.1171 +Goalw [stc_def] "x: SComplex ==> stc x = x";
 13.1172 +by (rtac some_equality 1);
 13.1173 +by (auto_tac (claset() addIs [(SComplex_subset_CFinite RS subsetD)],simpset()));
 13.1174 +by (blast_tac (claset() addDs [SComplex_capprox_iff RS iffD1]) 1);
 13.1175 +qed "stc_SComplex_eq";
 13.1176 +Addsimps [stc_SComplex_eq];
 13.1177 +
 13.1178 +Goal "stc (hcomplex_of_complex x) = hcomplex_of_complex x";
 13.1179 +by Auto_tac;
 13.1180 +qed "stc_hcomplex_of_complex";
 13.1181 +
 13.1182 +Goal "[| x: CFinite; y: CFinite; stc x = stc y |] ==> x @c= y";
 13.1183 +by (auto_tac (claset() addSDs [stc_capprox_self] 
 13.1184 +              addSEs [capprox_trans3], simpset()));
 13.1185 +qed "stc_eq_capprox";
 13.1186 +
 13.1187 +Goal "[| x: CFinite; y: CFinite; x @c= y |] ==> stc x = stc y";
 13.1188 +by (EVERY1 [forward_tac [stc_capprox_self],
 13.1189 +    forw_inst_tac [("x","y")] stc_capprox_self,
 13.1190 +    dtac stc_SComplex,dtac stc_SComplex]);
 13.1191 +by (fast_tac (claset() addEs [capprox_trans,
 13.1192 +    capprox_trans2,SComplex_capprox_iff RS iffD1]) 1);
 13.1193 +qed "capprox_stc_eq";
 13.1194 +
 13.1195 +Goal "[| x: CFinite; y: CFinite|] ==> (x @c= y) = (stc x = stc y)";
 13.1196 +by (blast_tac (claset() addIs [capprox_stc_eq,stc_eq_capprox]) 1);
 13.1197 +qed "stc_eq_capprox_iff";
 13.1198 +
 13.1199 +Goal "[| x: SComplex; e: CInfinitesimal |] ==> stc(x + e) = x";
 13.1200 +by (forward_tac [stc_SComplex_eq RS subst] 1);
 13.1201 +by (assume_tac 2);
 13.1202 +by (forward_tac [SComplex_subset_CFinite RS subsetD] 1);
 13.1203 +by (forward_tac [CInfinitesimal_subset_CFinite RS subsetD] 1);
 13.1204 +by (dtac stc_SComplex_eq 1);
 13.1205 +by (rtac capprox_stc_eq 1);
 13.1206 +by (auto_tac (claset() addIs  [CFinite_add],
 13.1207 +    simpset() addsimps [CInfinitesimal_add_capprox_self 
 13.1208 +    RS capprox_sym]));
 13.1209 +qed "stc_CInfinitesimal_add_SComplex";
 13.1210 +
 13.1211 +Goal "[| x: SComplex; e: CInfinitesimal |] ==> stc(e + x) = x";
 13.1212 +by (rtac (hcomplex_add_commute RS subst) 1);
 13.1213 +by (blast_tac (claset() addSIs [stc_CInfinitesimal_add_SComplex]) 1);
 13.1214 +qed "stc_CInfinitesimal_add_SComplex2";
 13.1215 +
 13.1216 +Goal "x: CFinite ==> EX e: CInfinitesimal. x = stc(x) + e";
 13.1217 +by (blast_tac (claset() addSDs [(stc_capprox_self RS 
 13.1218 +    capprox_sym),bex_CInfinitesimal_iff2 RS iffD2]) 1);
 13.1219 +qed "CFinite_stc_CInfinitesimal_add";
 13.1220 +
 13.1221 +Goal "[| x: CFinite; y: CFinite |] ==> stc (x + y) = stc(x) + stc(y)";
 13.1222 +by (forward_tac [CFinite_stc_CInfinitesimal_add] 1);
 13.1223 +by (forw_inst_tac [("x","y")] CFinite_stc_CInfinitesimal_add 1);
 13.1224 +by (Step_tac 1);
 13.1225 +by (subgoal_tac "stc (x + y) = stc ((stc x + e) + (stc y + ea))" 1);
 13.1226 +by (dtac sym 2 THEN dtac sym 2);
 13.1227 +by (Asm_full_simp_tac 2);
 13.1228 +by (asm_simp_tac (simpset() addsimps hcomplex_add_ac) 1);
 13.1229 +by (REPEAT(dtac stc_SComplex 1));
 13.1230 +by (dtac SComplex_add 1 THEN assume_tac 1);
 13.1231 +by (dtac CInfinitesimal_add 1 THEN assume_tac 1);
 13.1232 +by (rtac (hcomplex_add_assoc RS subst) 1);
 13.1233 +by (blast_tac (claset() addSIs [stc_CInfinitesimal_add_SComplex2]) 1);
 13.1234 +qed "stc_add";
 13.1235 +
 13.1236 +Goal "stc (number_of w) = number_of w";
 13.1237 +by (rtac (SComplex_number_of RS stc_SComplex_eq) 1);
 13.1238 +qed "stc_number_of";
 13.1239 +Addsimps [stc_number_of];
 13.1240 +
 13.1241 +Goal "stc 0 = 0";
 13.1242 +by (Simp_tac 1);
 13.1243 +qed "stc_zero";
 13.1244 +Addsimps [stc_zero];
 13.1245 +
 13.1246 +Goal "stc 1 = 1";
 13.1247 +by (Simp_tac 1);
 13.1248 +qed "stc_one";
 13.1249 +Addsimps [stc_one];
 13.1250 +
 13.1251 +Goal "y: CFinite ==> stc(-y) = -stc(y)";
 13.1252 +by (forward_tac [CFinite_minus_iff RS iffD2] 1);
 13.1253 +by (rtac hcomplex_add_minus_eq_minus 1);
 13.1254 +by (dtac (stc_add RS sym) 1 THEN assume_tac 1);
 13.1255 +by Auto_tac;  
 13.1256 +qed "stc_minus";
 13.1257 +
 13.1258 +Goalw [hcomplex_diff_def]
 13.1259 +     "[| x: CFinite; y: CFinite |] ==> stc (x-y) = stc(x) - stc(y)";
 13.1260 +by (forw_inst_tac [("y1","y")] (stc_minus RS sym) 1);
 13.1261 +by (dres_inst_tac [("x1","y")] (CFinite_minus_iff RS iffD2) 1);
 13.1262 +by (auto_tac (claset() addIs [stc_add],simpset()));
 13.1263 +qed "stc_diff";
 13.1264 +
 13.1265 +Goal "[| x: CFinite; y: CFinite; \
 13.1266 +\        e: CInfinitesimal;       \
 13.1267 +\        ea: CInfinitesimal |]   \
 13.1268 +\      ==> e*y + x*ea + e*ea: CInfinitesimal";
 13.1269 +by (forw_inst_tac [("x","e"),("y","y")] CInfinitesimal_CFinite_mult 1);
 13.1270 +by (forw_inst_tac [("x","ea"),("y","x")] CInfinitesimal_CFinite_mult 2);
 13.1271 +by (dtac CInfinitesimal_mult 3);
 13.1272 +by (auto_tac (claset() addIs [CInfinitesimal_add],
 13.1273 +              simpset() addsimps hcomplex_add_ac @ hcomplex_mult_ac));
 13.1274 +qed "lemma_stc_mult";
 13.1275 +
 13.1276 +Goal "[| x: CFinite; y: CFinite |] \
 13.1277 +\              ==> stc (x * y) = stc(x) * stc(y)";
 13.1278 +by (forward_tac [CFinite_stc_CInfinitesimal_add] 1);
 13.1279 +by (forw_inst_tac [("x","y")] CFinite_stc_CInfinitesimal_add 1);
 13.1280 +by (Step_tac 1);
 13.1281 +by (subgoal_tac "stc (x * y) = stc ((stc x + e) * (stc y + ea))" 1);
 13.1282 +by (dtac sym 2 THEN dtac sym 2);
 13.1283 +by (Asm_full_simp_tac 2);
 13.1284 +by (thin_tac "x = stc x + e" 1);
 13.1285 +by (thin_tac "y = stc y + ea" 1);
 13.1286 +by (asm_full_simp_tac (simpset() addsimps 
 13.1287 +    [hcomplex_add_mult_distrib,hcomplex_add_mult_distrib2]) 1);
 13.1288 +by (REPEAT(dtac stc_SComplex 1));
 13.1289 +by (full_simp_tac (simpset() addsimps [hcomplex_add_assoc]) 1);
 13.1290 +by (rtac stc_CInfinitesimal_add_SComplex 1);
 13.1291 +by (blast_tac (claset() addSIs [SComplex_mult]) 1);
 13.1292 +by (REPEAT(dtac (SComplex_subset_CFinite RS subsetD) 1));
 13.1293 +by (rtac (hcomplex_add_assoc RS subst) 1);
 13.1294 +by (blast_tac (claset() addSIs [lemma_stc_mult]) 1);
 13.1295 +qed "stc_mult";
 13.1296 +
 13.1297 +Goal "x: CInfinitesimal ==> stc x = 0";
 13.1298 +by (rtac (stc_zero RS subst) 1);
 13.1299 +by (rtac capprox_stc_eq 1);
 13.1300 +by (auto_tac (claset() addIs [CInfinitesimal_subset_CFinite RS subsetD],
 13.1301 +              simpset() addsimps [mem_cinfmal_iff RS sym]));
 13.1302 +qed "stc_CInfinitesimal";
 13.1303 +
 13.1304 +Goal "stc(x) ~= 0 ==> x ~: CInfinitesimal";
 13.1305 +by (fast_tac (claset() addIs [stc_CInfinitesimal]) 1);
 13.1306 +qed "stc_not_CInfinitesimal";
 13.1307 +
 13.1308 +Goal "[| x: CFinite; stc x ~= 0 |] \
 13.1309 +\     ==> stc(inverse x) = inverse (stc x)";
 13.1310 +by (res_inst_tac [("c1","stc x")] (hcomplex_mult_left_cancel RS iffD1) 1);
 13.1311 +by (auto_tac (claset(),
 13.1312 +       simpset() addsimps [stc_mult RS sym, stc_not_CInfinitesimal,
 13.1313 +                           CFinite_inverse]));
 13.1314 +by (stac hcomplex_mult_inv_right 1); 
 13.1315 +by Auto_tac;  
 13.1316 +qed "stc_inverse";
 13.1317 +
 13.1318 +Goal "[| x: CFinite; y: CFinite; stc y ~= 0 |] \
 13.1319 +\     ==> stc(x/y) = (stc x) / (stc y)";
 13.1320 +by (auto_tac (claset(),
 13.1321 +      simpset() addsimps [hcomplex_divide_def, stc_mult, stc_not_CInfinitesimal, 
 13.1322 +                          CFinite_inverse, stc_inverse]));
 13.1323 +qed "stc_divide";
 13.1324 +Addsimps [stc_divide];
 13.1325 +
 13.1326 +Goal "x: CFinite ==> stc(stc(x)) = stc(x)";
 13.1327 +by (blast_tac (claset() addIs [stc_CFinite, stc_capprox_self,
 13.1328 +                               capprox_stc_eq]) 1);
 13.1329 +qed "stc_idempotent";
 13.1330 +Addsimps [stc_idempotent];
 13.1331 +
 13.1332 +Goal "z : HFinite ==> hcomplex_of_hypreal z : CFinite";
 13.1333 +by (res_inst_tac [("z","z")] eq_Abs_hypreal 1);
 13.1334 +by (auto_tac (claset(),simpset() addsimps [hcomplex_of_hypreal,
 13.1335 +    CFinite_HFinite_iff,symmetric hypreal_zero_def]));
 13.1336 +qed "CFinite_HFinite_hcomplex_of_hypreal";
 13.1337 +
 13.1338 +Goal "x : Reals ==>  hcomplex_of_hypreal x : SComplex";
 13.1339 +by (res_inst_tac [("z","x")] eq_Abs_hypreal 1);
 13.1340 +by (auto_tac (claset(),simpset() addsimps [hcomplex_of_hypreal,
 13.1341 +    SComplex_SReal_iff,symmetric hypreal_zero_def]));
 13.1342 +qed "SComplex_SReal_hcomplex_of_hypreal";
 13.1343 +
 13.1344 +Goalw [st_def,stc_def] 
 13.1345 + "z : HFinite ==> stc(hcomplex_of_hypreal z) = hcomplex_of_hypreal (st z)";
 13.1346 +by (ftac st_part_Ex 1 THEN Step_tac 1);
 13.1347 +by (rtac someI2 1);
 13.1348 +by (auto_tac (claset() addIs [approx_sym],simpset()));
 13.1349 +by (dtac CFinite_HFinite_hcomplex_of_hypreal 1);
 13.1350 +by (ftac stc_part_Ex 1 THEN Step_tac 1);
 13.1351 +by (rtac someI2 1);
 13.1352 +by (auto_tac (claset() addIs [capprox_sym] addSIs [capprox_unique_complex] 
 13.1353 +    addDs [SComplex_SReal_hcomplex_of_hypreal],simpset()));
 13.1354 +qed "stc_hcomplex_of_hypreal";
 13.1355 +
 13.1356 +(*
 13.1357 +Goal "x: CFinite ==> hcmod(stc x) = st(hcmod x)";
 13.1358 +by (dtac stc_capprox_self 1);
 13.1359 +by (auto_tac (claset(),simpset() addsimps [bex_CInfinitesimal_iff2 RS sym]));
 13.1360 +
 13.1361 +
 13.1362 +approx_hcmod_add_hcmod
 13.1363 +*)
 13.1364 +
 13.1365 +(*---------------------------------------------------------------------------*)
 13.1366 +(* More nonstandard complex specific theorems                                *)        
 13.1367 +(*---------------------------------------------------------------------------*)
 13.1368 +Goal "(hcnj z : CInfinitesimal) = (z : CInfinitesimal)";
 13.1369 +by (auto_tac (claset(),simpset() addsimps [CInfinitesimal_hcmod_iff]));
 13.1370 +qed "CInfinitesimal_hcnj_iff";
 13.1371 +Addsimps [CInfinitesimal_hcnj_iff];
 13.1372 +
 13.1373 +Goal "(Abs_hcomplex(hcomplexrel ``{%n. X n}) : CInfinite) = \
 13.1374 +\     (Abs_hypreal(hyprel `` {%n. Re(X n)}) : HInfinite | \
 13.1375 +\      Abs_hypreal(hyprel `` {%n. Im(X n)}) : HInfinite)";
 13.1376 +by (auto_tac (claset(),simpset() addsimps [CInfinite_CFinite_iff,
 13.1377 +    HInfinite_HFinite_iff,CFinite_HFinite_iff]));
 13.1378 +qed "CInfinite_HInfinite_iff";
 13.1379 +
 13.1380 +Goal "(hcomplex_of_hypreal x + iii * hcomplex_of_hypreal y : CInfinitesimal) = \
 13.1381 +\     (x : Infinitesimal & y : Infinitesimal)";
 13.1382 +by (res_inst_tac [("z","x")] eq_Abs_hypreal 1);
 13.1383 +by (res_inst_tac [("z","y")] eq_Abs_hypreal 1);
 13.1384 +by (auto_tac (claset(),simpset() addsimps [iii_def,hcomplex_add,hcomplex_mult,
 13.1385 +    hcomplex_of_hypreal,CInfinitesimal_Infinitesimal_iff]));
 13.1386 +qed "hcomplex_split_CInfinitesimal_iff";
 13.1387 +
 13.1388 +Goal "(hcomplex_of_hypreal x + iii * hcomplex_of_hypreal y : CFinite) = \
 13.1389 +\     (x : HFinite & y : HFinite)";
 13.1390 +by (res_inst_tac [("z","x")] eq_Abs_hypreal 1);
 13.1391 +by (res_inst_tac [("z","y")] eq_Abs_hypreal 1);
 13.1392 +by (auto_tac (claset(),simpset() addsimps [iii_def,hcomplex_add,hcomplex_mult,
 13.1393 +    hcomplex_of_hypreal,CFinite_HFinite_iff]));
 13.1394 +qed "hcomplex_split_CFinite_iff";
 13.1395 +
 13.1396 +Goal "(hcomplex_of_hypreal x + iii * hcomplex_of_hypreal y : SComplex) = \
 13.1397 +\     (x : Reals & y : Reals)";
 13.1398 +by (res_inst_tac [("z","x")] eq_Abs_hypreal 1);
 13.1399 +by (res_inst_tac [("z","y")] eq_Abs_hypreal 1);
 13.1400 +by (auto_tac (claset(),simpset() addsimps [iii_def,hcomplex_add,hcomplex_mult,
 13.1401 +    hcomplex_of_hypreal,SComplex_SReal_iff]));
 13.1402 +qed "hcomplex_split_SComplex_iff";
 13.1403 +
 13.1404 +Goal "(hcomplex_of_hypreal x + iii * hcomplex_of_hypreal y : CInfinite) = \
 13.1405 +\     (x : HInfinite | y : HInfinite)";
 13.1406 +by (res_inst_tac [("z","x")] eq_Abs_hypreal 1);
 13.1407 +by (res_inst_tac [("z","y")] eq_Abs_hypreal 1);
 13.1408 +by (auto_tac (claset(),simpset() addsimps [iii_def,hcomplex_add,hcomplex_mult,
 13.1409 +    hcomplex_of_hypreal,CInfinite_HInfinite_iff]));
 13.1410 +qed "hcomplex_split_CInfinite_iff";
 13.1411 +
 13.1412 +Goal "(hcomplex_of_hypreal x + iii * hcomplex_of_hypreal y @c= \
 13.1413 +\      hcomplex_of_hypreal x' + iii * hcomplex_of_hypreal y') = \
 13.1414 +\     (x @= x' & y @= y')";
 13.1415 +by (res_inst_tac [("z","x")] eq_Abs_hypreal 1);
 13.1416 +by (res_inst_tac [("z","y")] eq_Abs_hypreal 1);
 13.1417 +by (res_inst_tac [("z","x'")] eq_Abs_hypreal 1);
 13.1418 +by (res_inst_tac [("z","y'")] eq_Abs_hypreal 1);
 13.1419 +by (auto_tac (claset(),simpset() addsimps [iii_def,hcomplex_add,hcomplex_mult,
 13.1420 +    hcomplex_of_hypreal,capprox_approx_iff]));
 13.1421 +qed "hcomplex_split_capprox_iff";
 13.1422 +
 13.1423 +(*** More theorems ***)
 13.1424 +
 13.1425 +Goal "ALL n. cmod (X n - x) < inverse (real (Suc n)) ==> \
 13.1426 +\     Abs_hcomplex(hcomplexrel``{X}) - hcomplex_of_complex x : CInfinitesimal";
 13.1427 +by (auto_tac (claset(),simpset() addsimps [hcomplex_diff,
 13.1428 +    CInfinitesimal_hcmod_iff,hcomplex_of_complex_def,
 13.1429 +    Infinitesimal_FreeUltrafilterNat_iff,hcmod]));
 13.1430 +by (rtac bexI 1 THEN Auto_tac);
 13.1431 +by (auto_tac (claset() addDs [FreeUltrafilterNat_inverse_real_of_posnat,
 13.1432 +                  FreeUltrafilterNat_all,FreeUltrafilterNat_Int] 
 13.1433 +           addIs [order_less_trans, FreeUltrafilterNat_subset],
 13.1434 +      simpset()));
 13.1435 +qed "complex_seq_to_hcomplex_CInfinitesimal";
 13.1436 +
 13.1437 +Goal "hcomplex_of_hypreal epsilon : CInfinitesimal";
 13.1438 +by (auto_tac (claset(),simpset() addsimps [CInfinitesimal_hcmod_iff]));
 13.1439 +qed "CInfinitesimal_hcomplex_of_hypreal_epsilon";
 13.1440 +Addsimps [CInfinitesimal_hcomplex_of_hypreal_epsilon];
 13.1441 +
 13.1442 +Goal "(hcomplex_of_complex z @c= 0) = (z = 0)";
 13.1443 +by (auto_tac (claset(),simpset() addsimps [hcomplex_of_complex_zero RS sym]
 13.1444 +    delsimps [hcomplex_of_complex_zero]));
 13.1445 +qed "hcomplex_of_complex_approx_zero_iff";
 13.1446 +
 13.1447 +Goal "(0 @c= hcomplex_of_complex z) = (z = 0)";
 13.1448 +by (auto_tac (claset(),simpset() addsimps [hcomplex_of_complex_zero RS sym]
 13.1449 +    delsimps [hcomplex_of_complex_zero]));
 13.1450 +qed "hcomplex_of_complex_approx_zero_iff2";
 13.1451 +
 13.1452 +Addsimps [hcomplex_of_complex_approx_zero_iff,hcomplex_of_complex_approx_zero_iff2];
 13.1453 +
 13.1454 +
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/src/HOL/Complex/NSCA.thy	Mon May 05 18:22:31 2003 +0200
    14.3 @@ -0,0 +1,44 @@
    14.4 +(*  Title       : NSCA.thy
    14.5 +    Author      : Jacques D. Fleuriot
    14.6 +    Copyright   : 2001,2002 University of Edinburgh
    14.7 +    Description : Infinite, infinitesimal complex number etc! 
    14.8 +*)
    14.9 +
   14.10 +NSCA = NSComplexArith0 + 
   14.11 +
   14.12 +consts   
   14.13 +
   14.14 +    (* infinitely close *)
   14.15 +    "@c="     :: [hcomplex,hcomplex] => bool  (infixl 50)  
   14.16 +
   14.17 +  
   14.18 +constdefs
   14.19 +   (* standard complex numbers reagarded as an embedded subset of NS complex *)
   14.20 +   SComplex  :: "hcomplex set"
   14.21 +   "SComplex == {x. EX r. x = hcomplex_of_complex r}"
   14.22 +
   14.23 +   CInfinitesimal  :: "hcomplex set"
   14.24 +   "CInfinitesimal == {x. ALL r: Reals. 0 < r --> hcmod x < r}"
   14.25 +
   14.26 +   CFinite :: "hcomplex set"
   14.27 +   "CFinite == {x. EX r: Reals. hcmod x < r}"
   14.28 +
   14.29 +   CInfinite :: "hcomplex set"
   14.30 +   "CInfinite == {x. ALL r: Reals. r < hcmod x}"
   14.31 +
   14.32 +   (* standard part map *)  
   14.33 +   stc :: hcomplex => hcomplex
   14.34 +   "stc x == (@r. x : CFinite & r:SComplex & r @c= x)"
   14.35 +
   14.36 +   cmonad    :: hcomplex => hcomplex set
   14.37 +   "cmonad x  == {y. x @c= y}"
   14.38 +
   14.39 +   cgalaxy   :: hcomplex => hcomplex set
   14.40 +   "cgalaxy x == {y. (x - y) : CFinite}"
   14.41 +
   14.42 +
   14.43 +defs  
   14.44 +
   14.45 +   capprox_def  "x @c= y == (x - y) : CInfinitesimal"     
   14.46 + 
   14.47 +end
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/src/HOL/Complex/NSComplex.ML	Mon May 05 18:22:31 2003 +0200
    15.3 @@ -0,0 +1,1895 @@
    15.4 +(*  Title:       NSComplex.ML
    15.5 +    Author:      Jacques D. Fleuriot
    15.6 +    Copyhright:  2001  University of Edinburgh
    15.7 +    Description: Nonstandard Complex numbers
    15.8 +*)
    15.9 +
   15.10 +Goalw [hcomplexrel_def]
   15.11 +   "((X,Y): hcomplexrel) = ({n. X n = Y n}: FreeUltrafilterNat)";
   15.12 +by (Fast_tac 1);
   15.13 +qed "hcomplexrel_iff";
   15.14 +
   15.15 +Goalw [hcomplexrel_def] 
   15.16 +     "!!X. {n. X n = Y n}: FreeUltrafilterNat \
   15.17 +\      ==> (X,Y): hcomplexrel";
   15.18 +by (Fast_tac 1);
   15.19 +qed "hcomplexrelI";
   15.20 +
   15.21 +Goalw [hcomplexrel_def]
   15.22 +  "p: hcomplexrel --> (EX X Y. \
   15.23 +\                 p = (X,Y) & {n. X n = Y n} : FreeUltrafilterNat)";
   15.24 +by (Fast_tac 1);
   15.25 +qed "hcomplexrelE_lemma";
   15.26 +
   15.27 +val [major,minor] = goal thy
   15.28 +  "[| p: hcomplexrel;  \
   15.29 +\     !!X Y. [| p = (X,Y); {n. X n = Y n}: FreeUltrafilterNat\
   15.30 +\                    |] ==> Q |] ==> Q";
   15.31 +by (cut_facts_tac [major RS (hcomplexrelE_lemma RS mp)] 1);
   15.32 +by (REPEAT (eresolve_tac [asm_rl,exE,conjE,minor] 1));
   15.33 +qed "hcomplexrelE";
   15.34 +
   15.35 +AddSIs [hcomplexrelI];
   15.36 +AddSEs [hcomplexrelE];
   15.37 +
   15.38 +Goalw [hcomplexrel_def] "(x,x): hcomplexrel";
   15.39 +by (Auto_tac);
   15.40 +qed "hcomplexrel_refl";
   15.41 +
   15.42 +Goalw [hcomplexrel_def] "(x,y): hcomplexrel --> (y,x):hcomplexrel";
   15.43 +by (auto_tac (claset() addIs [lemma_perm RS subst],simpset()));
   15.44 +qed_spec_mp "hcomplexrel_sym";
   15.45 +
   15.46 +Goalw [hcomplexrel_def]
   15.47 +      "(x,y): hcomplexrel --> (y,z):hcomplexrel --> (x,z):hcomplexrel";
   15.48 +by (Auto_tac);
   15.49 +by (Ultra_tac 1);
   15.50 +qed_spec_mp "hcomplexrel_trans";
   15.51 +
   15.52 +Goalw [equiv_def, refl_def, sym_def, trans_def]
   15.53 +    "equiv {x::nat=>complex. True} hcomplexrel";
   15.54 +by (auto_tac (claset() addSIs [hcomplexrel_refl] addSEs 
   15.55 +    [hcomplexrel_sym,hcomplexrel_trans] delrules [hcomplexrelI,hcomplexrelE],
   15.56 +    simpset()));
   15.57 +qed "equiv_hcomplexrel";
   15.58 +
   15.59 +val equiv_hcomplexrel_iff =
   15.60 +    [TrueI, TrueI] MRS 
   15.61 +    ([CollectI, CollectI] MRS 
   15.62 +    (equiv_hcomplexrel RS eq_equiv_class_iff));
   15.63 +
   15.64 +Goalw  [hcomplex_def,hcomplexrel_def,quotient_def] "hcomplexrel``{x}:hcomplex";
   15.65 +by (Blast_tac 1);
   15.66 +qed "hcomplexrel_in_hcomplex";
   15.67 +
   15.68 +Goal "inj_on Abs_hcomplex hcomplex";
   15.69 +by (rtac inj_on_inverseI 1);
   15.70 +by (etac Abs_hcomplex_inverse 1);
   15.71 +qed "inj_on_Abs_hcomplex";
   15.72 +
   15.73 +Addsimps [equiv_hcomplexrel_iff,inj_on_Abs_hcomplex RS inj_on_iff,
   15.74 +          hcomplexrel_iff, hcomplexrel_in_hcomplex, Abs_hcomplex_inverse];
   15.75 +
   15.76 +Addsimps [equiv_hcomplexrel RS eq_equiv_class_iff];
   15.77 +val eq_hcomplexrelD = equiv_hcomplexrel RSN (2,eq_equiv_class);
   15.78 +
   15.79 +Goal "inj(Rep_hcomplex)";
   15.80 +by (rtac inj_inverseI 1);
   15.81 +by (rtac Rep_hcomplex_inverse 1);
   15.82 +qed "inj_Rep_hcomplex";
   15.83 +
   15.84 +Goalw [hcomplexrel_def] "x: hcomplexrel `` {x}";
   15.85 +by (Step_tac 1);
   15.86 +by (Auto_tac);
   15.87 +qed "lemma_hcomplexrel_refl";
   15.88 +Addsimps [lemma_hcomplexrel_refl];
   15.89 +
   15.90 +Goalw [hcomplex_def] "{} ~: hcomplex";
   15.91 +by (auto_tac (claset() addSEs [quotientE],simpset()));
   15.92 +qed "hcomplex_empty_not_mem";
   15.93 +Addsimps [hcomplex_empty_not_mem];
   15.94 +
   15.95 +Goal "Rep_hcomplex x ~= {}";
   15.96 +by (cut_inst_tac [("x","x")] Rep_hcomplex 1);
   15.97 +by (Auto_tac);
   15.98 +qed "Rep_hcomplex_nonempty";
   15.99 +Addsimps [Rep_hcomplex_nonempty];
  15.100 +
  15.101 +val [prem] = goal thy
  15.102 +    "(!!x. z = Abs_hcomplex(hcomplexrel `` {x}) ==> P) ==> P";
  15.103 +by (res_inst_tac [("x1","z")] 
  15.104 +    (rewrite_rule [hcomplex_def] Rep_hcomplex RS quotientE) 1);
  15.105 +by (dres_inst_tac [("f","Abs_hcomplex")] arg_cong 1);
  15.106 +by (res_inst_tac [("x","x")] prem 1);
  15.107 +by (asm_full_simp_tac (simpset() addsimps [Rep_hcomplex_inverse]) 1);
  15.108 +qed "eq_Abs_hcomplex";
  15.109 +
  15.110 +(*-----------------------------------------------------------------------*)
  15.111 +(* Properties of nonstandard real and imaginary parts                    *)
  15.112 +(*-----------------------------------------------------------------------*)
  15.113 +
  15.114 +Goalw [hRe_def] 
  15.115 +     "hRe(Abs_hcomplex (hcomplexrel `` {X})) = \
  15.116 +\     Abs_hypreal(hyprel `` {%n. Re(X n)})";
  15.117 +by (res_inst_tac [("f","Abs_hypreal")] arg_cong 1);
  15.118 +by (Auto_tac THEN Ultra_tac 1);
  15.119 +qed "hRe";
  15.120 +
  15.121 +Goalw [hIm_def] 
  15.122 +     "hIm(Abs_hcomplex (hcomplexrel `` {X})) = \
  15.123 +\     Abs_hypreal(hyprel `` {%n. Im(X n)})";
  15.124 +by (res_inst_tac [("f","Abs_hypreal")] arg_cong 1);
  15.125 +by (Auto_tac THEN Ultra_tac 1);
  15.126 +qed "hIm";
  15.127 +
  15.128 +Goal "(w=z) = (hRe(w) = hRe(z) & hIm(w) = hIm(z))";
  15.129 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
  15.130 +by (res_inst_tac [("z","w")] eq_Abs_hcomplex 1);
  15.131 +by (auto_tac (claset(),simpset() addsimps [hRe,hIm,
  15.132 +    complex_Re_Im_cancel_iff]));
  15.133 +by (ALLGOALS(Ultra_tac));
  15.134 +qed "hcomplex_hRe_hIm_cancel_iff";
  15.135 +
  15.136 +Goalw [hcomplex_zero_def] "hRe 0 = 0";
  15.137 +by (simp_tac (simpset() addsimps [hRe,hypreal_zero_num]) 1);
  15.138 +qed "hcomplex_hRe_zero";
  15.139 +Addsimps [hcomplex_hRe_zero];
  15.140 +
  15.141 +Goalw [hcomplex_zero_def] "hIm 0 = 0";
  15.142 +by (simp_tac (simpset() addsimps [hIm,hypreal_zero_num]) 1);
  15.143 +qed "hcomplex_hIm_zero";
  15.144 +Addsimps [hcomplex_hIm_zero];
  15.145 +
  15.146 +Goalw [hcomplex_one_def] "hRe 1 = 1";
  15.147 +by (simp_tac (simpset() addsimps [hRe,hypreal_one_num]) 1);
  15.148 +qed "hcomplex_hRe_one";
  15.149 +Addsimps [hcomplex_hRe_one];
  15.150 +
  15.151 +Goalw [hcomplex_one_def] "hIm 1 = 0";
  15.152 +by (simp_tac (simpset() addsimps [hIm,hypreal_one_def,hypreal_zero_num]) 1);
  15.153 +qed "hcomplex_hIm_one";
  15.154 +Addsimps [hcomplex_hIm_one];
  15.155 +
  15.156 +(*-----------------------------------------------------------------------*)
  15.157 +(*   hcomplex_of_complex: the injection from complex to hcomplex         *)
  15.158 +(* ----------------------------------------------------------------------*)
  15.159 +
  15.160 +Goal "inj(hcomplex_of_complex)";
  15.161 +by (rtac injI 1 THEN rtac ccontr 1);
  15.162 +by (auto_tac (claset(),simpset() addsimps [hcomplex_of_complex_def]));
  15.163 +qed "inj_hcomplex_of_complex";
  15.164 +
  15.165 +Goalw [iii_def,hcomplex_of_complex_def] "iii = hcomplex_of_complex ii";
  15.166 +by (Simp_tac 1);
  15.167 +qed "hcomplex_of_complex_i";
  15.168 +
  15.169 +(*-----------------------------------------------------------------------*)
  15.170 +(*   Addition for nonstandard complex numbers: hcomplex_add              *)
  15.171 +(* ----------------------------------------------------------------------*)
  15.172 +
  15.173 +Goalw [congruent2_def]
  15.174 +    "congruent2 hcomplexrel (%X Y. hcomplexrel `` {%n. X n + Y n})";
  15.175 +by (safe_tac (claset()));
  15.176 +by (ALLGOALS(Ultra_tac));
  15.177 +qed "hcomplex_add_congruent2";
  15.178 +
  15.179 +Goalw [hcomplex_add_def]
  15.180 +  "Abs_hcomplex(hcomplexrel``{%n. X n}) + Abs_hcomplex(hcomplexrel``{%n. Y n}) = \
  15.181 +\  Abs_hcomplex(hcomplexrel``{%n. X n + Y n})";
  15.182 +by (res_inst_tac [("f","Abs_hcomplex")] arg_cong 1);
  15.183 +by Auto_tac;
  15.184 +by (Ultra_tac 1);
  15.185 +qed "hcomplex_add";
  15.186 +
  15.187 +Goal "(z::hcomplex) + w = w + z";
  15.188 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
  15.189 +by (res_inst_tac [("z","w")] eq_Abs_hcomplex 1);
  15.190 +by (asm_simp_tac (simpset() addsimps (complex_add_ac @ [hcomplex_add])) 1);
  15.191 +qed "hcomplex_add_commute";
  15.192 +
  15.193 +Goal "((z1::hcomplex) + z2) + z3 = z1 + (z2 + z3)";
  15.194 +by (res_inst_tac [("z","z1")] eq_Abs_hcomplex 1);
  15.195 +by (res_inst_tac [("z","z2")] eq_Abs_hcomplex 1);
  15.196 +by (res_inst_tac [("z","z3")] eq_Abs_hcomplex 1);
  15.197 +by (asm_simp_tac (simpset() addsimps [hcomplex_add,complex_add_assoc]) 1);
  15.198 +qed "hcomplex_add_assoc";
  15.199 +
  15.200 +(*For AC rewriting*)
  15.201 +Goal "(x::hcomplex)+(y+z)=y+(x+z)";
  15.202 +by (rtac (hcomplex_add_commute RS trans) 1);
  15.203 +by (rtac (hcomplex_add_assoc RS trans) 1);
  15.204 +by (rtac (hcomplex_add_commute RS arg_cong) 1);
  15.205 +qed "hcomplex_add_left_commute";
  15.206 +
  15.207 +(* hcomplex addition is an AC operator *)
  15.208 +val hcomplex_add_ac = [hcomplex_add_assoc,hcomplex_add_commute,
  15.209 +                      hcomplex_add_left_commute];
  15.210 +
  15.211 +Goalw [hcomplex_zero_def] "(0::hcomplex) + z = z";
  15.212 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
  15.213 +by (asm_full_simp_tac (simpset() addsimps 
  15.214 +    [hcomplex_add]) 1);
  15.215 +qed "hcomplex_add_zero_left";
  15.216 +
  15.217 +Goal "z + (0::hcomplex) = z";
  15.218 +by (simp_tac (simpset() addsimps 
  15.219 +    [hcomplex_add_zero_left,hcomplex_add_commute]) 1);
  15.220 +qed "hcomplex_add_zero_right";
  15.221 +Addsimps [hcomplex_add_zero_left,hcomplex_add_zero_right];
  15.222 +
  15.223 +Goal "hRe(x + y) = hRe(x) + hRe(y)";
  15.224 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
  15.225 +by (res_inst_tac [("z","y")] eq_Abs_hcomplex 1);
  15.226 +by (auto_tac (claset(),simpset() addsimps [hRe,hcomplex_add,
  15.227 +    hypreal_add,complex_Re_add]));
  15.228 +qed "hRe_add";
  15.229 +
  15.230 +Goal "hIm(x + y) = hIm(x) + hIm(y)";
  15.231 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
  15.232 +by (res_inst_tac [("z","y")] eq_Abs_hcomplex 1);
  15.233 +by (auto_tac (claset(),simpset() addsimps [hIm,hcomplex_add,
  15.234 +    hypreal_add,complex_Im_add]));
  15.235 +qed "hIm_add";
  15.236 +
  15.237 +(*-----------------------------------------------------------------------*)
  15.238 +(* hypreal_minus: additive inverse on nonstandard complex                *)
  15.239 +(* ----------------------------------------------------------------------*)
  15.240 +
  15.241 +Goalw [congruent_def]
  15.242 +  "congruent hcomplexrel (%X. hcomplexrel `` {%n. - (X n)})";
  15.243 +by (safe_tac (claset()));
  15.244 +by (ALLGOALS(Ultra_tac));
  15.245 +qed "hcomplex_minus_congruent";
  15.246 +
  15.247 +Goalw [hcomplex_minus_def]
  15.248 +  "- (Abs_hcomplex(hcomplexrel `` {%n. X n})) = \
  15.249 +\     Abs_hcomplex(hcomplexrel `` {%n. -(X n)})";
  15.250 +by (res_inst_tac [("f","Abs_hcomplex")] arg_cong 1);
  15.251 +by (Auto_tac THEN Ultra_tac 1);
  15.252 +qed "hcomplex_minus";
  15.253 +
  15.254 +Goal "- (- z) = (z::hcomplex)";
  15.255 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
  15.256 +by (asm_simp_tac (simpset() addsimps [hcomplex_minus]) 1);
  15.257 +qed "hcomplex_minus_minus";
  15.258 +Addsimps [hcomplex_minus_minus];
  15.259 +
  15.260 +Goal "inj(%z::hcomplex. -z)";
  15.261 +by (rtac injI 1);
  15.262 +by (dres_inst_tac [("f","uminus")] arg_cong 1);
  15.263 +by (Asm_full_simp_tac 1);
  15.264 +qed "inj_hcomplex_minus";
  15.265 +
  15.266 +Goalw [hcomplex_zero_def] "- 0 = (0::hcomplex)";
  15.267 +by (simp_tac (simpset() addsimps [hcomplex_minus]) 1);
  15.268 +qed "hcomplex_minus_zero";
  15.269 +Addsimps [hcomplex_minus_zero];
  15.270 +
  15.271 +Goal "(-x = 0) = (x = (0::hcomplex))"; 
  15.272 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
  15.273 +by (auto_tac (claset(),simpset() addsimps [hcomplex_zero_def,
  15.274 +    hcomplex_minus] @ complex_add_ac));
  15.275 +qed "hcomplex_minus_zero_iff";
  15.276 +Addsimps [hcomplex_minus_zero_iff];
  15.277 +
  15.278 +Goal "(0 = -x) = (x = (0::hcomplex))"; 
  15.279 +by (auto_tac (claset() addDs [sym],simpset()));
  15.280 +qed "hcomplex_minus_zero_iff2";
  15.281 +Addsimps [hcomplex_minus_zero_iff2];
  15.282 +
  15.283 +Goal "(-x ~= 0) = (x ~= (0::hcomplex))"; 
  15.284 +by Auto_tac;
  15.285 +qed "hcomplex_minus_not_zero_iff";
  15.286 +
  15.287 +Goal "z + - z = (0::hcomplex)";
  15.288 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
  15.289 +by (auto_tac (claset(),simpset() addsimps [hcomplex_add,hcomplex_minus,
  15.290 +    hcomplex_zero_def]));
  15.291 +qed "hcomplex_add_minus_right";
  15.292 +Addsimps [hcomplex_add_minus_right];
  15.293 +
  15.294 +Goal "-z + z = (0::hcomplex)";
  15.295 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
  15.296 +by (auto_tac (claset(),simpset() addsimps [hcomplex_add,hcomplex_minus,
  15.297 +    hcomplex_zero_def]));
  15.298 +qed "hcomplex_add_minus_left";
  15.299 +Addsimps [hcomplex_add_minus_left];
  15.300 +
  15.301 +Goal "z + (- z + w) = (w::hcomplex)";
  15.302 +by (simp_tac (simpset() addsimps [hcomplex_add_assoc RS sym]) 1);
  15.303 +qed "hcomplex_add_minus_cancel";
  15.304 +
  15.305 +Goal "(-z) + (z + w) = (w::hcomplex)";
  15.306 +by (simp_tac (simpset() addsimps [hcomplex_add_assoc RS sym]) 1);
  15.307 +qed "hcomplex_minus_add_cancel";
  15.308 +
  15.309 +Goal "hRe(-z) = - hRe(z)";
  15.310 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
  15.311 +by (auto_tac (claset(),simpset() addsimps [hRe,hcomplex_minus,
  15.312 +    hypreal_minus,complex_Re_minus]));
  15.313 +qed "hRe_minus";
  15.314 +
  15.315 +Goal "hIm(-z) = - hIm(z)";
  15.316 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
  15.317 +by (auto_tac (claset(),simpset() addsimps [hIm,hcomplex_minus,
  15.318 +    hypreal_minus,complex_Im_minus]));
  15.319 +qed "hIm_minus";
  15.320 +
  15.321 +Goalw [hcomplex_zero_def] 
  15.322 +      "x + y = (0::hcomplex) ==> x = -y";
  15.323 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
  15.324 +by (res_inst_tac [("z","y")] eq_Abs_hcomplex 1);
  15.325 +by (auto_tac (claset(),simpset() addsimps [hcomplex_add,hcomplex_minus]));
  15.326 +by (ultra_tac (claset() addIs [complex_add_minus_eq_minus],simpset()) 1);
  15.327 +qed "hcomplex_add_minus_eq_minus";
  15.328 +
  15.329 +Goal "-(x + y) = -x + -(y::hcomplex)";
  15.330 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
  15.331 +by (res_inst_tac [("z","y")] eq_Abs_hcomplex 1);
  15.332 +by (auto_tac (claset(),simpset() addsimps [hcomplex_add,hcomplex_minus]));
  15.333 +qed "hcomplex_minus_add_distrib";
  15.334 +Addsimps [hcomplex_minus_add_distrib];
  15.335 +
  15.336 +Goal "((x::hcomplex) + y = x + z) = (y = z)";
  15.337 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
  15.338 +by (res_inst_tac [("z","y")] eq_Abs_hcomplex 1);
  15.339 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
  15.340 +by (auto_tac (claset(),simpset() addsimps [hcomplex_add]));
  15.341 +qed "hcomplex_add_left_cancel";
  15.342 +AddIffs [hcomplex_add_left_cancel];
  15.343 +
  15.344 +Goal "(y + (x::hcomplex)= z + x) = (y = z)";
  15.345 +by (simp_tac (simpset() addsimps [hcomplex_add_commute]) 1);
  15.346 +qed "hcomplex_add_right_cancel";
  15.347 +AddIffs [hcomplex_add_right_cancel];
  15.348 +
  15.349 +Goal "((x::hcomplex) = y) = ((0::hcomplex) = x + - y)";
  15.350 +by (Step_tac 1);
  15.351 +by (res_inst_tac [("x1","-y")] 
  15.352 +      (hcomplex_add_right_cancel RS iffD1) 2);
  15.353 +by (Auto_tac);
  15.354 +qed "hcomplex_eq_minus_iff"; 
  15.355 +
  15.356 +Goal "((x::hcomplex) = y) = (x + - y = (0::hcomplex))";
  15.357 +by (Step_tac 1);
  15.358 +by (res_inst_tac [("x1","-y")] 
  15.359 +      (hcomplex_add_right_cancel RS iffD1) 2);
  15.360 +by (Auto_tac);
  15.361 +qed "hcomplex_eq_minus_iff2"; 
  15.362 +
  15.363 +(*-----------------------------------------------------------------------*)
  15.364 +(* Subraction for nonstandard complex numbers: hcomplex_diff             *)
  15.365 +(* ----------------------------------------------------------------------*)
  15.366 +
  15.367 +Goalw [hcomplex_diff_def] 
  15.368 +  "Abs_hcomplex(hcomplexrel``{%n. X n}) - Abs_hcomplex(hcomplexrel``{%n. Y n}) = \
  15.369 +\  Abs_hcomplex(hcomplexrel``{%n. X n - Y n})";
  15.370 +by (auto_tac (claset(),simpset() addsimps [hcomplex_minus,hcomplex_add,
  15.371 +    complex_diff_def]));
  15.372 +qed "hcomplex_diff";
  15.373 +
  15.374 +Goalw [hcomplex_diff_def] "(z::hcomplex) - z = (0::hcomplex)";
  15.375 +by (Simp_tac 1);
  15.376 +qed "hcomplex_diff_zero";
  15.377 +Addsimps [hcomplex_diff_zero];
  15.378 +
  15.379 +Goal "(0::hcomplex) - x = -x";
  15.380 +by (simp_tac (simpset() addsimps [hcomplex_diff_def]) 1);
  15.381 +qed "hcomplex_diff_0";
  15.382 +
  15.383 +Goal "x - (0::hcomplex) = x";
  15.384 +by (simp_tac (simpset() addsimps [hcomplex_diff_def]) 1);
  15.385 +qed "hcomplex_diff_0_right";
  15.386 +
  15.387 +Goal "x - x = (0::hcomplex)";
  15.388 +by (simp_tac (simpset() addsimps [hcomplex_diff_def]) 1);
  15.389 +qed "hcomplex_diff_self";
  15.390 +
  15.391 +Addsimps [hcomplex_diff_0, hcomplex_diff_0_right, hcomplex_diff_self];
  15.392 +
  15.393 +Goal "((x::hcomplex) - y = z) = (x = z + y)";
  15.394 +by (auto_tac (claset(),simpset() addsimps [hcomplex_diff_def,hcomplex_add_assoc]));
  15.395 +qed "hcomplex_diff_eq_eq";
  15.396 +
  15.397 +(*-----------------------------------------------------------------------*)
  15.398 +(* Multiplication for nonstandard complex numbers: hcomplex_mult         *)
  15.399 +(* ----------------------------------------------------------------------*)
  15.400 +
  15.401 +Goalw [hcomplex_mult_def] 
  15.402 +  "Abs_hcomplex(hcomplexrel``{%n. X n}) * Abs_hcomplex(hcomplexrel``{%n. Y n}) = \
  15.403 +\  Abs_hcomplex(hcomplexrel``{%n. X n * Y n})";
  15.404 +by (res_inst_tac [("f","Abs_hcomplex")] arg_cong 1);
  15.405 +by (Auto_tac THEN Ultra_tac 1);
  15.406 +qed "hcomplex_mult";
  15.407 +
  15.408 +Goal "(w::hcomplex) * z = z * w";
  15.409 +by (res_inst_tac [("z","w")] eq_Abs_hcomplex 1);
  15.410 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
  15.411 +by (auto_tac (claset(),simpset() addsimps [hcomplex_mult,
  15.412 +    complex_mult_commute]));
  15.413 +qed "hcomplex_mult_commute";
  15.414 +
  15.415 +Goal "((u::hcomplex) * v) * w = u * (v * w)";
  15.416 +by (res_inst_tac [("z","u")] eq_Abs_hcomplex 1);
  15.417 +by (res_inst_tac [("z","v")] eq_Abs_hcomplex 1);
  15.418 +by (res_inst_tac [("z","w")] eq_Abs_hcomplex 1);
  15.419 +by (auto_tac (claset(),simpset() addsimps [hcomplex_mult,
  15.420 +    complex_mult_assoc]));
  15.421 +qed "hcomplex_mult_assoc";
  15.422 +
  15.423 +Goal "(x::hcomplex) * (y * z) = y * (x * z)";
  15.424 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
  15.425 +by (res_inst_tac [("z","y")] eq_Abs_hcomplex 1);
  15.426 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
  15.427 +by (auto_tac (claset(),simpset() addsimps [hcomplex_mult,
  15.428 +    complex_mult_left_commute]));
  15.429 +qed "hcomplex_mult_left_commute";
  15.430 +
  15.431 +val hcomplex_mult_ac = [hcomplex_mult_assoc,hcomplex_mult_commute,
  15.432 +                        hcomplex_mult_left_commute];
  15.433 +
  15.434 +Goalw [hcomplex_one_def] "(1::hcomplex) * z = z";
  15.435 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
  15.436 +by (auto_tac (claset(),simpset() addsimps [hcomplex_mult]));
  15.437 +qed "hcomplex_mult_one_left";
  15.438 +Addsimps [hcomplex_mult_one_left];
  15.439 +
  15.440 +Goal "z * (1::hcomplex) = z";
  15.441 +by (simp_tac (simpset() addsimps [hcomplex_mult_commute]) 1);
  15.442 +qed "hcomplex_mult_one_right";
  15.443 +Addsimps [hcomplex_mult_one_right];
  15.444 +
  15.445 +Goalw [hcomplex_zero_def] "(0::hcomplex) * z = 0";
  15.446 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
  15.447 +by (auto_tac (claset(),simpset() addsimps [hcomplex_mult]));
  15.448 +qed "hcomplex_mult_zero_left";
  15.449 +Addsimps [hcomplex_mult_zero_left];
  15.450 +
  15.451 +Goal "z * (0::hcomplex) = 0";
  15.452 +by (simp_tac (simpset() addsimps [hcomplex_mult_commute]) 1);
  15.453 +qed "hcomplex_mult_zero_right";
  15.454 +Addsimps [hcomplex_mult_zero_right];
  15.455 +
  15.456 +Goal "-(x * y) = -x * (y::hcomplex)";
  15.457 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
  15.458 +by (res_inst_tac [("z","y")] eq_Abs_hcomplex 1);
  15.459 +by (auto_tac (claset(),simpset() addsimps [hcomplex_mult,
  15.460 +    hcomplex_minus]));
  15.461 +qed "hcomplex_minus_mult_eq1";
  15.462 +
  15.463 +Goal "-(x * y) = x * -(y::hcomplex)";
  15.464 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
  15.465 +by (res_inst_tac [("z","y")] eq_Abs_hcomplex 1);
  15.466 +by (auto_tac (claset(),simpset() addsimps [hcomplex_mult,
  15.467 +    hcomplex_minus]));
  15.468 +qed "hcomplex_minus_mult_eq2";
  15.469 +
  15.470 +Addsimps [hcomplex_minus_mult_eq1 RS sym,hcomplex_minus_mult_eq2 RS sym];
  15.471 +
  15.472 +Goal "- 1 * (z::hcomplex) = -z";
  15.473 +by (Simp_tac 1);
  15.474 +qed "hcomplex_mult_minus_one";
  15.475 +Addsimps [hcomplex_mult_minus_one];
  15.476 +
  15.477 +Goal "(z::hcomplex) * - 1 = -z";
  15.478 +by (stac hcomplex_mult_commute 1);
  15.479 +by (Simp_tac 1);
  15.480 +qed "hcomplex_mult_minus_one_right";
  15.481 +Addsimps [hcomplex_mult_minus_one_right];
  15.482 +
  15.483 +Goal "-x * -y = x * (y::hcomplex)";
  15.484 +by Auto_tac;
  15.485 +qed "hcomplex_minus_mult_cancel";
  15.486 +Addsimps [hcomplex_minus_mult_cancel];
  15.487 +
  15.488 +Goal "-x * y = x * -(y::hcomplex)";
  15.489 +by Auto_tac;
  15.490 +qed "hcomplex_minus_mult_commute";
  15.491 +
  15.492 +qed_goal "hcomplex_add_assoc_cong" thy
  15.493 +    "!!z. (z::hcomplex) + v = z' + v' ==> z + (v + w) = z' + (v' + w)"
  15.494 + (fn _ => [(asm_simp_tac (simpset() addsimps [hcomplex_add_assoc RS sym]) 1)]);
  15.495 +
  15.496 +qed_goal "hcomplex_add_assoc_swap" thy "(z::hcomplex) + (v + w) = v + (z + w)"
  15.497 + (fn _ => [(REPEAT (ares_tac [hcomplex_add_commute RS hcomplex_add_assoc_cong] 1))]);
  15.498 +
  15.499 +Goal "((z1::hcomplex) + z2) * w = (z1 * w) + (z2 * w)";
  15.500 +by (res_inst_tac [("z","z1")] eq_Abs_hcomplex 1);
  15.501 +by (res_inst_tac [("z","z2")] eq_Abs_hcomplex 1);
  15.502 +by (res_inst_tac [("z","w")] eq_Abs_hcomplex 1);
  15.503 +by (auto_tac (claset(),simpset() addsimps [hcomplex_mult,hcomplex_add,
  15.504 +    complex_add_mult_distrib]));
  15.505 +qed "hcomplex_add_mult_distrib";
  15.506 +
  15.507 +Goal "(w::hcomplex) * (z1 + z2) = (w * z1) + (w * z2)";
  15.508 +by (res_inst_tac [("z1","z1 + z2")] (hcomplex_mult_commute RS ssubst) 1);
  15.509 +by (simp_tac (simpset() addsimps [hcomplex_add_mult_distrib]) 1);
  15.510 +by (simp_tac (simpset() addsimps [hcomplex_mult_commute]) 1);
  15.511 +qed "hcomplex_add_mult_distrib2";
  15.512 +
  15.513 +Goalw [hcomplex_zero_def,hcomplex_one_def] "(0::hcomplex) ~= (1::hcomplex)";
  15.514 +by Auto_tac;
  15.515 +qed "hcomplex_zero_not_eq_one";
  15.516 +Addsimps [hcomplex_zero_not_eq_one];
  15.517 +Addsimps [hcomplex_zero_not_eq_one RS not_sym];
  15.518 +
  15.519 +(*-----------------------------------------------------------------------*)
  15.520 +(* Inverse of nonstandard complex number                                 *)
  15.521 +(*-----------------------------------------------------------------------*)
  15.522 +
  15.523 +Goalw [hcinv_def]
  15.524 +  "inverse (Abs_hcomplex(hcomplexrel `` {%n. X n})) = \
  15.525 +\     Abs_hcomplex(hcomplexrel `` {%n. inverse (X n)})";
  15.526 +by (res_inst_tac [("f","Abs_hcomplex")] arg_cong 1);
  15.527 +by (Auto_tac THEN Ultra_tac 1);
  15.528 +qed "hcomplex_inverse";
  15.529 +
  15.530 +Goalw [hcomplex_zero_def] "inverse (0::hcomplex) = 0";
  15.531 +by (auto_tac (claset(),simpset() addsimps [hcomplex_inverse]));
  15.532 +qed "HCOMPLEX_INVERSE_ZERO";
  15.533 +
  15.534 +Goal "a / (0::hcomplex) = 0";
  15.535 +by (simp_tac (simpset() addsimps [hcomplex_divide_def, HCOMPLEX_INVERSE_ZERO]) 1);
  15.536 +qed "HCOMPLEX_DIVISION_BY_ZERO";  (*NOT for adding to default simpset*)
  15.537 +
  15.538 +fun hcomplex_div_undefined_case_tac s i =
  15.539 +  case_tac s i THEN 
  15.540 +  asm_simp_tac (simpset() addsimps [HCOMPLEX_DIVISION_BY_ZERO, HCOMPLEX_INVERSE_ZERO]) i;
  15.541 +
  15.542 +Goalw [hcomplex_zero_def,hcomplex_one_def] 
  15.543 +      "z ~= (0::hcomplex) ==> inverse(z) * z = (1::hcomplex)";
  15.544 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
  15.545 +by (auto_tac (claset(),simpset() addsimps [hcomplex_inverse,hcomplex_mult]));
  15.546 +by (Ultra_tac 1);
  15.547 +by (rtac ccontr 1 THEN dtac (complex_mult_inv_left) 1);
  15.548 +by Auto_tac;
  15.549 +qed "hcomplex_mult_inv_left";
  15.550 +Addsimps [hcomplex_mult_inv_left];
  15.551 +
  15.552 +Goal "z ~= (0::hcomplex) ==> z * inverse(z) = (1::hcomplex)";
  15.553 +by (auto_tac (claset() addIs [hcomplex_mult_commute RS subst],simpset()));
  15.554 +qed "hcomplex_mult_inv_right";
  15.555 +Addsimps [hcomplex_mult_inv_right];
  15.556 +
  15.557 +Goal "(c::hcomplex) ~= (0::hcomplex) ==> (c*a=c*b) = (a=b)";
  15.558 +by Auto_tac;
  15.559 +by (dres_inst_tac [("f","%x. x*inverse c")] arg_cong 1);
  15.560 +by (asm_full_simp_tac (simpset() addsimps hcomplex_mult_ac)  1);
  15.561 +qed "hcomplex_mult_left_cancel";
  15.562 +        
  15.563 +Goal "(c::hcomplex) ~= (0::hcomplex) ==> (a*c=b*c) = (a=b)";
  15.564 +by (Step_tac 1);
  15.565 +by (dres_inst_tac [("f","%x. x*inverse c")] arg_cong 1);
  15.566 +by (asm_full_simp_tac (simpset() addsimps hcomplex_mult_ac)  1);
  15.567 +qed "hcomplex_mult_right_cancel";
  15.568 +
  15.569 +Goal "z ~= (0::hcomplex) ==> inverse(z) ~= 0";
  15.570 +by (Step_tac 1);
  15.571 +by (ftac (hcomplex_mult_right_cancel RS iffD2) 1);
  15.572 +by (thin_tac "inverse z = 0" 2);
  15.573 +by (assume_tac 1 THEN Auto_tac);
  15.574 +qed "hcomplex_inverse_not_zero";
  15.575 +Addsimps [hcomplex_inverse_not_zero];
  15.576 +
  15.577 +Goal "[| x ~= (0::hcomplex); y ~= 0 |] ==> x * y ~= 0";
  15.578 +by (Step_tac 1);
  15.579 +by (dres_inst_tac [("f","%z. inverse x*z")] arg_cong 1);
  15.580 +by (asm_full_simp_tac (simpset() addsimps [hcomplex_mult_assoc RS sym]) 1);
  15.581 +qed "hcomplex_mult_not_zero";
  15.582 +
  15.583 +bind_thm ("hcomplex_mult_not_zeroE",hcomplex_mult_not_zero RS notE);
  15.584 +
  15.585 +Goal "inverse(inverse x) = (x::hcomplex)";
  15.586 +by (hcomplex_div_undefined_case_tac "x = 0" 1);
  15.587 +by (res_inst_tac [("c1","inverse x")] (hcomplex_mult_right_cancel RS iffD1) 1);
  15.588 +by (etac hcomplex_inverse_not_zero 1);
  15.589 +by (auto_tac (claset() addDs [hcomplex_inverse_not_zero],simpset()));
  15.590 +qed "hcomplex_inverse_inverse";
  15.591 +Addsimps [hcomplex_inverse_inverse];
  15.592 +
  15.593 +Goalw [hcomplex_one_def] "inverse((1::hcomplex)) = 1";
  15.594 +by (simp_tac (simpset() addsimps [hcomplex_inverse]) 1);
  15.595 +qed "hcomplex_inverse_one";
  15.596 +Addsimps [hcomplex_inverse_one];
  15.597 +
  15.598 +Goal "inverse(-x) = -inverse(x::hcomplex)";
  15.599 +by (hcomplex_div_undefined_case_tac "x = 0" 1);
  15.600 +by (res_inst_tac [("c1","-x")] (hcomplex_mult_right_cancel RS iffD1) 1);
  15.601 +by (stac hcomplex_mult_inv_left 2);
  15.602 +by Auto_tac;
  15.603 +qed "hcomplex_minus_inverse";
  15.604 +
  15.605 +Goal "inverse(x*y) = inverse x * inverse (y::hcomplex)";
  15.606 +by (hcomplex_div_undefined_case_tac "x = 0" 1);
  15.607 +by (hcomplex_div_undefined_case_tac "y = 0" 1);
  15.608 +by (res_inst_tac [("c1","x*y")] (hcomplex_mult_left_cancel RS iffD1) 1);
  15.609 +by (auto_tac (claset(),simpset() addsimps [hcomplex_mult_not_zero]
  15.610 +    @ hcomplex_mult_ac));
  15.611 +by (auto_tac (claset(),simpset() addsimps [hcomplex_mult_not_zero,
  15.612 +    hcomplex_mult_assoc RS sym]));
  15.613 +qed "hcomplex_inverse_distrib";
  15.614 +
  15.615 +(*** division ***)
  15.616 +
  15.617 +(* adding some of these theorems to simpset as for reals: not 100% convinced for some*)
  15.618 +
  15.619 +Goal "(x::hcomplex) * (y/z) = (x*y)/z";
  15.620 +by (simp_tac (simpset() addsimps [hcomplex_divide_def, hcomplex_mult_assoc]) 1); 
  15.621 +qed "hcomplex_times_divide1_eq";
  15.622 +
  15.623 +Goal "(y/z) * (x::hcomplex) = (y*x)/z";
  15.624 +by (simp_tac (simpset() addsimps [hcomplex_divide_def] @ hcomplex_mult_ac) 1); 
  15.625 +qed "hcomplex_times_divide2_eq";
  15.626 +
  15.627 +Addsimps [hcomplex_times_divide1_eq, hcomplex_times_divide2_eq];
  15.628 +
  15.629 +Goal "(x::hcomplex) / (y/z) = (x*z)/y";
  15.630 +by (simp_tac (simpset() addsimps [hcomplex_divide_def, hcomplex_inverse_distrib]@
  15.631 +                                  hcomplex_mult_ac) 1); 
  15.632 +qed "hcomplex_divide_divide1_eq";
  15.633 +
  15.634 +Goal "((x::hcomplex) / y) / z = x/(y*z)";
  15.635 +by (simp_tac (simpset() addsimps [hcomplex_divide_def, hcomplex_inverse_distrib, 
  15.636 +                                  hcomplex_mult_assoc]) 1); 
  15.637 +qed "hcomplex_divide_divide2_eq";
  15.638 +
  15.639 +Addsimps [hcomplex_divide_divide1_eq, hcomplex_divide_divide2_eq];
  15.640 +
  15.641 +(** As with multiplication, pull minus signs OUT of the / operator **)
  15.642 +
  15.643 +Goal "(-x) / (y::hcomplex) = - (x/y)";
  15.644 +by (simp_tac (simpset() addsimps [hcomplex_divide_def]) 1); 
  15.645 +qed "hcomplex_minus_divide_eq";
  15.646 +Addsimps [hcomplex_minus_divide_eq];
  15.647 +
  15.648 +Goal "(x / -(y::hcomplex)) = - (x/y)";
  15.649 +by (simp_tac (simpset() addsimps [hcomplex_divide_def, hcomplex_minus_inverse]) 1); 
  15.650 +qed "hcomplex_divide_minus_eq";
  15.651 +Addsimps [hcomplex_divide_minus_eq];
  15.652 +
  15.653 +Goal "(x+y)/(z::hcomplex) = x/z + y/z";
  15.654 +by (simp_tac (simpset() addsimps [hcomplex_divide_def, hcomplex_add_mult_distrib]) 1); 
  15.655 +qed "hcomplex_add_divide_distrib";
  15.656 +
  15.657 +(*---------------------------------------------------------------------------*)
  15.658 +(* Embedding properties for hcomplex_of_hypreal map                          *)
  15.659 +(*---------------------------------------------------------------------------*)
  15.660 +
  15.661 +Goalw [hcomplex_of_hypreal_def]
  15.662 +  "hcomplex_of_hypreal (Abs_hypreal(hyprel `` {%n. X n})) = \
  15.663 +\     Abs_hcomplex(hcomplexrel `` {%n. complex_of_real (X n)})";
  15.664 +by (res_inst_tac [("f","Abs_hcomplex")] arg_cong 1);
  15.665 +by (Auto_tac THEN Ultra_tac 1);
  15.666 +qed "hcomplex_of_hypreal";
  15.667 +
  15.668 +Goal "inj hcomplex_of_hypreal";
  15.669 +by (rtac injI 1);
  15.670 +by (res_inst_tac [("z","x")] eq_Abs_hypreal 1);
  15.671 +by (res_inst_tac [("z","y")] eq_Abs_hypreal 1);
  15.672 +by (auto_tac (claset(),simpset() addsimps [hcomplex_of_hypreal]));
  15.673 +qed "inj_hcomplex_of_hypreal";
  15.674 +
  15.675 +Goal "(hcomplex_of_hypreal x = hcomplex_of_hypreal y) = (x = y)";
  15.676 +by (auto_tac (claset() addDs [inj_hcomplex_of_hypreal RS injD],simpset()));
  15.677 +qed "hcomplex_of_hypreal_cancel_iff";
  15.678 +AddIffs [hcomplex_of_hypreal_cancel_iff];
  15.679 +
  15.680 +Goal "hcomplex_of_hypreal(-x) = - hcomplex_of_hypreal x";
  15.681 +by (res_inst_tac [("z","x")] eq_Abs_hypreal 1);
  15.682 +by (auto_tac (claset(),simpset() addsimps [hcomplex_of_hypreal,
  15.683 +    hcomplex_minus,hypreal_minus,complex_of_real_minus]));
  15.684 +qed "hcomplex_of_hypreal_minus";
  15.685 +
  15.686 +Goal "hcomplex_of_hypreal(inverse x) = inverse(hcomplex_of_hypreal x)";
  15.687 +by (res_inst_tac [("z","x")] eq_Abs_hypreal 1);
  15.688 +by (auto_tac (claset(),simpset() addsimps [hcomplex_of_hypreal,
  15.689 +    hypreal_inverse,hcomplex_inverse,complex_of_real_inverse]));
  15.690 +qed "hcomplex_of_hypreal_inverse";
  15.691 +
  15.692 +Goal "hcomplex_of_hypreal x + hcomplex_of_hypreal y = \
  15.693 +\     hcomplex_of_hypreal (x + y)";
  15.694 +by (res_inst_tac [("z","x")] eq_Abs_hypreal 1);
  15.695 +by (res_inst_tac [("z","y")] eq_Abs_hypreal 1);
  15.696 +by (auto_tac (claset(),simpset() addsimps [hcomplex_of_hypreal,
  15.697 +    hypreal_add,hcomplex_add,complex_of_real_add]));
  15.698 +qed "hcomplex_of_hypreal_add";
  15.699 +
  15.700 +Goalw [hcomplex_diff_def] 
  15.701 +     "hcomplex_of_hypreal x - hcomplex_of_hypreal y = \
  15.702 +\     hcomplex_of_hypreal (x - y)";
  15.703 +by (auto_tac (claset(),simpset() addsimps [hcomplex_of_hypreal_minus 
  15.704 +    RS sym,hcomplex_of_hypreal_add,hypreal_diff_def]));
  15.705 +qed "hcomplex_of_hypreal_diff";
  15.706 +
  15.707 +Goal "hcomplex_of_hypreal x * hcomplex_of_hypreal y = \
  15.708 +\     hcomplex_of_hypreal (x * y)";
  15.709 +by (res_inst_tac [("z","x")] eq_Abs_hypreal 1);
  15.710 +by (res_inst_tac [("z","y")] eq_Abs_hypreal 1);
  15.711 +by (auto_tac (claset(),simpset() addsimps [hcomplex_of_hypreal,
  15.712 +    hypreal_mult,hcomplex_mult,complex_of_real_mult]));
  15.713 +qed "hcomplex_of_hypreal_mult";
  15.714 +
  15.715 +Goalw [hcomplex_divide_def]
  15.716 +  "hcomplex_of_hypreal x / hcomplex_of_hypreal y = hcomplex_of_hypreal(x/y)";
  15.717 +by (hypreal_div_undefined_case_tac "y=0" 1);
  15.718 +by (simp_tac (simpset() addsimps [rename_numerals HYPREAL_DIVISION_BY_ZERO,
  15.719 +    HCOMPLEX_INVERSE_ZERO]) 1);
  15.720 +by (auto_tac (claset(),simpset() addsimps [hcomplex_of_hypreal_mult,
  15.721 +    hcomplex_of_hypreal_inverse RS sym]));
  15.722 +by (simp_tac (simpset() addsimps [hypreal_divide_def]) 1);
  15.723 +qed "hcomplex_of_hypreal_divide";
  15.724 +
  15.725 +Goalw [hcomplex_one_def]
  15.726 +      "hcomplex_of_hypreal 1 = 1";
  15.727 +by (auto_tac (claset(),simpset() addsimps [hcomplex_of_hypreal,hypreal_one_num]));
  15.728 +qed "hcomplex_of_hypreal_one";
  15.729 +
  15.730 +Goalw [hcomplex_zero_def,hypreal_zero_def]
  15.731 +      "hcomplex_of_hypreal 0 = 0";
  15.732 +by (auto_tac (claset(),simpset() addsimps [hcomplex_of_hypreal]));
  15.733 +qed "hcomplex_of_hypreal_zero";
  15.734 +
  15.735 +Addsimps [hcomplex_of_hypreal_one,hcomplex_of_hypreal_zero,
  15.736 +          rename_numerals hcomplex_of_hypreal_zero];
  15.737 +
  15.738 +Goal "hcomplex_of_hypreal (x ^ n) = (hcomplex_of_hypreal x) ^ n";
  15.739 +by (induct_tac "n" 1);
  15.740 +by (auto_tac (claset(),simpset() addsimps [hcomplex_of_hypreal_mult RS sym]));
  15.741 +qed "hcomplex_of_hypreal_pow";
  15.742 +
  15.743 +Goal "hRe(hcomplex_of_hypreal z) = z";
  15.744 +by (res_inst_tac [("z","z")] eq_Abs_hypreal 1);
  15.745 +by (auto_tac (claset(),simpset() addsimps [hcomplex_of_hypreal,hRe]));
  15.746 +qed "hRe_hcomplex_of_hypreal";
  15.747 +Addsimps [hRe_hcomplex_of_hypreal];
  15.748 +
  15.749 +Goal "hIm(hcomplex_of_hypreal z) = 0";
  15.750 +by (res_inst_tac [("z","z")] eq_Abs_hypreal 1);
  15.751 +by (auto_tac (claset(),simpset() addsimps [hcomplex_of_hypreal,hIm,
  15.752 +    hypreal_zero_num]));
  15.753 +qed "hIm_hcomplex_of_hypreal";
  15.754 +Addsimps [hIm_hcomplex_of_hypreal];
  15.755 +
  15.756 +Goal "hcomplex_of_hypreal epsilon ~= 0";
  15.757 +by (auto_tac (claset(),simpset() addsimps [hcomplex_of_hypreal,
  15.758 +    epsilon_def,hcomplex_zero_def]));
  15.759 +qed "hcomplex_of_hypreal_epsilon_not_zero";
  15.760 +Addsimps [hcomplex_of_hypreal_epsilon_not_zero];
  15.761 +
  15.762 +(*---------------------------------------------------------------------------*)
  15.763 +(*  Modulus (absolute value) of nonstandard complex number                   *) 
  15.764 +(*---------------------------------------------------------------------------*)
  15.765 +
  15.766 +Goalw [hcmod_def]
  15.767 +  "hcmod (Abs_hcomplex(hcomplexrel `` {%n. X n})) = \
  15.768 +\     Abs_hypreal(hyprel `` {%n. cmod (X n)})";
  15.769 +by (res_inst_tac [("f","Abs_hypreal")] arg_cong 1);
  15.770 +by (Auto_tac THEN Ultra_tac 1);
  15.771 +qed "hcmod";
  15.772 +
  15.773 +Goalw [hcomplex_zero_def,hypreal_zero_def] 
  15.774 +      "hcmod(0) = 0";
  15.775 +by (auto_tac (claset(),simpset() addsimps [hcmod]));
  15.776 +qed "hcmod_zero";
  15.777 +Addsimps [hcmod_zero,rename_numerals hcmod_zero];
  15.778 +
  15.779 +Goalw [hcomplex_one_def] 
  15.780 +      "hcmod(1) = 1";
  15.781 +by (auto_tac (claset(),simpset() addsimps [hcmod,hypreal_one_num]));
  15.782 +qed "hcmod_one";
  15.783 +Addsimps [hcmod_one];
  15.784 +
  15.785 +Goal "hcmod(hcomplex_of_hypreal x) = abs x";
  15.786 +by (res_inst_tac [("z","x")] eq_Abs_hypreal 1);
  15.787 +by (auto_tac (claset(),simpset() addsimps [hcmod,hcomplex_of_hypreal,
  15.788 +    hypreal_hrabs]));
  15.789 +qed "hcmod_hcomplex_of_hypreal";
  15.790 +Addsimps [hcmod_hcomplex_of_hypreal];
  15.791 +
  15.792 +Goal "hcomplex_of_hypreal (abs x) = \
  15.793 +\     hcomplex_of_hypreal(hcmod(hcomplex_of_hypreal x))";
  15.794 +by (Simp_tac 1);
  15.795 +qed "hcomplex_of_hypreal_abs";
  15.796 +
  15.797 +(*---------------------------------------------------------------------------*)
  15.798 +(*                   conjugation                                             *)
  15.799 +(*---------------------------------------------------------------------------*)
  15.800 +
  15.801 +Goalw [hcnj_def]
  15.802 +  "hcnj (Abs_hcomplex(hcomplexrel `` {%n. X n})) = \
  15.803 +\     Abs_hcomplex(hcomplexrel `` {%n. cnj(X n)})";
  15.804 +by (res_inst_tac [("f","Abs_hcomplex")] arg_cong 1);
  15.805 +by (Auto_tac THEN Ultra_tac 1);
  15.806 +qed "hcnj";
  15.807 +
  15.808 +Goal "inj hcnj";
  15.809 +by (rtac injI 1);
  15.810 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
  15.811 +by (res_inst_tac [("z","y")] eq_Abs_hcomplex 1);
  15.812 +by (auto_tac (claset(),simpset() addsimps [hcnj]));
  15.813 +qed "inj_hcnj";
  15.814 +
  15.815 +Goal "(hcnj x = hcnj y) = (x = y)";
  15.816 +by (auto_tac (claset() addDs [inj_hcnj RS injD],simpset()));
  15.817 +qed "hcomplex_hcnj_cancel_iff";
  15.818 +Addsimps [hcomplex_hcnj_cancel_iff];
  15.819 +
  15.820 +Goal "hcnj (hcnj z) = z";
  15.821 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
  15.822 +by (auto_tac (claset(),simpset() addsimps [hcnj]));
  15.823 +qed "hcomplex_hcnj_hcnj";
  15.824 +Addsimps [hcomplex_hcnj_hcnj];
  15.825 +
  15.826 +Goal "hcnj (hcomplex_of_hypreal x) = hcomplex_of_hypreal x";
  15.827 +by (res_inst_tac [("z","x")] eq_Abs_hypreal 1);
  15.828 +by (auto_tac (claset(),simpset() addsimps [hcnj,hcomplex_of_hypreal]));
  15.829 +qed "hcomplex_hcnj_hcomplex_of_hypreal";
  15.830 +Addsimps [hcomplex_hcnj_hcomplex_of_hypreal];
  15.831 +
  15.832 +Goal "hcmod (hcnj z) = hcmod z";
  15.833 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
  15.834 +by (auto_tac (claset(),simpset() addsimps [hcnj,hcmod]));
  15.835 +qed "hcomplex_hmod_hcnj";
  15.836 +Addsimps [hcomplex_hmod_hcnj];
  15.837 +
  15.838 +Goal "hcnj (-z) = - hcnj z";
  15.839 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
  15.840 +by (auto_tac (claset(),simpset() addsimps [hcnj,hcomplex_minus,
  15.841 +    complex_cnj_minus]));
  15.842 +qed "hcomplex_hcnj_minus";
  15.843 +
  15.844 +Goal "hcnj(inverse z) = inverse(hcnj z)";
  15.845 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
  15.846 +by (auto_tac (claset(),simpset() addsimps [hcnj,hcomplex_inverse,
  15.847 +    complex_cnj_inverse]));
  15.848 +qed "hcomplex_hcnj_inverse";
  15.849 +
  15.850 +Goal "hcnj(w + z) = hcnj(w) + hcnj(z)";
  15.851 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
  15.852 +by (res_inst_tac [("z","w")] eq_Abs_hcomplex 1);
  15.853 +by (auto_tac (claset(),simpset() addsimps [hcnj,hcomplex_add,
  15.854 +    complex_cnj_add]));
  15.855 +qed "hcomplex_hcnj_add";
  15.856 +
  15.857 +Goal "hcnj(w - z) = hcnj(w) - hcnj(z)";
  15.858 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
  15.859 +by (res_inst_tac [("z","w")] eq_Abs_hcomplex 1);
  15.860 +by (auto_tac (claset(),simpset() addsimps [hcnj,hcomplex_diff,
  15.861 +    complex_cnj_diff]));
  15.862 +qed "hcomplex_hcnj_diff";
  15.863 +
  15.864 +Goal "hcnj(w * z) = hcnj(w) * hcnj(z)";
  15.865 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
  15.866 +by (res_inst_tac [("z","w")] eq_Abs_hcomplex 1);
  15.867 +by (auto_tac (claset(),simpset() addsimps [hcnj,hcomplex_mult,
  15.868 +    complex_cnj_mult]));
  15.869 +qed "hcomplex_hcnj_mult";
  15.870 +
  15.871 +Goalw [hcomplex_divide_def] "hcnj(w / z) = (hcnj w)/(hcnj z)";
  15.872 +by (simp_tac (simpset() addsimps [hcomplex_hcnj_mult,hcomplex_hcnj_inverse]) 1);
  15.873 +qed "hcomplex_hcnj_divide";
  15.874 +
  15.875 +Goalw [hcomplex_one_def] "hcnj 1 = 1";
  15.876 +by (simp_tac (simpset() addsimps [hcnj]) 1);
  15.877 +qed "hcnj_one";
  15.878 +Addsimps [hcnj_one];
  15.879 +
  15.880 +Goal "hcnj(z ^ n) = hcnj(z) ^ n";
  15.881 +by (induct_tac "n" 1);
  15.882 +by (auto_tac (claset(),simpset() addsimps [hcomplex_hcnj_mult]));
  15.883 +qed "hcomplex_hcnj_pow";
  15.884 +
  15.885 +(* MOVE to NSComplexBin
  15.886 +Goal "z + hcnj z = \
  15.887 +\     hcomplex_of_hypreal (2 * hRe(z))";
  15.888 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
  15.889 +by (auto_tac (claset(),HOL_ss addsimps [hRe,hcnj,hcomplex_add,
  15.890 +    hypreal_mult,hcomplex_of_hypreal,complex_add_cnj]));
  15.891 +qed "hcomplex_add_hcnj";
  15.892 +
  15.893 +Goal "z - hcnj z = \
  15.894 +\     hcomplex_of_hypreal (hypreal_of_real 2 * hIm(z)) * iii";
  15.895 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
  15.896 +by (auto_tac (claset(),simpset() addsimps [hIm,hcnj,hcomplex_diff,
  15.897 +    hypreal_of_real_def,hypreal_mult,hcomplex_of_hypreal,
  15.898 +    complex_diff_cnj,iii_def,hcomplex_mult]));
  15.899 +qed "hcomplex_diff_hcnj";
  15.900 +*)
  15.901 +
  15.902 +Goalw [hcomplex_zero_def] 
  15.903 +      "hcnj 0 = 0";
  15.904 +by (auto_tac (claset(),simpset() addsimps [hcnj]));
  15.905 +qed "hcomplex_hcnj_zero";
  15.906 +Addsimps [hcomplex_hcnj_zero];
  15.907 +
  15.908 +Goal "(hcnj z = 0) = (z = 0)";
  15.909 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
  15.910 +by (auto_tac (claset(),simpset() addsimps [hcomplex_zero_def,
  15.911 +    hcnj]));
  15.912 +qed "hcomplex_hcnj_zero_iff";
  15.913 +AddIffs [hcomplex_hcnj_zero_iff];
  15.914 +
  15.915 +Goal "z * hcnj z = hcomplex_of_hypreal (hRe(z) ^ 2 + hIm(z) ^ 2)";
  15.916 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
  15.917 +by (auto_tac (claset(),simpset() addsimps [hcnj,hcomplex_mult,
  15.918 +    hcomplex_of_hypreal,hRe,hIm,hypreal_add,hypreal_mult,
  15.919 +    complex_mult_cnj,two_eq_Suc_Suc]));
  15.920 +qed "hcomplex_mult_hcnj";
  15.921 +
  15.922 +
  15.923 +(*---------------------------------------------------------------------------*)
  15.924 +(*  some algebra etc.                                                        *)
  15.925 +(*---------------------------------------------------------------------------*)
  15.926 +
  15.927 +Goal "(x*y = (0::hcomplex)) = (x = 0 | y = 0)";
  15.928 +by Auto_tac;
  15.929 +by (auto_tac (claset() addIs [ccontr] addDs 
  15.930 +    [hcomplex_mult_not_zero],simpset()));
  15.931 +qed "hcomplex_mult_zero_iff";
  15.932 +Addsimps [hcomplex_mult_zero_iff];
  15.933 +
  15.934 +Goal "(x + y = x) = (y = (0::hcomplex))";
  15.935 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
  15.936 +by (res_inst_tac [("z","y")] eq_Abs_hcomplex 1);
  15.937 +by (auto_tac (claset(),simpset() addsimps [hcomplex_add,
  15.938 +    hcomplex_zero_def]));
  15.939 +qed "hcomplex_add_left_cancel_zero";
  15.940 +Addsimps [hcomplex_add_left_cancel_zero];
  15.941 +
  15.942 +Goalw [hcomplex_diff_def] 
  15.943 +      "((z1::hcomplex) - z2) * w = (z1 * w) - (z2 * w)";
  15.944 +by (simp_tac (simpset() addsimps [hcomplex_add_mult_distrib]) 1);
  15.945 +qed "hcomplex_diff_mult_distrib";
  15.946 +
  15.947 +Goalw [hcomplex_diff_def]
  15.948 +      "(w::hcomplex) * (z1 - z2) = (w * z1) - (w * z2)";
  15.949 +by (simp_tac (simpset() addsimps [hcomplex_add_mult_distrib2]) 1);
  15.950 +qed "hcomplex_diff_mult_distrib2";
  15.951 +
  15.952 +(*---------------------------------------------------------------------------*)
  15.953 +(*  More theorems about hcmod                                                *)
  15.954 +(*---------------------------------------------------------------------------*)
  15.955 +
  15.956 +Goal "(hcmod x = 0) = (x = 0)";
  15.957 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
  15.958 +by (auto_tac (claset(),simpset() addsimps [hcmod,hcomplex_zero_def,
  15.959 +    hypreal_zero_num]));
  15.960 +qed "hcomplex_hcmod_eq_zero_cancel";
  15.961 +Addsimps [hcomplex_hcmod_eq_zero_cancel];
  15.962 +
  15.963 +(* not proved already? strange! *)
  15.964 +Goalw [hypreal_le_def] 
  15.965 +      "(hypreal_of_nat n <= hypreal_of_nat m) = (n <= m)";
  15.966 +by Auto_tac;
  15.967 +qed "hypreal_of_nat_le_iff";
  15.968 +Addsimps [hypreal_of_nat_le_iff];
  15.969 +
  15.970 +Goal "0 <= hypreal_of_nat n";
  15.971 +by (simp_tac (simpset() addsimps [hypreal_of_nat_zero RS sym]
  15.972 +    delsimps [hypreal_of_nat_zero]) 1);
  15.973 +qed "hypreal_of_nat_ge_zero";
  15.974 +Addsimps [hypreal_of_nat_ge_zero];
  15.975 +
  15.976 +Addsimps [hypreal_of_nat_ge_zero RS hrabs_eqI1];
  15.977 +
  15.978 +Goal "0 <= hypreal_of_hypnat n";
  15.979 +by (res_inst_tac [("z","n")] eq_Abs_hypnat 1);
  15.980 +by (asm_simp_tac (simpset() addsimps [hypreal_of_hypnat,
  15.981 +    hypreal_zero_num,hypreal_le]) 1);
  15.982 +qed "hypreal_of_hypnat_ge_zero";
  15.983 +Addsimps [hypreal_of_hypnat_ge_zero];
  15.984 +
  15.985 +Addsimps [hypreal_of_hypnat_ge_zero RS hrabs_eqI1];
  15.986 +
  15.987 +Goal "hcmod (hcomplex_of_hypreal(hypreal_of_nat n)) = hypreal_of_nat n";
  15.988 +by Auto_tac;
  15.989 +qed "hcmod_hcomplex_of_hypreal_of_nat";
  15.990 +Addsimps [hcmod_hcomplex_of_hypreal_of_nat];
  15.991 +
  15.992 +Goal "hcmod (hcomplex_of_hypreal(hypreal_of_hypnat n)) = hypreal_of_hypnat n";
  15.993 +by Auto_tac;
  15.994 +qed "hcmod_hcomplex_of_hypreal_of_hypnat";
  15.995 +Addsimps [hcmod_hcomplex_of_hypreal_of_hypnat];
  15.996 +
  15.997 +Goal "hcmod (-x) = hcmod(x)";
  15.998 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
  15.999 +by (auto_tac (claset(),simpset() addsimps [hcmod,hcomplex_minus]));
 15.1000 +qed "hcmod_minus";
 15.1001 +Addsimps [hcmod_minus];
 15.1002 +
 15.1003 +Goal "hcmod(z * hcnj(z)) = hcmod(z) ^ 2";
 15.1004 +by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
 15.1005 +by (auto_tac (claset(),simpset() addsimps [hcmod,hcomplex_mult,
 15.1006 +    hcnj,hypreal_mult,complex_mod_mult_cnj,two_eq_Suc_Suc]));
 15.1007 +qed "hcmod_mult_hcnj";
 15.1008 +
 15.1009 +Goal "(0::hypreal) <= hcmod x";
 15.1010 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
 15.1011 +by (auto_tac (claset(),simpset() addsimps [hcmod,
 15.1012 +    hypreal_zero_num,hypreal_le]));
 15.1013 +qed "hcmod_ge_zero";
 15.1014 +Addsimps [hcmod_ge_zero];
 15.1015 +
 15.1016 +Goal "abs(hcmod x) = hcmod x";
 15.1017 +by (auto_tac (claset() addIs [hrabs_eqI1],simpset()));
 15.1018 +qed "hrabs_hcmod_cancel";
 15.1019 +Addsimps [hrabs_hcmod_cancel];
 15.1020 +
 15.1021 +Goal "hcmod(x*y) = hcmod(x) * hcmod(y)";
 15.1022 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
 15.1023 +by (res_inst_tac [("z","y")] eq_Abs_hcomplex 1);
 15.1024 +by (auto_tac (claset(),simpset() addsimps [hcmod,hcomplex_mult,
 15.1025 +    hypreal_mult,complex_mod_mult]));
 15.1026 +qed "hcmod_mult";
 15.1027 +
 15.1028 +Goal "hcmod(x + y) ^ 2 = hcmod(x) ^ 2 + hcmod(y) ^ 2 + 2 * hRe(x * hcnj y)";
 15.1029 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
 15.1030 +by (res_inst_tac [("z","y")] eq_Abs_hcomplex 1);
 15.1031 +by (auto_tac (claset(),simpset() addsimps [hcmod,hcomplex_add,
 15.1032 +    hypreal_mult,hRe,hcnj,hcomplex_mult,two_eq_Suc_Suc,
 15.1033 +    realpow_two RS sym] delsimps [realpow_Suc]));
 15.1034 +by (auto_tac (claset(),simpset() addsimps [two_eq_Suc_Suc RS sym,
 15.1035 +    complex_mod_add_squared_eq,hypreal_add RS sym,hypreal_mult RS sym,
 15.1036 +    symmetric hypreal_of_real_def]));
 15.1037 +qed "hcmod_add_squared_eq";
 15.1038 +
 15.1039 +Goal "hRe(x * hcnj y) <= hcmod(x * hcnj y)";
 15.1040 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
 15.1041 +by (res_inst_tac [("z","y")] eq_Abs_hcomplex 1);
 15.1042 +by (auto_tac (claset(),simpset() addsimps [hcmod,hcnj,
 15.1043 +    hcomplex_mult,hRe,hypreal_le]));
 15.1044 +qed "hcomplex_hRe_mult_hcnj_le_hcmod";
 15.1045 +Addsimps [hcomplex_hRe_mult_hcnj_le_hcmod];
 15.1046 +
 15.1047 +Goal "hRe(x * hcnj y) <= hcmod(x * y)";
 15.1048 +by (cut_inst_tac [("x","x"),("y","y")] hcomplex_hRe_mult_hcnj_le_hcmod 1);
 15.1049 +by (asm_full_simp_tac (simpset() addsimps [hcmod_mult]) 1);
 15.1050 +qed "hcomplex_hRe_mult_hcnj_le_hcmod2";
 15.1051 +Addsimps [hcomplex_hRe_mult_hcnj_le_hcmod2];
 15.1052 +
 15.1053 +Goal "hcmod (x + y) ^ 2 <= (hcmod(x) + hcmod(y)) ^ 2";
 15.1054 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
 15.1055 +by (res_inst_tac [("z","y")] eq_Abs_hcomplex 1);
 15.1056 +by (auto_tac (claset(),simpset() addsimps [hcmod,hcnj,
 15.1057 +    hcomplex_add,hypreal_mult,hypreal_add,hypreal_le,
 15.1058 +    realpow_two RS sym,two_eq_Suc_Suc] delsimps [realpow_Suc]));
 15.1059 +by (simp_tac (simpset() addsimps [two_eq_Suc_Suc RS sym]) 1);
 15.1060 +qed "hcmod_triangle_squared";
 15.1061 +Addsimps [hcmod_triangle_squared];
 15.1062 +
 15.1063 +Goal "hcmod (x + y) <= hcmod(x) + hcmod(y)";
 15.1064 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
 15.1065 +by (res_inst_tac [("z","y")] eq_Abs_hcomplex 1);
 15.1066 +by (auto_tac (claset(),simpset() addsimps [hcmod,
 15.1067 +    hcomplex_add,hypreal_add,hypreal_le]));
 15.1068 +qed "hcmod_triangle_ineq";
 15.1069 +Addsimps [hcmod_triangle_ineq];
 15.1070 +
 15.1071 +Goal "hcmod(b + a) - hcmod b <= hcmod a";
 15.1072 +by (cut_inst_tac [("x1","b"),("y1","a"),("x","-hcmod b")]
 15.1073 +   (hcmod_triangle_ineq RS hypreal_add_le_mono1) 1);
 15.1074 +by (asm_full_simp_tac (simpset() addsimps hypreal_add_ac) 1);
 15.1075 +qed "hcmod_triangle_ineq2";
 15.1076 +Addsimps [hcmod_triangle_ineq2];
 15.1077 +
 15.1078 +Goal "hcmod (x - y) = hcmod (y - x)";
 15.1079 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
 15.1080 +by (res_inst_tac [("z","y")] eq_Abs_hcomplex 1);
 15.1081 +by (auto_tac (claset(),simpset() addsimps [hcmod,
 15.1082 +    hcomplex_diff,complex_mod_diff_commute]));
 15.1083 +qed "hcmod_diff_commute";
 15.1084 +
 15.1085 +Goal "[| hcmod x < r; hcmod y < s |] ==> hcmod (x + y) < r + s";
 15.1086 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
 15.1087 +by (res_inst_tac [("z","y")] eq_Abs_hcomplex 1);
 15.1088 +by (res_inst_tac [("z","r")] eq_Abs_hypreal 1);
 15.1089 +by (res_inst_tac [("z","s")] eq_Abs_hypreal 1);
 15.1090 +by (auto_tac (claset(),simpset() addsimps [hcmod,hcomplex_add,
 15.1091 +    hypreal_add,hypreal_less]));
 15.1092 +by (ultra_tac (claset() addIs [complex_mod_add_less],simpset()) 1);
 15.1093 +qed "hcmod_add_less";
 15.1094 +
 15.1095 +Goal "[| hcmod x < r; hcmod y < s |] ==> hcmod (x * y) < r * s";
 15.1096 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
 15.1097 +by (res_inst_tac [("z","y")] eq_Abs_hcomplex 1);
 15.1098 +by (res_inst_tac [("z","r")] eq_Abs_hypreal 1);
 15.1099 +by (res_inst_tac [("z","s")] eq_Abs_hypreal 1);
 15.1100 +by (auto_tac (claset(),simpset() addsimps [hcmod,hypreal_mult,
 15.1101 +    hypreal_less,hcomplex_mult]));
 15.1102 +by (ultra_tac (claset() addIs [complex_mod_mult_less],simpset()) 1);
 15.1103 +qed "hcmod_mult_less";
 15.1104 +
 15.1105 +goal NSComplex.thy "hcmod(a) - hcmod(b) <= hcmod(a + b)";
 15.1106 +by (res_inst_tac [("z","a")] eq_Abs_hcomplex 1);
 15.1107 +by (res_inst_tac [("z","b")] eq_Abs_hcomplex 1);
 15.1108 +by (auto_tac (claset(),simpset() addsimps [hcmod,hcomplex_add,
 15.1109 +    hypreal_diff,hypreal_le]));
 15.1110 +qed "hcmod_diff_ineq";
 15.1111 +Addsimps [hcmod_diff_ineq];
 15.1112 +
 15.1113 +
 15.1114 +(*---------------------------------------------------------------------------*)
 15.1115 +(*                       a few nonlinear theorems                            *)
 15.1116 +(*---------------------------------------------------------------------------*)
 15.1117 +
 15.1118 +Goalw [hcpow_def] 
 15.1119 +  "Abs_hcomplex(hcomplexrel``{%n. X n}) hcpow \
 15.1120 +\  Abs_hypnat(hypnatrel``{%n. Y n}) = \
 15.1121 +\  Abs_hcomplex(hcomplexrel``{%n. X n ^ Y n})";
 15.1122 +by (res_inst_tac [("f","Abs_hcomplex")] arg_cong 1);
 15.1123 +by (Auto_tac THEN Ultra_tac 1);
 15.1124 +qed "hcpow";
 15.1125 +
 15.1126 +Goal "hcomplex_of_hypreal (x pow n) = (hcomplex_of_hypreal x) hcpow n";
 15.1127 +by (res_inst_tac [("z","x")] eq_Abs_hypreal 1);
 15.1128 +by (res_inst_tac [("z","n")] eq_Abs_hypnat 1);
 15.1129 +by (auto_tac (claset(),simpset() addsimps [hcomplex_of_hypreal,
 15.1130 +    hyperpow,hcpow,complex_of_real_pow]));
 15.1131 +qed "hcomplex_of_hypreal_hyperpow";
 15.1132 +
 15.1133 +Goal "hcmod(x ^ n) = hcmod(x) ^ n";
 15.1134 +by (induct_tac "n" 1);
 15.1135 +by (auto_tac (claset(),simpset() addsimps [hcmod_mult]));
 15.1136 +qed "hcmod_hcomplexpow";
 15.1137 +
 15.1138 +Goal "hcmod(x hcpow n) = hcmod(x) pow n";
 15.1139 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
 15.1140 +by (res_inst_tac [("z","n")] eq_Abs_hypnat 1);
 15.1141 +by (auto_tac (claset(),simpset() addsimps [hcpow,hyperpow,
 15.1142 +    hcmod,complex_mod_complexpow]));
 15.1143 +qed "hcmod_hcpow";
 15.1144 +
 15.1145 +Goal "(-x::hcomplex) ^ n = (if even n then (x ^ n) else -(x ^ n))";
 15.1146 +by (induct_tac "n" 1);
 15.1147 +by Auto_tac;
 15.1148 +qed "hcomplexpow_minus";
 15.1149 +
 15.1150 +Goal "(-x::hcomplex) hcpow n = \
 15.1151 +\     (if ( *pNat* even) n then (x hcpow n) else -(x hcpow n))";
 15.1152 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
 15.1153 +by (res_inst_tac [("z","n")] eq_Abs_hypnat 1);
 15.1154 +by (auto_tac (claset(),simpset() addsimps [hcpow,hyperpow,starPNat,
 15.1155 +    hcomplex_minus]));
 15.1156 +by (ALLGOALS(ultra_tac (claset(),simpset() addsimps [complexpow_minus])));
 15.1157 +qed "hcpow_minus";
 15.1158 +
 15.1159 +Goal "inverse(-x) = - inverse (x::hcomplex)";
 15.1160 +by (res_inst_tac [("z","x")] eq_Abs_hcomplex 1);
 15.1161 +by (auto_tac (claset(),simpset() addsimps [hcomplex_inverse,hcomplex_minus,
 15.1162 +    complex_inverse_minus]));