src/HOL/Complex/NSCA.thy
changeset 17318 bc1c75855f3d
parent 17300 5798fbf42a6a
child 17373 27509e72f29e
equal deleted inserted replaced
17317:3f12de2e2e6e 17318:bc1c75855f3d
    78      "[| x + y \<in> SComplex; y \<in> SComplex |] ==> x \<in> SComplex"
    78      "[| x + y \<in> SComplex; y \<in> SComplex |] ==> x \<in> SComplex"
    79 by (drule SComplex_diff, assumption, simp)
    79 by (drule SComplex_diff, assumption, simp)
    80 
    80 
    81 lemma SReal_hcmod_hcomplex_of_complex [simp]:
    81 lemma SReal_hcmod_hcomplex_of_complex [simp]:
    82      "hcmod (hcomplex_of_complex r) \<in> Reals"
    82      "hcmod (hcomplex_of_complex r) \<in> Reals"
    83 by (simp add: hcomplex_of_complex_def hcmod SReal_def hypreal_of_real_def star_of_def star_n_def)
    83 by (auto simp add: hcmod SReal_def star_of_def)
    84 
    84 
    85 lemma SReal_hcmod_number_of [simp]: "hcmod (number_of w ::hcomplex) \<in> Reals"
    85 lemma SReal_hcmod_number_of [simp]: "hcmod (number_of w ::hcomplex) \<in> Reals"
    86 apply (subst hcomplex_number_of [symmetric])
    86 apply (subst hcomplex_number_of [symmetric])
    87 apply (rule SReal_hcmod_hcomplex_of_complex)
    87 apply (rule SReal_hcmod_hcomplex_of_complex)
    88 done
    88 done
   132 done
   132 done
   133 
   133 
   134 lemma SComplex_hcmod_SReal: 
   134 lemma SComplex_hcmod_SReal: 
   135       "z \<in> SComplex ==> hcmod z \<in> Reals"
   135       "z \<in> SComplex ==> hcmod z \<in> Reals"
   136 apply (simp add: SComplex_def SReal_def)
   136 apply (simp add: SComplex_def SReal_def)
   137 apply (rule_tac z = z in eq_Abs_star)
   137 apply (cases z)
   138 apply (auto simp add: hcmod hypreal_of_real_def star_of_def star_n_def hcomplex_of_complex_def cmod_def)
   138 apply (auto simp add: hcmod star_of_def cmod_def star_n_eq_iff)
   139 apply (rule_tac x = "cmod r" in exI)
   139 apply (rule_tac x = "cmod r" in exI)
   140 apply (simp add: cmod_def, ultra)
   140 apply (simp add: cmod_def, ultra)
   141 done
   141 done
   142 
   142 
   143 lemma SComplex_zero [simp]: "0 \<in> SComplex"
   143 lemma SComplex_zero [simp]: "0 \<in> SComplex"
   144 by (simp add: SComplex_def hcomplex_of_complex_zero_iff)
   144 by (simp add: SComplex_def hcomplex_of_complex_zero_iff)
   145 
   145 
   146 lemma SComplex_one [simp]: "1 \<in> SComplex"
   146 lemma SComplex_one [simp]: "1 \<in> SComplex"
   147 by (simp add: SComplex_def hcomplex_of_complex_def star_of_def star_n_def hypreal_one_def)
   147 by (simp add: SComplex_def star_of_def star_n_one_num star_n_eq_iff)
   148 
   148 
   149 (*
   149 (*
   150 Goalw [SComplex_def,SReal_def] "hcmod z \<in> Reals ==> z \<in> SComplex"
   150 Goalw [SComplex_def,SReal_def] "hcmod z \<in> Reals ==> z \<in> SComplex"
   151 by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
   151 by (res_inst_tac [("z","z")] eq_Abs_hcomplex 1);
   152 by (auto_tac (claset(),simpset() addsimps [hcmod,hypreal_of_real_def,
   152 by (auto_tac (claset(),simpset() addsimps [hcmod,hypreal_of_real_def,
   233      "[| x \<in> CInfinitesimal; y \<in> CFinite |] ==> (x * y) \<in> CInfinitesimal"
   233      "[| x \<in> CInfinitesimal; y \<in> CFinite |] ==> (x * y) \<in> CInfinitesimal"
   234 by (auto intro: Infinitesimal_HFinite_mult simp add: CInfinitesimal_hcmod_iff CFinite_hcmod_iff hcmod_mult)
   234 by (auto intro: Infinitesimal_HFinite_mult simp add: CInfinitesimal_hcmod_iff CFinite_hcmod_iff hcmod_mult)
   235 
   235 
   236 lemma CInfinitesimal_CFinite_mult2:
   236 lemma CInfinitesimal_CFinite_mult2:
   237      "[| x \<in> CInfinitesimal; y \<in> CFinite |] ==> (y * x) \<in> CInfinitesimal"
   237      "[| x \<in> CInfinitesimal; y \<in> CFinite |] ==> (y * x) \<in> CInfinitesimal"
   238 by (auto dest: CInfinitesimal_CFinite_mult simp add: hcomplex_mult_commute)
   238 by (auto dest: CInfinitesimal_CFinite_mult simp add: mult_commute)
   239 
   239 
   240 lemma CInfinite_hcmod_iff: "(z \<in> CInfinite) = (hcmod z \<in> HInfinite)"
   240 lemma CInfinite_hcmod_iff: "(z \<in> CInfinite) = (hcmod z \<in> HInfinite)"
   241 by (simp add: CInfinite_def HInfinite_def)
   241 by (simp add: CInfinite_def HInfinite_def)
   242 
   242 
   243 lemma CInfinite_inverse_CInfinitesimal:
   243 lemma CInfinite_inverse_CInfinitesimal:
   390 by (blast intro!: capprox_add capprox_minus)
   390 by (blast intro!: capprox_add capprox_minus)
   391 
   391 
   392 lemma capprox_mult1: 
   392 lemma capprox_mult1: 
   393       "[| a @c= b; c \<in> CFinite|] ==> a*c @c= b*c"
   393       "[| a @c= b; c \<in> CFinite|] ==> a*c @c= b*c"
   394 apply (simp add: capprox_def diff_minus)
   394 apply (simp add: capprox_def diff_minus)
   395 apply (simp only: CInfinitesimal_CFinite_mult minus_mult_left hcomplex_add_mult_distrib [symmetric])
   395 apply (simp only: CInfinitesimal_CFinite_mult minus_mult_left left_distrib [symmetric])
   396 done
   396 done
   397 
   397 
   398 lemma capprox_mult2: "[|a @c= b; c \<in> CFinite|] ==> c*a @c= c*b"
   398 lemma capprox_mult2: "[|a @c= b; c \<in> CFinite|] ==> c*a @c= c*b"
   399 by (simp add: capprox_mult1 hcomplex_mult_commute)
   399 by (simp add: capprox_mult1 mult_commute)
   400 
   400 
   401 lemma capprox_mult_subst:
   401 lemma capprox_mult_subst:
   402      "[|u @c= v*x; x @c= y; v \<in> CFinite|] ==> u @c= v*y"
   402      "[|u @c= v*x; x @c= y; v \<in> CFinite|] ==> u @c= v*y"
   403 by (blast intro: capprox_mult2 capprox_trans)
   403 by (blast intro: capprox_mult2 capprox_trans)
   404 
   404 
   547 
   547 
   548 lemma Infinitesimal_hcmod_add_diff:
   548 lemma Infinitesimal_hcmod_add_diff:
   549      "u @c= 0 ==> hcmod(x + u) - hcmod x \<in> Infinitesimal"
   549      "u @c= 0 ==> hcmod(x + u) - hcmod x \<in> Infinitesimal"
   550 apply (rule_tac e = "hcmod u" and e' = "- hcmod u" in Infinitesimal_interval2)
   550 apply (rule_tac e = "hcmod u" and e' = "- hcmod u" in Infinitesimal_interval2)
   551 apply (auto dest: capprox_approx_zero_iff [THEN iffD1]
   551 apply (auto dest: capprox_approx_zero_iff [THEN iffD1]
   552              simp add: mem_infmal_iff [symmetric] hypreal_diff_def)
   552              simp add: mem_infmal_iff [symmetric] diff_def)
   553 apply (rule_tac c1 = "hcmod x" in add_le_cancel_left [THEN iffD1])
   553 apply (rule_tac c1 = "hcmod x" in add_le_cancel_left [THEN iffD1])
   554 apply (auto simp add: diff_minus [symmetric])
   554 apply (auto simp add: diff_minus [symmetric])
   555 done
   555 done
   556 
   556 
   557 lemma approx_hcmod_add_hcmod: "u @c= 0 ==> hcmod(x + u) @= hcmod x"
   557 lemma approx_hcmod_add_hcmod: "u @c= 0 ==> hcmod(x + u) @= hcmod x"
   657 lemma capprox_unique_complex:
   657 lemma capprox_unique_complex:
   658      "[| r \<in> SComplex; s \<in> SComplex; r @c= x; s @c= x|] ==> r = s"
   658      "[| r \<in> SComplex; s \<in> SComplex; r @c= x; s @c= x|] ==> r = s"
   659 by (blast intro: SComplex_capprox_iff [THEN iffD1] capprox_trans2)
   659 by (blast intro: SComplex_capprox_iff [THEN iffD1] capprox_trans2)
   660 
   660 
   661 lemma hcomplex_capproxD1:
   661 lemma hcomplex_capproxD1:
   662      "Abs_star(starrel ``{%n. X n}) @c= Abs_star(starrel``{%n. Y n})  
   662      "star_n X @c= star_n Y
   663       ==> Abs_star(starrel `` {%n. Re(X n)}) @=  
   663       ==> star_n (%n. Re(X n)) @= star_n (%n. Re(Y n))"
   664           Abs_star(starrel `` {%n. Re(Y n)})"
       
   665 apply (auto simp add: approx_FreeUltrafilterNat_iff)
   664 apply (auto simp add: approx_FreeUltrafilterNat_iff)
   666 apply (drule capprox_minus_iff [THEN iffD1])
   665 apply (drule capprox_minus_iff [THEN iffD1])
   667 apply (auto simp add: hcomplex_minus hcomplex_add mem_cinfmal_iff [symmetric] CInfinitesimal_hcmod_iff hcmod Infinitesimal_FreeUltrafilterNat_iff2)
   666 apply (auto simp add: star_n_minus star_n_add mem_cinfmal_iff [symmetric] CInfinitesimal_hcmod_iff hcmod Infinitesimal_FreeUltrafilterNat_iff2)
   668 apply (drule_tac x = m in spec, ultra)
   667 apply (drule_tac x = m in spec, ultra)
   669 apply (rename_tac Z x)
   668 apply (rename_tac Z x)
   670 apply (case_tac "X x")
   669 apply (case_tac "X x")
   671 apply (case_tac "Y x")
   670 apply (case_tac "Y x")
   672 apply (auto simp add: complex_minus complex_add complex_mod
   671 apply (auto simp add: complex_minus complex_add complex_mod
   676 apply (auto simp del: realpow_Suc)
   675 apply (auto simp del: realpow_Suc)
   677 done
   676 done
   678 
   677 
   679 (* same proof *)
   678 (* same proof *)
   680 lemma hcomplex_capproxD2:
   679 lemma hcomplex_capproxD2:
   681      "Abs_star(starrel ``{%n. X n}) @c= Abs_star(starrel``{%n. Y n})  
   680      "star_n X @c= star_n Y
   682       ==> Abs_star(starrel `` {%n. Im(X n)}) @=  
   681       ==> star_n (%n. Im(X n)) @= star_n (%n. Im(Y n))"
   683           Abs_star(starrel `` {%n. Im(Y n)})"
       
   684 apply (auto simp add: approx_FreeUltrafilterNat_iff)
   682 apply (auto simp add: approx_FreeUltrafilterNat_iff)
   685 apply (drule capprox_minus_iff [THEN iffD1])
   683 apply (drule capprox_minus_iff [THEN iffD1])
   686 apply (auto simp add: hcomplex_minus hcomplex_add mem_cinfmal_iff [symmetric] CInfinitesimal_hcmod_iff hcmod Infinitesimal_FreeUltrafilterNat_iff2)
   684 apply (auto simp add: star_n_minus star_n_add mem_cinfmal_iff [symmetric] CInfinitesimal_hcmod_iff hcmod Infinitesimal_FreeUltrafilterNat_iff2)
   687 apply (drule_tac x = m in spec, ultra)
   685 apply (drule_tac x = m in spec, ultra)
   688 apply (rename_tac Z x)
   686 apply (rename_tac Z x)
   689 apply (case_tac "X x")
   687 apply (case_tac "X x")
   690 apply (case_tac "Y x")
   688 apply (case_tac "Y x")
   691 apply (auto simp add: complex_minus complex_add complex_mod simp del: realpow_Suc)
   689 apply (auto simp add: complex_minus complex_add complex_mod simp del: realpow_Suc)
   693 apply (drule_tac t = "Z x" in sym)
   691 apply (drule_tac t = "Z x" in sym)
   694 apply (auto simp del: realpow_Suc)
   692 apply (auto simp del: realpow_Suc)
   695 done
   693 done
   696 
   694 
   697 lemma hcomplex_capproxI:
   695 lemma hcomplex_capproxI:
   698      "[| Abs_star(starrel `` {%n. Re(X n)}) @=  
   696      "[| star_n (%n. Re(X n)) @= star_n (%n. Re(Y n));  
   699          Abs_star(starrel `` {%n. Re(Y n)});  
   697          star_n (%n. Im(X n)) @= star_n (%n. Im(Y n))  
   700          Abs_star(starrel `` {%n. Im(X n)}) @=  
   698       |] ==> star_n X @c= star_n Y"
   701          Abs_star(starrel `` {%n. Im(Y n)})  
       
   702       |] ==> Abs_star(starrel ``{%n. X n}) @c= Abs_star(starrel``{%n. Y n})"
       
   703 apply (drule approx_minus_iff [THEN iffD1])
   699 apply (drule approx_minus_iff [THEN iffD1])
   704 apply (drule approx_minus_iff [THEN iffD1])
   700 apply (drule approx_minus_iff [THEN iffD1])
   705 apply (rule capprox_minus_iff [THEN iffD2])
   701 apply (rule capprox_minus_iff [THEN iffD2])
   706 apply (auto simp add: mem_cinfmal_iff [symmetric] mem_infmal_iff [symmetric] hypreal_minus hypreal_add hcomplex_minus hcomplex_add CInfinitesimal_hcmod_iff hcmod Infinitesimal_FreeUltrafilterNat_iff)
   702 apply (auto simp add: mem_cinfmal_iff [symmetric] mem_infmal_iff [symmetric] star_n_add star_n_minus CInfinitesimal_hcmod_iff hcmod Infinitesimal_FreeUltrafilterNat_iff)
   707 apply (rule bexI, rule_tac [2] lemma_starrel_refl, auto)
   703 apply (rule bexI [OF _ Rep_star_star_n], auto)
   708 apply (drule_tac x = "u/2" in spec)
   704 apply (drule_tac x = "u/2" in spec)
   709 apply (drule_tac x = "u/2" in spec, auto, ultra)
   705 apply (drule_tac x = "u/2" in spec, auto, ultra)
   710 apply (drule sym, drule sym)
   706 apply (drule sym, drule sym)
   711 apply (case_tac "X x")
   707 apply (case_tac "X x")
   712 apply (case_tac "Y x")
   708 apply (case_tac "Y x")
   716 apply (rule_tac [2] lemma_sqrt_hcomplex_capprox, auto)
   712 apply (rule_tac [2] lemma_sqrt_hcomplex_capprox, auto)
   717 apply (simp add: power2_eq_square)
   713 apply (simp add: power2_eq_square)
   718 done
   714 done
   719 
   715 
   720 lemma capprox_approx_iff:
   716 lemma capprox_approx_iff:
   721      "(Abs_star(starrel ``{%n. X n}) @c= Abs_star(starrel``{%n. Y n})) = 
   717      "(star_n X @c= star_n Y) = 
   722        (Abs_star(starrel `` {%n. Re(X n)}) @= Abs_star(starrel `` {%n. Re(Y n)}) &  
   718        (star_n (%n. Re(X n)) @= star_n (%n. Re(Y n)) &  
   723         Abs_star(starrel `` {%n. Im(X n)}) @= Abs_star(starrel `` {%n. Im(Y n)}))"
   719         star_n (%n. Im(X n)) @= star_n (%n. Im(Y n)))"
   724 apply (blast intro: hcomplex_capproxI hcomplex_capproxD1 hcomplex_capproxD2)
   720 apply (blast intro: hcomplex_capproxI hcomplex_capproxD1 hcomplex_capproxD2)
   725 done
   721 done
   726 
   722 
   727 lemma hcomplex_of_hypreal_capprox_iff [simp]:
   723 lemma hcomplex_of_hypreal_capprox_iff [simp]:
   728      "(hcomplex_of_hypreal x @c= hcomplex_of_hypreal z) = (x @= z)"
   724      "(hcomplex_of_hypreal x @c= hcomplex_of_hypreal z) = (x @= z)"
   729 apply (rule_tac z=x in eq_Abs_star, rule_tac z=z in eq_Abs_star)
   725 apply (cases x, cases z)
   730 apply (simp add: hcomplex_of_hypreal capprox_approx_iff)
   726 apply (simp add: hcomplex_of_hypreal capprox_approx_iff)
   731 done
   727 done
   732 
   728 
   733 lemma CFinite_HFinite_Re:
   729 lemma CFinite_HFinite_Re:
   734      "Abs_star(starrel ``{%n. X n}) \<in> CFinite  
   730      "star_n X \<in> CFinite  
   735       ==> Abs_star(starrel `` {%n. Re(X n)}) \<in> HFinite"
   731       ==> star_n (%n. Re(X n)) \<in> HFinite"
   736 apply (auto simp add: CFinite_hcmod_iff hcmod HFinite_FreeUltrafilterNat_iff)
   732 apply (auto simp add: CFinite_hcmod_iff hcmod HFinite_FreeUltrafilterNat_iff)
   737 apply (rule bexI, rule_tac [2] lemma_starrel_refl)
   733 apply (rule bexI [OF _ Rep_star_star_n])
   738 apply (rule_tac x = u in exI, ultra)
   734 apply (rule_tac x = u in exI, ultra)
   739 apply (drule sym, case_tac "X x")
   735 apply (drule sym, case_tac "X x")
   740 apply (auto simp add: complex_mod numeral_2_eq_2 simp del: realpow_Suc)
   736 apply (auto simp add: complex_mod numeral_2_eq_2 simp del: realpow_Suc)
   741 apply (rule ccontr, drule linorder_not_less [THEN iffD1])
   737 apply (rule ccontr, drule linorder_not_less [THEN iffD1])
   742 apply (drule order_less_le_trans, assumption)
   738 apply (drule order_less_le_trans, assumption)
   743 apply (drule real_sqrt_ge_abs1 [THEN [2] order_less_le_trans]) 
   739 apply (drule real_sqrt_ge_abs1 [THEN [2] order_less_le_trans]) 
   744 apply (auto simp add: numeral_2_eq_2 [symmetric]) 
   740 apply (auto simp add: numeral_2_eq_2 [symmetric]) 
   745 done
   741 done
   746 
   742 
   747 lemma CFinite_HFinite_Im:
   743 lemma CFinite_HFinite_Im:
   748      "Abs_star(starrel ``{%n. X n}) \<in> CFinite  
   744      "star_n X \<in> CFinite  
   749       ==> Abs_star(starrel `` {%n. Im(X n)}) \<in> HFinite"
   745       ==> star_n (%n. Im(X n)) \<in> HFinite"
   750 apply (auto simp add: CFinite_hcmod_iff hcmod HFinite_FreeUltrafilterNat_iff)
   746 apply (auto simp add: CFinite_hcmod_iff hcmod HFinite_FreeUltrafilterNat_iff)
   751 apply (rule bexI, rule_tac [2] lemma_starrel_refl)
   747 apply (rule bexI [OF _ Rep_star_star_n])
   752 apply (rule_tac x = u in exI, ultra)
   748 apply (rule_tac x = u in exI, ultra)
   753 apply (drule sym, case_tac "X x")
   749 apply (drule sym, case_tac "X x")
   754 apply (auto simp add: complex_mod simp del: realpow_Suc)
   750 apply (auto simp add: complex_mod simp del: realpow_Suc)
   755 apply (rule ccontr, drule linorder_not_less [THEN iffD1])
   751 apply (rule ccontr, drule linorder_not_less [THEN iffD1])
   756 apply (drule order_less_le_trans, assumption)
   752 apply (drule order_less_le_trans, assumption)
   757 apply (drule real_sqrt_ge_abs2 [THEN [2] order_less_le_trans], auto) 
   753 apply (drule real_sqrt_ge_abs2 [THEN [2] order_less_le_trans], auto) 
   758 done
   754 done
   759 
   755 
   760 lemma HFinite_Re_Im_CFinite:
   756 lemma HFinite_Re_Im_CFinite:
   761      "[| Abs_star(starrel `` {%n. Re(X n)}) \<in> HFinite;  
   757      "[| star_n (%n. Re(X n)) \<in> HFinite;  
   762          Abs_star(starrel `` {%n. Im(X n)}) \<in> HFinite  
   758          star_n (%n. Im(X n)) \<in> HFinite  
   763       |] ==> Abs_star(starrel ``{%n. X n}) \<in> CFinite"
   759       |] ==> star_n X \<in> CFinite"
   764 apply (auto simp add: CFinite_hcmod_iff hcmod HFinite_FreeUltrafilterNat_iff)
   760 apply (auto simp add: CFinite_hcmod_iff hcmod HFinite_FreeUltrafilterNat_iff)
   765 apply (rename_tac Y Z u v)
   761 apply (rename_tac Y Z u v)
   766 apply (rule bexI, rule_tac [2] lemma_starrel_refl)
   762 apply (rule bexI [OF _ Rep_star_star_n])
   767 apply (rule_tac x = "2* (u + v) " in exI)
   763 apply (rule_tac x = "2* (u + v) " in exI)
   768 apply ultra
   764 apply ultra
   769 apply (drule sym, case_tac "X x")
   765 apply (drule sym, case_tac "X x")
   770 apply (auto simp add: complex_mod numeral_2_eq_2 simp del: realpow_Suc)
   766 apply (auto simp add: complex_mod numeral_2_eq_2 simp del: realpow_Suc)
   771 apply (subgoal_tac "0 < u")
   767 apply (subgoal_tac "0 < u")
   776 apply (rule_tac [2] lemma_sqrt_hcomplex_capprox, auto)
   772 apply (rule_tac [2] lemma_sqrt_hcomplex_capprox, auto)
   777 apply (simp add: power2_eq_square)
   773 apply (simp add: power2_eq_square)
   778 done
   774 done
   779 
   775 
   780 lemma CFinite_HFinite_iff:
   776 lemma CFinite_HFinite_iff:
   781      "(Abs_star(starrel ``{%n. X n}) \<in> CFinite) =  
   777      "(star_n X \<in> CFinite) =  
   782       (Abs_star(starrel `` {%n. Re(X n)}) \<in> HFinite &  
   778       (star_n (%n. Re(X n)) \<in> HFinite &  
   783        Abs_star(starrel `` {%n. Im(X n)}) \<in> HFinite)"
   779        star_n (%n. Im(X n)) \<in> HFinite)"
   784 by (blast intro: HFinite_Re_Im_CFinite CFinite_HFinite_Im CFinite_HFinite_Re)
   780 by (blast intro: HFinite_Re_Im_CFinite CFinite_HFinite_Im CFinite_HFinite_Re)
   785 
   781 
   786 lemma SComplex_Re_SReal:
   782 lemma SComplex_Re_SReal:
   787      "Abs_star(starrel ``{%n. X n}) \<in> SComplex  
   783      "star_n X \<in> SComplex  
   788       ==> Abs_star(starrel `` {%n. Re(X n)}) \<in> Reals"
   784       ==> star_n (%n. Re(X n)) \<in> Reals"
   789 apply (auto simp add: SComplex_def hcomplex_of_complex_def SReal_def hypreal_of_real_def star_of_def star_n_def)
   785 apply (auto simp add: SComplex_def SReal_def star_of_def star_n_eq_iff)
   790 apply (rule_tac x = "Re r" in exI, ultra)
   786 apply (rule_tac x = "Re r" in exI, ultra)
   791 done
   787 done
   792 
   788 
   793 lemma SComplex_Im_SReal:
   789 lemma SComplex_Im_SReal:
   794      "Abs_star(starrel ``{%n. X n}) \<in> SComplex  
   790      "star_n X \<in> SComplex  
   795       ==> Abs_star(starrel `` {%n. Im(X n)}) \<in> Reals"
   791       ==> star_n (%n. Im(X n)) \<in> Reals"
   796 apply (auto simp add: SComplex_def hcomplex_of_complex_def SReal_def hypreal_of_real_def star_of_def star_n_def)
   792 apply (auto simp add: SComplex_def SReal_def star_of_def star_n_eq_iff)
   797 apply (rule_tac x = "Im r" in exI, ultra)
   793 apply (rule_tac x = "Im r" in exI, ultra)
   798 done
   794 done
   799 
   795 
   800 lemma Reals_Re_Im_SComplex:
   796 lemma Reals_Re_Im_SComplex:
   801      "[| Abs_star(starrel `` {%n. Re(X n)}) \<in> Reals;  
   797      "[| star_n (%n. Re(X n)) \<in> Reals;  
   802          Abs_star(starrel `` {%n. Im(X n)}) \<in> Reals  
   798          star_n (%n. Im(X n)) \<in> Reals  
   803       |] ==> Abs_star(starrel ``{%n. X n}) \<in> SComplex"
   799       |] ==> star_n X \<in> SComplex"
   804 apply (auto simp add: SComplex_def hcomplex_of_complex_def SReal_def hypreal_of_real_def star_of_def star_n_def)
   800 apply (auto simp add: SComplex_def SReal_def star_of_def star_n_eq_iff)
   805 apply (rule_tac x = "Complex r ra" in exI, ultra)
   801 apply (rule_tac x = "Complex r ra" in exI, ultra)
   806 done
   802 done
   807 
   803 
   808 lemma SComplex_SReal_iff:
   804 lemma SComplex_SReal_iff:
   809      "(Abs_star(starrel ``{%n. X n}) \<in> SComplex) =  
   805      "(star_n X \<in> SComplex) =  
   810       (Abs_star(starrel `` {%n. Re(X n)}) \<in> Reals &  
   806       (star_n (%n. Re(X n)) \<in> Reals &  
   811        Abs_star(starrel `` {%n. Im(X n)}) \<in> Reals)"
   807        star_n (%n. Im(X n)) \<in> Reals)"
   812 by (blast intro: SComplex_Re_SReal SComplex_Im_SReal Reals_Re_Im_SComplex)
   808 by (blast intro: SComplex_Re_SReal SComplex_Im_SReal Reals_Re_Im_SComplex)
   813 
   809 
   814 lemma CInfinitesimal_Infinitesimal_iff:
   810 lemma CInfinitesimal_Infinitesimal_iff:
   815      "(Abs_star(starrel ``{%n. X n}) \<in> CInfinitesimal) =  
   811      "(star_n X \<in> CInfinitesimal) =  
   816       (Abs_star(starrel `` {%n. Re(X n)}) \<in> Infinitesimal &  
   812       (star_n (%n. Re(X n)) \<in> Infinitesimal &  
   817        Abs_star(starrel `` {%n. Im(X n)}) \<in> Infinitesimal)"
   813        star_n (%n. Im(X n)) \<in> Infinitesimal)"
   818 by (simp add: mem_cinfmal_iff mem_infmal_iff hcomplex_zero_num hypreal_zero_num capprox_approx_iff)
   814 by (simp add: mem_cinfmal_iff mem_infmal_iff star_n_zero_num capprox_approx_iff)
   819 
   815 
   820 lemma eq_Abs_star_EX:
   816 lemma eq_Abs_star_EX:
   821      "(\<exists>t. P t) = (\<exists>X. P (Abs_star(starrel `` {X})))"
   817      "(\<exists>t. P t) = (\<exists>X. P (star_n X))"
   822 apply auto
   818 apply auto
   823 apply (rule_tac z = t in eq_Abs_star, auto)
   819 apply (rule_tac x = t in star_cases, auto)
   824 done
   820 done
   825 
   821 
   826 lemma eq_Abs_star_Bex:
   822 lemma eq_Abs_star_Bex:
   827      "(\<exists>t \<in> A. P t) = (\<exists>X. (Abs_star(starrel `` {X})) \<in> A &  
   823      "(\<exists>t \<in> A. P t) = (\<exists>X. star_n X \<in> A & P (star_n X))"
   828                          P (Abs_star(starrel `` {X})))"
       
   829 apply auto
   824 apply auto
   830 apply (rule_tac z = t in eq_Abs_star, auto)
   825 apply (rule_tac x = t in star_cases, auto)
   831 done
   826 done
   832 
   827 
   833 (* Here we go - easy proof now!! *)
   828 (* Here we go - easy proof now!! *)
   834 lemma stc_part_Ex: "x:CFinite ==> \<exists>t \<in> SComplex. x @c= t"
   829 lemma stc_part_Ex: "x:CFinite ==> \<exists>t \<in> SComplex. x @c= t"
   835 apply (rule_tac z = x in eq_Abs_star)
   830 apply (cases x)
   836 apply (auto simp add: CFinite_HFinite_iff eq_Abs_star_Bex SComplex_SReal_iff capprox_approx_iff)
   831 apply (auto simp add: CFinite_HFinite_iff eq_Abs_star_Bex SComplex_SReal_iff capprox_approx_iff)
   837 apply (drule st_part_Ex, safe)+
   832 apply (drule st_part_Ex, safe)+
   838 apply (rule_tac z = t in eq_Abs_star)
   833 apply (rule_tac x = t in star_cases)
   839 apply (rule_tac z = ta in eq_Abs_star, auto)
   834 apply (rule_tac x = ta in star_cases, auto)
   840 apply (rule_tac x = "%n. Complex (xa n) (xb n) " in exI)
   835 apply (rule_tac x = "%n. Complex (Xa n) (Xb n) " in exI)
   841 apply auto
   836 apply auto
   842 done
   837 done
   843 
   838 
   844 lemma stc_part_Ex1: "x:CFinite ==> EX! t. t \<in> SComplex &  x @c= t"
   839 lemma stc_part_Ex1: "x:CFinite ==> EX! t. t \<in> SComplex &  x @c= t"
   845 apply (drule stc_part_Ex, safe)
   840 apply (drule stc_part_Ex, safe)
  1095 apply (subgoal_tac "stc (x * y) = stc ((stc x + e) * (stc y + ea))")
  1090 apply (subgoal_tac "stc (x * y) = stc ((stc x + e) * (stc y + ea))")
  1096 apply (drule_tac [2] sym, drule_tac [2] sym)
  1091 apply (drule_tac [2] sym, drule_tac [2] sym)
  1097  prefer 2 apply simp 
  1092  prefer 2 apply simp 
  1098 apply (erule_tac V = "x = stc x + e" in thin_rl)
  1093 apply (erule_tac V = "x = stc x + e" in thin_rl)
  1099 apply (erule_tac V = "y = stc y + ea" in thin_rl)
  1094 apply (erule_tac V = "y = stc y + ea" in thin_rl)
  1100 apply (simp add: hcomplex_add_mult_distrib right_distrib)
  1095 apply (simp add: left_distrib right_distrib)
  1101 apply (drule stc_SComplex)+
  1096 apply (drule stc_SComplex)+
  1102 apply (simp (no_asm_use) add: add_assoc)
  1097 apply (simp (no_asm_use) add: add_assoc)
  1103 apply (rule stc_CInfinitesimal_add_SComplex)
  1098 apply (rule stc_CInfinitesimal_add_SComplex)
  1104 apply (blast intro!: SComplex_mult)
  1099 apply (blast intro!: SComplex_mult)
  1105 apply (drule SComplex_subset_CFinite [THEN subsetD])+
  1100 apply (drule SComplex_subset_CFinite [THEN subsetD])+
  1133 lemma stc_idempotent [simp]: "x \<in> CFinite ==> stc(stc(x)) = stc(x)"
  1128 lemma stc_idempotent [simp]: "x \<in> CFinite ==> stc(stc(x)) = stc(x)"
  1134 by (blast intro: stc_CFinite stc_capprox_self capprox_stc_eq)
  1129 by (blast intro: stc_CFinite stc_capprox_self capprox_stc_eq)
  1135 
  1130 
  1136 lemma CFinite_HFinite_hcomplex_of_hypreal:
  1131 lemma CFinite_HFinite_hcomplex_of_hypreal:
  1137      "z \<in> HFinite ==> hcomplex_of_hypreal z \<in> CFinite"
  1132      "z \<in> HFinite ==> hcomplex_of_hypreal z \<in> CFinite"
  1138 apply (rule_tac z=z in eq_Abs_star)
  1133 apply (cases z)
  1139 apply (simp add: hcomplex_of_hypreal CFinite_HFinite_iff hypreal_zero_def [symmetric])
  1134 apply (simp add: hcomplex_of_hypreal CFinite_HFinite_iff star_n_zero_num [symmetric])
  1140 done
  1135 done
  1141 
  1136 
  1142 lemma SComplex_SReal_hcomplex_of_hypreal:
  1137 lemma SComplex_SReal_hcomplex_of_hypreal:
  1143      "x \<in> Reals ==>  hcomplex_of_hypreal x \<in> SComplex"
  1138      "x \<in> Reals ==>  hcomplex_of_hypreal x \<in> SComplex"
  1144 apply (rule_tac z=x in eq_Abs_star)
  1139 apply (cases x)
  1145 apply (simp add: hcomplex_of_hypreal SComplex_SReal_iff hypreal_zero_def [symmetric])
  1140 apply (simp add: hcomplex_of_hypreal SComplex_SReal_iff star_n_zero_num [symmetric])
  1146 done
  1141 done
  1147 
  1142 
  1148 lemma stc_hcomplex_of_hypreal: 
  1143 lemma stc_hcomplex_of_hypreal: 
  1149  "z \<in> HFinite ==> stc(hcomplex_of_hypreal z) = hcomplex_of_hypreal (st z)"
  1144  "z \<in> HFinite ==> stc(hcomplex_of_hypreal z) = hcomplex_of_hypreal (st z)"
  1150 apply (simp add: st_def stc_def)
  1145 apply (simp add: st_def stc_def)
  1169 lemma CInfinitesimal_hcnj_iff [simp]:
  1164 lemma CInfinitesimal_hcnj_iff [simp]:
  1170      "(hcnj z \<in> CInfinitesimal) = (z \<in> CInfinitesimal)"
  1165      "(hcnj z \<in> CInfinitesimal) = (z \<in> CInfinitesimal)"
  1171 by (simp add: CInfinitesimal_hcmod_iff)
  1166 by (simp add: CInfinitesimal_hcmod_iff)
  1172 
  1167 
  1173 lemma CInfinite_HInfinite_iff:
  1168 lemma CInfinite_HInfinite_iff:
  1174      "(Abs_star(starrel ``{%n. X n}) \<in> CInfinite) =  
  1169      "(star_n X \<in> CInfinite) =  
  1175       (Abs_star(starrel `` {%n. Re(X n)}) \<in> HInfinite |  
  1170       (star_n (%n. Re(X n)) \<in> HInfinite |  
  1176        Abs_star(starrel `` {%n. Im(X n)}) \<in> HInfinite)"
  1171        star_n (%n. Im(X n)) \<in> HInfinite)"
  1177 by (simp add: CInfinite_CFinite_iff HInfinite_HFinite_iff CFinite_HFinite_iff)
  1172 by (simp add: CInfinite_CFinite_iff HInfinite_HFinite_iff CFinite_HFinite_iff)
  1178 
  1173 
  1179 text{*These theorems should probably be deleted*}
  1174 text{*These theorems should probably be deleted*}
  1180 lemma hcomplex_split_CInfinitesimal_iff:
  1175 lemma hcomplex_split_CInfinitesimal_iff:
  1181      "(hcomplex_of_hypreal x + iii * hcomplex_of_hypreal y \<in> CInfinitesimal) =  
  1176      "(hcomplex_of_hypreal x + iii * hcomplex_of_hypreal y \<in> CInfinitesimal) =  
  1182       (x \<in> Infinitesimal & y \<in> Infinitesimal)"
  1177       (x \<in> Infinitesimal & y \<in> Infinitesimal)"
  1183 apply (rule_tac z=x in eq_Abs_star, rule_tac z=y in eq_Abs_star)
  1178 apply (cases x, cases y)
  1184 apply (simp add: iii_def hcomplex_add hcomplex_mult hcomplex_of_hypreal CInfinitesimal_Infinitesimal_iff)
  1179 apply (simp add: iii_def star_of_def star_n_add star_n_mult hcomplex_of_hypreal CInfinitesimal_Infinitesimal_iff)
  1185 done
  1180 done
  1186 
  1181 
  1187 lemma hcomplex_split_CFinite_iff:
  1182 lemma hcomplex_split_CFinite_iff:
  1188      "(hcomplex_of_hypreal x + iii * hcomplex_of_hypreal y \<in> CFinite) =  
  1183      "(hcomplex_of_hypreal x + iii * hcomplex_of_hypreal y \<in> CFinite) =  
  1189       (x \<in> HFinite & y \<in> HFinite)"
  1184       (x \<in> HFinite & y \<in> HFinite)"
  1190 apply (rule_tac z=x in eq_Abs_star, rule_tac z=y in eq_Abs_star)
  1185 apply (cases x, cases y)
  1191 apply (simp add: iii_def hcomplex_add hcomplex_mult hcomplex_of_hypreal CFinite_HFinite_iff)
  1186 apply (simp add: iii_def star_of_def star_n_add star_n_mult hcomplex_of_hypreal CFinite_HFinite_iff)
  1192 done
  1187 done
  1193 
  1188 
  1194 lemma hcomplex_split_SComplex_iff:
  1189 lemma hcomplex_split_SComplex_iff:
  1195      "(hcomplex_of_hypreal x + iii * hcomplex_of_hypreal y \<in> SComplex) =  
  1190      "(hcomplex_of_hypreal x + iii * hcomplex_of_hypreal y \<in> SComplex) =  
  1196       (x \<in> Reals & y \<in> Reals)"
  1191       (x \<in> Reals & y \<in> Reals)"
  1197 apply (rule_tac z=x in eq_Abs_star, rule_tac z=y in eq_Abs_star)
  1192 apply (cases x, cases y)
  1198 apply (simp add: iii_def hcomplex_add hcomplex_mult hcomplex_of_hypreal SComplex_SReal_iff)
  1193 apply (simp add: iii_def star_of_def star_n_add star_n_mult hcomplex_of_hypreal SComplex_SReal_iff)
  1199 done
  1194 done
  1200 
  1195 
  1201 lemma hcomplex_split_CInfinite_iff:
  1196 lemma hcomplex_split_CInfinite_iff:
  1202      "(hcomplex_of_hypreal x + iii * hcomplex_of_hypreal y \<in> CInfinite) =  
  1197      "(hcomplex_of_hypreal x + iii * hcomplex_of_hypreal y \<in> CInfinite) =  
  1203       (x \<in> HInfinite | y \<in> HInfinite)"
  1198       (x \<in> HInfinite | y \<in> HInfinite)"
  1204 apply (rule_tac z=x in eq_Abs_star, rule_tac z=y in eq_Abs_star)
  1199 apply (cases x, cases y)
  1205 apply (simp add: iii_def hcomplex_add hcomplex_mult hcomplex_of_hypreal CInfinite_HInfinite_iff)
  1200 apply (simp add: iii_def star_of_def star_n_add star_n_mult hcomplex_of_hypreal CInfinite_HInfinite_iff)
  1206 done
  1201 done
  1207 
  1202 
  1208 lemma hcomplex_split_capprox_iff:
  1203 lemma hcomplex_split_capprox_iff:
  1209      "(hcomplex_of_hypreal x + iii * hcomplex_of_hypreal y @c=  
  1204      "(hcomplex_of_hypreal x + iii * hcomplex_of_hypreal y @c=  
  1210        hcomplex_of_hypreal x' + iii * hcomplex_of_hypreal y') =  
  1205        hcomplex_of_hypreal x' + iii * hcomplex_of_hypreal y') =  
  1211       (x @= x' & y @= y')"
  1206       (x @= x' & y @= y')"
  1212 apply (rule_tac z=x in eq_Abs_star, rule_tac z=y in eq_Abs_star)
  1207 apply (cases x, cases y, cases x', cases y')
  1213 apply (rule_tac z=x' in eq_Abs_star, rule_tac z=y' in eq_Abs_star)
  1208 apply (simp add: iii_def star_of_def star_n_add star_n_mult hcomplex_of_hypreal capprox_approx_iff)
  1214 apply (simp add: iii_def hcomplex_add hcomplex_mult hcomplex_of_hypreal capprox_approx_iff)
       
  1215 done
  1209 done
  1216 
  1210 
  1217 lemma complex_seq_to_hcomplex_CInfinitesimal:
  1211 lemma complex_seq_to_hcomplex_CInfinitesimal:
  1218      "\<forall>n. cmod (X n - x) < inverse (real (Suc n)) ==>  
  1212      "\<forall>n. cmod (X n - x) < inverse (real (Suc n)) ==>  
  1219       Abs_star(starrel``{X}) - hcomplex_of_complex x \<in> CInfinitesimal"
  1213       star_n X - hcomplex_of_complex x \<in> CInfinitesimal"
  1220 apply (simp add: hcomplex_diff CInfinitesimal_hcmod_iff hcomplex_of_complex_def star_of_def star_n_def Infinitesimal_FreeUltrafilterNat_iff hcmod)
  1214 apply (simp add: star_n_diff CInfinitesimal_hcmod_iff star_of_def Infinitesimal_FreeUltrafilterNat_iff hcmod)
  1221 apply (rule bexI, auto)
  1215 apply (rule bexI, auto)
  1222 apply (auto dest: FreeUltrafilterNat_inverse_real_of_posnat FreeUltrafilterNat_all FreeUltrafilterNat_Int intro: order_less_trans FreeUltrafilterNat_subset)
  1216 apply (auto dest: FreeUltrafilterNat_inverse_real_of_posnat FreeUltrafilterNat_all FreeUltrafilterNat_Int intro: order_less_trans FreeUltrafilterNat_subset)
  1223 done
  1217 done
  1224 
  1218 
  1225 lemma CInfinitesimal_hcomplex_of_hypreal_epsilon [simp]:
  1219 lemma CInfinitesimal_hcomplex_of_hypreal_epsilon [simp]:
  1226      "hcomplex_of_hypreal epsilon \<in> CInfinitesimal"
  1220      "hcomplex_of_hypreal epsilon \<in> CInfinitesimal"
  1227 by (simp add: CInfinitesimal_hcmod_iff)
  1221 by (simp add: CInfinitesimal_hcmod_iff)
  1228 
  1222 
  1229 lemma hcomplex_of_complex_approx_zero_iff [simp]:
  1223 lemma hcomplex_of_complex_approx_zero_iff [simp]:
  1230      "(hcomplex_of_complex z @c= 0) = (z = 0)"
  1224      "(hcomplex_of_complex z @c= 0) = (z = 0)"
  1231 by (simp add: hcomplex_of_complex_zero [symmetric]
  1225 by (simp add: star_of_zero [symmetric] del: star_of_zero)
  1232          del: hcomplex_of_complex_zero)
       
  1233 
  1226 
  1234 lemma hcomplex_of_complex_approx_zero_iff2 [simp]:
  1227 lemma hcomplex_of_complex_approx_zero_iff2 [simp]:
  1235      "(0 @c= hcomplex_of_complex z) = (z = 0)"
  1228      "(0 @c= hcomplex_of_complex z) = (z = 0)"
  1236 by (simp add: hcomplex_of_complex_zero [symmetric]
  1229 by (simp add: star_of_zero [symmetric] del: star_of_zero)
  1237          del: hcomplex_of_complex_zero)
       
  1238 
  1230 
  1239 
  1231 
  1240 ML
  1232 ML
  1241 {*
  1233 {*
  1242 val SComplex_add = thm "SComplex_add";
  1234 val SComplex_add = thm "SComplex_add";