src/HOL/Hyperreal/Transcendental.thy
author paulson
Wed Jul 28 16:25:40 2004 +0200 (2004-07-28)
changeset 15081 32402f5624d1
parent 15079 2ef899e4526d
child 15085 5693a977a767
permissions -rw-r--r--
abs notation
     1 (*  Title       : Transcendental.thy
     2     Author      : Jacques D. Fleuriot
     3     Copyright   : 1998,1999 University of Cambridge
     4                   1999,2001 University of Edinburgh
     5     Conversion to Isar and new proofs by Lawrence C Paulson, 2004
     6 *)
     7 
     8 header{*Power Series, Transcendental Functions etc.*}
     9 
    10 theory Transcendental = NthRoot + Fact + HSeries + EvenOdd + Lim:
    11 
    12 (*????FOR RING_AND_FIELD*)
    13 
    14 constdefs
    15     root :: "[nat,real] => real"
    16     "root n x == (@u. ((0::real) < x --> 0 < u) & (u ^ n = x))"
    17 
    18     sqrt :: "real => real"
    19     "sqrt x == root 2 x"
    20 
    21     exp :: "real => real"
    22     "exp x == suminf(%n. inverse(real (fact n)) * (x ^ n))"
    23 
    24     sin :: "real => real"
    25     "sin x == suminf(%n. (if even(n) then 0 else
    26              ((- 1) ^ ((n - Suc 0) div 2))/(real (fact n))) * x ^ n)"
    27  
    28     diffs :: "(nat => real) => nat => real"
    29     "diffs c == (%n. real (Suc n) * c(Suc n))"
    30 
    31     cos :: "real => real"
    32     "cos x == suminf(%n. (if even(n) then ((- 1) ^ (n div 2))/(real (fact n)) 
    33                           else 0) * x ^ n)"
    34   
    35     ln :: "real => real"
    36     "ln x == (@u. exp u = x)"
    37 
    38     pi :: "real"
    39     "pi == 2 * (@x. 0 \<le> (x::real) & x \<le> 2 & cos x = 0)"
    40 
    41     tan :: "real => real"
    42     "tan x == (sin x)/(cos x)"
    43 
    44     arcsin :: "real => real"
    45     "arcsin y == (@x. -(pi/2) \<le> x & x \<le> pi/2 & sin x = y)"
    46 
    47     arcos :: "real => real"
    48     "arcos y == (@x. 0 \<le> x & x \<le> pi & cos x = y)"
    49      
    50     arctan :: "real => real"
    51     "arctan y == (@x. -(pi/2) < x & x < pi/2 & tan x = y)"
    52 
    53 
    54 lemma real_root_zero [simp]: "root (Suc n) 0 = 0"
    55 apply (unfold root_def)
    56 apply (safe intro!: some_equality power_0_Suc elim!: realpow_zero_zero)
    57 done
    58 
    59 lemma real_root_pow_pos: 
    60      "0 < x ==> (root(Suc n) x) ^ (Suc n) = x"
    61 apply (unfold root_def)
    62 apply (drule_tac n = n in realpow_pos_nth2)
    63 apply (auto intro: someI2)
    64 done
    65 
    66 lemma real_root_pow_pos2: "0 \<le> x ==> (root(Suc n) x) ^ (Suc n) = x"
    67 by (auto dest!: real_le_imp_less_or_eq dest: real_root_pow_pos)
    68 
    69 lemma real_root_pos: 
    70      "0 < x ==> root(Suc n) (x ^ (Suc n)) = x"
    71 apply (unfold root_def)
    72 apply (rule some_equality)
    73 apply (frule_tac [2] n = n in zero_less_power)
    74 apply (auto simp add: zero_less_mult_iff)
    75 apply (rule_tac x = u and y = x in linorder_cases)
    76 apply (drule_tac n1 = n and x = u in zero_less_Suc [THEN [3] realpow_less])
    77 apply (drule_tac [4] n1 = n and x = x in zero_less_Suc [THEN [3] realpow_less])
    78 apply (auto simp add: order_less_irrefl)
    79 done
    80 
    81 lemma real_root_pos2: "0 \<le> x ==> root(Suc n) (x ^ (Suc n)) = x"
    82 by (auto dest!: real_le_imp_less_or_eq real_root_pos)
    83 
    84 lemma real_root_pos_pos: 
    85      "0 < x ==> 0 \<le> root(Suc n) x"
    86 apply (unfold root_def)
    87 apply (drule_tac n = n in realpow_pos_nth2)
    88 apply (safe, rule someI2)
    89 apply (auto intro!: order_less_imp_le dest: zero_less_power simp add: zero_less_mult_iff)
    90 done
    91 
    92 lemma real_root_pos_pos_le: "0 \<le> x ==> 0 \<le> root(Suc n) x"
    93 by (auto dest!: real_le_imp_less_or_eq dest: real_root_pos_pos)
    94 
    95 lemma real_root_one [simp]: "root (Suc n) 1 = 1"
    96 apply (unfold root_def)
    97 apply (rule some_equality, auto)
    98 apply (rule ccontr)
    99 apply (rule_tac x = u and y = 1 in linorder_cases)
   100 apply (drule_tac n = n in realpow_Suc_less_one)
   101 apply (drule_tac [4] n = n in power_gt1_lemma)
   102 apply (auto simp add: order_less_irrefl)
   103 done
   104 
   105 
   106 subsection{*Square Root*}
   107 
   108 (*lcp: needed now because 2 is a binary numeral!*)
   109 lemma root_2_eq [simp]: "root 2 = root (Suc (Suc 0))"
   110 apply (simp (no_asm) del: nat_numeral_0_eq_0 nat_numeral_1_eq_1 add: nat_numeral_0_eq_0 [symmetric])
   111 done
   112 
   113 lemma real_sqrt_zero [simp]: "sqrt 0 = 0"
   114 by (unfold sqrt_def, auto)
   115 
   116 lemma real_sqrt_one [simp]: "sqrt 1 = 1"
   117 by (unfold sqrt_def, auto)
   118 
   119 lemma real_sqrt_pow2_iff [simp]: "((sqrt x)\<twosuperior> = x) = (0 \<le> x)"
   120 apply (unfold sqrt_def)
   121 apply (rule iffI) 
   122  apply (cut_tac r = "root 2 x" in realpow_two_le)
   123  apply (simp add: numeral_2_eq_2)
   124 apply (subst numeral_2_eq_2)
   125 apply (erule real_root_pow_pos2)
   126 done
   127 
   128 lemma [simp]: "(sqrt(u2\<twosuperior> + v2\<twosuperior>))\<twosuperior> = u2\<twosuperior> + v2\<twosuperior>"
   129 by (rule realpow_two_le_add_order [THEN real_sqrt_pow2_iff [THEN iffD2]])
   130 
   131 lemma real_sqrt_pow2 [simp]: "0 \<le> x ==> (sqrt x)\<twosuperior> = x"
   132 by (simp add: real_sqrt_pow2_iff)
   133 
   134 lemma real_sqrt_abs_abs [simp]: "sqrt\<bar>x\<bar> ^ 2 = \<bar>x\<bar>"
   135 by (rule real_sqrt_pow2_iff [THEN iffD2], arith)
   136 
   137 lemma real_pow_sqrt_eq_sqrt_pow: 
   138       "0 \<le> x ==> (sqrt x)\<twosuperior> = sqrt(x\<twosuperior>)"
   139 apply (unfold sqrt_def)
   140 apply (subst numeral_2_eq_2)
   141 apply (auto intro: real_root_pow_pos2 [THEN ssubst] real_root_pos2 [THEN ssubst] simp del: realpow_Suc)
   142 done
   143 
   144 lemma real_pow_sqrt_eq_sqrt_abs_pow2:
   145      "0 \<le> x ==> (sqrt x)\<twosuperior> = sqrt(\<bar>x\<bar> ^ 2)" 
   146 by (simp add: real_pow_sqrt_eq_sqrt_pow [symmetric])
   147 
   148 lemma real_sqrt_pow_abs: "0 \<le> x ==> (sqrt x)\<twosuperior> = \<bar>x\<bar>"
   149 apply (rule real_sqrt_abs_abs [THEN subst])
   150 apply (rule_tac x1 = x in real_pow_sqrt_eq_sqrt_abs_pow2 [THEN ssubst])
   151 apply (rule_tac [2] real_pow_sqrt_eq_sqrt_pow [symmetric])
   152 apply (assumption, arith)
   153 done
   154 
   155 lemma not_real_square_gt_zero [simp]: "(~ (0::real) < x*x) = (x = 0)"
   156 apply auto
   157 apply (cut_tac x = x and y = 0 in linorder_less_linear)
   158 apply (simp add: zero_less_mult_iff)
   159 done
   160 
   161 lemma real_mult_self_eq_zero_iff [simp]: "(r * r = 0) = (r = (0::real))"
   162 by auto
   163 
   164 lemma real_sqrt_gt_zero: "0 < x ==> 0 < sqrt(x)"
   165 apply (unfold sqrt_def root_def)
   166 apply (subst numeral_2_eq_2)
   167 apply (drule realpow_pos_nth2 [where n=1], safe)
   168 apply (rule someI2, auto)
   169 done
   170 
   171 lemma real_sqrt_ge_zero: "0 \<le> x ==> 0 \<le> sqrt(x)"
   172 by (auto intro: real_sqrt_gt_zero simp add: order_le_less)
   173 
   174 
   175 (*we need to prove something like this:
   176 lemma "[|r ^ n = a; 0<n; 0 < a \<longrightarrow> 0 < r|] ==> root n a = r"
   177 apply (case_tac n, simp) 
   178 apply (unfold root_def) 
   179 apply (rule someI2 [of _ r], safe)
   180 apply (auto simp del: realpow_Suc dest: power_inject_base)
   181 *)
   182 
   183 lemma sqrt_eqI: "[|r\<twosuperior> = a; 0 \<le> r|] ==> sqrt a = r"
   184 apply (unfold sqrt_def root_def) 
   185 apply (rule someI2 [of _ r], auto) 
   186 apply (auto simp add: numeral_2_eq_2 simp del: realpow_Suc 
   187             dest: power_inject_base) 
   188 done
   189 
   190 lemma real_sqrt_mult_distrib: 
   191      "[| 0 \<le> x; 0 \<le> y |] ==> sqrt(x*y) = sqrt(x) * sqrt(y)"
   192 apply (rule sqrt_eqI)
   193 apply (simp add: power_mult_distrib)  
   194 apply (simp add: zero_le_mult_iff real_sqrt_ge_zero) 
   195 done
   196 
   197 lemma real_sqrt_mult_distrib2: "[|0\<le>x; 0\<le>y |] ==> sqrt(x*y) =  sqrt(x) * sqrt(y)"
   198 by (auto intro: real_sqrt_mult_distrib simp add: order_le_less)
   199 
   200 lemma real_sqrt_sum_squares_ge_zero [simp]: "0 \<le> sqrt (x\<twosuperior> + y\<twosuperior>)"
   201 by (auto intro!: real_sqrt_ge_zero)
   202 
   203 lemma real_sqrt_sum_squares_mult_ge_zero [simp]: "0 \<le> sqrt ((x\<twosuperior> + y\<twosuperior>)*(xa\<twosuperior> + ya\<twosuperior>))"
   204 by (auto intro!: real_sqrt_ge_zero simp add: zero_le_mult_iff)
   205 
   206 lemma real_sqrt_sum_squares_mult_squared_eq [simp]:
   207      "sqrt ((x\<twosuperior> + y\<twosuperior>) * (xa\<twosuperior> + ya\<twosuperior>)) ^ 2 = (x\<twosuperior> + y\<twosuperior>) * (xa\<twosuperior> + ya\<twosuperior>)"
   208 by (auto simp add: real_sqrt_pow2_iff zero_le_mult_iff simp del: realpow_Suc)
   209 
   210 lemma real_sqrt_abs [simp]: "sqrt(x\<twosuperior>) = \<bar>x\<bar>"
   211 apply (rule abs_realpow_two [THEN subst])
   212 apply (rule real_sqrt_abs_abs [THEN subst])
   213 apply (subst real_pow_sqrt_eq_sqrt_pow)
   214 apply (auto simp add: numeral_2_eq_2 abs_mult)
   215 done
   216 
   217 lemma real_sqrt_abs2 [simp]: "sqrt(x*x) = \<bar>x\<bar>"
   218 apply (rule realpow_two [THEN subst])
   219 apply (subst numeral_2_eq_2 [symmetric])
   220 apply (rule real_sqrt_abs)
   221 done
   222 
   223 lemma real_sqrt_pow2_gt_zero: "0 < x ==> 0 < (sqrt x)\<twosuperior>"
   224 by simp
   225 
   226 lemma real_sqrt_not_eq_zero: "0 < x ==> sqrt x \<noteq> 0"
   227 apply (frule real_sqrt_pow2_gt_zero)
   228 apply (auto simp add: numeral_2_eq_2 order_less_irrefl)
   229 done
   230 
   231 lemma real_inv_sqrt_pow2: "0 < x ==> inverse (sqrt(x)) ^ 2 = inverse x"
   232 by (cut_tac n1 = 2 and a1 = "sqrt x" in power_inverse [symmetric], auto)
   233 
   234 lemma real_sqrt_eq_zero_cancel: "[| 0 \<le> x; sqrt(x) = 0|] ==> x = 0"
   235 apply (drule real_le_imp_less_or_eq)
   236 apply (auto dest: real_sqrt_not_eq_zero)
   237 done
   238 
   239 lemma real_sqrt_eq_zero_cancel_iff [simp]: "0 \<le> x ==> ((sqrt x = 0) = (x = 0))"
   240 by (auto simp add: real_sqrt_eq_zero_cancel)
   241 
   242 lemma real_sqrt_sum_squares_ge1 [simp]: "x \<le> sqrt(x\<twosuperior> + y\<twosuperior>)"
   243 apply (subgoal_tac "x \<le> 0 | 0 \<le> x", safe)
   244 apply (rule real_le_trans)
   245 apply (auto simp del: realpow_Suc)
   246 apply (rule_tac n = 1 in realpow_increasing)
   247 apply (auto simp add: numeral_2_eq_2 [symmetric] simp del: realpow_Suc)
   248 done
   249 
   250 lemma real_sqrt_sum_squares_ge2 [simp]: "y \<le> sqrt(z\<twosuperior> + y\<twosuperior>)"
   251 apply (simp (no_asm) add: real_add_commute del: realpow_Suc)
   252 done
   253 
   254 lemma real_sqrt_ge_one: "1 \<le> x ==> 1 \<le> sqrt x"
   255 apply (rule_tac n = 1 in realpow_increasing)
   256 apply (auto simp add: numeral_2_eq_2 [symmetric] real_sqrt_ge_zero simp 
   257             del: realpow_Suc)
   258 done
   259 
   260 
   261 subsection{*Exponential Function*}
   262 
   263 lemma summable_exp: "summable (%n. inverse (real (fact n)) * x ^ n)"
   264 apply (cut_tac 'a = real in zero_less_one [THEN dense], safe)
   265 apply (cut_tac x = r in reals_Archimedean3, auto)
   266 apply (drule_tac x = "\<bar>x\<bar>" in spec, safe)
   267 apply (rule_tac N = n and c = r in ratio_test)
   268 apply (auto simp add: abs_mult mult_assoc [symmetric] simp del: fact_Suc)
   269 apply (rule mult_right_mono)
   270 apply (rule_tac b1 = "\<bar>x\<bar>" in mult_commute [THEN ssubst])
   271 apply (subst fact_Suc)
   272 apply (subst real_of_nat_mult)
   273 apply (auto simp add: abs_mult inverse_mult_distrib)
   274 apply (auto simp add: mult_assoc [symmetric] abs_eqI2 positive_imp_inverse_positive)
   275 apply (rule order_less_imp_le)
   276 apply (rule_tac z1 = "real (Suc na) " in real_mult_less_iff1 [THEN iffD1])
   277 apply (auto simp add: real_not_refl2 [THEN not_sym] mult_assoc abs_inverse)
   278 apply (erule order_less_trans)
   279 apply (auto simp add: mult_less_cancel_left mult_ac)
   280 done
   281 
   282 
   283 lemma summable_sin: 
   284      "summable (%n.  
   285            (if even n then 0  
   286            else (- 1) ^ ((n - Suc 0) div 2)/(real (fact n))) *  
   287                 x ^ n)"
   288 apply (unfold real_divide_def)
   289 apply (rule_tac g = " (%n. inverse (real (fact n)) * \<bar>x\<bar> ^ n) " in summable_comparison_test)
   290 apply (rule_tac [2] summable_exp)
   291 apply (rule_tac x = 0 in exI)
   292 apply (auto simp add: power_abs [symmetric] abs_mult zero_le_mult_iff)
   293 done
   294 
   295 lemma summable_cos: 
   296       "summable (%n.  
   297            (if even n then  
   298            (- 1) ^ (n div 2)/(real (fact n)) else 0) * x ^ n)"
   299 apply (unfold real_divide_def)
   300 apply (rule_tac g = " (%n. inverse (real (fact n)) * \<bar>x\<bar> ^ n) " in summable_comparison_test)
   301 apply (rule_tac [2] summable_exp)
   302 apply (rule_tac x = 0 in exI)
   303 apply (auto simp add: power_abs [symmetric] abs_mult zero_le_mult_iff)
   304 done
   305 
   306 lemma lemma_STAR_sin [simp]: "(if even n then 0  
   307        else (- 1) ^ ((n - Suc 0) div 2)/(real (fact n))) * 0 ^ n = 0"
   308 apply (induct_tac "n", auto)
   309 done
   310 
   311 lemma lemma_STAR_cos [simp]: "0 < n -->  
   312       (- 1) ^ (n div 2)/(real (fact n)) * 0 ^ n = 0"
   313 apply (induct_tac "n", auto)
   314 done
   315 
   316 lemma lemma_STAR_cos1 [simp]: "0 < n -->  
   317       (-1) ^ (n div 2)/(real (fact n)) * 0 ^ n = 0"
   318 apply (induct_tac "n", auto)
   319 done
   320 
   321 lemma lemma_STAR_cos2 [simp]: "sumr 1 n (%n. if even n  
   322                     then (- 1) ^ (n div 2)/(real (fact n)) *  
   323                           0 ^ n  
   324                     else 0) = 0"
   325 apply (induct_tac "n")
   326 apply (case_tac [2] "n", auto)
   327 done
   328 
   329 lemma exp_converges: "(%n. inverse (real (fact n)) * x ^ n) sums exp(x)"
   330 apply (unfold exp_def)
   331 apply (rule summable_exp [THEN summable_sums])
   332 done
   333 
   334 lemma sin_converges: 
   335       "(%n. (if even n then 0  
   336             else (- 1) ^ ((n - Suc 0) div 2)/(real (fact n))) *  
   337                  x ^ n) sums sin(x)"
   338 apply (unfold sin_def)
   339 apply (rule summable_sin [THEN summable_sums])
   340 done
   341 
   342 lemma cos_converges: 
   343       "(%n. (if even n then  
   344            (- 1) ^ (n div 2)/(real (fact n))  
   345            else 0) * x ^ n) sums cos(x)"
   346 apply (unfold cos_def)
   347 apply (rule summable_cos [THEN summable_sums])
   348 done
   349 
   350 lemma lemma_realpow_diff [rule_format (no_asm)]: "p \<le> n --> y ^ (Suc n - p) = ((y::real) ^ (n - p)) * y"
   351 apply (induct_tac "n", auto)
   352 apply (subgoal_tac "p = Suc n")
   353 apply (simp (no_asm_simp), auto)
   354 apply (drule sym)
   355 apply (simp add: Suc_diff_le mult_commute realpow_Suc [symmetric] 
   356        del: realpow_Suc)
   357 done
   358 
   359 
   360 subsection{*Properties of Power Series*}
   361 
   362 lemma lemma_realpow_diff_sumr:
   363      "sumr 0 (Suc n) (%p. (x ^ p) * y ^ ((Suc n) - p)) =  
   364       y * sumr 0 (Suc n) (%p. (x ^ p) * (y ^ (n - p)))"
   365 apply (auto simp add: sumr_mult simp del: sumr_Suc)
   366 apply (rule sumr_subst)
   367 apply (intro strip)
   368 apply (subst lemma_realpow_diff)
   369 apply (auto simp add: mult_ac)
   370 done
   371 
   372 lemma lemma_realpow_diff_sumr2: "x ^ (Suc n) - y ^ (Suc n) =  
   373       (x - y) * sumr 0 (Suc n) (%p. (x ^ p) * (y ^(n - p)))"
   374 apply (induct_tac "n", simp)
   375 apply (auto simp del: sumr_Suc)
   376 apply (subst sumr_Suc)
   377 apply (drule sym)
   378 apply (auto simp add: lemma_realpow_diff_sumr right_distrib real_diff_def mult_ac simp del: sumr_Suc)
   379 done
   380 
   381 lemma lemma_realpow_rev_sumr: "sumr 0 (Suc n) (%p. (x ^ p) * (y ^ (n - p))) =  
   382       sumr 0 (Suc n) (%p. (x ^ (n - p)) * (y ^ p))"
   383 apply (case_tac "x = y")
   384 apply (auto simp add: mult_commute power_add [symmetric] simp del: sumr_Suc)
   385 apply (rule_tac c1 = "x - y" in real_mult_left_cancel [THEN iffD1])
   386 apply (rule_tac [2] minus_minus [THEN subst], simp)
   387 apply (subst minus_mult_left)
   388 apply (simp add: lemma_realpow_diff_sumr2 [symmetric] del: sumr_Suc)
   389 done
   390 
   391 text{*Power series has a `circle` of convergence, i.e. if it sums for @{term
   392 x}, then it sums absolutely for @{term z} with @{term "\<bar>z\<bar> < \<bar>x\<bar>"}.*}
   393 
   394 lemma powser_insidea:
   395      "[| summable (%n. f(n) * (x ^ n)); \<bar>z\<bar> < \<bar>x\<bar> |]  
   396       ==> summable (%n. \<bar>f(n)\<bar> * (z ^ n))"
   397 apply (drule summable_LIMSEQ_zero)
   398 apply (drule convergentI)
   399 apply (simp add: Cauchy_convergent_iff [symmetric])
   400 apply (drule Cauchy_Bseq)
   401 apply (simp add: Bseq_def, safe)
   402 apply (rule_tac g = "%n. K * \<bar>z ^ n\<bar> * inverse (\<bar>x ^ n\<bar>)" in summable_comparison_test)
   403 apply (rule_tac x = 0 in exI, safe)
   404 apply (subgoal_tac "0 < \<bar>x ^ n\<bar> ")
   405 apply (rule_tac c="\<bar>x ^ n\<bar>" in mult_right_le_imp_le) 
   406 apply (auto simp add: mult_assoc power_abs)
   407  prefer 2
   408  apply (drule_tac x = 0 in spec, force)
   409 apply (auto simp add: abs_mult power_abs mult_ac)
   410 apply (rule_tac a2 = "z ^ n" 
   411        in abs_ge_zero [THEN real_le_imp_less_or_eq, THEN disjE])
   412 apply (auto intro!: mult_right_mono simp add: mult_assoc [symmetric] power_abs summable_def power_0_left)
   413 apply (rule_tac x = "K * inverse (1 - (\<bar>z\<bar> * inverse (\<bar>x\<bar>))) " in exI)
   414 apply (auto intro!: sums_mult simp add: mult_assoc)
   415 apply (subgoal_tac "\<bar>z ^ n\<bar> * inverse (\<bar>x\<bar> ^ n) = (\<bar>z\<bar> * inverse (\<bar>x\<bar>)) ^ n")
   416 apply (auto simp add: power_abs [symmetric])
   417 apply (subgoal_tac "x \<noteq> 0")
   418 apply (subgoal_tac [3] "x \<noteq> 0")
   419 apply (auto simp del: abs_inverse abs_mult simp add: abs_inverse [symmetric] realpow_not_zero abs_mult [symmetric] power_inverse power_mult_distrib [symmetric])
   420 apply (auto intro!: geometric_sums simp add: power_abs inverse_eq_divide)
   421 apply (rule_tac c="\<bar>x\<bar>" in mult_right_less_imp_less) 
   422 apply (auto simp add: abs_mult [symmetric] mult_assoc)
   423 done
   424 
   425 lemma powser_inside: "[| summable (%n. f(n) * (x ^ n)); \<bar>z\<bar> < \<bar>x\<bar> |]  
   426       ==> summable (%n. f(n) * (z ^ n))"
   427 apply (drule_tac z = "\<bar>z\<bar>" in powser_insidea)
   428 apply (auto intro: summable_rabs_cancel simp add: power_abs [symmetric])
   429 done
   430 
   431 
   432 subsection{*Differentiation of Power Series*}
   433 
   434 text{*Lemma about distributing negation over it*}
   435 lemma diffs_minus: "diffs (%n. - c n) = (%n. - diffs c n)"
   436 by (simp add: diffs_def)
   437 
   438 text{*Show that we can shift the terms down one*}
   439 lemma lemma_diffs:
   440      "sumr 0 n (%n. (diffs c)(n) * (x ^ n)) =  
   441       sumr 0 n (%n. real n * c(n) * (x ^ (n - Suc 0))) +  
   442       (real n * c(n) * x ^ (n - Suc 0))"
   443 apply (induct_tac "n")
   444 apply (auto simp add: mult_assoc add_assoc [symmetric] diffs_def)
   445 done
   446 
   447 lemma lemma_diffs2: "sumr 0 n (%n. real n * c(n) * (x ^ (n - Suc 0))) =  
   448       sumr 0 n (%n. (diffs c)(n) * (x ^ n)) -  
   449       (real n * c(n) * x ^ (n - Suc 0))"
   450 by (auto simp add: lemma_diffs)
   451 
   452 
   453 lemma diffs_equiv: "summable (%n. (diffs c)(n) * (x ^ n)) ==>  
   454       (%n. real n * c(n) * (x ^ (n - Suc 0))) sums  
   455          (suminf(%n. (diffs c)(n) * (x ^ n)))"
   456 apply (subgoal_tac " (%n. real n * c (n) * (x ^ (n - Suc 0))) ----> 0")
   457 apply (rule_tac [2] LIMSEQ_imp_Suc)
   458 apply (drule summable_sums) 
   459 apply (auto simp add: sums_def)
   460 apply (drule_tac X="(\<lambda>n. \<Sum>n = 0..<n. diffs c n * x ^ n)" in LIMSEQ_diff)
   461 apply (auto simp add: lemma_diffs2 [symmetric] diffs_def [symmetric])
   462 apply (simp add: diffs_def summable_LIMSEQ_zero)
   463 done
   464 
   465 
   466 subsection{*Term-by-Term Differentiability of Power Series*}
   467 
   468 lemma lemma_termdiff1:
   469      "sumr 0 m (%p. (((z + h) ^ (m - p)) * (z ^ p)) - (z ^ m)) =  
   470         sumr 0 m (%p. (z ^ p) *  
   471         (((z + h) ^ (m - p)) - (z ^ (m - p))))"
   472 apply (rule sumr_subst)
   473 apply (auto simp add: right_distrib real_diff_def power_add [symmetric] mult_ac)
   474 done
   475 
   476 lemma less_add_one: "m < n ==> (\<exists>d. n = m + d + Suc 0)"
   477 by (simp add: less_iff_Suc_add)
   478 
   479 lemma sumdiff: "a + b - (c + d) = a - c + b - (d::real)"
   480 by arith
   481 
   482 
   483 lemma lemma_termdiff2: " h \<noteq> 0 ==>  
   484         (((z + h) ^ n) - (z ^ n)) * inverse h -  
   485             real n * (z ^ (n - Suc 0)) =  
   486          h * sumr 0 (n - Suc 0) (%p. (z ^ p) *  
   487                sumr 0 ((n - Suc 0) - p)  
   488                  (%q. ((z + h) ^ q) * (z ^ (((n - 2) - p) - q))))"
   489 apply (rule real_mult_left_cancel [THEN iffD1], simp (no_asm_simp))
   490 apply (simp add: right_diff_distrib mult_ac)
   491 apply (simp add: mult_assoc [symmetric])
   492 apply (case_tac "n")
   493 apply (auto simp add: lemma_realpow_diff_sumr2 
   494                       right_diff_distrib [symmetric] mult_assoc
   495             simp del: realpow_Suc sumr_Suc)
   496 apply (auto simp add: lemma_realpow_rev_sumr simp del: sumr_Suc)
   497 apply (auto simp add: real_of_nat_Suc sumr_diff_mult_const left_distrib 
   498                 sumdiff lemma_termdiff1 sumr_mult)
   499 apply (auto intro!: sumr_subst simp add: real_diff_def real_add_assoc)
   500 apply (simp add: diff_minus [symmetric] less_iff_Suc_add) 
   501 apply (auto simp add: sumr_mult lemma_realpow_diff_sumr2 mult_ac simp
   502                  del: sumr_Suc realpow_Suc)
   503 done
   504 
   505 lemma lemma_termdiff3: "[| h \<noteq> 0; \<bar>z\<bar> \<le> K; \<bar>z + h\<bar> \<le> K |]  
   506       ==> abs (((z + h) ^ n - z ^ n) * inverse h - real n * z ^ (n - Suc 0))  
   507           \<le> real n * real (n - Suc 0) * K ^ (n - 2) * \<bar>h\<bar>"
   508 apply (subst lemma_termdiff2, assumption)
   509 apply (simp add: abs_mult mult_commute) 
   510 apply (simp add: mult_commute [of _ "K ^ (n - 2)"]) 
   511 apply (rule sumr_rabs [THEN real_le_trans])
   512 apply (simp add: mult_assoc [symmetric])
   513 apply (simp add: mult_commute [of _ "real (n - Suc 0)"])
   514 apply (auto intro!: sumr_bound2 simp add: abs_mult)
   515 apply (case_tac "n", auto)
   516 apply (drule less_add_one)
   517 (*CLAIM_SIMP " (a * b * c = a * (c * (b::real))" mult_ac]*)
   518 apply clarify 
   519 apply (subgoal_tac "K ^ p * K ^ d * real (Suc (Suc (p + d))) =
   520                     K ^ p * (real (Suc (Suc (p + d))) * K ^ d)") 
   521 apply (simp (no_asm_simp) add: power_add del: sumr_Suc)
   522 apply (auto intro!: mult_mono simp del: sumr_Suc)
   523 apply (auto intro!: power_mono simp add: power_abs simp del: sumr_Suc)
   524 apply (rule_tac j = "real (Suc d) * (K ^ d) " in real_le_trans)
   525 apply (subgoal_tac [2] "0 \<le> K")
   526 apply (drule_tac [2] n = d in zero_le_power)
   527 apply (auto simp del: sumr_Suc)
   528 apply (rule sumr_rabs [THEN real_le_trans])
   529 apply (rule sumr_bound2, auto dest!: less_add_one intro!: mult_mono simp add: abs_mult power_add)
   530 apply (auto intro!: power_mono zero_le_power simp add: power_abs, arith+)
   531 done
   532 
   533 lemma lemma_termdiff4: 
   534   "[| 0 < k;  
   535       (\<forall>h. 0 < \<bar>h\<bar> & \<bar>h\<bar> < k --> \<bar>f h\<bar> \<le> K * \<bar>h\<bar>) |]  
   536    ==> f -- 0 --> 0"
   537 apply (unfold LIM_def, auto)
   538 apply (subgoal_tac "0 \<le> K")
   539 apply (drule_tac [2] x = "k/2" in spec)
   540 apply (frule_tac [2] real_less_half_sum)
   541 apply (drule_tac [2] real_gt_half_sum)
   542 apply (auto simp add: abs_eqI2)
   543 apply (rule_tac [2] c = "k/2" in mult_right_le_imp_le)
   544 apply (auto intro: abs_ge_zero [THEN real_le_trans])
   545 apply (drule real_le_imp_less_or_eq, auto)
   546 apply (subgoal_tac "0 < (r * inverse K) * inverse 2")
   547 apply (rule_tac [2] real_mult_order)+
   548 apply (drule_tac ?d1.0 = "r * inverse K * inverse 2" and ?d2.0 = k in real_lbound_gt_zero)
   549 apply (auto simp add: positive_imp_inverse_positive zero_less_mult_iff)
   550 apply (rule_tac [2] y="\<bar>f (k / 2)\<bar> * 2" in order_trans, auto)
   551 apply (rule_tac x = e in exI, auto)
   552 apply (rule_tac y = "K * \<bar>x\<bar>" in order_le_less_trans)
   553 apply (rule_tac [2] y = "K * e" in order_less_trans)
   554 apply (rule_tac [3] c = "inverse K" in mult_right_less_imp_less, force)
   555 apply (simp add: mult_less_cancel_left)
   556 apply (auto simp add: mult_ac)
   557 done
   558 
   559 lemma lemma_termdiff5: "[| 0 < k;  
   560             summable f;  
   561             \<forall>h. 0 < \<bar>h\<bar> & \<bar>h\<bar> < k -->  
   562                     (\<forall>n. abs(g(h) (n::nat)) \<le> (f(n) * \<bar>h\<bar>)) |]  
   563          ==> (%h. suminf(g h)) -- 0 --> 0"
   564 apply (drule summable_sums)
   565 apply (subgoal_tac "\<forall>h. 0 < \<bar>h\<bar> & \<bar>h\<bar> < k --> \<bar>suminf (g h)\<bar> \<le> suminf f * \<bar>h\<bar>")
   566 apply (auto intro!: lemma_termdiff4 simp add: sums_summable [THEN suminf_mult, symmetric])
   567 apply (subgoal_tac "summable (%n. f n * \<bar>h\<bar>) ")
   568  prefer 2
   569  apply (simp add: summable_def) 
   570  apply (rule_tac x = "suminf f * \<bar>h\<bar>" in exI)
   571  apply (drule_tac c = "\<bar>h\<bar>" in sums_mult)
   572  apply (simp add: mult_ac) 
   573 apply (subgoal_tac "summable (%n. abs (g (h::real) (n::nat))) ")
   574  apply (rule_tac [2] g = "%n. f n * \<bar>h\<bar>" in summable_comparison_test)
   575   apply (rule_tac [2] x = 0 in exI, auto)
   576 apply (rule_tac j = "suminf (%n. \<bar>g h n\<bar>)" in real_le_trans)
   577 apply (auto intro: summable_rabs summable_le simp add: sums_summable [THEN suminf_mult])
   578 done
   579 
   580 
   581 
   582 text{* FIXME: Long proofs*}
   583 
   584 lemma termdiffs_aux:
   585      "[|summable (\<lambda>n. diffs (diffs c) n * K ^ n); \<bar>x\<bar> < \<bar>K\<bar> |]
   586     ==> (\<lambda>h. suminf
   587              (\<lambda>n. c n *
   588                   (((x + h) ^ n - x ^ n) * inverse h -
   589                    real n * x ^ (n - Suc 0))))
   590        -- 0 --> 0"
   591 apply (drule dense, safe)
   592 apply (frule real_less_sum_gt_zero)
   593 apply (drule_tac
   594          f = "%n. \<bar>c n\<bar> * real n * real (n - Suc 0) * (r ^ (n - 2))" 
   595      and g = "%h n. c (n) * ((( ((x + h) ^ n) - (x ^ n)) * inverse h) 
   596                              - (real n * (x ^ (n - Suc 0))))" 
   597        in lemma_termdiff5)
   598 apply (auto simp add: add_commute)
   599 apply (subgoal_tac "summable (%n. \<bar>diffs (diffs c) n\<bar> * (r ^ n))")
   600 apply (rule_tac [2] x = K in powser_insidea, auto)
   601 apply (subgoal_tac [2] "\<bar>r\<bar> = r", auto)
   602 apply (rule_tac [2] y1 = "\<bar>x\<bar>" in order_trans [THEN abs_eqI1], auto)
   603 apply (simp add: diffs_def mult_assoc [symmetric])
   604 apply (subgoal_tac
   605         "\<forall>n. real (Suc n) * real (Suc (Suc n)) * \<bar>c (Suc (Suc n))\<bar> * (r ^ n) 
   606               = diffs (diffs (%n. \<bar>c n\<bar>)) n * (r ^ n) ") 
   607 apply auto
   608 apply (drule diffs_equiv)
   609 apply (drule sums_summable)
   610 apply (simp_all add: diffs_def) 
   611 apply (simp add: diffs_def mult_ac)
   612 apply (subgoal_tac " (%n. real n * (real (Suc n) * (\<bar>c (Suc n)\<bar> * (r ^ (n - Suc 0))))) = (%n. diffs (%m. real (m - Suc 0) * \<bar>c m\<bar> * inverse r) n * (r ^ n))")
   613 apply auto
   614   prefer 2
   615   apply (rule ext)
   616   apply (simp add: diffs_def) 
   617   apply (case_tac "n", auto)
   618 txt{*23*}
   619    apply (drule abs_ge_zero [THEN order_le_less_trans])
   620    apply (simp add: mult_ac) 
   621   apply (drule abs_ge_zero [THEN order_le_less_trans])
   622   apply (simp add: mult_ac) 
   623  apply (drule diffs_equiv)
   624  apply (drule sums_summable)
   625 apply (subgoal_tac
   626           "summable
   627             (\<lambda>n. real n * (real (n - Suc 0) * \<bar>c n\<bar> * inverse r) *
   628                  r ^ (n - Suc 0)) =
   629            summable
   630             (\<lambda>n. real n * (\<bar>c n\<bar> * (real (n - Suc 0) * r ^ (n - 2))))")
   631 apply simp 
   632 apply (rule_tac f = summable in arg_cong, rule ext)
   633 txt{*33*}
   634 apply (case_tac "n", auto)
   635 apply (case_tac "nat", auto)
   636 apply (drule abs_ge_zero [THEN order_le_less_trans], auto) 
   637 apply (drule abs_ge_zero [THEN order_le_less_trans])
   638 apply (simp add: mult_assoc)
   639 apply (rule mult_left_mono)
   640 apply (rule add_commute [THEN subst])
   641 apply (simp (no_asm) add: mult_assoc [symmetric])
   642 apply (rule lemma_termdiff3)
   643 apply (auto intro: abs_triangle_ineq [THEN order_trans], arith)
   644 done
   645 
   646 
   647 lemma termdiffs: 
   648     "[| summable(%n. c(n) * (K ^ n));  
   649         summable(%n. (diffs c)(n) * (K ^ n));  
   650         summable(%n. (diffs(diffs c))(n) * (K ^ n));  
   651         \<bar>x\<bar> < \<bar>K\<bar> |]  
   652      ==> DERIV (%x. suminf (%n. c(n) * (x ^ n)))  x :>  
   653              suminf (%n. (diffs c)(n) * (x ^ n))"
   654 apply (unfold deriv_def)
   655 apply (rule_tac g = "%h. suminf (%n. ((c (n) * ( (x + h) ^ n)) - (c (n) * (x ^ n))) * inverse h) " in LIM_trans)
   656 apply (simp add: LIM_def, safe)
   657 apply (rule_tac x = "\<bar>K\<bar> - \<bar>x\<bar>" in exI)
   658 apply (auto simp add: less_diff_eq)
   659 apply (drule abs_triangle_ineq [THEN order_le_less_trans])
   660 apply (rule_tac y = 0 in order_le_less_trans, auto)
   661 apply (subgoal_tac " (%n. (c n) * (x ^ n)) sums (suminf (%n. (c n) * (x ^ n))) & (%n. (c n) * ((x + xa) ^ n)) sums (suminf (%n. (c n) * ( (x + xa) ^ n))) ")
   662 apply (auto intro!: summable_sums)
   663 apply (rule_tac [2] powser_inside, rule_tac [4] powser_inside)
   664 apply (auto simp add: add_commute)
   665 apply (drule_tac x="(\<lambda>n. c n * (xa + x) ^ n)" in sums_diff, assumption) 
   666 apply (drule_tac x = " (%n. c n * (xa + x) ^ n - c n * x ^ n) " and c = "inverse xa" in sums_mult)
   667 apply (rule sums_unique [symmetric])
   668 apply (simp add: diff_def divide_inverse add_ac mult_ac)
   669 apply (rule LIM_zero_cancel)
   670 apply (rule_tac g = "%h. suminf (%n. c (n) * ((( ((x + h) ^ n) - (x ^ n)) * inverse h) - (real n * (x ^ (n - Suc 0))))) " in LIM_trans)
   671  prefer 2 apply (blast intro: termdiffs_aux) 
   672 apply (simp add: LIM_def, safe)
   673 apply (rule_tac x = "\<bar>K\<bar> - \<bar>x\<bar>" in exI)
   674 apply (auto simp add: less_diff_eq)
   675 apply (drule abs_triangle_ineq [THEN order_le_less_trans])
   676 apply (rule_tac y = 0 in order_le_less_trans, auto)
   677 apply (subgoal_tac "summable (%n. (diffs c) (n) * (x ^ n))")
   678 apply (rule_tac [2] powser_inside, auto)
   679 apply (drule_tac c = c and x = x in diffs_equiv)
   680 apply (frule sums_unique, auto)
   681 apply (subgoal_tac " (%n. (c n) * (x ^ n)) sums (suminf (%n. (c n) * (x ^ n))) & (%n. (c n) * ((x + xa) ^ n)) sums (suminf (%n. (c n) * ( (x + xa) ^ n))) ")
   682 apply safe
   683 apply (auto intro!: summable_sums)
   684 apply (rule_tac [2] powser_inside, rule_tac [4] powser_inside)
   685 apply (auto simp add: add_commute)
   686 apply (frule_tac x = " (%n. c n * (xa + x) ^ n) " and y = " (%n. c n * x ^ n) " in sums_diff, assumption)
   687 apply (simp add: suminf_diff [OF sums_summable sums_summable] 
   688                right_diff_distrib [symmetric])
   689 apply (frule_tac x = " (%n. c n * ((xa + x) ^ n - x ^ n))" and c = "inverse xa" in sums_mult)
   690 apply (simp add: sums_summable [THEN suminf_mult2])
   691 apply (frule_tac x = " (%n. inverse xa * (c n * ((xa + x) ^ n - x ^ n))) " and y = " (%n. real n * c n * x ^ (n - Suc 0))" in sums_diff)
   692 apply assumption
   693 apply (subst minus_equation_iff, simp (no_asm))  
   694 apply (simp add: suminf_diff [OF sums_summable sums_summable] add_ac mult_ac)
   695 apply (rule_tac f = suminf in arg_cong)
   696 apply (rule ext)
   697 apply (simp add: diff_def right_distrib add_ac mult_ac)
   698 done
   699 
   700 
   701 subsection{*Formal Derivatives of Exp, Sin, and Cos Series*} 
   702 
   703 lemma exp_fdiffs: 
   704       "diffs (%n. inverse(real (fact n))) = (%n. inverse(real (fact n)))"
   705 apply (unfold diffs_def)
   706 apply (rule ext)
   707 apply (subst fact_Suc)
   708 apply (subst real_of_nat_mult)
   709 apply (subst inverse_mult_distrib)
   710 apply (auto simp add: mult_assoc [symmetric])
   711 done
   712 
   713 lemma sin_fdiffs: 
   714       "diffs(%n. if even n then 0  
   715            else (- 1) ^ ((n - Suc 0) div 2)/(real (fact n)))  
   716        = (%n. if even n then  
   717                  (- 1) ^ (n div 2)/(real (fact n))  
   718               else 0)"
   719 apply (unfold diffs_def real_divide_def)
   720 apply (rule ext)
   721 apply (subst fact_Suc)
   722 apply (subst real_of_nat_mult)
   723 apply (subst even_nat_Suc)
   724 apply (subst inverse_mult_distrib, auto)
   725 done
   726 
   727 lemma sin_fdiffs2: 
   728        "diffs(%n. if even n then 0  
   729            else (- 1) ^ ((n - Suc 0) div 2)/(real (fact n))) n  
   730        = (if even n then  
   731                  (- 1) ^ (n div 2)/(real (fact n))  
   732               else 0)"
   733 apply (unfold diffs_def real_divide_def)
   734 apply (subst fact_Suc)
   735 apply (subst real_of_nat_mult)
   736 apply (subst even_nat_Suc)
   737 apply (subst inverse_mult_distrib, auto)
   738 done
   739 
   740 lemma cos_fdiffs: 
   741       "diffs(%n. if even n then  
   742                  (- 1) ^ (n div 2)/(real (fact n)) else 0)  
   743        = (%n. - (if even n then 0  
   744            else (- 1) ^ ((n - Suc 0)div 2)/(real (fact n))))"
   745 apply (unfold diffs_def real_divide_def)
   746 apply (rule ext)
   747 apply (subst fact_Suc)
   748 apply (subst real_of_nat_mult)
   749 apply (auto simp add: mult_assoc odd_Suc_mult_two_ex)
   750 done
   751 
   752 
   753 lemma cos_fdiffs2: 
   754       "diffs(%n. if even n then  
   755                  (- 1) ^ (n div 2)/(real (fact n)) else 0) n 
   756        = - (if even n then 0  
   757            else (- 1) ^ ((n - Suc 0)div 2)/(real (fact n)))"
   758 apply (unfold diffs_def real_divide_def)
   759 apply (subst fact_Suc)
   760 apply (subst real_of_nat_mult) 
   761 apply (auto simp add: mult_assoc odd_Suc_mult_two_ex)
   762 done
   763 
   764 text{*Now at last we can get the derivatives of exp, sin and cos*}
   765 
   766 lemma lemma_sin_minus:
   767      "- sin x =
   768          suminf(%n. - ((if even n then 0 
   769                   else (- 1) ^ ((n - Suc 0) div 2)/(real (fact n))) * x ^ n))"
   770 by (auto intro!: sums_unique sums_minus sin_converges)
   771 
   772 lemma lemma_exp_ext: "exp = (%x. suminf (%n. inverse (real (fact n)) * x ^ n))"
   773 by (auto intro!: ext simp add: exp_def)
   774 
   775 lemma DERIV_exp [simp]: "DERIV exp x :> exp(x)"
   776 apply (unfold exp_def)
   777 apply (subst lemma_exp_ext)
   778 apply (subgoal_tac "DERIV (%u. suminf (%n. inverse (real (fact n)) * u ^ n)) x :> suminf (%n. diffs (%n. inverse (real (fact n))) n * x ^ n) ")
   779 apply (rule_tac [2] K = "1 + \<bar>x\<bar> " in termdiffs)
   780 apply (auto intro: exp_converges [THEN sums_summable] simp add: exp_fdiffs, arith)
   781 done
   782 
   783 lemma lemma_sin_ext:
   784      "sin = (%x. suminf(%n. 
   785                    (if even n then 0  
   786                        else (- 1) ^ ((n - Suc 0) div 2)/(real (fact n))) *  
   787                    x ^ n))"
   788 by (auto intro!: ext simp add: sin_def)
   789 
   790 lemma lemma_cos_ext:
   791      "cos = (%x. suminf(%n. 
   792                    (if even n then (- 1) ^ (n div 2)/(real (fact n)) else 0) *
   793                    x ^ n))"
   794 by (auto intro!: ext simp add: cos_def)
   795 
   796 lemma DERIV_sin [simp]: "DERIV sin x :> cos(x)"
   797 apply (unfold cos_def)
   798 apply (subst lemma_sin_ext)
   799 apply (auto simp add: sin_fdiffs2 [symmetric])
   800 apply (rule_tac K = "1 + \<bar>x\<bar> " in termdiffs)
   801 apply (auto intro: sin_converges cos_converges sums_summable intro!: sums_minus [THEN sums_summable] simp add: cos_fdiffs sin_fdiffs, arith)
   802 done
   803 
   804 lemma DERIV_cos [simp]: "DERIV cos x :> -sin(x)"
   805 apply (subst lemma_cos_ext)
   806 apply (auto simp add: lemma_sin_minus cos_fdiffs2 [symmetric] minus_mult_left)
   807 apply (rule_tac K = "1 + \<bar>x\<bar> " in termdiffs)
   808 apply (auto intro: sin_converges cos_converges sums_summable intro!: sums_minus [THEN sums_summable] simp add: cos_fdiffs sin_fdiffs diffs_minus, arith)
   809 done
   810 
   811 
   812 subsection{*Properties of the Exponential Function*}
   813 
   814 lemma exp_zero [simp]: "exp 0 = 1"
   815 proof -
   816   have "(\<Sum>n = 0..<1. inverse (real (fact n)) * 0 ^ n) =
   817         suminf (\<lambda>n. inverse (real (fact n)) * 0 ^ n)"
   818     by (rule series_zero [rule_format, THEN sums_unique],
   819         case_tac "m", auto)
   820   thus ?thesis by (simp add:  exp_def) 
   821 qed
   822 
   823 lemma exp_ge_add_one_self [simp]: "0 \<le> x ==> (1 + x) \<le> exp(x)"
   824 apply (drule real_le_imp_less_or_eq, auto)
   825 apply (unfold exp_def)
   826 apply (rule real_le_trans)
   827 apply (rule_tac [2] n = 2 and f = " (%n. inverse (real (fact n)) * x ^ n) " in series_pos_le)
   828 apply (auto intro: summable_exp simp add: numeral_2_eq_2 zero_le_power zero_le_mult_iff)
   829 done
   830 
   831 lemma exp_gt_one [simp]: "0 < x ==> 1 < exp x"
   832 apply (rule order_less_le_trans)
   833 apply (rule_tac [2] exp_ge_add_one_self, auto)
   834 done
   835 
   836 lemma DERIV_exp_add_const: "DERIV (%x. exp (x + y)) x :> exp(x + y)"
   837 proof -
   838   have "DERIV (exp \<circ> (\<lambda>x. x + y)) x :> exp (x + y) * (1+0)"
   839     by (fast intro: DERIV_chain DERIV_add DERIV_exp DERIV_Id DERIV_const) 
   840   thus ?thesis by (simp add: o_def)
   841 qed
   842 
   843 lemma DERIV_exp_minus [simp]: "DERIV (%x. exp (-x)) x :> - exp(-x)"
   844 proof -
   845   have "DERIV (exp \<circ> uminus) x :> exp (- x) * - 1"
   846     by (fast intro: DERIV_chain DERIV_minus DERIV_exp DERIV_Id) 
   847   thus ?thesis by (simp add: o_def)
   848 qed
   849 
   850 lemma DERIV_exp_exp_zero [simp]: "DERIV (%x. exp (x + y) * exp (- x)) x :> 0"
   851 proof -
   852   have "DERIV (\<lambda>x. exp (x + y) * exp (- x)) x
   853        :> exp (x + y) * exp (- x) + - exp (- x) * exp (x + y)"
   854     by (fast intro: DERIV_exp_add_const DERIV_exp_minus DERIV_mult) 
   855   thus ?thesis by simp
   856 qed
   857 
   858 lemma exp_add_mult_minus [simp]: "exp(x + y)*exp(-x) = exp(y)"
   859 proof -
   860   have "\<forall>x. DERIV (%x. exp (x + y) * exp (- x)) x :> 0" by simp
   861   hence "exp (x + y) * exp (- x) = exp (0 + y) * exp (- 0)" 
   862     by (rule DERIV_isconst_all) 
   863   thus ?thesis by simp
   864 qed
   865 
   866 lemma exp_mult_minus [simp]: "exp x * exp(-x) = 1"
   867 proof -
   868   have "exp (x + 0) * exp (- x) = exp 0" by (rule exp_add_mult_minus) 
   869   thus ?thesis by simp
   870 qed
   871 
   872 lemma exp_mult_minus2 [simp]: "exp(-x)*exp(x) = 1"
   873 by (simp add: mult_commute)
   874 
   875 
   876 lemma exp_minus: "exp(-x) = inverse(exp(x))"
   877 by (auto intro: inverse_unique [symmetric])
   878 
   879 lemma exp_add: "exp(x + y) = exp(x) * exp(y)"
   880 proof -
   881   have "exp x * exp y = exp x * (exp (x + y) * exp (- x))" by simp
   882   thus ?thesis by (simp (no_asm_simp) add: mult_ac)
   883 qed
   884 
   885 text{*Proof: because every exponential can be seen as a square.*}
   886 lemma exp_ge_zero [simp]: "0 \<le> exp x"
   887 apply (rule_tac t = x in real_sum_of_halves [THEN subst])
   888 apply (subst exp_add, auto)
   889 done
   890 
   891 lemma exp_not_eq_zero [simp]: "exp x \<noteq> 0"
   892 apply (cut_tac x = x in exp_mult_minus2)
   893 apply (auto simp del: exp_mult_minus2)
   894 done
   895 
   896 lemma exp_gt_zero [simp]: "0 < exp x"
   897 by (simp add: order_less_le)
   898 
   899 lemma inv_exp_gt_zero [simp]: "0 < inverse(exp x)"
   900 by (auto intro: positive_imp_inverse_positive)
   901 
   902 lemma abs_exp_cancel [simp]: "\<bar>exp x\<bar> = exp x"
   903 by (auto simp add: abs_eqI2)
   904 
   905 lemma exp_real_of_nat_mult: "exp(real n * x) = exp(x) ^ n"
   906 apply (induct_tac "n")
   907 apply (auto simp add: real_of_nat_Suc right_distrib exp_add mult_commute)
   908 done
   909 
   910 lemma exp_diff: "exp(x - y) = exp(x)/(exp y)"
   911 apply (unfold real_diff_def real_divide_def)
   912 apply (simp (no_asm) add: exp_add exp_minus)
   913 done
   914 
   915 
   916 lemma exp_less_mono:
   917   assumes xy: "x < y" shows "exp x < exp y"
   918 proof -
   919   have "1 < exp (y + - x)"
   920     by (rule real_less_sum_gt_zero [THEN exp_gt_one])
   921   hence "exp x * inverse (exp x) < exp y * inverse (exp x)"
   922     by (auto simp add: exp_add exp_minus)
   923   thus ?thesis
   924     by (simp add: divide_inverse [symmetric] pos_less_divide_eq)
   925 qed
   926 
   927 lemma exp_less_cancel: "exp x < exp y ==> x < y"
   928 apply (rule ccontr) 
   929 apply (simp add: linorder_not_less order_le_less) 
   930 apply (auto dest: exp_less_mono)
   931 done
   932 
   933 lemma exp_less_cancel_iff [iff]: "(exp(x) < exp(y)) = (x < y)"
   934 by (auto intro: exp_less_mono exp_less_cancel)
   935 
   936 lemma exp_le_cancel_iff [iff]: "(exp(x) \<le> exp(y)) = (x \<le> y)"
   937 by (auto simp add: linorder_not_less [symmetric])
   938 
   939 lemma exp_inj_iff [iff]: "(exp x = exp y) = (x = y)"
   940 by (simp add: order_eq_iff)
   941 
   942 lemma lemma_exp_total: "1 \<le> y ==> \<exists>x. 0 \<le> x & x \<le> y - 1 & exp(x) = y"
   943 apply (rule IVT)
   944 apply (auto intro: DERIV_exp [THEN DERIV_isCont] simp add: le_diff_eq)
   945 apply (subgoal_tac "1 + (y - 1) \<le> exp (y - 1)") 
   946 apply simp 
   947 apply (rule exp_ge_add_one_self, simp)
   948 done
   949 
   950 lemma exp_total: "0 < y ==> \<exists>x. exp x = y"
   951 apply (rule_tac x = 1 and y = y in linorder_cases)
   952 apply (drule order_less_imp_le [THEN lemma_exp_total])
   953 apply (rule_tac [2] x = 0 in exI)
   954 apply (frule_tac [3] real_inverse_gt_one)
   955 apply (drule_tac [4] order_less_imp_le [THEN lemma_exp_total], auto)
   956 apply (rule_tac x = "-x" in exI)
   957 apply (simp add: exp_minus)
   958 done
   959 
   960 
   961 subsection{*Properties of the Logarithmic Function*}
   962 
   963 lemma ln_exp[simp]: "ln(exp x) = x"
   964 by (simp add: ln_def)
   965 
   966 lemma exp_ln_iff[simp]: "(exp(ln x) = x) = (0 < x)"
   967 apply (auto dest: exp_total)
   968 apply (erule subst, simp) 
   969 done
   970 
   971 lemma ln_mult: "[| 0 < x; 0 < y |] ==> ln(x * y) = ln(x) + ln(y)"
   972 apply (rule exp_inj_iff [THEN iffD1])
   973 apply (frule real_mult_order)
   974 apply (auto simp add: exp_add exp_ln_iff [symmetric] simp del: exp_inj_iff exp_ln_iff)
   975 done
   976 
   977 lemma ln_inj_iff[simp]: "[| 0 < x; 0 < y |] ==> (ln x = ln y) = (x = y)"
   978 apply (simp only: exp_ln_iff [symmetric])
   979 apply (erule subst)+
   980 apply simp 
   981 done
   982 
   983 lemma ln_one[simp]: "ln 1 = 0"
   984 by (rule exp_inj_iff [THEN iffD1], auto)
   985 
   986 lemma ln_inverse: "0 < x ==> ln(inverse x) = - ln x"
   987 apply (rule_tac a1 = "ln x" in add_left_cancel [THEN iffD1])
   988 apply (auto simp add: positive_imp_inverse_positive ln_mult [symmetric])
   989 done
   990 
   991 lemma ln_div: 
   992     "[|0 < x; 0 < y|] ==> ln(x/y) = ln x - ln y"
   993 apply (unfold real_divide_def)
   994 apply (auto simp add: positive_imp_inverse_positive ln_mult ln_inverse)
   995 done
   996 
   997 lemma ln_less_cancel_iff[simp]: "[| 0 < x; 0 < y|] ==> (ln x < ln y) = (x < y)"
   998 apply (simp only: exp_ln_iff [symmetric])
   999 apply (erule subst)+
  1000 apply simp 
  1001 done
  1002 
  1003 lemma ln_le_cancel_iff[simp]: "[| 0 < x; 0 < y|] ==> (ln x \<le> ln y) = (x \<le> y)"
  1004 by (auto simp add: linorder_not_less [symmetric])
  1005 
  1006 lemma ln_realpow: "0 < x ==> ln(x ^ n) = real n * ln(x)"
  1007 by (auto dest!: exp_total simp add: exp_real_of_nat_mult [symmetric])
  1008 
  1009 lemma ln_add_one_self_le_self [simp]: "0 \<le> x ==> ln(1 + x) \<le> x"
  1010 apply (rule ln_exp [THEN subst])
  1011 apply (rule ln_le_cancel_iff [THEN iffD2], auto)
  1012 done
  1013 
  1014 lemma ln_less_self [simp]: "0 < x ==> ln x < x"
  1015 apply (rule order_less_le_trans)
  1016 apply (rule_tac [2] ln_add_one_self_le_self)
  1017 apply (rule ln_less_cancel_iff [THEN iffD2], auto)
  1018 done
  1019 
  1020 lemma ln_ge_zero:
  1021   assumes x: "1 \<le> x" shows "0 \<le> ln x"
  1022 proof -
  1023   have "0 < x" using x by arith
  1024   hence "exp 0 \<le> exp (ln x)"
  1025     by (simp add: x exp_ln_iff [symmetric] del: exp_ln_iff)
  1026   thus ?thesis by (simp only: exp_le_cancel_iff)
  1027 qed
  1028 
  1029 lemma ln_ge_zero_imp_ge_one:
  1030   assumes ln: "0 \<le> ln x" 
  1031       and x:  "0 < x"
  1032   shows "1 \<le> x"
  1033 proof -
  1034   from ln have "ln 1 \<le> ln x" by simp
  1035   thus ?thesis by (simp add: x del: ln_one) 
  1036 qed
  1037 
  1038 lemma ln_ge_zero_iff [simp]: "0 < x ==> (0 \<le> ln x) = (1 \<le> x)"
  1039 by (blast intro: ln_ge_zero ln_ge_zero_imp_ge_one)
  1040 
  1041 lemma ln_gt_zero:
  1042   assumes x: "1 < x" shows "0 < ln x"
  1043 proof -
  1044   have "0 < x" using x by arith
  1045   hence "exp 0 < exp (ln x)"
  1046     by (simp add: x exp_ln_iff [symmetric] del: exp_ln_iff)
  1047   thus ?thesis  by (simp only: exp_less_cancel_iff)
  1048 qed
  1049 
  1050 lemma ln_gt_zero_imp_gt_one:
  1051   assumes ln: "0 < ln x" 
  1052       and x:  "0 < x"
  1053   shows "1 < x"
  1054 proof -
  1055   from ln have "ln 1 < ln x" by simp
  1056   thus ?thesis by (simp add: x del: ln_one) 
  1057 qed
  1058 
  1059 lemma ln_gt_zero_iff [simp]: "0 < x ==> (0 < ln x) = (1 < x)"
  1060 by (blast intro: ln_gt_zero ln_gt_zero_imp_gt_one)
  1061 
  1062 lemma ln_not_eq_zero [simp]: "[| 0 < x; x \<noteq> 1 |] ==> ln x \<noteq> 0"
  1063 apply safe
  1064 apply (drule exp_inj_iff [THEN iffD2])
  1065 apply (drule exp_ln_iff [THEN iffD2], auto)
  1066 done
  1067 
  1068 lemma ln_less_zero: "[| 0 < x; x < 1 |] ==> ln x < 0"
  1069 apply (rule exp_less_cancel_iff [THEN iffD1])
  1070 apply (auto simp add: exp_ln_iff [symmetric] simp del: exp_ln_iff)
  1071 done
  1072 
  1073 lemma exp_ln_eq: "exp u = x ==> ln x = u"
  1074 by auto
  1075 
  1076 
  1077 subsection{*Basic Properties of the Trigonometric Functions*}
  1078 
  1079 lemma sin_zero [simp]: "sin 0 = 0"
  1080 by (auto intro!: sums_unique [symmetric] LIMSEQ_const 
  1081          simp add: sin_def sums_def simp del: power_0_left)
  1082 
  1083 lemma lemma_series_zero2: "(\<forall>m. n \<le> m --> f m = 0) --> f sums sumr 0 n f"
  1084 by (auto intro: series_zero)
  1085 
  1086 lemma cos_zero [simp]: "cos 0 = 1"
  1087 apply (unfold cos_def)
  1088 apply (rule sums_unique [symmetric])
  1089 apply (cut_tac n = 1 and f = " (%n. (if even n then (- 1) ^ (n div 2) / (real (fact n)) else 0) * 0 ^ n) " in lemma_series_zero2)
  1090 apply auto
  1091 done
  1092 
  1093 lemma DERIV_sin_sin_mult [simp]:
  1094      "DERIV (%x. sin(x)*sin(x)) x :> cos(x) * sin(x) + cos(x) * sin(x)"
  1095 by (rule DERIV_mult, auto)
  1096 
  1097 lemma DERIV_sin_sin_mult2 [simp]:
  1098      "DERIV (%x. sin(x)*sin(x)) x :> 2 * cos(x) * sin(x)"
  1099 apply (cut_tac x = x in DERIV_sin_sin_mult)
  1100 apply (auto simp add: mult_assoc)
  1101 done
  1102 
  1103 lemma DERIV_sin_realpow2 [simp]:
  1104      "DERIV (%x. (sin x)\<twosuperior>) x :> cos(x) * sin(x) + cos(x) * sin(x)"
  1105 by (auto simp add: numeral_2_eq_2 real_mult_assoc [symmetric])
  1106 
  1107 lemma DERIV_sin_realpow2a [simp]:
  1108      "DERIV (%x. (sin x)\<twosuperior>) x :> 2 * cos(x) * sin(x)"
  1109 by (auto simp add: numeral_2_eq_2)
  1110 
  1111 lemma DERIV_cos_cos_mult [simp]:
  1112      "DERIV (%x. cos(x)*cos(x)) x :> -sin(x) * cos(x) + -sin(x) * cos(x)"
  1113 by (rule DERIV_mult, auto)
  1114 
  1115 lemma DERIV_cos_cos_mult2 [simp]:
  1116      "DERIV (%x. cos(x)*cos(x)) x :> -2 * cos(x) * sin(x)"
  1117 apply (cut_tac x = x in DERIV_cos_cos_mult)
  1118 apply (auto simp add: mult_ac)
  1119 done
  1120 
  1121 lemma DERIV_cos_realpow2 [simp]:
  1122      "DERIV (%x. (cos x)\<twosuperior>) x :> -sin(x) * cos(x) + -sin(x) * cos(x)"
  1123 by (auto simp add: numeral_2_eq_2 real_mult_assoc [symmetric])
  1124 
  1125 lemma DERIV_cos_realpow2a [simp]:
  1126      "DERIV (%x. (cos x)\<twosuperior>) x :> -2 * cos(x) * sin(x)"
  1127 by (auto simp add: numeral_2_eq_2)
  1128 
  1129 lemma lemma_DERIV_subst: "[| DERIV f x :> D; D = E |] ==> DERIV f x :> E"
  1130 by auto
  1131 
  1132 lemma DERIV_cos_realpow2b: "DERIV (%x. (cos x)\<twosuperior>) x :> -(2 * cos(x) * sin(x))"
  1133 apply (rule lemma_DERIV_subst)
  1134 apply (rule DERIV_cos_realpow2a, auto)
  1135 done
  1136 
  1137 (* most useful *)
  1138 lemma DERIV_cos_cos_mult3 [simp]: "DERIV (%x. cos(x)*cos(x)) x :> -(2 * cos(x) * sin(x))"
  1139 apply (rule lemma_DERIV_subst)
  1140 apply (rule DERIV_cos_cos_mult2, auto)
  1141 done
  1142 
  1143 lemma DERIV_sin_circle_all: 
  1144      "\<forall>x. DERIV (%x. (sin x)\<twosuperior> + (cos x)\<twosuperior>) x :>  
  1145              (2*cos(x)*sin(x) - 2*cos(x)*sin(x))"
  1146 apply (unfold real_diff_def, safe)
  1147 apply (rule DERIV_add)
  1148 apply (auto simp add: numeral_2_eq_2)
  1149 done
  1150 
  1151 lemma DERIV_sin_circle_all_zero [simp]: "\<forall>x. DERIV (%x. (sin x)\<twosuperior> + (cos x)\<twosuperior>) x :> 0"
  1152 by (cut_tac DERIV_sin_circle_all, auto)
  1153 
  1154 lemma sin_cos_squared_add [simp]: "((sin x)\<twosuperior>) + ((cos x)\<twosuperior>) = 1"
  1155 apply (cut_tac x = x and y = 0 in DERIV_sin_circle_all_zero [THEN DERIV_isconst_all])
  1156 apply (auto simp add: numeral_2_eq_2)
  1157 done
  1158 
  1159 lemma sin_cos_squared_add2 [simp]: "((cos x)\<twosuperior>) + ((sin x)\<twosuperior>) = 1"
  1160 apply (subst real_add_commute)
  1161 apply (simp (no_asm) del: realpow_Suc)
  1162 done
  1163 
  1164 lemma sin_cos_squared_add3 [simp]: "cos x * cos x + sin x * sin x = 1"
  1165 apply (cut_tac x = x in sin_cos_squared_add2)
  1166 apply (auto simp add: numeral_2_eq_2)
  1167 done
  1168 
  1169 lemma sin_squared_eq: "(sin x)\<twosuperior> = 1 - (cos x)\<twosuperior>"
  1170 apply (rule_tac a1 = "(cos x)\<twosuperior> " in add_right_cancel [THEN iffD1])
  1171 apply (simp del: realpow_Suc)
  1172 done
  1173 
  1174 lemma cos_squared_eq: "(cos x)\<twosuperior> = 1 - (sin x)\<twosuperior>"
  1175 apply (rule_tac a1 = "(sin x)\<twosuperior>" in add_right_cancel [THEN iffD1])
  1176 apply (simp del: realpow_Suc)
  1177 done
  1178 
  1179 lemma real_gt_one_ge_zero_add_less: "[| 1 < x; 0 \<le> y |] ==> 1 < x + (y::real)"
  1180 by arith
  1181 
  1182 lemma abs_sin_le_one [simp]: "\<bar>sin x\<bar> \<le> 1"
  1183 apply (auto simp add: linorder_not_less [symmetric])
  1184 apply (drule_tac n = "Suc 0" in power_gt1)
  1185 apply (auto simp del: realpow_Suc)
  1186 apply (drule_tac r1 = "cos x" in realpow_two_le [THEN [2] real_gt_one_ge_zero_add_less])
  1187 apply (simp add: numeral_2_eq_2 [symmetric] del: realpow_Suc)
  1188 done
  1189 
  1190 lemma sin_ge_minus_one [simp]: "-1 \<le> sin x"
  1191 apply (insert abs_sin_le_one [of x]) 
  1192 apply (simp add: abs_le_interval_iff del: abs_sin_le_one) 
  1193 done
  1194 
  1195 lemma sin_le_one [simp]: "sin x \<le> 1"
  1196 apply (insert abs_sin_le_one [of x]) 
  1197 apply (simp add: abs_le_interval_iff del: abs_sin_le_one) 
  1198 done
  1199 
  1200 lemma abs_cos_le_one [simp]: "\<bar>cos x\<bar> \<le> 1"
  1201 apply (auto simp add: linorder_not_less [symmetric])
  1202 apply (drule_tac n = "Suc 0" in power_gt1)
  1203 apply (auto simp del: realpow_Suc)
  1204 apply (drule_tac r1 = "sin x" in realpow_two_le [THEN [2] real_gt_one_ge_zero_add_less])
  1205 apply (simp add: numeral_2_eq_2 [symmetric] del: realpow_Suc)
  1206 done
  1207 
  1208 lemma cos_ge_minus_one [simp]: "-1 \<le> cos x"
  1209 apply (insert abs_cos_le_one [of x]) 
  1210 apply (simp add: abs_le_interval_iff del: abs_cos_le_one) 
  1211 done
  1212 
  1213 lemma cos_le_one [simp]: "cos x \<le> 1"
  1214 apply (insert abs_cos_le_one [of x]) 
  1215 apply (simp add: abs_le_interval_iff del: abs_cos_le_one)
  1216 done
  1217 
  1218 lemma DERIV_fun_pow: "DERIV g x :> m ==>  
  1219       DERIV (%x. (g x) ^ n) x :> real n * (g x) ^ (n - 1) * m"
  1220 apply (rule lemma_DERIV_subst)
  1221 apply (rule_tac f = " (%x. x ^ n) " in DERIV_chain2)
  1222 apply (rule DERIV_pow, auto)
  1223 done
  1224 
  1225 lemma DERIV_fun_exp: "DERIV g x :> m ==> DERIV (%x. exp(g x)) x :> exp(g x) * m"
  1226 apply (rule lemma_DERIV_subst)
  1227 apply (rule_tac f = exp in DERIV_chain2)
  1228 apply (rule DERIV_exp, auto)
  1229 done
  1230 
  1231 lemma DERIV_fun_sin: "DERIV g x :> m ==> DERIV (%x. sin(g x)) x :> cos(g x) * m"
  1232 apply (rule lemma_DERIV_subst)
  1233 apply (rule_tac f = sin in DERIV_chain2)
  1234 apply (rule DERIV_sin, auto)
  1235 done
  1236 
  1237 lemma DERIV_fun_cos: "DERIV g x :> m ==> DERIV (%x. cos(g x)) x :> -sin(g x) * m"
  1238 apply (rule lemma_DERIV_subst)
  1239 apply (rule_tac f = cos in DERIV_chain2)
  1240 apply (rule DERIV_cos, auto)
  1241 done
  1242 
  1243 lemmas DERIV_intros = DERIV_Id DERIV_const DERIV_cos DERIV_cmult 
  1244                     DERIV_sin  DERIV_exp  DERIV_inverse DERIV_pow 
  1245                     DERIV_add  DERIV_diff  DERIV_mult  DERIV_minus 
  1246                     DERIV_inverse_fun DERIV_quotient DERIV_fun_pow 
  1247                     DERIV_fun_exp DERIV_fun_sin DERIV_fun_cos 
  1248                     DERIV_Id DERIV_const DERIV_cos
  1249 
  1250 (* lemma *)
  1251 lemma lemma_DERIV_sin_cos_add: "\<forall>x.  
  1252          DERIV (%x. (sin (x + y) - (sin x * cos y + cos x * sin y)) ^ 2 +  
  1253                (cos (x + y) - (cos x * cos y - sin x * sin y)) ^ 2) x :> 0"
  1254 apply (safe, rule lemma_DERIV_subst)
  1255 apply (best intro!: DERIV_intros intro: DERIV_chain2) 
  1256   --{*replaces the old @{text DERIV_tac}*}
  1257 apply (auto simp add: real_diff_def left_distrib right_distrib mult_ac add_ac)
  1258 done
  1259 
  1260 lemma sin_cos_add [simp]:
  1261      "(sin (x + y) - (sin x * cos y + cos x * sin y)) ^ 2 +  
  1262       (cos (x + y) - (cos x * cos y - sin x * sin y)) ^ 2 = 0"
  1263 apply (cut_tac y = 0 and x = x and y7 = y 
  1264        in lemma_DERIV_sin_cos_add [THEN DERIV_isconst_all])
  1265 apply (auto simp add: numeral_2_eq_2)
  1266 done
  1267 
  1268 lemma sin_add: "sin (x + y) = sin x * cos y + cos x * sin y"
  1269 apply (cut_tac x = x and y = y in sin_cos_add)
  1270 apply (auto dest!: real_sum_squares_cancel_a 
  1271             simp add: numeral_2_eq_2 simp del: sin_cos_add)
  1272 done
  1273 
  1274 lemma cos_add: "cos (x + y) = cos x * cos y - sin x * sin y"
  1275 apply (cut_tac x = x and y = y in sin_cos_add)
  1276 apply (auto dest!: real_sum_squares_cancel_a
  1277             simp add: numeral_2_eq_2 simp del: sin_cos_add)
  1278 done
  1279 
  1280 lemma lemma_DERIV_sin_cos_minus: "\<forall>x.  
  1281           DERIV (%x. (sin(-x) + (sin x)) ^ 2 + (cos(-x) - (cos x)) ^ 2) x :> 0"
  1282 apply (safe, rule lemma_DERIV_subst)
  1283 apply (best intro!: DERIV_intros intro: DERIV_chain2) 
  1284 apply (auto simp add: real_diff_def left_distrib right_distrib mult_ac add_ac)
  1285 done
  1286 
  1287 lemma sin_cos_minus [simp]: "(sin(-x) + (sin x)) ^ 2 + (cos(-x) - (cos x)) ^ 2 = 0"
  1288 apply (cut_tac y = 0 and x = x in lemma_DERIV_sin_cos_minus [THEN DERIV_isconst_all])
  1289 apply (auto simp add: numeral_2_eq_2)
  1290 done
  1291 
  1292 lemma sin_minus [simp]: "sin (-x) = -sin(x)"
  1293 apply (cut_tac x = x in sin_cos_minus)
  1294 apply (auto dest!: real_sum_squares_cancel_a simp add: numeral_2_eq_2 simp del: sin_cos_minus)
  1295 done
  1296 
  1297 lemma cos_minus [simp]: "cos (-x) = cos(x)"
  1298 apply (cut_tac x = x in sin_cos_minus)
  1299 apply (auto dest!: real_sum_squares_cancel_a simp add: numeral_2_eq_2 simp del: sin_cos_minus)
  1300 done
  1301 
  1302 lemma sin_diff: "sin (x - y) = sin x * cos y - cos x * sin y"
  1303 apply (unfold real_diff_def)
  1304 apply (simp (no_asm) add: sin_add)
  1305 done
  1306 
  1307 lemma sin_diff2: "sin (x - y) = cos y * sin x - sin y * cos x"
  1308 by (simp add: sin_diff mult_commute)
  1309 
  1310 lemma cos_diff: "cos (x - y) = cos x * cos y + sin x * sin y"
  1311 apply (unfold real_diff_def)
  1312 apply (simp (no_asm) add: cos_add)
  1313 done
  1314 
  1315 lemma cos_diff2: "cos (x - y) = cos y * cos x + sin y * sin x"
  1316 by (simp add: cos_diff mult_commute)
  1317 
  1318 lemma sin_double [simp]: "sin(2 * x) = 2* sin x * cos x"
  1319 by (cut_tac x = x and y = x in sin_add, auto)
  1320 
  1321 
  1322 lemma cos_double: "cos(2* x) = ((cos x)\<twosuperior>) - ((sin x)\<twosuperior>)"
  1323 apply (cut_tac x = x and y = x in cos_add)
  1324 apply (auto simp add: numeral_2_eq_2)
  1325 done
  1326 
  1327 
  1328 subsection{*The Constant Pi*}
  1329 
  1330 text{*Show that there's a least positive @{term x} with @{term "cos(x) = 0"}; 
  1331    hence define pi.*}
  1332 
  1333 lemma sin_paired:
  1334      "(%n. (- 1) ^ n /(real (fact (2 * n + 1))) * x ^ (2 * n + 1)) 
  1335       sums  sin x"
  1336 proof -
  1337   have "(\<lambda>n. \<Sum>k = n * 2..<n * 2 + 2.
  1338             (if even k then 0
  1339              else (- 1) ^ ((k - Suc 0) div 2) / real (fact k)) *
  1340             x ^ k) 
  1341 	sums
  1342 	suminf (\<lambda>n. (if even n then 0
  1343 		     else (- 1) ^ ((n - Suc 0) div 2) / real (fact n)) *
  1344 	            x ^ n)" 
  1345     by (rule sin_converges [THEN sums_summable, THEN sums_group], simp) 
  1346   thus ?thesis by (simp add: mult_ac sin_def)
  1347 qed
  1348 
  1349 lemma sin_gt_zero: "[|0 < x; x < 2 |] ==> 0 < sin x"
  1350 apply (subgoal_tac 
  1351        "(\<lambda>n. \<Sum>k = n * 2..<n * 2 + 2.
  1352               (- 1) ^ k / real (fact (2 * k + 1)) * x ^ (2 * k + 1)) 
  1353      sums suminf (\<lambda>n. (- 1) ^ n / real (fact (2 * n + 1)) * x ^ (2 * n + 1))")
  1354  prefer 2
  1355  apply (rule sin_paired [THEN sums_summable, THEN sums_group], simp) 
  1356 apply (rotate_tac 2)
  1357 apply (drule sin_paired [THEN sums_unique, THEN ssubst])
  1358 apply (auto simp del: fact_Suc realpow_Suc)
  1359 apply (frule sums_unique)
  1360 apply (auto simp del: fact_Suc realpow_Suc)
  1361 apply (rule_tac n1 = 0 in series_pos_less [THEN [2] order_le_less_trans])
  1362 apply (auto simp del: fact_Suc realpow_Suc)
  1363 apply (erule sums_summable)
  1364 apply (case_tac "m=0")
  1365 apply (simp (no_asm_simp))
  1366 apply (subgoal_tac "6 * (x * (x * x) / real (Suc (Suc (Suc (Suc (Suc (Suc 0))))))) < 6 * x")
  1367 apply (simp only: mult_less_cancel_left, simp)
  1368 apply (simp (no_asm_simp) add: numeral_2_eq_2 [symmetric] mult_assoc [symmetric])
  1369 apply (subgoal_tac "x*x < 2*3", simp) 
  1370 apply (rule mult_strict_mono)
  1371 apply (auto simp add: real_of_nat_Suc simp del: fact_Suc)
  1372 apply (subst fact_Suc)
  1373 apply (subst fact_Suc)
  1374 apply (subst fact_Suc)
  1375 apply (subst fact_Suc)
  1376 apply (subst real_of_nat_mult)
  1377 apply (subst real_of_nat_mult)
  1378 apply (subst real_of_nat_mult)
  1379 apply (subst real_of_nat_mult)
  1380 apply (simp (no_asm) add: divide_inverse inverse_mult_distrib del: fact_Suc)
  1381 apply (auto simp add: mult_assoc [symmetric] simp del: fact_Suc)
  1382 apply (rule_tac c="real (Suc (Suc (4*m)))" in mult_less_imp_less_right) 
  1383 apply (auto simp add: mult_assoc simp del: fact_Suc)
  1384 apply (rule_tac c="real (Suc (Suc (Suc (4*m))))" in mult_less_imp_less_right) 
  1385 apply (auto simp add: mult_assoc mult_less_cancel_left simp del: fact_Suc)
  1386 apply (subgoal_tac "x * (x * x ^ (4*m)) = (x ^ (4*m)) * (x * x)") 
  1387 apply (erule ssubst)+
  1388 apply (auto simp del: fact_Suc)
  1389 apply (subgoal_tac "0 < x ^ (4 * m) ")
  1390  prefer 2 apply (simp only: zero_less_power) 
  1391 apply (simp (no_asm_simp) add: mult_less_cancel_left)
  1392 apply (rule mult_strict_mono)
  1393 apply (simp_all (no_asm_simp))
  1394 done
  1395 
  1396 lemma sin_gt_zero1: "[|0 < x; x < 2 |] ==> 0 < sin x"
  1397 by (auto intro: sin_gt_zero)
  1398 
  1399 lemma cos_double_less_one: "[| 0 < x; x < 2 |] ==> cos (2 * x) < 1"
  1400 apply (cut_tac x = x in sin_gt_zero1)
  1401 apply (auto simp add: cos_squared_eq cos_double)
  1402 done
  1403 
  1404 lemma cos_paired:
  1405      "(%n. (- 1) ^ n /(real (fact (2 * n))) * x ^ (2 * n)) sums cos x"
  1406 proof -
  1407   have "(\<lambda>n. \<Sum>k = n * 2..<n * 2 + 2.
  1408             (if even k then (- 1) ^ (k div 2) / real (fact k) else 0) *
  1409             x ^ k) 
  1410         sums
  1411 	suminf
  1412 	 (\<lambda>n. (if even n then (- 1) ^ (n div 2) / real (fact n) else 0) *
  1413 	      x ^ n)" 
  1414     by (rule cos_converges [THEN sums_summable, THEN sums_group], simp) 
  1415   thus ?thesis by (simp add: mult_ac cos_def)
  1416 qed
  1417 
  1418 declare zero_less_power [simp]
  1419 
  1420 lemma fact_lemma: "real (n::nat) * 4 = real (4 * n)"
  1421 by simp
  1422 
  1423 lemma cos_two_less_zero: "cos (2) < 0"
  1424 apply (cut_tac x = 2 in cos_paired)
  1425 apply (drule sums_minus)
  1426 apply (rule neg_less_iff_less [THEN iffD1]) 
  1427 apply (frule sums_unique, auto)
  1428 apply (rule_tac y = "sumr 0 (Suc (Suc (Suc 0))) (%n. - ((- 1) ^ n / (real (fact (2 * n))) * 2 ^ (2 * n))) " in order_less_trans)
  1429 apply (simp (no_asm) add: fact_num_eq_if realpow_num_eq_if del: fact_Suc realpow_Suc)
  1430 apply (simp (no_asm) add: mult_assoc del: sumr_Suc)
  1431 apply (rule sumr_pos_lt_pair)
  1432 apply (erule sums_summable, safe)
  1433 apply (simp (no_asm) add: divide_inverse mult_assoc [symmetric] del: fact_Suc)
  1434 apply (rule real_mult_inverse_cancel2)
  1435 apply (rule real_of_nat_fact_gt_zero)+
  1436 apply (simp (no_asm) add: mult_assoc [symmetric] del: fact_Suc)
  1437 apply (subst fact_lemma) 
  1438 apply (subst fact_Suc)
  1439 apply (subst real_of_nat_mult)
  1440 apply (erule ssubst, subst real_of_nat_mult)
  1441 apply (rule real_mult_less_mono, force)
  1442 prefer 2 apply force
  1443 apply (rule_tac [2] real_of_nat_fact_gt_zero)
  1444 apply (rule real_of_nat_less_iff [THEN iffD2])
  1445 apply (rule fact_less_mono, auto)
  1446 done
  1447 declare cos_two_less_zero [simp]
  1448 declare cos_two_less_zero [THEN real_not_refl2, simp]
  1449 declare cos_two_less_zero [THEN order_less_imp_le, simp]
  1450 
  1451 lemma cos_is_zero: "EX! x. 0 \<le> x & x \<le> 2 & cos x = 0"
  1452 apply (subgoal_tac "\<exists>x. 0 \<le> x & x \<le> 2 & cos x = 0")
  1453 apply (rule_tac [2] IVT2)
  1454 apply (auto intro: DERIV_isCont DERIV_cos)
  1455 apply (cut_tac x = xa and y = y in linorder_less_linear)
  1456 apply (rule ccontr)
  1457 apply (subgoal_tac " (\<forall>x. cos differentiable x) & (\<forall>x. isCont cos x) ")
  1458 apply (auto intro: DERIV_cos DERIV_isCont simp add: differentiable_def)
  1459 apply (drule_tac f = cos in Rolle)
  1460 apply (drule_tac [5] f = cos in Rolle)
  1461 apply (auto dest!: DERIV_cos [THEN DERIV_unique] simp add: differentiable_def)
  1462 apply (drule_tac y1 = xa in order_le_less_trans [THEN sin_gt_zero])
  1463 apply (assumption, rule_tac y=y in order_less_le_trans, simp_all) 
  1464 apply (drule_tac y1 = y in order_le_less_trans [THEN sin_gt_zero], assumption, simp_all) 
  1465 done
  1466     
  1467 lemma pi_half: "pi/2 = (@x. 0 \<le> x & x \<le> 2 & cos x = 0)"
  1468 by (simp add: pi_def)
  1469 
  1470 lemma cos_pi_half [simp]: "cos (pi / 2) = 0"
  1471 apply (rule cos_is_zero [THEN ex1E])
  1472 apply (auto intro!: someI2 simp add: pi_half)
  1473 done
  1474 
  1475 lemma pi_half_gt_zero: "0 < pi / 2"
  1476 apply (rule cos_is_zero [THEN ex1E])
  1477 apply (auto simp add: pi_half)
  1478 apply (rule someI2, blast, safe)
  1479 apply (drule_tac y = xa in real_le_imp_less_or_eq)
  1480 apply (safe, simp)
  1481 done
  1482 declare pi_half_gt_zero [simp]
  1483 declare pi_half_gt_zero [THEN real_not_refl2, THEN not_sym, simp]
  1484 declare pi_half_gt_zero [THEN order_less_imp_le, simp]
  1485 
  1486 lemma pi_half_less_two: "pi / 2 < 2"
  1487 apply (rule cos_is_zero [THEN ex1E])
  1488 apply (auto simp add: pi_half)
  1489 apply (rule someI2, blast, safe)
  1490 apply (drule_tac x = xa in order_le_imp_less_or_eq)
  1491 apply (safe, simp)
  1492 done
  1493 declare pi_half_less_two [simp]
  1494 declare pi_half_less_two [THEN real_not_refl2, simp]
  1495 declare pi_half_less_two [THEN order_less_imp_le, simp]
  1496 
  1497 lemma pi_gt_zero [simp]: "0 < pi"
  1498 apply (rule_tac c="inverse 2" in mult_less_imp_less_right) 
  1499 apply (cut_tac pi_half_gt_zero, simp_all)
  1500 done
  1501 
  1502 lemma pi_neq_zero [simp]: "pi \<noteq> 0"
  1503 by (rule pi_gt_zero [THEN real_not_refl2, THEN not_sym])
  1504 
  1505 lemma pi_not_less_zero [simp]: "~ (pi < 0)"
  1506 apply (insert pi_gt_zero)
  1507 apply (blast elim: order_less_asym) 
  1508 done
  1509 
  1510 lemma pi_ge_zero [simp]: "0 \<le> pi"
  1511 by (auto intro: order_less_imp_le)
  1512 
  1513 lemma minus_pi_half_less_zero [simp]: "-(pi/2) < 0"
  1514 by auto
  1515 
  1516 lemma sin_pi_half [simp]: "sin(pi/2) = 1"
  1517 apply (cut_tac x = "pi/2" in sin_cos_squared_add2)
  1518 apply (cut_tac sin_gt_zero [OF pi_half_gt_zero pi_half_less_two])
  1519 apply (auto simp add: numeral_2_eq_2)
  1520 done
  1521 
  1522 lemma cos_pi [simp]: "cos pi = -1"
  1523 by (cut_tac x = "pi/2" and y = "pi/2" in cos_add, simp)
  1524 
  1525 lemma sin_pi [simp]: "sin pi = 0"
  1526 by (cut_tac x = "pi/2" and y = "pi/2" in sin_add, simp)
  1527 
  1528 lemma sin_cos_eq: "sin x = cos (pi/2 - x)"
  1529 apply (unfold real_diff_def)
  1530 apply (simp (no_asm) add: cos_add)
  1531 done
  1532 
  1533 lemma minus_sin_cos_eq: "-sin x = cos (x + pi/2)"
  1534 apply (simp (no_asm) add: cos_add)
  1535 done
  1536 declare minus_sin_cos_eq [symmetric, simp]
  1537 
  1538 lemma cos_sin_eq: "cos x = sin (pi/2 - x)"
  1539 apply (unfold real_diff_def)
  1540 apply (simp (no_asm) add: sin_add)
  1541 done
  1542 declare sin_cos_eq [symmetric, simp] cos_sin_eq [symmetric, simp]
  1543 
  1544 lemma sin_periodic_pi [simp]: "sin (x + pi) = - sin x"
  1545 apply (simp (no_asm) add: sin_add)
  1546 done
  1547 
  1548 lemma sin_periodic_pi2 [simp]: "sin (pi + x) = - sin x"
  1549 apply (simp (no_asm) add: sin_add)
  1550 done
  1551 
  1552 lemma cos_periodic_pi [simp]: "cos (x + pi) = - cos x"
  1553 apply (simp (no_asm) add: cos_add)
  1554 done
  1555 
  1556 lemma sin_periodic [simp]: "sin (x + 2*pi) = sin x"
  1557 by (simp add: sin_add cos_double)
  1558 
  1559 lemma cos_periodic [simp]: "cos (x + 2*pi) = cos x"
  1560 by (simp add: cos_add cos_double)
  1561 
  1562 lemma cos_npi [simp]: "cos (real n * pi) = -1 ^ n"
  1563 apply (induct_tac "n")
  1564 apply (auto simp add: real_of_nat_Suc left_distrib)
  1565 done
  1566 
  1567 lemma sin_npi [simp]: "sin (real (n::nat) * pi) = 0"
  1568 apply (induct_tac "n")
  1569 apply (auto simp add: real_of_nat_Suc left_distrib)
  1570 done
  1571 
  1572 lemma sin_npi2 [simp]: "sin (pi * real (n::nat)) = 0"
  1573 apply (cut_tac n = n in sin_npi)
  1574 apply (auto simp add: mult_commute simp del: sin_npi)
  1575 done
  1576 
  1577 lemma cos_two_pi [simp]: "cos (2 * pi) = 1"
  1578 by (simp add: cos_double)
  1579 
  1580 lemma sin_two_pi [simp]: "sin (2 * pi) = 0"
  1581 apply (simp (no_asm))
  1582 done
  1583 
  1584 lemma sin_gt_zero2: "[| 0 < x; x < pi/2 |] ==> 0 < sin x"
  1585 apply (rule sin_gt_zero, assumption)
  1586 apply (rule order_less_trans, assumption)
  1587 apply (rule pi_half_less_two)
  1588 done
  1589 
  1590 lemma sin_less_zero: 
  1591   assumes lb: "- pi/2 < x" and "x < 0" shows "sin x < 0"
  1592 proof -
  1593   have "0 < sin (- x)" using prems by (simp only: sin_gt_zero2) 
  1594   thus ?thesis by simp
  1595 qed
  1596 
  1597 lemma pi_less_4: "pi < 4"
  1598 by (cut_tac pi_half_less_two, auto)
  1599 
  1600 lemma cos_gt_zero: "[| 0 < x; x < pi/2 |] ==> 0 < cos x"
  1601 apply (cut_tac pi_less_4)
  1602 apply (cut_tac f = cos and a = 0 and b = x and y = 0 in IVT2_objl, safe, simp_all)
  1603 apply (force intro: DERIV_isCont DERIV_cos)
  1604 apply (cut_tac cos_is_zero, safe)
  1605 apply (rename_tac y z)
  1606 apply (drule_tac x = y in spec)
  1607 apply (drule_tac x = "pi/2" in spec, simp) 
  1608 done
  1609 
  1610 lemma cos_gt_zero_pi: "[| -(pi/2) < x; x < pi/2 |] ==> 0 < cos x"
  1611 apply (rule_tac x = x and y = 0 in linorder_cases)
  1612 apply (rule cos_minus [THEN subst])
  1613 apply (rule cos_gt_zero)
  1614 apply (auto intro: cos_gt_zero)
  1615 done
  1616  
  1617 lemma cos_ge_zero: "[| -(pi/2) \<le> x; x \<le> pi/2 |] ==> 0 \<le> cos x"
  1618 apply (auto simp add: order_le_less cos_gt_zero_pi)
  1619 apply (subgoal_tac "x = pi/2", auto) 
  1620 done
  1621 
  1622 lemma sin_gt_zero_pi: "[| 0 < x; x < pi  |] ==> 0 < sin x"
  1623 apply (subst sin_cos_eq)
  1624 apply (rotate_tac 1)
  1625 apply (drule real_sum_of_halves [THEN ssubst])
  1626 apply (auto intro!: cos_gt_zero_pi simp del: sin_cos_eq [symmetric])
  1627 done
  1628 
  1629 lemma sin_ge_zero: "[| 0 \<le> x; x \<le> pi |] ==> 0 \<le> sin x"
  1630 by (auto simp add: order_le_less sin_gt_zero_pi)
  1631 
  1632 lemma cos_total: "[| -1 \<le> y; y \<le> 1 |] ==> EX! x. 0 \<le> x & x \<le> pi & (cos x = y)"
  1633 apply (subgoal_tac "\<exists>x. 0 \<le> x & x \<le> pi & cos x = y")
  1634 apply (rule_tac [2] IVT2)
  1635 apply (auto intro: order_less_imp_le DERIV_isCont DERIV_cos)
  1636 apply (cut_tac x = xa and y = y in linorder_less_linear)
  1637 apply (rule ccontr, auto)
  1638 apply (drule_tac f = cos in Rolle)
  1639 apply (drule_tac [5] f = cos in Rolle)
  1640 apply (auto intro: order_less_imp_le DERIV_isCont DERIV_cos
  1641             dest!: DERIV_cos [THEN DERIV_unique] 
  1642             simp add: differentiable_def)
  1643 apply (auto dest: sin_gt_zero_pi [OF order_le_less_trans order_less_le_trans])
  1644 done
  1645 
  1646 lemma sin_total:
  1647      "[| -1 \<le> y; y \<le> 1 |] ==> EX! x. -(pi/2) \<le> x & x \<le> pi/2 & (sin x = y)"
  1648 apply (rule ccontr)
  1649 apply (subgoal_tac "\<forall>x. (- (pi/2) \<le> x & x \<le> pi/2 & (sin x = y)) = (0 \<le> (x + pi/2) & (x + pi/2) \<le> pi & (cos (x + pi/2) = -y))")
  1650 apply (erule swap)
  1651 apply (simp del: minus_sin_cos_eq [symmetric])
  1652 apply (cut_tac y="-y" in cos_total, simp) apply simp 
  1653 apply (erule ex1E)
  1654 apply (rule_tac a = "x - (pi/2) " in ex1I)
  1655 apply (simp (no_asm) add: real_add_assoc)
  1656 apply (rotate_tac 3)
  1657 apply (drule_tac x = "xa + pi/2" in spec, safe, simp_all) 
  1658 done
  1659 
  1660 lemma reals_Archimedean4:
  1661      "[| 0 < y; 0 \<le> x |] ==> \<exists>n. real n * y \<le> x & x < real (Suc n) * y"
  1662 apply (auto dest!: reals_Archimedean3)
  1663 apply (drule_tac x = x in spec, clarify) 
  1664 apply (subgoal_tac "x < real(LEAST m::nat. x < real m * y) * y")
  1665  prefer 2 apply (erule LeastI) 
  1666 apply (case_tac "LEAST m::nat. x < real m * y", simp) 
  1667 apply (subgoal_tac "~ x < real nat * y")
  1668  prefer 2 apply (rule not_less_Least, simp, force)  
  1669 done
  1670 
  1671 (* Pre Isabelle99-2 proof was simpler- numerals arithmetic 
  1672    now causes some unwanted re-arrangements of literals!   *)
  1673 lemma cos_zero_lemma: "[| 0 \<le> x; cos x = 0 |] ==>  
  1674       \<exists>n::nat. ~even n & x = real n * (pi/2)"
  1675 apply (drule pi_gt_zero [THEN reals_Archimedean4], safe)
  1676 apply (subgoal_tac "0 \<le> x - real n * pi & (x - real n * pi) \<le> pi & (cos (x - real n * pi) = 0) ")
  1677 apply safe
  1678   prefer 3 apply (simp add: cos_diff) 
  1679  prefer 2 apply (simp add: real_of_nat_Suc left_distrib) 
  1680 apply (simp add: cos_diff)
  1681 apply (subgoal_tac "EX! x. 0 \<le> x & x \<le> pi & cos x = 0")
  1682 apply (rule_tac [2] cos_total, safe)
  1683 apply (drule_tac x = "x - real n * pi" in spec)
  1684 apply (drule_tac x = "pi/2" in spec)
  1685 apply (simp add: cos_diff)
  1686 apply (rule_tac x = "Suc (2 * n) " in exI)
  1687 apply (simp add: real_of_nat_Suc left_distrib, auto)
  1688 done
  1689 
  1690 lemma sin_zero_lemma: "[| 0 \<le> x; sin x = 0 |] ==>  
  1691       \<exists>n::nat. even n & x = real n * (pi/2)"
  1692 apply (subgoal_tac "\<exists>n::nat. ~ even n & x + pi/2 = real n * (pi/2) ")
  1693  apply (clarify, rule_tac x = "n - 1" in exI)
  1694  apply (force simp add: odd_Suc_mult_two_ex real_of_nat_Suc left_distrib)
  1695 apply (rule cos_zero_lemma, clarify) 
  1696 apply (rule minus_le_iff [THEN iffD1])  
  1697 apply (rule_tac y=0 in order_trans, auto)
  1698 done
  1699 
  1700 
  1701 (* also spoilt by numeral arithmetic *)
  1702 lemma cos_zero_iff: "(cos x = 0) =  
  1703       ((\<exists>n::nat. ~even n & (x = real n * (pi/2))) |    
  1704        (\<exists>n::nat. ~even n & (x = -(real n * (pi/2)))))"
  1705 apply (rule iffI)
  1706 apply (cut_tac linorder_linear [of 0 x], safe)
  1707 apply (drule cos_zero_lemma, assumption+)
  1708 apply (cut_tac x="-x" in cos_zero_lemma, simp, simp) 
  1709 apply (force simp add: minus_equation_iff [of x]) 
  1710 apply (auto simp only: odd_Suc_mult_two_ex real_of_nat_Suc left_distrib) 
  1711 apply (auto simp add: cos_add)
  1712 done
  1713 
  1714 (* ditto: but to a lesser extent *)
  1715 lemma sin_zero_iff: "(sin x = 0) =  
  1716       ((\<exists>n::nat. even n & (x = real n * (pi/2))) |    
  1717        (\<exists>n::nat. even n & (x = -(real n * (pi/2)))))"
  1718 apply (rule iffI)
  1719 apply (cut_tac linorder_linear [of 0 x], safe)
  1720 apply (drule sin_zero_lemma, assumption+)
  1721 apply (cut_tac x="-x" in sin_zero_lemma, simp, simp, safe)
  1722 apply (force simp add: minus_equation_iff [of x]) 
  1723 apply (auto simp add: even_mult_two_ex)
  1724 done
  1725 
  1726 
  1727 subsection{*Tangent*}
  1728 
  1729 lemma tan_zero [simp]: "tan 0 = 0"
  1730 by (simp add: tan_def)
  1731 
  1732 lemma tan_pi [simp]: "tan pi = 0"
  1733 by (simp add: tan_def)
  1734 
  1735 lemma tan_npi [simp]: "tan (real (n::nat) * pi) = 0"
  1736 by (simp add: tan_def)
  1737 
  1738 lemma tan_minus [simp]: "tan (-x) = - tan x"
  1739 by (simp add: tan_def minus_mult_left)
  1740 
  1741 lemma tan_periodic [simp]: "tan (x + 2*pi) = tan x"
  1742 by (simp add: tan_def)
  1743 
  1744 lemma lemma_tan_add1: 
  1745       "[| cos x \<noteq> 0; cos y \<noteq> 0 |]  
  1746         ==> 1 - tan(x)*tan(y) = cos (x + y)/(cos x * cos y)"
  1747 apply (unfold tan_def real_divide_def)
  1748 apply (auto simp del: inverse_mult_distrib simp add: inverse_mult_distrib [symmetric] mult_ac)
  1749 apply (rule_tac c1 = "cos x * cos y" in real_mult_right_cancel [THEN subst])
  1750 apply (auto simp del: inverse_mult_distrib simp add: mult_assoc left_diff_distrib cos_add)
  1751 done
  1752 
  1753 lemma add_tan_eq: 
  1754       "[| cos x \<noteq> 0; cos y \<noteq> 0 |]  
  1755        ==> tan x + tan y = sin(x + y)/(cos x * cos y)"
  1756 apply (unfold tan_def)
  1757 apply (rule_tac c1 = "cos x * cos y" in real_mult_right_cancel [THEN subst])
  1758 apply (auto simp add: mult_assoc left_distrib)
  1759 apply (simp (no_asm) add: sin_add)
  1760 done
  1761 
  1762 lemma tan_add: "[| cos x \<noteq> 0; cos y \<noteq> 0; cos (x + y) \<noteq> 0 |]  
  1763       ==> tan(x + y) = (tan(x) + tan(y))/(1 - tan(x) * tan(y))"
  1764 apply (simp (no_asm_simp) add: add_tan_eq lemma_tan_add1)
  1765 apply (simp add: tan_def)
  1766 done
  1767 
  1768 lemma tan_double: "[| cos x \<noteq> 0; cos (2 * x) \<noteq> 0 |]  
  1769       ==> tan (2 * x) = (2 * tan x)/(1 - (tan(x) ^ 2))"
  1770 apply (insert tan_add [of x x]) 
  1771 apply (simp add: mult_2 [symmetric])  
  1772 apply (auto simp add: numeral_2_eq_2)
  1773 done
  1774 
  1775 lemma tan_gt_zero: "[| 0 < x; x < pi/2 |] ==> 0 < tan x"
  1776 apply (unfold tan_def real_divide_def)
  1777 apply (auto intro!: sin_gt_zero2 cos_gt_zero_pi intro!: real_mult_order positive_imp_inverse_positive)
  1778 done
  1779 
  1780 lemma tan_less_zero: 
  1781   assumes lb: "- pi/2 < x" and "x < 0" shows "tan x < 0"
  1782 proof -
  1783   have "0 < tan (- x)" using prems by (simp only: tan_gt_zero) 
  1784   thus ?thesis by simp
  1785 qed
  1786 
  1787 lemma lemma_DERIV_tan:
  1788      "cos x \<noteq> 0 ==> DERIV (%x. sin(x)/cos(x)) x :> inverse((cos x)\<twosuperior>)"
  1789 apply (rule lemma_DERIV_subst)
  1790 apply (best intro!: DERIV_intros intro: DERIV_chain2) 
  1791 apply (auto simp add: divide_inverse numeral_2_eq_2)
  1792 done
  1793 
  1794 lemma DERIV_tan [simp]: "cos x \<noteq> 0 ==> DERIV tan x :> inverse((cos x)\<twosuperior>)"
  1795 by (auto dest: lemma_DERIV_tan simp add: tan_def [symmetric])
  1796 
  1797 lemma LIM_cos_div_sin [simp]: "(%x. cos(x)/sin(x)) -- pi/2 --> 0"
  1798 apply (unfold real_divide_def)
  1799 apply (subgoal_tac "(\<lambda>x. cos x * inverse (sin x)) -- pi * inverse 2 --> 0*1")
  1800 apply simp 
  1801 apply (rule LIM_mult2)
  1802 apply (rule_tac [2] inverse_1 [THEN subst])
  1803 apply (rule_tac [2] LIM_inverse)
  1804 apply (simp_all add: divide_inverse [symmetric]) 
  1805 apply (simp_all only: isCont_def [symmetric] cos_pi_half [symmetric] sin_pi_half [symmetric]) 
  1806 apply (blast intro!: DERIV_isCont DERIV_sin DERIV_cos)+
  1807 done
  1808 
  1809 lemma lemma_tan_total: "0 < y ==> \<exists>x. 0 < x & x < pi/2 & y < tan x"
  1810 apply (cut_tac LIM_cos_div_sin)
  1811 apply (simp only: LIM_def)
  1812 apply (drule_tac x = "inverse y" in spec, safe, force)
  1813 apply (drule_tac ?d1.0 = s in pi_half_gt_zero [THEN [2] real_lbound_gt_zero], safe)
  1814 apply (rule_tac x = " (pi/2) - e" in exI)
  1815 apply (simp (no_asm_simp))
  1816 apply (drule_tac x = " (pi/2) - e" in spec)
  1817 apply (auto simp add: abs_eqI2 tan_def)
  1818 apply (rule inverse_less_iff_less [THEN iffD1])
  1819 apply (auto simp add: divide_inverse)
  1820 apply (rule real_mult_order)
  1821 apply (subgoal_tac [3] "0 < sin e")
  1822 apply (subgoal_tac [3] "0 < cos e")
  1823 apply (auto intro: cos_gt_zero sin_gt_zero2 simp add: inverse_mult_distrib abs_mult)
  1824 apply (drule_tac a = "cos e" in positive_imp_inverse_positive)
  1825 apply (drule_tac x = "inverse (cos e) " in abs_eqI2)
  1826 apply (auto dest!: abs_eqI2 simp add: mult_ac)
  1827 done
  1828 
  1829 lemma tan_total_pos: "0 \<le> y ==> \<exists>x. 0 \<le> x & x < pi/2 & tan x = y"
  1830 apply (frule real_le_imp_less_or_eq, safe)
  1831  prefer 2 apply force
  1832 apply (drule lemma_tan_total, safe)
  1833 apply (cut_tac f = tan and a = 0 and b = x and y = y in IVT_objl)
  1834 apply (auto intro!: DERIV_tan [THEN DERIV_isCont])
  1835 apply (drule_tac y = xa in order_le_imp_less_or_eq)
  1836 apply (auto dest: cos_gt_zero)
  1837 done
  1838 
  1839 lemma lemma_tan_total1: "\<exists>x. -(pi/2) < x & x < (pi/2) & tan x = y"
  1840 apply (cut_tac linorder_linear [of 0 y], safe)
  1841 apply (drule tan_total_pos)
  1842 apply (cut_tac [2] y="-y" in tan_total_pos, safe)
  1843 apply (rule_tac [3] x = "-x" in exI)
  1844 apply (auto intro!: exI)
  1845 done
  1846 
  1847 lemma tan_total: "EX! x. -(pi/2) < x & x < (pi/2) & tan x = y"
  1848 apply (cut_tac y = y in lemma_tan_total1, auto)
  1849 apply (cut_tac x = xa and y = y in linorder_less_linear, auto)
  1850 apply (subgoal_tac [2] "\<exists>z. y < z & z < xa & DERIV tan z :> 0")
  1851 apply (subgoal_tac "\<exists>z. xa < z & z < y & DERIV tan z :> 0")
  1852 apply (rule_tac [4] Rolle)
  1853 apply (rule_tac [2] Rolle)
  1854 apply (auto intro!: DERIV_tan DERIV_isCont exI 
  1855             simp add: differentiable_def)
  1856 txt{*Now, simulate TRYALL*}
  1857 apply (rule_tac [!] DERIV_tan asm_rl)
  1858 apply (auto dest!: DERIV_unique [OF _ DERIV_tan]
  1859 	    simp add: cos_gt_zero_pi [THEN real_not_refl2, THEN not_sym]) 
  1860 done
  1861 
  1862 lemma arcsin_pi: "[| -1 \<le> y; y \<le> 1 |]  
  1863       ==> -(pi/2) \<le> arcsin y & arcsin y \<le> pi & sin(arcsin y) = y"
  1864 apply (drule sin_total, assumption)
  1865 apply (erule ex1E)
  1866 apply (unfold arcsin_def)
  1867 apply (rule someI2, blast) 
  1868 apply (force intro: order_trans) 
  1869 done
  1870 
  1871 lemma arcsin: "[| -1 \<le> y; y \<le> 1 |]  
  1872       ==> -(pi/2) \<le> arcsin y &  
  1873            arcsin y \<le> pi/2 & sin(arcsin y) = y"
  1874 apply (unfold arcsin_def)
  1875 apply (drule sin_total, assumption)
  1876 apply (fast intro: someI2)
  1877 done
  1878 
  1879 lemma sin_arcsin [simp]: "[| -1 \<le> y; y \<le> 1 |] ==> sin(arcsin y) = y"
  1880 by (blast dest: arcsin)
  1881       
  1882 lemma arcsin_bounded:
  1883      "[| -1 \<le> y; y \<le> 1 |] ==> -(pi/2) \<le> arcsin y & arcsin y \<le> pi/2"
  1884 by (blast dest: arcsin)
  1885 
  1886 lemma arcsin_lbound: "[| -1 \<le> y; y \<le> 1 |] ==> -(pi/2) \<le> arcsin y"
  1887 by (blast dest: arcsin)
  1888 
  1889 lemma arcsin_ubound: "[| -1 \<le> y; y \<le> 1 |] ==> arcsin y \<le> pi/2"
  1890 by (blast dest: arcsin)
  1891 
  1892 lemma arcsin_lt_bounded:
  1893      "[| -1 < y; y < 1 |] ==> -(pi/2) < arcsin y & arcsin y < pi/2"
  1894 apply (frule order_less_imp_le)
  1895 apply (frule_tac y = y in order_less_imp_le)
  1896 apply (frule arcsin_bounded)
  1897 apply (safe, simp)
  1898 apply (drule_tac y = "arcsin y" in order_le_imp_less_or_eq)
  1899 apply (drule_tac [2] y = "pi/2" in order_le_imp_less_or_eq, safe)
  1900 apply (drule_tac [!] f = sin in arg_cong, auto)
  1901 done
  1902 
  1903 lemma arcsin_sin: "[|-(pi/2) \<le> x; x \<le> pi/2 |] ==> arcsin(sin x) = x"
  1904 apply (unfold arcsin_def)
  1905 apply (rule some1_equality)
  1906 apply (rule sin_total, auto)
  1907 done
  1908 
  1909 lemma arcos: "[| -1 \<le> y; y \<le> 1 |]  
  1910       ==> 0 \<le> arcos y & arcos y \<le> pi & cos(arcos y) = y"
  1911 apply (unfold arcos_def)
  1912 apply (drule cos_total, assumption)
  1913 apply (fast intro: someI2)
  1914 done
  1915 
  1916 lemma cos_arcos [simp]: "[| -1 \<le> y; y \<le> 1 |] ==> cos(arcos y) = y"
  1917 by (blast dest: arcos)
  1918       
  1919 lemma arcos_bounded: "[| -1 \<le> y; y \<le> 1 |] ==> 0 \<le> arcos y & arcos y \<le> pi"
  1920 by (blast dest: arcos)
  1921 
  1922 lemma arcos_lbound: "[| -1 \<le> y; y \<le> 1 |] ==> 0 \<le> arcos y"
  1923 by (blast dest: arcos)
  1924 
  1925 lemma arcos_ubound: "[| -1 \<le> y; y \<le> 1 |] ==> arcos y \<le> pi"
  1926 by (blast dest: arcos)
  1927 
  1928 lemma arcos_lt_bounded: "[| -1 < y; y < 1 |]  
  1929       ==> 0 < arcos y & arcos y < pi"
  1930 apply (frule order_less_imp_le)
  1931 apply (frule_tac y = y in order_less_imp_le)
  1932 apply (frule arcos_bounded, auto)
  1933 apply (drule_tac y = "arcos y" in order_le_imp_less_or_eq)
  1934 apply (drule_tac [2] y = pi in order_le_imp_less_or_eq, auto)
  1935 apply (drule_tac [!] f = cos in arg_cong, auto)
  1936 done
  1937 
  1938 lemma arcos_cos: "[|0 \<le> x; x \<le> pi |] ==> arcos(cos x) = x"
  1939 apply (unfold arcos_def)
  1940 apply (auto intro!: some1_equality cos_total)
  1941 done
  1942 
  1943 lemma arcos_cos2: "[|x \<le> 0; -pi \<le> x |] ==> arcos(cos x) = -x"
  1944 apply (unfold arcos_def)
  1945 apply (auto intro!: some1_equality cos_total)
  1946 done
  1947 
  1948 lemma arctan [simp]:
  1949      "- (pi/2) < arctan y  & arctan y < pi/2 & tan (arctan y) = y"
  1950 apply (cut_tac y = y in tan_total)
  1951 apply (unfold arctan_def)
  1952 apply (fast intro: someI2)
  1953 done
  1954 
  1955 lemma tan_arctan: "tan(arctan y) = y"
  1956 by auto
  1957 
  1958 lemma arctan_bounded: "- (pi/2) < arctan y  & arctan y < pi/2"
  1959 by (auto simp only: arctan)
  1960 
  1961 lemma arctan_lbound: "- (pi/2) < arctan y"
  1962 by auto
  1963 
  1964 lemma arctan_ubound: "arctan y < pi/2"
  1965 by (auto simp only: arctan)
  1966 
  1967 lemma arctan_tan: 
  1968       "[|-(pi/2) < x; x < pi/2 |] ==> arctan(tan x) = x"
  1969 apply (unfold arctan_def)
  1970 apply (rule some1_equality)
  1971 apply (rule tan_total, auto)
  1972 done
  1973 
  1974 lemma arctan_zero_zero [simp]: "arctan 0 = 0"
  1975 by (insert arctan_tan [of 0], simp)
  1976 
  1977 lemma cos_arctan_not_zero [simp]: "cos(arctan x) \<noteq> 0"
  1978 apply (auto simp add: cos_zero_iff)
  1979 apply (case_tac "n")
  1980 apply (case_tac [3] "n")
  1981 apply (cut_tac [2] y = x in arctan_ubound)
  1982 apply (cut_tac [4] y = x in arctan_lbound) 
  1983 apply (auto simp add: real_of_nat_Suc left_distrib mult_less_0_iff)
  1984 done
  1985 
  1986 lemma tan_sec: "cos x \<noteq> 0 ==> 1 + tan(x) ^ 2 = inverse(cos x) ^ 2"
  1987 apply (rule power_inverse [THEN subst])
  1988 apply (rule_tac c1 = "(cos x)\<twosuperior>" in real_mult_right_cancel [THEN iffD1])
  1989 apply (auto dest: realpow_not_zero 
  1990         simp add: power_mult_distrib left_distrib realpow_divide tan_def 
  1991                   mult_assoc power_inverse [symmetric] 
  1992         simp del: realpow_Suc)
  1993 done
  1994 
  1995 lemma lemma_sin_cos_eq [simp]: "sin (xa + 1 / 2 * real (Suc m) * pi) =  
  1996       cos (xa + 1 / 2 * real  (m) * pi)"
  1997 apply (simp only: cos_add sin_add real_of_nat_Suc left_distrib right_distrib, auto)
  1998 done
  1999 
  2000 lemma lemma_sin_cos_eq2 [simp]: "sin (xa + real (Suc m) * pi / 2) =  
  2001       cos (xa + real (m) * pi / 2)"
  2002 apply (simp only: cos_add sin_add divide_inverse real_of_nat_Suc left_distrib right_distrib, auto)
  2003 done
  2004 
  2005 lemma DERIV_sin_add [simp]: "DERIV (%x. sin (x + k)) xa :> cos (xa + k)"
  2006 apply (rule lemma_DERIV_subst)
  2007 apply (rule_tac f = sin and g = "%x. x + k" in DERIV_chain2)
  2008 apply (best intro!: DERIV_intros intro: DERIV_chain2)+
  2009 apply (simp (no_asm))
  2010 done
  2011 
  2012 (* which further simplifies to (- 1 ^ m) !! *)
  2013 lemma sin_cos_npi [simp]: "sin ((real m + 1/2) * pi) = cos (real m * pi)"
  2014 by (auto simp add: right_distrib sin_add left_distrib mult_ac)
  2015 
  2016 lemma sin_cos_npi2 [simp]: "sin (real (Suc (2 * n)) * pi / 2) = (-1) ^ n"
  2017 apply (cut_tac m = n in sin_cos_npi)
  2018 apply (simp only: real_of_nat_Suc left_distrib divide_inverse, auto)
  2019 done
  2020 
  2021 lemma cos_2npi [simp]: "cos (2 * real (n::nat) * pi) = 1"
  2022 by (simp add: cos_double mult_assoc power_add [symmetric] numeral_2_eq_2)
  2023 
  2024 lemma cos_3over2_pi [simp]: "cos (3 / 2 * pi) = 0"
  2025 apply (subgoal_tac "3/2 = (1+1 / 2::real)")
  2026 apply (simp only: left_distrib) 
  2027 apply (auto simp add: cos_add mult_ac)
  2028 done
  2029 
  2030 lemma sin_2npi [simp]: "sin (2 * real (n::nat) * pi) = 0"
  2031 by (auto simp add: mult_assoc)
  2032 
  2033 lemma sin_3over2_pi [simp]: "sin (3 / 2 * pi) = - 1"
  2034 apply (subgoal_tac "3/2 = (1+1 / 2::real)")
  2035 apply (simp only: left_distrib) 
  2036 apply (auto simp add: sin_add mult_ac)
  2037 done
  2038 
  2039 (*NEEDED??*)
  2040 lemma [simp]: "cos(x + 1 / 2 * real(Suc m) * pi) = -sin (x + 1 / 2 * real m * pi)"
  2041 apply (simp only: cos_add sin_add real_of_nat_Suc right_distrib left_distrib minus_mult_right, auto)
  2042 done
  2043 
  2044 (*NEEDED??*)
  2045 lemma [simp]: "cos (x + real(Suc m) * pi / 2) = -sin (x + real m * pi / 2)"
  2046 apply (simp only: cos_add sin_add divide_inverse real_of_nat_Suc left_distrib right_distrib, auto)
  2047 done
  2048 
  2049 lemma cos_pi_eq_zero [simp]: "cos (pi * real (Suc (2 * m)) / 2) = 0"
  2050 by (simp only: cos_add sin_add divide_inverse real_of_nat_Suc left_distrib right_distrib, auto)
  2051 
  2052 lemma DERIV_cos_add [simp]: "DERIV (%x. cos (x + k)) xa :> - sin (xa + k)"
  2053 apply (rule lemma_DERIV_subst)
  2054 apply (rule_tac f = cos and g = "%x. x + k" in DERIV_chain2)
  2055 apply (best intro!: DERIV_intros intro: DERIV_chain2)+
  2056 apply (simp (no_asm))
  2057 done
  2058 
  2059 lemma isCont_cos [simp]: "isCont cos x"
  2060 by (rule DERIV_cos [THEN DERIV_isCont])
  2061 
  2062 lemma isCont_sin [simp]: "isCont sin x"
  2063 by (rule DERIV_sin [THEN DERIV_isCont])
  2064 
  2065 lemma isCont_exp [simp]: "isCont exp x"
  2066 by (rule DERIV_exp [THEN DERIV_isCont])
  2067 
  2068 lemma sin_zero_abs_cos_one: "sin x = 0 ==> \<bar>cos x\<bar> = 1"
  2069 by (auto simp add: sin_zero_iff even_mult_two_ex)
  2070 
  2071 lemma exp_eq_one_iff [simp]: "(exp x = 1) = (x = 0)"
  2072 apply auto
  2073 apply (drule_tac f = ln in arg_cong, auto)
  2074 done
  2075 
  2076 lemma cos_one_sin_zero: "cos x = 1 ==> sin x = 0"
  2077 by (cut_tac x = x in sin_cos_squared_add3, auto)
  2078 
  2079 
  2080 lemma real_root_less_mono: "[| 0 \<le> x; x < y |] ==> root(Suc n) x < root(Suc n) y"
  2081 apply (frule order_le_less_trans, assumption)
  2082 apply (frule_tac n1 = n in real_root_pow_pos2 [THEN ssubst])
  2083 apply (rotate_tac 1, assumption)
  2084 apply (frule_tac n1 = n in real_root_pow_pos [THEN ssubst])
  2085 apply (rotate_tac 3, assumption)
  2086 apply (drule_tac y = "root (Suc n) y ^ Suc n" in order_less_imp_le)
  2087 apply (frule_tac n = n in real_root_pos_pos_le)
  2088 apply (frule_tac n = n in real_root_pos_pos)
  2089 apply (drule_tac x = "root (Suc n) x" and y = "root (Suc n) y" in realpow_increasing)
  2090 apply (assumption, assumption)
  2091 apply (drule_tac x = "root (Suc n) x" in order_le_imp_less_or_eq)
  2092 apply auto
  2093 apply (drule_tac f = "%x. x ^ (Suc n) " in arg_cong)
  2094 apply (auto simp add: real_root_pow_pos2 simp del: realpow_Suc)
  2095 done
  2096 
  2097 lemma real_root_le_mono: "[| 0 \<le> x; x \<le> y |] ==> root(Suc n) x \<le> root(Suc n) y"
  2098 apply (drule_tac y = y in order_le_imp_less_or_eq)
  2099 apply (auto dest: real_root_less_mono intro: order_less_imp_le)
  2100 done
  2101 
  2102 lemma real_root_less_iff [simp]: "[| 0 \<le> x; 0 \<le> y |] ==> (root(Suc n) x < root(Suc n) y) = (x < y)"
  2103 apply (auto intro: real_root_less_mono)
  2104 apply (rule ccontr, drule linorder_not_less [THEN iffD1])
  2105 apply (drule_tac x = y and n = n in real_root_le_mono, auto)
  2106 done
  2107 
  2108 lemma real_root_le_iff [simp]: "[| 0 \<le> x; 0 \<le> y |] ==> (root(Suc n) x \<le> root(Suc n) y) = (x \<le> y)"
  2109 apply (auto intro: real_root_le_mono)
  2110 apply (simp (no_asm) add: linorder_not_less [symmetric])
  2111 apply auto
  2112 apply (drule_tac x = y and n = n in real_root_less_mono, auto)
  2113 done
  2114 
  2115 lemma real_root_eq_iff [simp]: "[| 0 \<le> x; 0 \<le> y |] ==> (root(Suc n) x = root(Suc n) y) = (x = y)"
  2116 apply (auto intro!: order_antisym)
  2117 apply (rule_tac n1 = n in real_root_le_iff [THEN iffD1])
  2118 apply (rule_tac [4] n1 = n in real_root_le_iff [THEN iffD1], auto)
  2119 done
  2120 
  2121 lemma real_root_pos_unique: "[| 0 \<le> x; 0 \<le> y; y ^ (Suc n) = x |] ==> root (Suc n) x = y"
  2122 by (auto dest: real_root_pos2 simp del: realpow_Suc)
  2123 
  2124 lemma real_root_mult: "[| 0 \<le> x; 0 \<le> y |] 
  2125       ==> root(Suc n) (x * y) = root(Suc n) x * root(Suc n) y"
  2126 apply (rule real_root_pos_unique)
  2127 apply (auto intro!: real_root_pos_pos_le simp add: power_mult_distrib zero_le_mult_iff real_root_pow_pos2 simp del: realpow_Suc)
  2128 done
  2129 
  2130 lemma real_root_inverse: "0 \<le> x ==> (root(Suc n) (inverse x) = inverse(root(Suc n) x))"
  2131 apply (rule real_root_pos_unique)
  2132 apply (auto intro: real_root_pos_pos_le simp add: power_inverse [symmetric] real_root_pow_pos2 simp del: realpow_Suc)
  2133 done
  2134 
  2135 lemma real_root_divide: 
  2136      "[| 0 \<le> x; 0 \<le> y |]  
  2137       ==> (root(Suc n) (x / y) = root(Suc n) x / root(Suc n) y)"
  2138 apply (unfold real_divide_def)
  2139 apply (auto simp add: real_root_mult real_root_inverse)
  2140 done
  2141 
  2142 lemma real_sqrt_less_mono: "[| 0 \<le> x; x < y |] ==> sqrt(x) < sqrt(y)"
  2143 apply (unfold sqrt_def)
  2144 apply (auto intro: real_root_less_mono)
  2145 done
  2146 
  2147 lemma real_sqrt_le_mono: "[| 0 \<le> x; x \<le> y |] ==> sqrt(x) \<le> sqrt(y)"
  2148 apply (unfold sqrt_def)
  2149 apply (auto intro: real_root_le_mono)
  2150 done
  2151 
  2152 lemma real_sqrt_less_iff [simp]: "[| 0 \<le> x; 0 \<le> y |] ==> (sqrt(x) < sqrt(y)) = (x < y)"
  2153 by (unfold sqrt_def, auto)
  2154 
  2155 lemma real_sqrt_le_iff [simp]: "[| 0 \<le> x; 0 \<le> y |] ==> (sqrt(x) \<le> sqrt(y)) = (x \<le> y)"
  2156 by (unfold sqrt_def, auto)
  2157 
  2158 lemma real_sqrt_eq_iff [simp]: "[| 0 \<le> x; 0 \<le> y |] ==> (sqrt(x) = sqrt(y)) = (x = y)"
  2159 by (unfold sqrt_def, auto)
  2160 
  2161 lemma real_sqrt_sos_less_one_iff [simp]: "(sqrt(x\<twosuperior> + y\<twosuperior>) < 1) = (x\<twosuperior> + y\<twosuperior> < 1)"
  2162 apply (rule real_sqrt_one [THEN subst], safe)
  2163 apply (rule_tac [2] real_sqrt_less_mono)
  2164 apply (drule real_sqrt_less_iff [THEN [2] rev_iffD1], auto)
  2165 done
  2166 
  2167 lemma real_sqrt_sos_eq_one_iff [simp]: "(sqrt(x\<twosuperior> + y\<twosuperior>) = 1) = (x\<twosuperior> + y\<twosuperior> = 1)"
  2168 apply (rule real_sqrt_one [THEN subst], safe)
  2169 apply (drule real_sqrt_eq_iff [THEN [2] rev_iffD1], auto)
  2170 done
  2171 
  2172 lemma real_divide_square_eq [simp]: "(((r::real) * a) / (r * r)) = a / r"
  2173 apply (unfold real_divide_def)
  2174 apply (case_tac "r=0")
  2175 apply (auto simp add: inverse_mult_distrib mult_ac)
  2176 done
  2177 
  2178 
  2179 subsection{*Theorems About Sqrt, Transcendental Functions for Complex*}
  2180 
  2181 lemma lemma_real_divide_sqrt: 
  2182     "0 < x ==> 0 \<le> x/(sqrt (x * x + y * y))"
  2183 apply (unfold real_divide_def)
  2184 apply (rule real_mult_order [THEN order_less_imp_le], assumption)
  2185 apply (subgoal_tac "0 < inverse (sqrt (x\<twosuperior> + y\<twosuperior>))") 
  2186  apply (simp add: numeral_2_eq_2)
  2187 apply (simp add: real_sqrt_sum_squares_ge1 [THEN [2] order_less_le_trans]) 
  2188 done
  2189 
  2190 lemma lemma_real_divide_sqrt_ge_minus_one:
  2191      "0 < x ==> -1 \<le> x/(sqrt (x * x + y * y))"
  2192 apply (rule real_le_trans)
  2193 apply (rule_tac [2] lemma_real_divide_sqrt, auto)
  2194 done
  2195 
  2196 lemma real_sqrt_sum_squares_gt_zero1: "x < 0 ==> 0 < sqrt (x * x + y * y)"
  2197 apply (rule real_sqrt_gt_zero)
  2198 apply (subgoal_tac "0 < x*x & 0 \<le> y*y", arith) 
  2199 apply (auto simp add: zero_less_mult_iff)
  2200 done
  2201 
  2202 lemma real_sqrt_sum_squares_gt_zero2: "0 < x ==> 0 < sqrt (x * x + y * y)"
  2203 apply (rule real_sqrt_gt_zero)
  2204 apply (subgoal_tac "0 < x*x & 0 \<le> y*y", arith) 
  2205 apply (auto simp add: zero_less_mult_iff)
  2206 done
  2207 
  2208 lemma real_sqrt_sum_squares_gt_zero3: "x \<noteq> 0 ==> 0 < sqrt(x\<twosuperior> + y\<twosuperior>)"
  2209 apply (cut_tac x = x and y = 0 in linorder_less_linear)
  2210 apply (auto intro: real_sqrt_sum_squares_gt_zero2 real_sqrt_sum_squares_gt_zero1 simp add: numeral_2_eq_2)
  2211 done
  2212 
  2213 lemma real_sqrt_sum_squares_gt_zero3a: "y \<noteq> 0 ==> 0 < sqrt(x\<twosuperior> + y\<twosuperior>)"
  2214 apply (drule_tac y = x in real_sqrt_sum_squares_gt_zero3)
  2215 apply (auto simp add: real_add_commute)
  2216 done
  2217 
  2218 lemma real_sqrt_sum_squares_eq_cancel [simp]: "sqrt(x\<twosuperior> + y\<twosuperior>) = x ==> y = 0"
  2219 by (drule_tac f = "%x. x\<twosuperior>" in arg_cong, auto)
  2220 
  2221 lemma real_sqrt_sum_squares_eq_cancel2 [simp]: "sqrt(x\<twosuperior> + y\<twosuperior>) = y ==> x = 0"
  2222 apply (rule_tac x = y in real_sqrt_sum_squares_eq_cancel)
  2223 apply (simp add: real_add_commute)
  2224 done
  2225 
  2226 lemma lemma_real_divide_sqrt_le_one: "x < 0 ==> x/(sqrt (x * x + y * y)) \<le> 1"
  2227 by (insert lemma_real_divide_sqrt_ge_minus_one [of "-x" y], simp)
  2228 
  2229 lemma lemma_real_divide_sqrt_ge_minus_one2:
  2230      "x < 0 ==> -1 \<le> x/(sqrt (x * x + y * y))"
  2231 apply (case_tac "y = 0", auto)
  2232 apply (frule abs_minus_eqI2)
  2233 apply (auto simp add: inverse_minus_eq)
  2234 apply (rule order_less_imp_le)
  2235 apply (rule_tac z1 = "sqrt (x * x + y * y) " in real_mult_less_iff1 [THEN iffD1])
  2236 apply (frule_tac [2] y2 = y in
  2237        real_sqrt_sum_squares_gt_zero1 [THEN real_not_refl2, THEN not_sym])
  2238 apply (auto intro: real_sqrt_sum_squares_gt_zero1 simp add: mult_ac)
  2239 apply (cut_tac x = "-x" and y = y in real_sqrt_sum_squares_ge1)
  2240 apply (drule order_le_less [THEN iffD1], safe) 
  2241 apply (simp add: numeral_2_eq_2)
  2242 apply (drule sym [THEN real_sqrt_sum_squares_eq_cancel], simp)
  2243 done
  2244 
  2245 lemma lemma_real_divide_sqrt_le_one2: "0 < x ==> x/(sqrt (x * x + y * y)) \<le> 1"
  2246 by (cut_tac x = "-x" and y = y in lemma_real_divide_sqrt_ge_minus_one2, auto)
  2247 
  2248 
  2249 lemma cos_x_y_ge_minus_one: "-1 \<le> x / sqrt (x * x + y * y)"
  2250 apply (cut_tac x = x and y = 0 in linorder_less_linear, safe)
  2251 apply (rule lemma_real_divide_sqrt_ge_minus_one2)
  2252 apply (rule_tac [3] lemma_real_divide_sqrt_ge_minus_one, auto)
  2253 done
  2254 
  2255 lemma cos_x_y_ge_minus_one1a [simp]: "-1 \<le> y / sqrt (x * x + y * y)"
  2256 apply (cut_tac x = y and y = x in cos_x_y_ge_minus_one)
  2257 apply (simp add: real_add_commute)
  2258 done
  2259 
  2260 lemma cos_x_y_le_one [simp]: "x / sqrt (x * x + y * y) \<le> 1"
  2261 apply (cut_tac x = x and y = 0 in linorder_less_linear, safe)
  2262 apply (rule lemma_real_divide_sqrt_le_one)
  2263 apply (rule_tac [3] lemma_real_divide_sqrt_le_one2, auto)
  2264 done
  2265 
  2266 lemma cos_x_y_le_one2 [simp]: "y / sqrt (x * x + y * y) \<le> 1"
  2267 apply (cut_tac x = y and y = x in cos_x_y_le_one)
  2268 apply (simp add: real_add_commute)
  2269 done
  2270 
  2271 declare cos_arcos [OF cos_x_y_ge_minus_one cos_x_y_le_one, simp] 
  2272 declare arcos_bounded [OF cos_x_y_ge_minus_one cos_x_y_le_one, simp] 
  2273 
  2274 declare cos_arcos [OF cos_x_y_ge_minus_one1a cos_x_y_le_one2, simp] 
  2275 declare arcos_bounded [OF cos_x_y_ge_minus_one1a cos_x_y_le_one2, simp] 
  2276 
  2277 lemma cos_abs_x_y_ge_minus_one [simp]:
  2278      "-1 \<le> \<bar>x\<bar> / sqrt (x * x + y * y)"
  2279 apply (cut_tac x = x and y = 0 in linorder_less_linear)
  2280 apply (auto simp add: abs_minus_eqI2 abs_eqI2)
  2281 apply (drule lemma_real_divide_sqrt_ge_minus_one, force)
  2282 done
  2283 
  2284 lemma cos_abs_x_y_le_one [simp]: "\<bar>x\<bar> / sqrt (x * x + y * y) \<le> 1"
  2285 apply (cut_tac x = x and y = 0 in linorder_less_linear)
  2286 apply (auto simp add: abs_minus_eqI2 abs_eqI2)
  2287 apply (drule lemma_real_divide_sqrt_ge_minus_one2, force)
  2288 done
  2289 
  2290 declare cos_arcos [OF cos_abs_x_y_ge_minus_one cos_abs_x_y_le_one, simp] 
  2291 declare arcos_bounded [OF cos_abs_x_y_ge_minus_one cos_abs_x_y_le_one, simp] 
  2292 
  2293 lemma minus_pi_less_zero: "-pi < 0"
  2294 apply (simp (no_asm))
  2295 done
  2296 declare minus_pi_less_zero [simp]
  2297 declare minus_pi_less_zero [THEN order_less_imp_le, simp]
  2298 
  2299 lemma arcos_ge_minus_pi: "[| -1 \<le> y; y \<le> 1 |] ==> -pi \<le> arcos y"
  2300 apply (rule real_le_trans)
  2301 apply (rule_tac [2] arcos_lbound, auto)
  2302 done
  2303 
  2304 declare arcos_ge_minus_pi [OF cos_x_y_ge_minus_one cos_x_y_le_one, simp] 
  2305 
  2306 (* How tedious! *)
  2307 lemma lemma_divide_rearrange:
  2308      "[| x + (y::real) \<noteq> 0; 1 - z = x/(x + y) |] ==> z = y/(x + y)"
  2309 apply (rule_tac c1 = "x + y" in real_mult_right_cancel [THEN iffD1])
  2310 apply (frule_tac [2] c1 = "x + y" in real_mult_right_cancel [THEN iffD2])
  2311 prefer 2 apply assumption
  2312 apply (rotate_tac [2] 2)
  2313 apply (drule_tac [2] mult_assoc [THEN subst])
  2314 apply (rotate_tac [2] 2)
  2315 apply (frule_tac [2] left_inverse [THEN subst])
  2316 prefer 2 apply assumption
  2317 apply (erule_tac [2] V = " (1 - z) * (x + y) = x / (x + y) * (x + y) " in thin_rl)
  2318 apply (erule_tac [2] V = "1 - z = x / (x + y) " in thin_rl)
  2319 apply (auto simp add: mult_assoc)
  2320 apply (auto simp add: right_distrib left_diff_distrib)
  2321 done
  2322 
  2323 lemma lemma_cos_sin_eq:
  2324      "[| 0 < x * x + y * y;  
  2325          1 - (sin xa)\<twosuperior> = (x / sqrt (x * x + y * y)) ^ 2 |] 
  2326       ==> (sin xa)\<twosuperior> = (y / sqrt (x * x + y * y)) ^ 2"
  2327 by (auto intro: lemma_divide_rearrange
  2328          simp add: realpow_divide power2_eq_square [symmetric])
  2329 
  2330 
  2331 lemma lemma_sin_cos_eq:
  2332      "[| 0 < x * x + y * y;  
  2333          1 - (cos xa)\<twosuperior> = (y / sqrt (x * x + y * y)) ^ 2 |]
  2334       ==> (cos xa)\<twosuperior> = (x / sqrt (x * x + y * y)) ^ 2"
  2335 apply (auto simp add: realpow_divide power2_eq_square [symmetric])
  2336 apply (rule add_commute [THEN subst])
  2337 apply (rule lemma_divide_rearrange, simp)
  2338 apply (simp add: add_commute)
  2339 done
  2340 
  2341 lemma sin_x_y_disj:
  2342      "[| x \<noteq> 0;  
  2343          cos xa = x / sqrt (x * x + y * y)  
  2344       |] ==>  sin xa = y / sqrt (x * x + y * y) |  
  2345               sin xa = - y / sqrt (x * x + y * y)"
  2346 apply (drule_tac f = "%x. x\<twosuperior>" in arg_cong)
  2347 apply (frule_tac y = y in real_sum_square_gt_zero)
  2348 apply (simp add: cos_squared_eq)
  2349 apply (subgoal_tac "(sin xa)\<twosuperior> = (y / sqrt (x * x + y * y)) ^ 2")
  2350 apply (rule_tac [2] lemma_cos_sin_eq)
  2351 apply (auto simp add: realpow_two_disj numeral_2_eq_2 simp del: realpow_Suc)
  2352 done
  2353 
  2354 lemma lemma_cos_not_eq_zero: "x \<noteq> 0 ==> x / sqrt (x * x + y * y) \<noteq> 0"
  2355 apply (unfold real_divide_def)
  2356 apply (frule_tac y3 = y in real_sqrt_sum_squares_gt_zero3 [THEN real_not_refl2, THEN not_sym, THEN nonzero_imp_inverse_nonzero])
  2357 apply (auto simp add: power2_eq_square)
  2358 done
  2359 
  2360 lemma cos_x_y_disj: "[| x \<noteq> 0;  
  2361          sin xa = y / sqrt (x * x + y * y)  
  2362       |] ==>  cos xa = x / sqrt (x * x + y * y) |  
  2363               cos xa = - x / sqrt (x * x + y * y)"
  2364 apply (drule_tac f = "%x. x\<twosuperior>" in arg_cong)
  2365 apply (frule_tac y = y in real_sum_square_gt_zero)
  2366 apply (simp add: sin_squared_eq del: realpow_Suc)
  2367 apply (subgoal_tac "(cos xa)\<twosuperior> = (x / sqrt (x * x + y * y)) ^ 2")
  2368 apply (rule_tac [2] lemma_sin_cos_eq)
  2369 apply (auto simp add: realpow_two_disj numeral_2_eq_2 simp del: realpow_Suc)
  2370 done
  2371 
  2372 lemma real_sqrt_divide_less_zero: "0 < y ==> - y / sqrt (x * x + y * y) < 0"
  2373 apply (case_tac "x = 0")
  2374 apply (auto simp add: abs_eqI2)
  2375 apply (drule_tac y = y in real_sqrt_sum_squares_gt_zero3)
  2376 apply (auto simp add: zero_less_mult_iff divide_inverse power2_eq_square)
  2377 done
  2378 
  2379 lemma polar_ex1: "[| x \<noteq> 0; 0 < y |] ==> \<exists>r a. x = r * cos a & y = r * sin a"
  2380 apply (rule_tac x = "sqrt (x\<twosuperior> + y\<twosuperior>) " in exI)
  2381 apply (rule_tac x = "arcos (x / sqrt (x * x + y * y))" in exI)
  2382 apply auto
  2383 apply (drule_tac y2 = y in real_sqrt_sum_squares_gt_zero3 [THEN real_not_refl2, THEN not_sym])
  2384 apply (auto simp add: power2_eq_square)
  2385 apply (unfold arcos_def)
  2386 apply (cut_tac x1 = x and y1 = y 
  2387        in cos_total [OF cos_x_y_ge_minus_one cos_x_y_le_one])
  2388 apply (rule someI2_ex, blast)
  2389 apply (erule_tac V = "EX! xa. 0 \<le> xa & xa \<le> pi & cos xa = x / sqrt (x * x + y * y) " in thin_rl)
  2390 apply (frule sin_x_y_disj, blast)
  2391 apply (drule_tac y2 = y in real_sqrt_sum_squares_gt_zero3 [THEN real_not_refl2, THEN not_sym])
  2392 apply (auto simp add: power2_eq_square)
  2393 apply (drule sin_ge_zero, assumption)
  2394 apply (drule_tac x = x in real_sqrt_divide_less_zero, auto)
  2395 done
  2396 
  2397 lemma real_sum_squares_cancel2a: "x * x = -(y * y) ==> y = (0::real)"
  2398 by (auto intro: real_sum_squares_cancel)
  2399 
  2400 lemma polar_ex2: "[| x \<noteq> 0; y < 0 |] ==> \<exists>r a. x = r * cos a & y = r * sin a"
  2401 apply (cut_tac x = 0 and y = x in linorder_less_linear, auto)
  2402 apply (rule_tac x = "sqrt (x\<twosuperior> + y\<twosuperior>) " in exI)
  2403 apply (rule_tac x = "arcsin (y / sqrt (x * x + y * y))" in exI)
  2404 apply (auto dest: real_sum_squares_cancel2a simp add: power2_eq_square)
  2405 apply (unfold arcsin_def)
  2406 apply (cut_tac x1 = x and y1 = y 
  2407        in sin_total [OF cos_x_y_ge_minus_one1a cos_x_y_le_one2])
  2408 apply (rule someI2_ex, blast)
  2409 apply (erule_tac V = "EX! xa. - (pi/2) \<le> xa & xa \<le> pi/2 & sin xa = y / sqrt (x * x + y * y) " in thin_rl)
  2410 apply (cut_tac x=x and y=y in cos_x_y_disj, simp, blast, auto)
  2411 apply (drule cos_ge_zero, force)
  2412 apply (drule_tac x = y in real_sqrt_divide_less_zero)
  2413 apply (auto simp add: real_add_commute)
  2414 apply (insert polar_ex1 [of x "-y"], simp, clarify) 
  2415 apply (rule_tac x = r in exI)
  2416 apply (rule_tac x = "-a" in exI, simp) 
  2417 done
  2418 
  2419 lemma polar_Ex: "\<exists>r a. x = r * cos a & y = r * sin a"
  2420 apply (case_tac "x = 0", auto)
  2421 apply (rule_tac x = y in exI)
  2422 apply (rule_tac x = "pi/2" in exI, auto)
  2423 apply (cut_tac x = 0 and y = y in linorder_less_linear, auto)
  2424 apply (rule_tac [2] x = x in exI)
  2425 apply (rule_tac [2] x = 0 in exI, auto)
  2426 apply (blast intro: polar_ex1 polar_ex2)+
  2427 done
  2428 
  2429 lemma real_sqrt_ge_abs1 [simp]: "\<bar>x\<bar> \<le> sqrt (x\<twosuperior> + y\<twosuperior>)"
  2430 apply (rule_tac n = 1 in realpow_increasing)
  2431 apply (auto simp add: numeral_2_eq_2 [symmetric])
  2432 done
  2433 
  2434 lemma real_sqrt_ge_abs2 [simp]: "\<bar>y\<bar> \<le> sqrt (x\<twosuperior> + y\<twosuperior>)"
  2435 apply (rule real_add_commute [THEN subst])
  2436 apply (rule real_sqrt_ge_abs1)
  2437 done
  2438 declare real_sqrt_ge_abs1 [simp] real_sqrt_ge_abs2 [simp]
  2439 
  2440 lemma real_sqrt_two_gt_zero [simp]: "0 < sqrt 2"
  2441 by (auto intro: real_sqrt_gt_zero)
  2442 
  2443 lemma real_sqrt_two_ge_zero [simp]: "0 \<le> sqrt 2"
  2444 by (auto intro: real_sqrt_ge_zero)
  2445 
  2446 lemma real_sqrt_two_gt_one [simp]: "1 < sqrt 2"
  2447 apply (rule order_less_le_trans [of _ "7/5"], simp) 
  2448 apply (rule_tac n = 1 in realpow_increasing)
  2449   prefer 3 apply (simp add: numeral_2_eq_2 [symmetric] del: realpow_Suc)
  2450 apply (simp_all add: numeral_2_eq_2)
  2451 done
  2452 
  2453 lemma lemma_real_divide_sqrt_less: "0 < u ==> u / sqrt 2 < u"
  2454 apply (rule_tac z1 = "inverse u" in real_mult_less_iff1 [THEN iffD1], auto)
  2455 apply (rule_tac z1 = "sqrt 2" in real_mult_less_iff1 [THEN iffD1], auto)
  2456 done
  2457 
  2458 lemma four_x_squared: 
  2459   fixes x::real
  2460   shows "4 * x\<twosuperior> = (2 * x)\<twosuperior>"
  2461 by (simp add: power2_eq_square)
  2462 
  2463 
  2464 text{*Needed for the infinitely close relation over the nonstandard
  2465     complex numbers*}
  2466 lemma lemma_sqrt_hcomplex_capprox:
  2467      "[| 0 < u; x < u/2; y < u/2; 0 \<le> x; 0 \<le> y |] ==> sqrt (x\<twosuperior> + y\<twosuperior>) < u"
  2468 apply (rule_tac y = "u/sqrt 2" in order_le_less_trans)
  2469 apply (erule_tac [2] lemma_real_divide_sqrt_less)
  2470 apply (rule_tac n = 1 in realpow_increasing)
  2471 apply (auto simp add: real_0_le_divide_iff realpow_divide numeral_2_eq_2 [symmetric] 
  2472         simp del: realpow_Suc)
  2473 apply (rule_tac t = "u\<twosuperior>" in real_sum_of_halves [THEN subst])
  2474 apply (rule add_mono)
  2475 apply (auto simp add: four_x_squared simp del: realpow_Suc intro: power_mono)
  2476 done
  2477 
  2478 declare real_sqrt_sum_squares_ge_zero [THEN abs_eqI1, simp]
  2479 
  2480 
  2481 subsection{*A Few Theorems Involving Ln, Derivatives, etc.*}
  2482 
  2483 lemma lemma_DERIV_ln:
  2484      "DERIV ln z :> l ==> DERIV (%x. exp (ln x)) z :> exp (ln z) * l"
  2485 by (erule DERIV_fun_exp)
  2486 
  2487 lemma STAR_exp_ln: "0 < z ==> ( *f* (%x. exp (ln x))) z = z"
  2488 apply (rule_tac z = z in eq_Abs_hypreal)
  2489 apply (auto simp add: starfun hypreal_zero_def hypreal_less)
  2490 done
  2491 
  2492 lemma hypreal_add_Infinitesimal_gt_zero: "[|e : Infinitesimal; 0 < x |] ==> 0 < hypreal_of_real x + e"
  2493 apply (rule_tac c1 = "-e" in add_less_cancel_right [THEN iffD1])
  2494 apply (auto intro: Infinitesimal_less_SReal)
  2495 done
  2496 
  2497 lemma NSDERIV_exp_ln_one: "0 < z ==> NSDERIV (%x. exp (ln x)) z :> 1"
  2498 apply (unfold nsderiv_def NSLIM_def, auto)
  2499 apply (rule ccontr)
  2500 apply (subgoal_tac "0 < hypreal_of_real z + h")
  2501 apply (drule STAR_exp_ln)
  2502 apply (rule_tac [2] hypreal_add_Infinitesimal_gt_zero)
  2503 apply (subgoal_tac "h/h = 1")
  2504 apply (auto simp add: exp_ln_iff [symmetric] simp del: exp_ln_iff)
  2505 done
  2506 
  2507 lemma DERIV_exp_ln_one: "0 < z ==> DERIV (%x. exp (ln x)) z :> 1"
  2508 by (auto intro: NSDERIV_exp_ln_one simp add: NSDERIV_DERIV_iff [symmetric])
  2509 
  2510 lemma lemma_DERIV_ln2: "[| 0 < z; DERIV ln z :> l |] ==>  exp (ln z) * l = 1"
  2511 apply (rule DERIV_unique)
  2512 apply (rule lemma_DERIV_ln)
  2513 apply (rule_tac [2] DERIV_exp_ln_one, auto)
  2514 done
  2515 
  2516 lemma lemma_DERIV_ln3: "[| 0 < z; DERIV ln z :> l |] ==>  l = 1/(exp (ln z))"
  2517 apply (rule_tac c1 = "exp (ln z) " in real_mult_left_cancel [THEN iffD1])
  2518 apply (auto intro: lemma_DERIV_ln2)
  2519 done
  2520 
  2521 lemma lemma_DERIV_ln4: "[| 0 < z; DERIV ln z :> l |] ==>  l = 1/z"
  2522 apply (rule_tac t = z in exp_ln_iff [THEN iffD2, THEN subst])
  2523 apply (auto intro: lemma_DERIV_ln3)
  2524 done
  2525 
  2526 (* need to rename second isCont_inverse *)
  2527 
  2528 lemma isCont_inv_fun: "[| 0 < d; \<forall>z. \<bar>z - x\<bar> \<le> d --> g(f(z)) = z;  
  2529          \<forall>z. \<bar>z - x\<bar> \<le> d --> isCont f z |]  
  2530       ==> isCont g (f x)"
  2531 apply (simp (no_asm) add: isCont_iff LIM_def)
  2532 apply safe
  2533 apply (drule_tac ?d1.0 = r in real_lbound_gt_zero)
  2534 apply (assumption, safe)
  2535 apply (subgoal_tac "\<forall>z. \<bar>z - x\<bar> \<le> e --> (g (f z) = z) ")
  2536 prefer 2 apply force
  2537 apply (subgoal_tac "\<forall>z. \<bar>z - x\<bar> \<le> e --> isCont f z")
  2538 prefer 2 apply force
  2539 apply (drule_tac d = e in isCont_inj_range)
  2540 prefer 2 apply (assumption, assumption, safe)
  2541 apply (rule_tac x = ea in exI, auto)
  2542 apply (rotate_tac 4)
  2543 apply (drule_tac x = "f (x) + xa" in spec)
  2544 apply auto
  2545 apply (drule sym, auto, arith)
  2546 done
  2547 
  2548 lemma isCont_inv_fun_inv:
  2549      "[| 0 < d;  
  2550          \<forall>z. \<bar>z - x\<bar> \<le> d --> g(f(z)) = z;  
  2551          \<forall>z. \<bar>z - x\<bar> \<le> d --> isCont f z |]  
  2552        ==> \<exists>e. 0 < e &  
  2553              (\<forall>y. 0 < \<bar>y - f(x)\<bar> & \<bar>y - f(x)\<bar> < e --> f(g(y)) = y)"
  2554 apply (drule isCont_inj_range)
  2555 prefer 2 apply (assumption, assumption, auto)
  2556 apply (rule_tac x = e in exI, auto)
  2557 apply (rotate_tac 2)
  2558 apply (drule_tac x = y in spec, auto)
  2559 done
  2560 
  2561 
  2562 text{*Bartle/Sherbert: Introduction to Real Analysis, Theorem 4.2.9, p. 110*}
  2563 lemma LIM_fun_gt_zero: "[| f -- c --> l; 0 < l |]  
  2564          ==> \<exists>r. 0 < r & (\<forall>x. x \<noteq> c & \<bar>c - x\<bar> < r --> 0 < f x)"
  2565 apply (auto simp add: LIM_def)
  2566 apply (drule_tac x = "l/2" in spec, safe, force)
  2567 apply (rule_tac x = s in exI)
  2568 apply (auto simp only: abs_interval_iff)
  2569 done
  2570 
  2571 lemma LIM_fun_less_zero: "[| f -- c --> l; l < 0 |]  
  2572          ==> \<exists>r. 0 < r & (\<forall>x. x \<noteq> c & \<bar>c - x\<bar> < r --> f x < 0)"
  2573 apply (auto simp add: LIM_def)
  2574 apply (drule_tac x = "-l/2" in spec, safe, force)
  2575 apply (rule_tac x = s in exI)
  2576 apply (auto simp only: abs_interval_iff)
  2577 done
  2578 
  2579 
  2580 lemma LIM_fun_not_zero:
  2581      "[| f -- c --> l; l \<noteq> 0 |] 
  2582       ==> \<exists>r. 0 < r & (\<forall>x. x \<noteq> c & \<bar>c - x\<bar> < r --> f x \<noteq> 0)"
  2583 apply (cut_tac x = l and y = 0 in linorder_less_linear, auto)
  2584 apply (drule LIM_fun_less_zero)
  2585 apply (drule_tac [3] LIM_fun_gt_zero, auto)
  2586 apply (rule_tac [!] x = r in exI, auto)
  2587 done
  2588 
  2589 ML
  2590 {*
  2591 val inverse_unique = thm "inverse_unique";
  2592 val real_root_zero = thm "real_root_zero";
  2593 val real_root_pow_pos = thm "real_root_pow_pos";
  2594 val real_root_pow_pos2 = thm "real_root_pow_pos2";
  2595 val real_root_pos = thm "real_root_pos";
  2596 val real_root_pos2 = thm "real_root_pos2";
  2597 val real_root_pos_pos = thm "real_root_pos_pos";
  2598 val real_root_pos_pos_le = thm "real_root_pos_pos_le";
  2599 val real_root_one = thm "real_root_one";
  2600 val root_2_eq = thm "root_2_eq";
  2601 val real_sqrt_zero = thm "real_sqrt_zero";
  2602 val real_sqrt_one = thm "real_sqrt_one";
  2603 val real_sqrt_pow2_iff = thm "real_sqrt_pow2_iff";
  2604 val real_sqrt_pow2 = thm "real_sqrt_pow2";
  2605 val real_sqrt_abs_abs = thm "real_sqrt_abs_abs";
  2606 val real_pow_sqrt_eq_sqrt_pow = thm "real_pow_sqrt_eq_sqrt_pow";
  2607 val real_pow_sqrt_eq_sqrt_abs_pow2 = thm "real_pow_sqrt_eq_sqrt_abs_pow2";
  2608 val real_sqrt_pow_abs = thm "real_sqrt_pow_abs";
  2609 val not_real_square_gt_zero = thm "not_real_square_gt_zero";
  2610 val real_mult_self_eq_zero_iff = thm "real_mult_self_eq_zero_iff";
  2611 val real_sqrt_gt_zero = thm "real_sqrt_gt_zero";
  2612 val real_sqrt_ge_zero = thm "real_sqrt_ge_zero";
  2613 val sqrt_eqI = thm "sqrt_eqI";
  2614 val real_sqrt_mult_distrib = thm "real_sqrt_mult_distrib";
  2615 val real_sqrt_mult_distrib2 = thm "real_sqrt_mult_distrib2";
  2616 val real_sqrt_sum_squares_ge_zero = thm "real_sqrt_sum_squares_ge_zero";
  2617 val real_sqrt_sum_squares_mult_ge_zero = thm "real_sqrt_sum_squares_mult_ge_zero";
  2618 val real_sqrt_sum_squares_mult_squared_eq = thm "real_sqrt_sum_squares_mult_squared_eq";
  2619 val real_sqrt_abs = thm "real_sqrt_abs";
  2620 val real_sqrt_abs2 = thm "real_sqrt_abs2";
  2621 val real_sqrt_pow2_gt_zero = thm "real_sqrt_pow2_gt_zero";
  2622 val real_sqrt_not_eq_zero = thm "real_sqrt_not_eq_zero";
  2623 val real_inv_sqrt_pow2 = thm "real_inv_sqrt_pow2";
  2624 val real_sqrt_eq_zero_cancel = thm "real_sqrt_eq_zero_cancel";
  2625 val real_sqrt_eq_zero_cancel_iff = thm "real_sqrt_eq_zero_cancel_iff";
  2626 val real_sqrt_sum_squares_ge1 = thm "real_sqrt_sum_squares_ge1";
  2627 val real_sqrt_sum_squares_ge2 = thm "real_sqrt_sum_squares_ge2";
  2628 val real_sqrt_ge_one = thm "real_sqrt_ge_one";
  2629 val summable_exp = thm "summable_exp";
  2630 val summable_sin = thm "summable_sin";
  2631 val summable_cos = thm "summable_cos";
  2632 val exp_converges = thm "exp_converges";
  2633 val sin_converges = thm "sin_converges";
  2634 val cos_converges = thm "cos_converges";
  2635 val powser_insidea = thm "powser_insidea";
  2636 val powser_inside = thm "powser_inside";
  2637 val diffs_minus = thm "diffs_minus";
  2638 val diffs_equiv = thm "diffs_equiv";
  2639 val less_add_one = thm "less_add_one";
  2640 val termdiffs_aux = thm "termdiffs_aux";
  2641 val termdiffs = thm "termdiffs";
  2642 val exp_fdiffs = thm "exp_fdiffs";
  2643 val sin_fdiffs = thm "sin_fdiffs";
  2644 val sin_fdiffs2 = thm "sin_fdiffs2";
  2645 val cos_fdiffs = thm "cos_fdiffs";
  2646 val cos_fdiffs2 = thm "cos_fdiffs2";
  2647 val DERIV_exp = thm "DERIV_exp";
  2648 val DERIV_sin = thm "DERIV_sin";
  2649 val DERIV_cos = thm "DERIV_cos";
  2650 val exp_zero = thm "exp_zero";
  2651 val exp_ge_add_one_self = thm "exp_ge_add_one_self";
  2652 val exp_gt_one = thm "exp_gt_one";
  2653 val DERIV_exp_add_const = thm "DERIV_exp_add_const";
  2654 val DERIV_exp_minus = thm "DERIV_exp_minus";
  2655 val DERIV_exp_exp_zero = thm "DERIV_exp_exp_zero";
  2656 val exp_add_mult_minus = thm "exp_add_mult_minus";
  2657 val exp_mult_minus = thm "exp_mult_minus";
  2658 val exp_mult_minus2 = thm "exp_mult_minus2";
  2659 val exp_minus = thm "exp_minus";
  2660 val exp_add = thm "exp_add";
  2661 val exp_ge_zero = thm "exp_ge_zero";
  2662 val exp_not_eq_zero = thm "exp_not_eq_zero";
  2663 val exp_gt_zero = thm "exp_gt_zero";
  2664 val inv_exp_gt_zero = thm "inv_exp_gt_zero";
  2665 val abs_exp_cancel = thm "abs_exp_cancel";
  2666 val exp_real_of_nat_mult = thm "exp_real_of_nat_mult";
  2667 val exp_diff = thm "exp_diff";
  2668 val exp_less_mono = thm "exp_less_mono";
  2669 val exp_less_cancel = thm "exp_less_cancel";
  2670 val exp_less_cancel_iff = thm "exp_less_cancel_iff";
  2671 val exp_le_cancel_iff = thm "exp_le_cancel_iff";
  2672 val exp_inj_iff = thm "exp_inj_iff";
  2673 val exp_total = thm "exp_total";
  2674 val ln_exp = thm "ln_exp";
  2675 val exp_ln_iff = thm "exp_ln_iff";
  2676 val ln_mult = thm "ln_mult";
  2677 val ln_inj_iff = thm "ln_inj_iff";
  2678 val ln_one = thm "ln_one";
  2679 val ln_inverse = thm "ln_inverse";
  2680 val ln_div = thm "ln_div";
  2681 val ln_less_cancel_iff = thm "ln_less_cancel_iff";
  2682 val ln_le_cancel_iff = thm "ln_le_cancel_iff";
  2683 val ln_realpow = thm "ln_realpow";
  2684 val ln_add_one_self_le_self = thm "ln_add_one_self_le_self";
  2685 val ln_less_self = thm "ln_less_self";
  2686 val ln_ge_zero = thm "ln_ge_zero";
  2687 val ln_gt_zero = thm "ln_gt_zero";
  2688 val ln_not_eq_zero = thm "ln_not_eq_zero";
  2689 val ln_less_zero = thm "ln_less_zero";
  2690 val exp_ln_eq = thm "exp_ln_eq";
  2691 val sin_zero = thm "sin_zero";
  2692 val cos_zero = thm "cos_zero";
  2693 val DERIV_sin_sin_mult = thm "DERIV_sin_sin_mult";
  2694 val DERIV_sin_sin_mult2 = thm "DERIV_sin_sin_mult2";
  2695 val DERIV_sin_realpow2 = thm "DERIV_sin_realpow2";
  2696 val DERIV_sin_realpow2a = thm "DERIV_sin_realpow2a";
  2697 val DERIV_cos_cos_mult = thm "DERIV_cos_cos_mult";
  2698 val DERIV_cos_cos_mult2 = thm "DERIV_cos_cos_mult2";
  2699 val DERIV_cos_realpow2 = thm "DERIV_cos_realpow2";
  2700 val DERIV_cos_realpow2a = thm "DERIV_cos_realpow2a";
  2701 val DERIV_cos_realpow2b = thm "DERIV_cos_realpow2b";
  2702 val DERIV_cos_cos_mult3 = thm "DERIV_cos_cos_mult3";
  2703 val DERIV_sin_circle_all = thm "DERIV_sin_circle_all";
  2704 val DERIV_sin_circle_all_zero = thm "DERIV_sin_circle_all_zero";
  2705 val sin_cos_squared_add = thm "sin_cos_squared_add";
  2706 val sin_cos_squared_add2 = thm "sin_cos_squared_add2";
  2707 val sin_cos_squared_add3 = thm "sin_cos_squared_add3";
  2708 val sin_squared_eq = thm "sin_squared_eq";
  2709 val cos_squared_eq = thm "cos_squared_eq";
  2710 val real_gt_one_ge_zero_add_less = thm "real_gt_one_ge_zero_add_less";
  2711 val abs_sin_le_one = thm "abs_sin_le_one";
  2712 val sin_ge_minus_one = thm "sin_ge_minus_one";
  2713 val sin_le_one = thm "sin_le_one";
  2714 val abs_cos_le_one = thm "abs_cos_le_one";
  2715 val cos_ge_minus_one = thm "cos_ge_minus_one";
  2716 val cos_le_one = thm "cos_le_one";
  2717 val DERIV_fun_pow = thm "DERIV_fun_pow";
  2718 val DERIV_fun_exp = thm "DERIV_fun_exp";
  2719 val DERIV_fun_sin = thm "DERIV_fun_sin";
  2720 val DERIV_fun_cos = thm "DERIV_fun_cos";
  2721 val DERIV_intros = thms "DERIV_intros";
  2722 val sin_cos_add = thm "sin_cos_add";
  2723 val sin_add = thm "sin_add";
  2724 val cos_add = thm "cos_add";
  2725 val sin_cos_minus = thm "sin_cos_minus";
  2726 val sin_minus = thm "sin_minus";
  2727 val cos_minus = thm "cos_minus";
  2728 val sin_diff = thm "sin_diff";
  2729 val sin_diff2 = thm "sin_diff2";
  2730 val cos_diff = thm "cos_diff";
  2731 val cos_diff2 = thm "cos_diff2";
  2732 val sin_double = thm "sin_double";
  2733 val cos_double = thm "cos_double";
  2734 val sin_paired = thm "sin_paired";
  2735 val sin_gt_zero = thm "sin_gt_zero";
  2736 val sin_gt_zero1 = thm "sin_gt_zero1";
  2737 val cos_double_less_one = thm "cos_double_less_one";
  2738 val cos_paired = thm "cos_paired";
  2739 val cos_two_less_zero = thm "cos_two_less_zero";
  2740 val cos_is_zero = thm "cos_is_zero";
  2741 val pi_half = thm "pi_half";
  2742 val cos_pi_half = thm "cos_pi_half";
  2743 val pi_half_gt_zero = thm "pi_half_gt_zero";
  2744 val pi_half_less_two = thm "pi_half_less_two";
  2745 val pi_gt_zero = thm "pi_gt_zero";
  2746 val pi_neq_zero = thm "pi_neq_zero";
  2747 val pi_not_less_zero = thm "pi_not_less_zero";
  2748 val pi_ge_zero = thm "pi_ge_zero";
  2749 val minus_pi_half_less_zero = thm "minus_pi_half_less_zero";
  2750 val sin_pi_half = thm "sin_pi_half";
  2751 val cos_pi = thm "cos_pi";
  2752 val sin_pi = thm "sin_pi";
  2753 val sin_cos_eq = thm "sin_cos_eq";
  2754 val minus_sin_cos_eq = thm "minus_sin_cos_eq";
  2755 val cos_sin_eq = thm "cos_sin_eq";
  2756 val sin_periodic_pi = thm "sin_periodic_pi";
  2757 val sin_periodic_pi2 = thm "sin_periodic_pi2";
  2758 val cos_periodic_pi = thm "cos_periodic_pi";
  2759 val sin_periodic = thm "sin_periodic";
  2760 val cos_periodic = thm "cos_periodic";
  2761 val cos_npi = thm "cos_npi";
  2762 val sin_npi = thm "sin_npi";
  2763 val sin_npi2 = thm "sin_npi2";
  2764 val cos_two_pi = thm "cos_two_pi";
  2765 val sin_two_pi = thm "sin_two_pi";
  2766 val sin_gt_zero2 = thm "sin_gt_zero2";
  2767 val sin_less_zero = thm "sin_less_zero";
  2768 val pi_less_4 = thm "pi_less_4";
  2769 val cos_gt_zero = thm "cos_gt_zero";
  2770 val cos_gt_zero_pi = thm "cos_gt_zero_pi";
  2771 val cos_ge_zero = thm "cos_ge_zero";
  2772 val sin_gt_zero_pi = thm "sin_gt_zero_pi";
  2773 val sin_ge_zero = thm "sin_ge_zero";
  2774 val cos_total = thm "cos_total";
  2775 val sin_total = thm "sin_total";
  2776 val reals_Archimedean4 = thm "reals_Archimedean4";
  2777 val cos_zero_lemma = thm "cos_zero_lemma";
  2778 val sin_zero_lemma = thm "sin_zero_lemma";
  2779 val cos_zero_iff = thm "cos_zero_iff";
  2780 val sin_zero_iff = thm "sin_zero_iff";
  2781 val tan_zero = thm "tan_zero";
  2782 val tan_pi = thm "tan_pi";
  2783 val tan_npi = thm "tan_npi";
  2784 val tan_minus = thm "tan_minus";
  2785 val tan_periodic = thm "tan_periodic";
  2786 val add_tan_eq = thm "add_tan_eq";
  2787 val tan_add = thm "tan_add";
  2788 val tan_double = thm "tan_double";
  2789 val tan_gt_zero = thm "tan_gt_zero";
  2790 val tan_less_zero = thm "tan_less_zero";
  2791 val DERIV_tan = thm "DERIV_tan";
  2792 val LIM_cos_div_sin = thm "LIM_cos_div_sin";
  2793 val tan_total_pos = thm "tan_total_pos";
  2794 val tan_total = thm "tan_total";
  2795 val arcsin_pi = thm "arcsin_pi";
  2796 val arcsin = thm "arcsin";
  2797 val sin_arcsin = thm "sin_arcsin";
  2798 val arcsin_bounded = thm "arcsin_bounded";
  2799 val arcsin_lbound = thm "arcsin_lbound";
  2800 val arcsin_ubound = thm "arcsin_ubound";
  2801 val arcsin_lt_bounded = thm "arcsin_lt_bounded";
  2802 val arcsin_sin = thm "arcsin_sin";
  2803 val arcos = thm "arcos";
  2804 val cos_arcos = thm "cos_arcos";
  2805 val arcos_bounded = thm "arcos_bounded";
  2806 val arcos_lbound = thm "arcos_lbound";
  2807 val arcos_ubound = thm "arcos_ubound";
  2808 val arcos_lt_bounded = thm "arcos_lt_bounded";
  2809 val arcos_cos = thm "arcos_cos";
  2810 val arcos_cos2 = thm "arcos_cos2";
  2811 val arctan = thm "arctan";
  2812 val tan_arctan = thm "tan_arctan";
  2813 val arctan_bounded = thm "arctan_bounded";
  2814 val arctan_lbound = thm "arctan_lbound";
  2815 val arctan_ubound = thm "arctan_ubound";
  2816 val arctan_tan = thm "arctan_tan";
  2817 val arctan_zero_zero = thm "arctan_zero_zero";
  2818 val cos_arctan_not_zero = thm "cos_arctan_not_zero";
  2819 val tan_sec = thm "tan_sec";
  2820 val DERIV_sin_add = thm "DERIV_sin_add";
  2821 val sin_cos_npi = thm "sin_cos_npi";
  2822 val sin_cos_npi2 = thm "sin_cos_npi2";
  2823 val cos_2npi = thm "cos_2npi";
  2824 val cos_3over2_pi = thm "cos_3over2_pi";
  2825 val sin_2npi = thm "sin_2npi";
  2826 val sin_3over2_pi = thm "sin_3over2_pi";
  2827 val cos_pi_eq_zero = thm "cos_pi_eq_zero";
  2828 val DERIV_cos_add = thm "DERIV_cos_add";
  2829 val isCont_cos = thm "isCont_cos";
  2830 val isCont_sin = thm "isCont_sin";
  2831 val isCont_exp = thm "isCont_exp";
  2832 val sin_zero_abs_cos_one = thm "sin_zero_abs_cos_one";
  2833 val exp_eq_one_iff = thm "exp_eq_one_iff";
  2834 val cos_one_sin_zero = thm "cos_one_sin_zero";
  2835 val real_root_less_mono = thm "real_root_less_mono";
  2836 val real_root_le_mono = thm "real_root_le_mono";
  2837 val real_root_less_iff = thm "real_root_less_iff";
  2838 val real_root_le_iff = thm "real_root_le_iff";
  2839 val real_root_eq_iff = thm "real_root_eq_iff";
  2840 val real_root_pos_unique = thm "real_root_pos_unique";
  2841 val real_root_mult = thm "real_root_mult";
  2842 val real_root_inverse = thm "real_root_inverse";
  2843 val real_root_divide = thm "real_root_divide";
  2844 val real_sqrt_less_mono = thm "real_sqrt_less_mono";
  2845 val real_sqrt_le_mono = thm "real_sqrt_le_mono";
  2846 val real_sqrt_less_iff = thm "real_sqrt_less_iff";
  2847 val real_sqrt_le_iff = thm "real_sqrt_le_iff";
  2848 val real_sqrt_eq_iff = thm "real_sqrt_eq_iff";
  2849 val real_sqrt_sos_less_one_iff = thm "real_sqrt_sos_less_one_iff";
  2850 val real_sqrt_sos_eq_one_iff = thm "real_sqrt_sos_eq_one_iff";
  2851 val real_divide_square_eq = thm "real_divide_square_eq";
  2852 val real_sqrt_sum_squares_gt_zero1 = thm "real_sqrt_sum_squares_gt_zero1";
  2853 val real_sqrt_sum_squares_gt_zero2 = thm "real_sqrt_sum_squares_gt_zero2";
  2854 val real_sqrt_sum_squares_gt_zero3 = thm "real_sqrt_sum_squares_gt_zero3";
  2855 val real_sqrt_sum_squares_gt_zero3a = thm "real_sqrt_sum_squares_gt_zero3a";
  2856 val real_sqrt_sum_squares_eq_cancel = thm "real_sqrt_sum_squares_eq_cancel";
  2857 val real_sqrt_sum_squares_eq_cancel2 = thm "real_sqrt_sum_squares_eq_cancel2";
  2858 val cos_x_y_ge_minus_one = thm "cos_x_y_ge_minus_one";
  2859 val cos_x_y_ge_minus_one1a = thm "cos_x_y_ge_minus_one1a";
  2860 val cos_x_y_le_one = thm "cos_x_y_le_one";
  2861 val cos_x_y_le_one2 = thm "cos_x_y_le_one2";
  2862 val cos_abs_x_y_ge_minus_one = thm "cos_abs_x_y_ge_minus_one";
  2863 val cos_abs_x_y_le_one = thm "cos_abs_x_y_le_one";
  2864 val minus_pi_less_zero = thm "minus_pi_less_zero";
  2865 val arcos_ge_minus_pi = thm "arcos_ge_minus_pi";
  2866 val sin_x_y_disj = thm "sin_x_y_disj";
  2867 val cos_x_y_disj = thm "cos_x_y_disj";
  2868 val real_sqrt_divide_less_zero = thm "real_sqrt_divide_less_zero";
  2869 val polar_ex1 = thm "polar_ex1";
  2870 val real_sum_squares_cancel2a = thm "real_sum_squares_cancel2a";
  2871 val polar_ex2 = thm "polar_ex2";
  2872 val polar_Ex = thm "polar_Ex";
  2873 val real_sqrt_ge_abs1 = thm "real_sqrt_ge_abs1";
  2874 val real_sqrt_ge_abs2 = thm "real_sqrt_ge_abs2";
  2875 val real_sqrt_two_gt_zero = thm "real_sqrt_two_gt_zero";
  2876 val real_sqrt_two_ge_zero = thm "real_sqrt_two_ge_zero";
  2877 val real_sqrt_two_gt_one = thm "real_sqrt_two_gt_one";
  2878 val STAR_exp_ln = thm "STAR_exp_ln";
  2879 val hypreal_add_Infinitesimal_gt_zero = thm "hypreal_add_Infinitesimal_gt_zero";
  2880 val NSDERIV_exp_ln_one = thm "NSDERIV_exp_ln_one";
  2881 val DERIV_exp_ln_one = thm "DERIV_exp_ln_one";
  2882 val isCont_inv_fun = thm "isCont_inv_fun";
  2883 val isCont_inv_fun_inv = thm "isCont_inv_fun_inv";
  2884 val LIM_fun_gt_zero = thm "LIM_fun_gt_zero";
  2885 val LIM_fun_less_zero = thm "LIM_fun_less_zero";
  2886 val LIM_fun_not_zero = thm "LIM_fun_not_zero";
  2887 *}
  2888   
  2889 end