src/HOL/Hyperreal/Transcendental.thy
author nipkow
Mon Aug 16 14:22:27 2004 +0200 (2004-08-16)
changeset 15131 c69542757a4d
parent 15086 e6a2a98d5ef5
child 15140 322485b816ac
permissions -rw-r--r--
New theory header syntax.
     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
    11 import NthRoot Fact HSeries EvenOdd Lim
    12 begin
    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)
   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 (simp add: suminf_diff [OF sums_summable sums_summable] add_ac mult_ac)
   694 apply (rule_tac f = suminf in arg_cong)
   695 apply (rule ext)
   696 apply (simp add: diff_def right_distrib add_ac mult_ac)
   697 done
   698 
   699 
   700 subsection{*Formal Derivatives of Exp, Sin, and Cos Series*} 
   701 
   702 lemma exp_fdiffs: 
   703       "diffs (%n. inverse(real (fact n))) = (%n. inverse(real (fact n)))"
   704 apply (unfold diffs_def)
   705 apply (rule ext)
   706 apply (subst fact_Suc)
   707 apply (subst real_of_nat_mult)
   708 apply (subst inverse_mult_distrib)
   709 apply (auto simp add: mult_assoc [symmetric])
   710 done
   711 
   712 lemma sin_fdiffs: 
   713       "diffs(%n. if even n then 0  
   714            else (- 1) ^ ((n - Suc 0) div 2)/(real (fact n)))  
   715        = (%n. if even n then  
   716                  (- 1) ^ (n div 2)/(real (fact n))  
   717               else 0)"
   718 apply (unfold diffs_def real_divide_def)
   719 apply (rule ext)
   720 apply (subst fact_Suc)
   721 apply (subst real_of_nat_mult)
   722 apply (subst even_nat_Suc)
   723 apply (subst inverse_mult_distrib, auto)
   724 done
   725 
   726 lemma sin_fdiffs2: 
   727        "diffs(%n. if even n then 0  
   728            else (- 1) ^ ((n - Suc 0) div 2)/(real (fact n))) n  
   729        = (if even n then  
   730                  (- 1) ^ (n div 2)/(real (fact n))  
   731               else 0)"
   732 apply (unfold diffs_def real_divide_def)
   733 apply (subst fact_Suc)
   734 apply (subst real_of_nat_mult)
   735 apply (subst even_nat_Suc)
   736 apply (subst inverse_mult_distrib, auto)
   737 done
   738 
   739 lemma cos_fdiffs: 
   740       "diffs(%n. if even n then  
   741                  (- 1) ^ (n div 2)/(real (fact n)) else 0)  
   742        = (%n. - (if even n then 0  
   743            else (- 1) ^ ((n - Suc 0)div 2)/(real (fact n))))"
   744 apply (unfold diffs_def real_divide_def)
   745 apply (rule ext)
   746 apply (subst fact_Suc)
   747 apply (subst real_of_nat_mult)
   748 apply (auto simp add: mult_assoc odd_Suc_mult_two_ex)
   749 done
   750 
   751 
   752 lemma cos_fdiffs2: 
   753       "diffs(%n. if even n then  
   754                  (- 1) ^ (n div 2)/(real (fact n)) else 0) n 
   755        = - (if even n then 0  
   756            else (- 1) ^ ((n - Suc 0)div 2)/(real (fact n)))"
   757 apply (unfold diffs_def real_divide_def)
   758 apply (subst fact_Suc)
   759 apply (subst real_of_nat_mult) 
   760 apply (auto simp add: mult_assoc odd_Suc_mult_two_ex)
   761 done
   762 
   763 text{*Now at last we can get the derivatives of exp, sin and cos*}
   764 
   765 lemma lemma_sin_minus:
   766      "- sin x =
   767          suminf(%n. - ((if even n then 0 
   768                   else (- 1) ^ ((n - Suc 0) div 2)/(real (fact n))) * x ^ n))"
   769 by (auto intro!: sums_unique sums_minus sin_converges)
   770 
   771 lemma lemma_exp_ext: "exp = (%x. suminf (%n. inverse (real (fact n)) * x ^ n))"
   772 by (auto intro!: ext simp add: exp_def)
   773 
   774 lemma DERIV_exp [simp]: "DERIV exp x :> exp(x)"
   775 apply (unfold exp_def)
   776 apply (subst lemma_exp_ext)
   777 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) ")
   778 apply (rule_tac [2] K = "1 + \<bar>x\<bar> " in termdiffs)
   779 apply (auto intro: exp_converges [THEN sums_summable] simp add: exp_fdiffs, arith)
   780 done
   781 
   782 lemma lemma_sin_ext:
   783      "sin = (%x. suminf(%n. 
   784                    (if even n then 0  
   785                        else (- 1) ^ ((n - Suc 0) div 2)/(real (fact n))) *  
   786                    x ^ n))"
   787 by (auto intro!: ext simp add: sin_def)
   788 
   789 lemma lemma_cos_ext:
   790      "cos = (%x. suminf(%n. 
   791                    (if even n then (- 1) ^ (n div 2)/(real (fact n)) else 0) *
   792                    x ^ n))"
   793 by (auto intro!: ext simp add: cos_def)
   794 
   795 lemma DERIV_sin [simp]: "DERIV sin x :> cos(x)"
   796 apply (unfold cos_def)
   797 apply (subst lemma_sin_ext)
   798 apply (auto simp add: sin_fdiffs2 [symmetric])
   799 apply (rule_tac K = "1 + \<bar>x\<bar> " in termdiffs)
   800 apply (auto intro: sin_converges cos_converges sums_summable intro!: sums_minus [THEN sums_summable] simp add: cos_fdiffs sin_fdiffs, arith)
   801 done
   802 
   803 lemma DERIV_cos [simp]: "DERIV cos x :> -sin(x)"
   804 apply (subst lemma_cos_ext)
   805 apply (auto simp add: lemma_sin_minus cos_fdiffs2 [symmetric] minus_mult_left)
   806 apply (rule_tac K = "1 + \<bar>x\<bar> " in termdiffs)
   807 apply (auto intro: sin_converges cos_converges sums_summable intro!: sums_minus [THEN sums_summable] simp add: cos_fdiffs sin_fdiffs diffs_minus, arith)
   808 done
   809 
   810 
   811 subsection{*Properties of the Exponential Function*}
   812 
   813 lemma exp_zero [simp]: "exp 0 = 1"
   814 proof -
   815   have "(\<Sum>n = 0..<1. inverse (real (fact n)) * 0 ^ n) =
   816         suminf (\<lambda>n. inverse (real (fact n)) * 0 ^ n)"
   817     by (rule series_zero [rule_format, THEN sums_unique],
   818         case_tac "m", auto)
   819   thus ?thesis by (simp add:  exp_def) 
   820 qed
   821 
   822 lemma exp_ge_add_one_self [simp]: "0 \<le> x ==> (1 + x) \<le> exp(x)"
   823 apply (drule real_le_imp_less_or_eq, auto)
   824 apply (unfold exp_def)
   825 apply (rule real_le_trans)
   826 apply (rule_tac [2] n = 2 and f = " (%n. inverse (real (fact n)) * x ^ n) " in series_pos_le)
   827 apply (auto intro: summable_exp simp add: numeral_2_eq_2 zero_le_power zero_le_mult_iff)
   828 done
   829 
   830 lemma exp_gt_one [simp]: "0 < x ==> 1 < exp x"
   831 apply (rule order_less_le_trans)
   832 apply (rule_tac [2] exp_ge_add_one_self, auto)
   833 done
   834 
   835 lemma DERIV_exp_add_const: "DERIV (%x. exp (x + y)) x :> exp(x + y)"
   836 proof -
   837   have "DERIV (exp \<circ> (\<lambda>x. x + y)) x :> exp (x + y) * (1+0)"
   838     by (fast intro: DERIV_chain DERIV_add DERIV_exp DERIV_Id DERIV_const) 
   839   thus ?thesis by (simp add: o_def)
   840 qed
   841 
   842 lemma DERIV_exp_minus [simp]: "DERIV (%x. exp (-x)) x :> - exp(-x)"
   843 proof -
   844   have "DERIV (exp \<circ> uminus) x :> exp (- x) * - 1"
   845     by (fast intro: DERIV_chain DERIV_minus DERIV_exp DERIV_Id) 
   846   thus ?thesis by (simp add: o_def)
   847 qed
   848 
   849 lemma DERIV_exp_exp_zero [simp]: "DERIV (%x. exp (x + y) * exp (- x)) x :> 0"
   850 proof -
   851   have "DERIV (\<lambda>x. exp (x + y) * exp (- x)) x
   852        :> exp (x + y) * exp (- x) + - exp (- x) * exp (x + y)"
   853     by (fast intro: DERIV_exp_add_const DERIV_exp_minus DERIV_mult) 
   854   thus ?thesis by simp
   855 qed
   856 
   857 lemma exp_add_mult_minus [simp]: "exp(x + y)*exp(-x) = exp(y)"
   858 proof -
   859   have "\<forall>x. DERIV (%x. exp (x + y) * exp (- x)) x :> 0" by simp
   860   hence "exp (x + y) * exp (- x) = exp (0 + y) * exp (- 0)" 
   861     by (rule DERIV_isconst_all) 
   862   thus ?thesis by simp
   863 qed
   864 
   865 lemma exp_mult_minus [simp]: "exp x * exp(-x) = 1"
   866 proof -
   867   have "exp (x + 0) * exp (- x) = exp 0" by (rule exp_add_mult_minus) 
   868   thus ?thesis by simp
   869 qed
   870 
   871 lemma exp_mult_minus2 [simp]: "exp(-x)*exp(x) = 1"
   872 by (simp add: mult_commute)
   873 
   874 
   875 lemma exp_minus: "exp(-x) = inverse(exp(x))"
   876 by (auto intro: inverse_unique [symmetric])
   877 
   878 lemma exp_add: "exp(x + y) = exp(x) * exp(y)"
   879 proof -
   880   have "exp x * exp y = exp x * (exp (x + y) * exp (- x))" by simp
   881   thus ?thesis by (simp (no_asm_simp) add: mult_ac)
   882 qed
   883 
   884 text{*Proof: because every exponential can be seen as a square.*}
   885 lemma exp_ge_zero [simp]: "0 \<le> exp x"
   886 apply (rule_tac t = x in real_sum_of_halves [THEN subst])
   887 apply (subst exp_add, auto)
   888 done
   889 
   890 lemma exp_not_eq_zero [simp]: "exp x \<noteq> 0"
   891 apply (cut_tac x = x in exp_mult_minus2)
   892 apply (auto simp del: exp_mult_minus2)
   893 done
   894 
   895 lemma exp_gt_zero [simp]: "0 < exp x"
   896 by (simp add: order_less_le)
   897 
   898 lemma inv_exp_gt_zero [simp]: "0 < inverse(exp x)"
   899 by (auto intro: positive_imp_inverse_positive)
   900 
   901 lemma abs_exp_cancel [simp]: "\<bar>exp x\<bar> = exp x"
   902 by (auto simp add: abs_eqI2)
   903 
   904 lemma exp_real_of_nat_mult: "exp(real n * x) = exp(x) ^ n"
   905 apply (induct_tac "n")
   906 apply (auto simp add: real_of_nat_Suc right_distrib exp_add mult_commute)
   907 done
   908 
   909 lemma exp_diff: "exp(x - y) = exp(x)/(exp y)"
   910 apply (unfold real_diff_def real_divide_def)
   911 apply (simp (no_asm) add: exp_add exp_minus)
   912 done
   913 
   914 
   915 lemma exp_less_mono:
   916   assumes xy: "x < y" shows "exp x < exp y"
   917 proof -
   918   have "1 < exp (y + - x)"
   919     by (rule real_less_sum_gt_zero [THEN exp_gt_one])
   920   hence "exp x * inverse (exp x) < exp y * inverse (exp x)"
   921     by (auto simp add: exp_add exp_minus)
   922   thus ?thesis
   923     by (simp add: divide_inverse [symmetric] pos_less_divide_eq)
   924 qed
   925 
   926 lemma exp_less_cancel: "exp x < exp y ==> x < y"
   927 apply (rule ccontr) 
   928 apply (simp add: linorder_not_less order_le_less) 
   929 apply (auto dest: exp_less_mono)
   930 done
   931 
   932 lemma exp_less_cancel_iff [iff]: "(exp(x) < exp(y)) = (x < y)"
   933 by (auto intro: exp_less_mono exp_less_cancel)
   934 
   935 lemma exp_le_cancel_iff [iff]: "(exp(x) \<le> exp(y)) = (x \<le> y)"
   936 by (auto simp add: linorder_not_less [symmetric])
   937 
   938 lemma exp_inj_iff [iff]: "(exp x = exp y) = (x = y)"
   939 by (simp add: order_eq_iff)
   940 
   941 lemma lemma_exp_total: "1 \<le> y ==> \<exists>x. 0 \<le> x & x \<le> y - 1 & exp(x) = y"
   942 apply (rule IVT)
   943 apply (auto intro: DERIV_exp [THEN DERIV_isCont] simp add: le_diff_eq)
   944 apply (subgoal_tac "1 + (y - 1) \<le> exp (y - 1)") 
   945 apply simp 
   946 apply (rule exp_ge_add_one_self, simp)
   947 done
   948 
   949 lemma exp_total: "0 < y ==> \<exists>x. exp x = y"
   950 apply (rule_tac x = 1 and y = y in linorder_cases)
   951 apply (drule order_less_imp_le [THEN lemma_exp_total])
   952 apply (rule_tac [2] x = 0 in exI)
   953 apply (frule_tac [3] real_inverse_gt_one)
   954 apply (drule_tac [4] order_less_imp_le [THEN lemma_exp_total], auto)
   955 apply (rule_tac x = "-x" in exI)
   956 apply (simp add: exp_minus)
   957 done
   958 
   959 
   960 subsection{*Properties of the Logarithmic Function*}
   961 
   962 lemma ln_exp[simp]: "ln(exp x) = x"
   963 by (simp add: ln_def)
   964 
   965 lemma exp_ln_iff[simp]: "(exp(ln x) = x) = (0 < x)"
   966 apply (auto dest: exp_total)
   967 apply (erule subst, simp) 
   968 done
   969 
   970 lemma ln_mult: "[| 0 < x; 0 < y |] ==> ln(x * y) = ln(x) + ln(y)"
   971 apply (rule exp_inj_iff [THEN iffD1])
   972 apply (frule real_mult_order)
   973 apply (auto simp add: exp_add exp_ln_iff [symmetric] simp del: exp_inj_iff exp_ln_iff)
   974 done
   975 
   976 lemma ln_inj_iff[simp]: "[| 0 < x; 0 < y |] ==> (ln x = ln y) = (x = y)"
   977 apply (simp only: exp_ln_iff [symmetric])
   978 apply (erule subst)+
   979 apply simp 
   980 done
   981 
   982 lemma ln_one[simp]: "ln 1 = 0"
   983 by (rule exp_inj_iff [THEN iffD1], auto)
   984 
   985 lemma ln_inverse: "0 < x ==> ln(inverse x) = - ln x"
   986 apply (rule_tac a1 = "ln x" in add_left_cancel [THEN iffD1])
   987 apply (auto simp add: positive_imp_inverse_positive ln_mult [symmetric])
   988 done
   989 
   990 lemma ln_div: 
   991     "[|0 < x; 0 < y|] ==> ln(x/y) = ln x - ln y"
   992 apply (unfold real_divide_def)
   993 apply (auto simp add: positive_imp_inverse_positive ln_mult ln_inverse)
   994 done
   995 
   996 lemma ln_less_cancel_iff[simp]: "[| 0 < x; 0 < y|] ==> (ln x < ln y) = (x < y)"
   997 apply (simp only: exp_ln_iff [symmetric])
   998 apply (erule subst)+
   999 apply simp 
  1000 done
  1001 
  1002 lemma ln_le_cancel_iff[simp]: "[| 0 < x; 0 < y|] ==> (ln x \<le> ln y) = (x \<le> y)"
  1003 by (auto simp add: linorder_not_less [symmetric])
  1004 
  1005 lemma ln_realpow: "0 < x ==> ln(x ^ n) = real n * ln(x)"
  1006 by (auto dest!: exp_total simp add: exp_real_of_nat_mult [symmetric])
  1007 
  1008 lemma ln_add_one_self_le_self [simp]: "0 \<le> x ==> ln(1 + x) \<le> x"
  1009 apply (rule ln_exp [THEN subst])
  1010 apply (rule ln_le_cancel_iff [THEN iffD2], auto)
  1011 done
  1012 
  1013 lemma ln_less_self [simp]: "0 < x ==> ln x < x"
  1014 apply (rule order_less_le_trans)
  1015 apply (rule_tac [2] ln_add_one_self_le_self)
  1016 apply (rule ln_less_cancel_iff [THEN iffD2], auto)
  1017 done
  1018 
  1019 lemma ln_ge_zero:
  1020   assumes x: "1 \<le> x" shows "0 \<le> ln x"
  1021 proof -
  1022   have "0 < x" using x by arith
  1023   hence "exp 0 \<le> exp (ln x)"
  1024     by (simp add: x exp_ln_iff [symmetric] del: exp_ln_iff)
  1025   thus ?thesis by (simp only: exp_le_cancel_iff)
  1026 qed
  1027 
  1028 lemma ln_ge_zero_imp_ge_one:
  1029   assumes ln: "0 \<le> ln x" 
  1030       and x:  "0 < x"
  1031   shows "1 \<le> x"
  1032 proof -
  1033   from ln have "ln 1 \<le> ln x" by simp
  1034   thus ?thesis by (simp add: x del: ln_one) 
  1035 qed
  1036 
  1037 lemma ln_ge_zero_iff [simp]: "0 < x ==> (0 \<le> ln x) = (1 \<le> x)"
  1038 by (blast intro: ln_ge_zero ln_ge_zero_imp_ge_one)
  1039 
  1040 lemma ln_gt_zero:
  1041   assumes x: "1 < x" shows "0 < ln x"
  1042 proof -
  1043   have "0 < x" using x by arith
  1044   hence "exp 0 < exp (ln x)"
  1045     by (simp add: x exp_ln_iff [symmetric] del: exp_ln_iff)
  1046   thus ?thesis  by (simp only: exp_less_cancel_iff)
  1047 qed
  1048 
  1049 lemma ln_gt_zero_imp_gt_one:
  1050   assumes ln: "0 < ln x" 
  1051       and x:  "0 < x"
  1052   shows "1 < x"
  1053 proof -
  1054   from ln have "ln 1 < ln x" by simp
  1055   thus ?thesis by (simp add: x del: ln_one) 
  1056 qed
  1057 
  1058 lemma ln_gt_zero_iff [simp]: "0 < x ==> (0 < ln x) = (1 < x)"
  1059 by (blast intro: ln_gt_zero ln_gt_zero_imp_gt_one)
  1060 
  1061 lemma ln_not_eq_zero [simp]: "[| 0 < x; x \<noteq> 1 |] ==> ln x \<noteq> 0"
  1062 apply safe
  1063 apply (drule exp_inj_iff [THEN iffD2])
  1064 apply (drule exp_ln_iff [THEN iffD2], auto)
  1065 done
  1066 
  1067 lemma ln_less_zero: "[| 0 < x; x < 1 |] ==> ln x < 0"
  1068 apply (rule exp_less_cancel_iff [THEN iffD1])
  1069 apply (auto simp add: exp_ln_iff [symmetric] simp del: exp_ln_iff)
  1070 done
  1071 
  1072 lemma exp_ln_eq: "exp u = x ==> ln x = u"
  1073 by auto
  1074 
  1075 
  1076 subsection{*Basic Properties of the Trigonometric Functions*}
  1077 
  1078 lemma sin_zero [simp]: "sin 0 = 0"
  1079 by (auto intro!: sums_unique [symmetric] LIMSEQ_const 
  1080          simp add: sin_def sums_def simp del: power_0_left)
  1081 
  1082 lemma lemma_series_zero2: "(\<forall>m. n \<le> m --> f m = 0) --> f sums sumr 0 n f"
  1083 by (auto intro: series_zero)
  1084 
  1085 lemma cos_zero [simp]: "cos 0 = 1"
  1086 apply (unfold cos_def)
  1087 apply (rule sums_unique [symmetric])
  1088 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)
  1089 apply auto
  1090 done
  1091 
  1092 lemma DERIV_sin_sin_mult [simp]:
  1093      "DERIV (%x. sin(x)*sin(x)) x :> cos(x) * sin(x) + cos(x) * sin(x)"
  1094 by (rule DERIV_mult, auto)
  1095 
  1096 lemma DERIV_sin_sin_mult2 [simp]:
  1097      "DERIV (%x. sin(x)*sin(x)) x :> 2 * cos(x) * sin(x)"
  1098 apply (cut_tac x = x in DERIV_sin_sin_mult)
  1099 apply (auto simp add: mult_assoc)
  1100 done
  1101 
  1102 lemma DERIV_sin_realpow2 [simp]:
  1103      "DERIV (%x. (sin x)\<twosuperior>) x :> cos(x) * sin(x) + cos(x) * sin(x)"
  1104 by (auto simp add: numeral_2_eq_2 real_mult_assoc [symmetric])
  1105 
  1106 lemma DERIV_sin_realpow2a [simp]:
  1107      "DERIV (%x. (sin x)\<twosuperior>) x :> 2 * cos(x) * sin(x)"
  1108 by (auto simp add: numeral_2_eq_2)
  1109 
  1110 lemma DERIV_cos_cos_mult [simp]:
  1111      "DERIV (%x. cos(x)*cos(x)) x :> -sin(x) * cos(x) + -sin(x) * cos(x)"
  1112 by (rule DERIV_mult, auto)
  1113 
  1114 lemma DERIV_cos_cos_mult2 [simp]:
  1115      "DERIV (%x. cos(x)*cos(x)) x :> -2 * cos(x) * sin(x)"
  1116 apply (cut_tac x = x in DERIV_cos_cos_mult)
  1117 apply (auto simp add: mult_ac)
  1118 done
  1119 
  1120 lemma DERIV_cos_realpow2 [simp]:
  1121      "DERIV (%x. (cos x)\<twosuperior>) x :> -sin(x) * cos(x) + -sin(x) * cos(x)"
  1122 by (auto simp add: numeral_2_eq_2 real_mult_assoc [symmetric])
  1123 
  1124 lemma DERIV_cos_realpow2a [simp]:
  1125      "DERIV (%x. (cos x)\<twosuperior>) x :> -2 * cos(x) * sin(x)"
  1126 by (auto simp add: numeral_2_eq_2)
  1127 
  1128 lemma lemma_DERIV_subst: "[| DERIV f x :> D; D = E |] ==> DERIV f x :> E"
  1129 by auto
  1130 
  1131 lemma DERIV_cos_realpow2b: "DERIV (%x. (cos x)\<twosuperior>) x :> -(2 * cos(x) * sin(x))"
  1132 apply (rule lemma_DERIV_subst)
  1133 apply (rule DERIV_cos_realpow2a, auto)
  1134 done
  1135 
  1136 (* most useful *)
  1137 lemma DERIV_cos_cos_mult3 [simp]: "DERIV (%x. cos(x)*cos(x)) x :> -(2 * cos(x) * sin(x))"
  1138 apply (rule lemma_DERIV_subst)
  1139 apply (rule DERIV_cos_cos_mult2, auto)
  1140 done
  1141 
  1142 lemma DERIV_sin_circle_all: 
  1143      "\<forall>x. DERIV (%x. (sin x)\<twosuperior> + (cos x)\<twosuperior>) x :>  
  1144              (2*cos(x)*sin(x) - 2*cos(x)*sin(x))"
  1145 apply (unfold real_diff_def, safe)
  1146 apply (rule DERIV_add)
  1147 apply (auto simp add: numeral_2_eq_2)
  1148 done
  1149 
  1150 lemma DERIV_sin_circle_all_zero [simp]: "\<forall>x. DERIV (%x. (sin x)\<twosuperior> + (cos x)\<twosuperior>) x :> 0"
  1151 by (cut_tac DERIV_sin_circle_all, auto)
  1152 
  1153 lemma sin_cos_squared_add [simp]: "((sin x)\<twosuperior>) + ((cos x)\<twosuperior>) = 1"
  1154 apply (cut_tac x = x and y = 0 in DERIV_sin_circle_all_zero [THEN DERIV_isconst_all])
  1155 apply (auto simp add: numeral_2_eq_2)
  1156 done
  1157 
  1158 lemma sin_cos_squared_add2 [simp]: "((cos x)\<twosuperior>) + ((sin x)\<twosuperior>) = 1"
  1159 apply (subst real_add_commute)
  1160 apply (simp (no_asm) del: realpow_Suc)
  1161 done
  1162 
  1163 lemma sin_cos_squared_add3 [simp]: "cos x * cos x + sin x * sin x = 1"
  1164 apply (cut_tac x = x in sin_cos_squared_add2)
  1165 apply (auto simp add: numeral_2_eq_2)
  1166 done
  1167 
  1168 lemma sin_squared_eq: "(sin x)\<twosuperior> = 1 - (cos x)\<twosuperior>"
  1169 apply (rule_tac a1 = "(cos x)\<twosuperior> " in add_right_cancel [THEN iffD1])
  1170 apply (simp del: realpow_Suc)
  1171 done
  1172 
  1173 lemma cos_squared_eq: "(cos x)\<twosuperior> = 1 - (sin x)\<twosuperior>"
  1174 apply (rule_tac a1 = "(sin x)\<twosuperior>" in add_right_cancel [THEN iffD1])
  1175 apply (simp del: realpow_Suc)
  1176 done
  1177 
  1178 lemma real_gt_one_ge_zero_add_less: "[| 1 < x; 0 \<le> y |] ==> 1 < x + (y::real)"
  1179 by arith
  1180 
  1181 lemma abs_sin_le_one [simp]: "\<bar>sin x\<bar> \<le> 1"
  1182 apply (auto simp add: linorder_not_less [symmetric])
  1183 apply (drule_tac n = "Suc 0" in power_gt1)
  1184 apply (auto simp del: realpow_Suc)
  1185 apply (drule_tac r1 = "cos x" in realpow_two_le [THEN [2] real_gt_one_ge_zero_add_less])
  1186 apply (simp add: numeral_2_eq_2 [symmetric] del: realpow_Suc)
  1187 done
  1188 
  1189 lemma sin_ge_minus_one [simp]: "-1 \<le> sin x"
  1190 apply (insert abs_sin_le_one [of x]) 
  1191 apply (simp add: abs_le_interval_iff del: abs_sin_le_one) 
  1192 done
  1193 
  1194 lemma sin_le_one [simp]: "sin x \<le> 1"
  1195 apply (insert abs_sin_le_one [of x]) 
  1196 apply (simp add: abs_le_interval_iff del: abs_sin_le_one) 
  1197 done
  1198 
  1199 lemma abs_cos_le_one [simp]: "\<bar>cos x\<bar> \<le> 1"
  1200 apply (auto simp add: linorder_not_less [symmetric])
  1201 apply (drule_tac n = "Suc 0" in power_gt1)
  1202 apply (auto simp del: realpow_Suc)
  1203 apply (drule_tac r1 = "sin x" in realpow_two_le [THEN [2] real_gt_one_ge_zero_add_less])
  1204 apply (simp add: numeral_2_eq_2 [symmetric] del: realpow_Suc)
  1205 done
  1206 
  1207 lemma cos_ge_minus_one [simp]: "-1 \<le> cos x"
  1208 apply (insert abs_cos_le_one [of x]) 
  1209 apply (simp add: abs_le_interval_iff del: abs_cos_le_one) 
  1210 done
  1211 
  1212 lemma cos_le_one [simp]: "cos x \<le> 1"
  1213 apply (insert abs_cos_le_one [of x]) 
  1214 apply (simp add: abs_le_interval_iff del: abs_cos_le_one)
  1215 done
  1216 
  1217 lemma DERIV_fun_pow: "DERIV g x :> m ==>  
  1218       DERIV (%x. (g x) ^ n) x :> real n * (g x) ^ (n - 1) * m"
  1219 apply (rule lemma_DERIV_subst)
  1220 apply (rule_tac f = " (%x. x ^ n) " in DERIV_chain2)
  1221 apply (rule DERIV_pow, auto)
  1222 done
  1223 
  1224 lemma DERIV_fun_exp: "DERIV g x :> m ==> DERIV (%x. exp(g x)) x :> exp(g x) * m"
  1225 apply (rule lemma_DERIV_subst)
  1226 apply (rule_tac f = exp in DERIV_chain2)
  1227 apply (rule DERIV_exp, auto)
  1228 done
  1229 
  1230 lemma DERIV_fun_sin: "DERIV g x :> m ==> DERIV (%x. sin(g x)) x :> cos(g x) * m"
  1231 apply (rule lemma_DERIV_subst)
  1232 apply (rule_tac f = sin in DERIV_chain2)
  1233 apply (rule DERIV_sin, auto)
  1234 done
  1235 
  1236 lemma DERIV_fun_cos: "DERIV g x :> m ==> DERIV (%x. cos(g x)) x :> -sin(g x) * m"
  1237 apply (rule lemma_DERIV_subst)
  1238 apply (rule_tac f = cos in DERIV_chain2)
  1239 apply (rule DERIV_cos, auto)
  1240 done
  1241 
  1242 lemmas DERIV_intros = DERIV_Id DERIV_const DERIV_cos DERIV_cmult 
  1243                     DERIV_sin  DERIV_exp  DERIV_inverse DERIV_pow 
  1244                     DERIV_add  DERIV_diff  DERIV_mult  DERIV_minus 
  1245                     DERIV_inverse_fun DERIV_quotient DERIV_fun_pow 
  1246                     DERIV_fun_exp DERIV_fun_sin DERIV_fun_cos 
  1247                     DERIV_Id DERIV_const DERIV_cos
  1248 
  1249 (* lemma *)
  1250 lemma lemma_DERIV_sin_cos_add: "\<forall>x.  
  1251          DERIV (%x. (sin (x + y) - (sin x * cos y + cos x * sin y)) ^ 2 +  
  1252                (cos (x + y) - (cos x * cos y - sin x * sin y)) ^ 2) x :> 0"
  1253 apply (safe, rule lemma_DERIV_subst)
  1254 apply (best intro!: DERIV_intros intro: DERIV_chain2) 
  1255   --{*replaces the old @{text DERIV_tac}*}
  1256 apply (auto simp add: real_diff_def left_distrib right_distrib mult_ac add_ac)
  1257 done
  1258 
  1259 lemma sin_cos_add [simp]:
  1260      "(sin (x + y) - (sin x * cos y + cos x * sin y)) ^ 2 +  
  1261       (cos (x + y) - (cos x * cos y - sin x * sin y)) ^ 2 = 0"
  1262 apply (cut_tac y = 0 and x = x and y7 = y 
  1263        in lemma_DERIV_sin_cos_add [THEN DERIV_isconst_all])
  1264 apply (auto simp add: numeral_2_eq_2)
  1265 done
  1266 
  1267 lemma sin_add: "sin (x + y) = sin x * cos y + cos x * sin y"
  1268 apply (cut_tac x = x and y = y in sin_cos_add)
  1269 apply (auto dest!: real_sum_squares_cancel_a 
  1270             simp add: numeral_2_eq_2 real_add_eq_0_iff simp del: sin_cos_add)
  1271 done
  1272 
  1273 lemma cos_add: "cos (x + y) = cos x * cos y - sin x * sin y"
  1274 apply (cut_tac x = x and y = y in sin_cos_add)
  1275 apply (auto dest!: real_sum_squares_cancel_a
  1276             simp add: numeral_2_eq_2 real_add_eq_0_iff simp del: sin_cos_add)
  1277 done
  1278 
  1279 lemma lemma_DERIV_sin_cos_minus:
  1280     "\<forall>x. DERIV (%x. (sin(-x) + (sin x)) ^ 2 + (cos(-x) - (cos x)) ^ 2) x :> 0"
  1281 apply (safe, rule lemma_DERIV_subst)
  1282 apply (best intro!: DERIV_intros intro: DERIV_chain2) 
  1283 apply (auto simp add: real_diff_def left_distrib right_distrib mult_ac add_ac)
  1284 done
  1285 
  1286 lemma sin_cos_minus [simp]: 
  1287     "(sin(-x) + (sin x)) ^ 2 + (cos(-x) - (cos x)) ^ 2 = 0"
  1288 apply (cut_tac y = 0 and x = x 
  1289        in lemma_DERIV_sin_cos_minus [THEN DERIV_isconst_all])
  1290 apply (auto simp add: numeral_2_eq_2)
  1291 done
  1292 
  1293 lemma sin_minus [simp]: "sin (-x) = -sin(x)"
  1294 apply (cut_tac x = x in sin_cos_minus)
  1295 apply (auto dest!: real_sum_squares_cancel_a 
  1296        simp add: numeral_2_eq_2 real_add_eq_0_iff simp del: sin_cos_minus)
  1297 done
  1298 
  1299 lemma cos_minus [simp]: "cos (-x) = cos(x)"
  1300 apply (cut_tac x = x in sin_cos_minus)
  1301 apply (auto dest!: real_sum_squares_cancel_a 
  1302                    simp add: numeral_2_eq_2 simp del: sin_cos_minus)
  1303 done
  1304 
  1305 lemma sin_diff: "sin (x - y) = sin x * cos y - cos x * sin y"
  1306 apply (unfold real_diff_def)
  1307 apply (simp (no_asm) add: sin_add)
  1308 done
  1309 
  1310 lemma sin_diff2: "sin (x - y) = cos y * sin x - sin y * cos x"
  1311 by (simp add: sin_diff mult_commute)
  1312 
  1313 lemma cos_diff: "cos (x - y) = cos x * cos y + sin x * sin y"
  1314 apply (unfold real_diff_def)
  1315 apply (simp (no_asm) add: cos_add)
  1316 done
  1317 
  1318 lemma cos_diff2: "cos (x - y) = cos y * cos x + sin y * sin x"
  1319 by (simp add: cos_diff mult_commute)
  1320 
  1321 lemma sin_double [simp]: "sin(2 * x) = 2* sin x * cos x"
  1322 by (cut_tac x = x and y = x in sin_add, auto)
  1323 
  1324 
  1325 lemma cos_double: "cos(2* x) = ((cos x)\<twosuperior>) - ((sin x)\<twosuperior>)"
  1326 apply (cut_tac x = x and y = x in cos_add)
  1327 apply (auto simp add: numeral_2_eq_2)
  1328 done
  1329 
  1330 
  1331 subsection{*The Constant Pi*}
  1332 
  1333 text{*Show that there's a least positive @{term x} with @{term "cos(x) = 0"}; 
  1334    hence define pi.*}
  1335 
  1336 lemma sin_paired:
  1337      "(%n. (- 1) ^ n /(real (fact (2 * n + 1))) * x ^ (2 * n + 1)) 
  1338       sums  sin x"
  1339 proof -
  1340   have "(\<lambda>n. \<Sum>k = n * 2..<n * 2 + 2.
  1341             (if even k then 0
  1342              else (- 1) ^ ((k - Suc 0) div 2) / real (fact k)) *
  1343             x ^ k) 
  1344 	sums
  1345 	suminf (\<lambda>n. (if even n then 0
  1346 		     else (- 1) ^ ((n - Suc 0) div 2) / real (fact n)) *
  1347 	            x ^ n)" 
  1348     by (rule sin_converges [THEN sums_summable, THEN sums_group], simp) 
  1349   thus ?thesis by (simp add: mult_ac sin_def)
  1350 qed
  1351 
  1352 lemma sin_gt_zero: "[|0 < x; x < 2 |] ==> 0 < sin x"
  1353 apply (subgoal_tac 
  1354        "(\<lambda>n. \<Sum>k = n * 2..<n * 2 + 2.
  1355               (- 1) ^ k / real (fact (2 * k + 1)) * x ^ (2 * k + 1)) 
  1356      sums suminf (\<lambda>n. (- 1) ^ n / real (fact (2 * n + 1)) * x ^ (2 * n + 1))")
  1357  prefer 2
  1358  apply (rule sin_paired [THEN sums_summable, THEN sums_group], simp) 
  1359 apply (rotate_tac 2)
  1360 apply (drule sin_paired [THEN sums_unique, THEN ssubst])
  1361 apply (auto simp del: fact_Suc realpow_Suc)
  1362 apply (frule sums_unique)
  1363 apply (auto simp del: fact_Suc realpow_Suc)
  1364 apply (rule_tac n1 = 0 in series_pos_less [THEN [2] order_le_less_trans])
  1365 apply (auto simp del: fact_Suc realpow_Suc)
  1366 apply (erule sums_summable)
  1367 apply (case_tac "m=0")
  1368 apply (simp (no_asm_simp))
  1369 apply (subgoal_tac "6 * (x * (x * x) / real (Suc (Suc (Suc (Suc (Suc (Suc 0))))))) < 6 * x")
  1370 apply (simp only: mult_less_cancel_left, simp)
  1371 apply (simp (no_asm_simp) add: numeral_2_eq_2 [symmetric] mult_assoc [symmetric])
  1372 apply (subgoal_tac "x*x < 2*3", simp) 
  1373 apply (rule mult_strict_mono)
  1374 apply (auto simp add: real_0_less_add_iff real_of_nat_Suc simp del: fact_Suc)
  1375 apply (subst fact_Suc)
  1376 apply (subst fact_Suc)
  1377 apply (subst fact_Suc)
  1378 apply (subst fact_Suc)
  1379 apply (subst real_of_nat_mult)
  1380 apply (subst real_of_nat_mult)
  1381 apply (subst real_of_nat_mult)
  1382 apply (subst real_of_nat_mult)
  1383 apply (simp (no_asm) add: divide_inverse inverse_mult_distrib del: fact_Suc)
  1384 apply (auto simp add: mult_assoc [symmetric] simp del: fact_Suc)
  1385 apply (rule_tac c="real (Suc (Suc (4*m)))" in mult_less_imp_less_right) 
  1386 apply (auto simp add: mult_assoc simp del: fact_Suc)
  1387 apply (rule_tac c="real (Suc (Suc (Suc (4*m))))" in mult_less_imp_less_right) 
  1388 apply (auto simp add: mult_assoc mult_less_cancel_left simp del: fact_Suc)
  1389 apply (subgoal_tac "x * (x * x ^ (4*m)) = (x ^ (4*m)) * (x * x)") 
  1390 apply (erule ssubst)+
  1391 apply (auto simp del: fact_Suc)
  1392 apply (subgoal_tac "0 < x ^ (4 * m) ")
  1393  prefer 2 apply (simp only: zero_less_power) 
  1394 apply (simp (no_asm_simp) add: mult_less_cancel_left)
  1395 apply (rule mult_strict_mono)
  1396 apply (simp_all (no_asm_simp))
  1397 done
  1398 
  1399 lemma sin_gt_zero1: "[|0 < x; x < 2 |] ==> 0 < sin x"
  1400 by (auto intro: sin_gt_zero)
  1401 
  1402 lemma cos_double_less_one: "[| 0 < x; x < 2 |] ==> cos (2 * x) < 1"
  1403 apply (cut_tac x = x in sin_gt_zero1)
  1404 apply (auto simp add: cos_squared_eq cos_double)
  1405 done
  1406 
  1407 lemma cos_paired:
  1408      "(%n. (- 1) ^ n /(real (fact (2 * n))) * x ^ (2 * n)) sums cos x"
  1409 proof -
  1410   have "(\<lambda>n. \<Sum>k = n * 2..<n * 2 + 2.
  1411             (if even k then (- 1) ^ (k div 2) / real (fact k) else 0) *
  1412             x ^ k) 
  1413         sums
  1414 	suminf
  1415 	 (\<lambda>n. (if even n then (- 1) ^ (n div 2) / real (fact n) else 0) *
  1416 	      x ^ n)" 
  1417     by (rule cos_converges [THEN sums_summable, THEN sums_group], simp) 
  1418   thus ?thesis by (simp add: mult_ac cos_def)
  1419 qed
  1420 
  1421 declare zero_less_power [simp]
  1422 
  1423 lemma fact_lemma: "real (n::nat) * 4 = real (4 * n)"
  1424 by simp
  1425 
  1426 lemma cos_two_less_zero: "cos (2) < 0"
  1427 apply (cut_tac x = 2 in cos_paired)
  1428 apply (drule sums_minus)
  1429 apply (rule neg_less_iff_less [THEN iffD1]) 
  1430 apply (frule sums_unique, auto)
  1431 apply (rule_tac y = "sumr 0 (Suc (Suc (Suc 0))) (%n. - ((- 1) ^ n / (real (fact (2 * n))) * 2 ^ (2 * n))) " in order_less_trans)
  1432 apply (simp (no_asm) add: fact_num_eq_if realpow_num_eq_if del: fact_Suc realpow_Suc)
  1433 apply (simp (no_asm) add: mult_assoc del: sumr_Suc)
  1434 apply (rule sumr_pos_lt_pair)
  1435 apply (erule sums_summable, safe)
  1436 apply (simp (no_asm) add: divide_inverse real_0_less_add_iff mult_assoc [symmetric] 
  1437             del: fact_Suc)
  1438 apply (rule real_mult_inverse_cancel2)
  1439 apply (rule real_of_nat_fact_gt_zero)+
  1440 apply (simp (no_asm) add: mult_assoc [symmetric] del: fact_Suc)
  1441 apply (subst fact_lemma) 
  1442 apply (subst fact_Suc)
  1443 apply (subst real_of_nat_mult)
  1444 apply (erule ssubst, subst real_of_nat_mult)
  1445 apply (rule real_mult_less_mono, force)
  1446 prefer 2 apply force
  1447 apply (rule_tac [2] real_of_nat_fact_gt_zero)
  1448 apply (rule real_of_nat_less_iff [THEN iffD2])
  1449 apply (rule fact_less_mono, auto)
  1450 done
  1451 declare cos_two_less_zero [simp]
  1452 declare cos_two_less_zero [THEN real_not_refl2, simp]
  1453 declare cos_two_less_zero [THEN order_less_imp_le, simp]
  1454 
  1455 lemma cos_is_zero: "EX! x. 0 \<le> x & x \<le> 2 & cos x = 0"
  1456 apply (subgoal_tac "\<exists>x. 0 \<le> x & x \<le> 2 & cos x = 0")
  1457 apply (rule_tac [2] IVT2)
  1458 apply (auto intro: DERIV_isCont DERIV_cos)
  1459 apply (cut_tac x = xa and y = y in linorder_less_linear)
  1460 apply (rule ccontr)
  1461 apply (subgoal_tac " (\<forall>x. cos differentiable x) & (\<forall>x. isCont cos x) ")
  1462 apply (auto intro: DERIV_cos DERIV_isCont simp add: differentiable_def)
  1463 apply (drule_tac f = cos in Rolle)
  1464 apply (drule_tac [5] f = cos in Rolle)
  1465 apply (auto dest!: DERIV_cos [THEN DERIV_unique] simp add: differentiable_def)
  1466 apply (drule_tac y1 = xa in order_le_less_trans [THEN sin_gt_zero])
  1467 apply (assumption, rule_tac y=y in order_less_le_trans, simp_all) 
  1468 apply (drule_tac y1 = y in order_le_less_trans [THEN sin_gt_zero], assumption, simp_all) 
  1469 done
  1470     
  1471 lemma pi_half: "pi/2 = (@x. 0 \<le> x & x \<le> 2 & cos x = 0)"
  1472 by (simp add: pi_def)
  1473 
  1474 lemma cos_pi_half [simp]: "cos (pi / 2) = 0"
  1475 apply (rule cos_is_zero [THEN ex1E])
  1476 apply (auto intro!: someI2 simp add: pi_half)
  1477 done
  1478 
  1479 lemma pi_half_gt_zero: "0 < pi / 2"
  1480 apply (rule cos_is_zero [THEN ex1E])
  1481 apply (auto simp add: pi_half)
  1482 apply (rule someI2, blast, safe)
  1483 apply (drule_tac y = xa in real_le_imp_less_or_eq)
  1484 apply (safe, simp)
  1485 done
  1486 declare pi_half_gt_zero [simp]
  1487 declare pi_half_gt_zero [THEN real_not_refl2, THEN not_sym, simp]
  1488 declare pi_half_gt_zero [THEN order_less_imp_le, simp]
  1489 
  1490 lemma pi_half_less_two: "pi / 2 < 2"
  1491 apply (rule cos_is_zero [THEN ex1E])
  1492 apply (auto simp add: pi_half)
  1493 apply (rule someI2, blast, safe)
  1494 apply (drule_tac x = xa in order_le_imp_less_or_eq)
  1495 apply (safe, simp)
  1496 done
  1497 declare pi_half_less_two [simp]
  1498 declare pi_half_less_two [THEN real_not_refl2, simp]
  1499 declare pi_half_less_two [THEN order_less_imp_le, simp]
  1500 
  1501 lemma pi_gt_zero [simp]: "0 < pi"
  1502 apply (rule_tac c="inverse 2" in mult_less_imp_less_right) 
  1503 apply (cut_tac pi_half_gt_zero, simp_all)
  1504 done
  1505 
  1506 lemma pi_neq_zero [simp]: "pi \<noteq> 0"
  1507 by (rule pi_gt_zero [THEN real_not_refl2, THEN not_sym])
  1508 
  1509 lemma pi_not_less_zero [simp]: "~ (pi < 0)"
  1510 apply (insert pi_gt_zero)
  1511 apply (blast elim: order_less_asym) 
  1512 done
  1513 
  1514 lemma pi_ge_zero [simp]: "0 \<le> pi"
  1515 by (auto intro: order_less_imp_le)
  1516 
  1517 lemma minus_pi_half_less_zero [simp]: "-(pi/2) < 0"
  1518 by auto
  1519 
  1520 lemma sin_pi_half [simp]: "sin(pi/2) = 1"
  1521 apply (cut_tac x = "pi/2" in sin_cos_squared_add2)
  1522 apply (cut_tac sin_gt_zero [OF pi_half_gt_zero pi_half_less_two])
  1523 apply (auto simp add: numeral_2_eq_2)
  1524 done
  1525 
  1526 lemma cos_pi [simp]: "cos pi = -1"
  1527 by (cut_tac x = "pi/2" and y = "pi/2" in cos_add, simp)
  1528 
  1529 lemma sin_pi [simp]: "sin pi = 0"
  1530 by (cut_tac x = "pi/2" and y = "pi/2" in sin_add, simp)
  1531 
  1532 lemma sin_cos_eq: "sin x = cos (pi/2 - x)"
  1533 apply (unfold real_diff_def)
  1534 apply (simp (no_asm) add: cos_add)
  1535 done
  1536 
  1537 lemma minus_sin_cos_eq: "-sin x = cos (x + pi/2)"
  1538 apply (simp (no_asm) add: cos_add)
  1539 done
  1540 declare minus_sin_cos_eq [symmetric, simp]
  1541 
  1542 lemma cos_sin_eq: "cos x = sin (pi/2 - x)"
  1543 apply (unfold real_diff_def)
  1544 apply (simp (no_asm) add: sin_add)
  1545 done
  1546 declare sin_cos_eq [symmetric, simp] cos_sin_eq [symmetric, simp]
  1547 
  1548 lemma sin_periodic_pi [simp]: "sin (x + pi) = - sin x"
  1549 apply (simp (no_asm) add: sin_add)
  1550 done
  1551 
  1552 lemma sin_periodic_pi2 [simp]: "sin (pi + x) = - sin x"
  1553 apply (simp (no_asm) add: sin_add)
  1554 done
  1555 
  1556 lemma cos_periodic_pi [simp]: "cos (x + pi) = - cos x"
  1557 apply (simp (no_asm) add: cos_add)
  1558 done
  1559 
  1560 lemma sin_periodic [simp]: "sin (x + 2*pi) = sin x"
  1561 by (simp add: sin_add cos_double)
  1562 
  1563 lemma cos_periodic [simp]: "cos (x + 2*pi) = cos x"
  1564 by (simp add: cos_add cos_double)
  1565 
  1566 lemma cos_npi [simp]: "cos (real n * pi) = -1 ^ n"
  1567 apply (induct_tac "n")
  1568 apply (auto simp add: real_of_nat_Suc left_distrib)
  1569 done
  1570 
  1571 lemma sin_npi [simp]: "sin (real (n::nat) * pi) = 0"
  1572 apply (induct_tac "n")
  1573 apply (auto simp add: real_of_nat_Suc left_distrib)
  1574 done
  1575 
  1576 lemma sin_npi2 [simp]: "sin (pi * real (n::nat)) = 0"
  1577 apply (cut_tac n = n in sin_npi)
  1578 apply (auto simp add: mult_commute simp del: sin_npi)
  1579 done
  1580 
  1581 lemma cos_two_pi [simp]: "cos (2 * pi) = 1"
  1582 by (simp add: cos_double)
  1583 
  1584 lemma sin_two_pi [simp]: "sin (2 * pi) = 0"
  1585 apply (simp (no_asm))
  1586 done
  1587 
  1588 lemma sin_gt_zero2: "[| 0 < x; x < pi/2 |] ==> 0 < sin x"
  1589 apply (rule sin_gt_zero, assumption)
  1590 apply (rule order_less_trans, assumption)
  1591 apply (rule pi_half_less_two)
  1592 done
  1593 
  1594 lemma sin_less_zero: 
  1595   assumes lb: "- pi/2 < x" and "x < 0" shows "sin x < 0"
  1596 proof -
  1597   have "0 < sin (- x)" using prems by (simp only: sin_gt_zero2) 
  1598   thus ?thesis by simp
  1599 qed
  1600 
  1601 lemma pi_less_4: "pi < 4"
  1602 by (cut_tac pi_half_less_two, auto)
  1603 
  1604 lemma cos_gt_zero: "[| 0 < x; x < pi/2 |] ==> 0 < cos x"
  1605 apply (cut_tac pi_less_4)
  1606 apply (cut_tac f = cos and a = 0 and b = x and y = 0 in IVT2_objl, safe, simp_all)
  1607 apply (force intro: DERIV_isCont DERIV_cos)
  1608 apply (cut_tac cos_is_zero, safe)
  1609 apply (rename_tac y z)
  1610 apply (drule_tac x = y in spec)
  1611 apply (drule_tac x = "pi/2" in spec, simp) 
  1612 done
  1613 
  1614 lemma cos_gt_zero_pi: "[| -(pi/2) < x; x < pi/2 |] ==> 0 < cos x"
  1615 apply (rule_tac x = x and y = 0 in linorder_cases)
  1616 apply (rule cos_minus [THEN subst])
  1617 apply (rule cos_gt_zero)
  1618 apply (auto intro: cos_gt_zero)
  1619 done
  1620  
  1621 lemma cos_ge_zero: "[| -(pi/2) \<le> x; x \<le> pi/2 |] ==> 0 \<le> cos x"
  1622 apply (auto simp add: order_le_less cos_gt_zero_pi)
  1623 apply (subgoal_tac "x = pi/2", auto) 
  1624 done
  1625 
  1626 lemma sin_gt_zero_pi: "[| 0 < x; x < pi  |] ==> 0 < sin x"
  1627 apply (subst sin_cos_eq)
  1628 apply (rotate_tac 1)
  1629 apply (drule real_sum_of_halves [THEN ssubst])
  1630 apply (auto intro!: cos_gt_zero_pi simp del: sin_cos_eq [symmetric])
  1631 done
  1632 
  1633 lemma sin_ge_zero: "[| 0 \<le> x; x \<le> pi |] ==> 0 \<le> sin x"
  1634 by (auto simp add: order_le_less sin_gt_zero_pi)
  1635 
  1636 lemma cos_total: "[| -1 \<le> y; y \<le> 1 |] ==> EX! x. 0 \<le> x & x \<le> pi & (cos x = y)"
  1637 apply (subgoal_tac "\<exists>x. 0 \<le> x & x \<le> pi & cos x = y")
  1638 apply (rule_tac [2] IVT2)
  1639 apply (auto intro: order_less_imp_le DERIV_isCont DERIV_cos)
  1640 apply (cut_tac x = xa and y = y in linorder_less_linear)
  1641 apply (rule ccontr, auto)
  1642 apply (drule_tac f = cos in Rolle)
  1643 apply (drule_tac [5] f = cos in Rolle)
  1644 apply (auto intro: order_less_imp_le DERIV_isCont DERIV_cos
  1645             dest!: DERIV_cos [THEN DERIV_unique] 
  1646             simp add: differentiable_def)
  1647 apply (auto dest: sin_gt_zero_pi [OF order_le_less_trans order_less_le_trans])
  1648 done
  1649 
  1650 lemma sin_total:
  1651      "[| -1 \<le> y; y \<le> 1 |] ==> EX! x. -(pi/2) \<le> x & x \<le> pi/2 & (sin x = y)"
  1652 apply (rule ccontr)
  1653 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))")
  1654 apply (erule swap)
  1655 apply (simp del: minus_sin_cos_eq [symmetric])
  1656 apply (cut_tac y="-y" in cos_total, simp) apply simp 
  1657 apply (erule ex1E)
  1658 apply (rule_tac a = "x - (pi/2) " in ex1I)
  1659 apply (simp (no_asm) add: real_add_assoc)
  1660 apply (rotate_tac 3)
  1661 apply (drule_tac x = "xa + pi/2" in spec, safe, simp_all) 
  1662 done
  1663 
  1664 lemma reals_Archimedean4:
  1665      "[| 0 < y; 0 \<le> x |] ==> \<exists>n. real n * y \<le> x & x < real (Suc n) * y"
  1666 apply (auto dest!: reals_Archimedean3)
  1667 apply (drule_tac x = x in spec, clarify) 
  1668 apply (subgoal_tac "x < real(LEAST m::nat. x < real m * y) * y")
  1669  prefer 2 apply (erule LeastI) 
  1670 apply (case_tac "LEAST m::nat. x < real m * y", simp) 
  1671 apply (subgoal_tac "~ x < real nat * y")
  1672  prefer 2 apply (rule not_less_Least, simp, force)  
  1673 done
  1674 
  1675 (* Pre Isabelle99-2 proof was simpler- numerals arithmetic 
  1676    now causes some unwanted re-arrangements of literals!   *)
  1677 lemma cos_zero_lemma: "[| 0 \<le> x; cos x = 0 |] ==>  
  1678       \<exists>n::nat. ~even n & x = real n * (pi/2)"
  1679 apply (drule pi_gt_zero [THEN reals_Archimedean4], safe)
  1680 apply (subgoal_tac "0 \<le> x - real n * pi & 
  1681                     (x - real n * pi) \<le> pi & (cos (x - real n * pi) = 0) ")
  1682 apply (auto simp add: compare_rls) 
  1683   prefer 3 apply (simp add: cos_diff) 
  1684  prefer 2 apply (simp add: real_of_nat_Suc left_distrib) 
  1685 apply (simp add: cos_diff)
  1686 apply (subgoal_tac "EX! x. 0 \<le> x & x \<le> pi & cos x = 0")
  1687 apply (rule_tac [2] cos_total, safe)
  1688 apply (drule_tac x = "x - real n * pi" in spec)
  1689 apply (drule_tac x = "pi/2" in spec)
  1690 apply (simp add: cos_diff)
  1691 apply (rule_tac x = "Suc (2 * n) " in exI)
  1692 apply (simp add: real_of_nat_Suc left_distrib, auto)
  1693 done
  1694 
  1695 lemma sin_zero_lemma: "[| 0 \<le> x; sin x = 0 |] ==>  
  1696       \<exists>n::nat. even n & x = real n * (pi/2)"
  1697 apply (subgoal_tac "\<exists>n::nat. ~ even n & x + pi/2 = real n * (pi/2) ")
  1698  apply (clarify, rule_tac x = "n - 1" in exI)
  1699  apply (force simp add: odd_Suc_mult_two_ex real_of_nat_Suc left_distrib)
  1700 apply (rule cos_zero_lemma)
  1701 apply (simp_all add: add_increasing)  
  1702 done
  1703 
  1704 
  1705 lemma cos_zero_iff: "(cos x = 0) =  
  1706       ((\<exists>n::nat. ~even n & (x = real n * (pi/2))) |    
  1707        (\<exists>n::nat. ~even n & (x = -(real n * (pi/2)))))"
  1708 apply (rule iffI)
  1709 apply (cut_tac linorder_linear [of 0 x], safe)
  1710 apply (drule cos_zero_lemma, assumption+)
  1711 apply (cut_tac x="-x" in cos_zero_lemma, simp, simp) 
  1712 apply (force simp add: minus_equation_iff [of x]) 
  1713 apply (auto simp only: odd_Suc_mult_two_ex real_of_nat_Suc left_distrib) 
  1714 apply (auto simp add: cos_add)
  1715 done
  1716 
  1717 (* ditto: but to a lesser extent *)
  1718 lemma sin_zero_iff: "(sin x = 0) =  
  1719       ((\<exists>n::nat. even n & (x = real n * (pi/2))) |    
  1720        (\<exists>n::nat. even n & (x = -(real n * (pi/2)))))"
  1721 apply (rule iffI)
  1722 apply (cut_tac linorder_linear [of 0 x], safe)
  1723 apply (drule sin_zero_lemma, assumption+)
  1724 apply (cut_tac x="-x" in sin_zero_lemma, simp, simp, safe)
  1725 apply (force simp add: minus_equation_iff [of x]) 
  1726 apply (auto simp add: even_mult_two_ex)
  1727 done
  1728 
  1729 
  1730 subsection{*Tangent*}
  1731 
  1732 lemma tan_zero [simp]: "tan 0 = 0"
  1733 by (simp add: tan_def)
  1734 
  1735 lemma tan_pi [simp]: "tan pi = 0"
  1736 by (simp add: tan_def)
  1737 
  1738 lemma tan_npi [simp]: "tan (real (n::nat) * pi) = 0"
  1739 by (simp add: tan_def)
  1740 
  1741 lemma tan_minus [simp]: "tan (-x) = - tan x"
  1742 by (simp add: tan_def minus_mult_left)
  1743 
  1744 lemma tan_periodic [simp]: "tan (x + 2*pi) = tan x"
  1745 by (simp add: tan_def)
  1746 
  1747 lemma lemma_tan_add1: 
  1748       "[| cos x \<noteq> 0; cos y \<noteq> 0 |]  
  1749         ==> 1 - tan(x)*tan(y) = cos (x + y)/(cos x * cos y)"
  1750 apply (unfold tan_def real_divide_def)
  1751 apply (auto simp del: inverse_mult_distrib simp add: inverse_mult_distrib [symmetric] mult_ac)
  1752 apply (rule_tac c1 = "cos x * cos y" in real_mult_right_cancel [THEN subst])
  1753 apply (auto simp del: inverse_mult_distrib simp add: mult_assoc left_diff_distrib cos_add)
  1754 done
  1755 
  1756 lemma add_tan_eq: 
  1757       "[| cos x \<noteq> 0; cos y \<noteq> 0 |]  
  1758        ==> tan x + tan y = sin(x + y)/(cos x * cos y)"
  1759 apply (unfold tan_def)
  1760 apply (rule_tac c1 = "cos x * cos y" in real_mult_right_cancel [THEN subst])
  1761 apply (auto simp add: mult_assoc left_distrib)
  1762 apply (simp (no_asm) add: sin_add)
  1763 done
  1764 
  1765 lemma tan_add: "[| cos x \<noteq> 0; cos y \<noteq> 0; cos (x + y) \<noteq> 0 |]  
  1766       ==> tan(x + y) = (tan(x) + tan(y))/(1 - tan(x) * tan(y))"
  1767 apply (simp (no_asm_simp) add: add_tan_eq lemma_tan_add1)
  1768 apply (simp add: tan_def)
  1769 done
  1770 
  1771 lemma tan_double: "[| cos x \<noteq> 0; cos (2 * x) \<noteq> 0 |]  
  1772       ==> tan (2 * x) = (2 * tan x)/(1 - (tan(x) ^ 2))"
  1773 apply (insert tan_add [of x x]) 
  1774 apply (simp add: mult_2 [symmetric])  
  1775 apply (auto simp add: numeral_2_eq_2)
  1776 done
  1777 
  1778 lemma tan_gt_zero: "[| 0 < x; x < pi/2 |] ==> 0 < tan x"
  1779 apply (unfold tan_def real_divide_def)
  1780 apply (auto intro!: sin_gt_zero2 cos_gt_zero_pi intro!: real_mult_order positive_imp_inverse_positive)
  1781 done
  1782 
  1783 lemma tan_less_zero: 
  1784   assumes lb: "- pi/2 < x" and "x < 0" shows "tan x < 0"
  1785 proof -
  1786   have "0 < tan (- x)" using prems by (simp only: tan_gt_zero) 
  1787   thus ?thesis by simp
  1788 qed
  1789 
  1790 lemma lemma_DERIV_tan:
  1791      "cos x \<noteq> 0 ==> DERIV (%x. sin(x)/cos(x)) x :> inverse((cos x)\<twosuperior>)"
  1792 apply (rule lemma_DERIV_subst)
  1793 apply (best intro!: DERIV_intros intro: DERIV_chain2) 
  1794 apply (auto simp add: divide_inverse numeral_2_eq_2)
  1795 done
  1796 
  1797 lemma DERIV_tan [simp]: "cos x \<noteq> 0 ==> DERIV tan x :> inverse((cos x)\<twosuperior>)"
  1798 by (auto dest: lemma_DERIV_tan simp add: tan_def [symmetric])
  1799 
  1800 lemma LIM_cos_div_sin [simp]: "(%x. cos(x)/sin(x)) -- pi/2 --> 0"
  1801 apply (unfold real_divide_def)
  1802 apply (subgoal_tac "(\<lambda>x. cos x * inverse (sin x)) -- pi * inverse 2 --> 0*1")
  1803 apply simp 
  1804 apply (rule LIM_mult2)
  1805 apply (rule_tac [2] inverse_1 [THEN subst])
  1806 apply (rule_tac [2] LIM_inverse)
  1807 apply (simp_all add: divide_inverse [symmetric]) 
  1808 apply (simp_all only: isCont_def [symmetric] cos_pi_half [symmetric] sin_pi_half [symmetric]) 
  1809 apply (blast intro!: DERIV_isCont DERIV_sin DERIV_cos)+
  1810 done
  1811 
  1812 lemma lemma_tan_total: "0 < y ==> \<exists>x. 0 < x & x < pi/2 & y < tan x"
  1813 apply (cut_tac LIM_cos_div_sin)
  1814 apply (simp only: LIM_def)
  1815 apply (drule_tac x = "inverse y" in spec, safe, force)
  1816 apply (drule_tac ?d1.0 = s in pi_half_gt_zero [THEN [2] real_lbound_gt_zero], safe)
  1817 apply (rule_tac x = " (pi/2) - e" in exI)
  1818 apply (simp (no_asm_simp))
  1819 apply (drule_tac x = " (pi/2) - e" in spec)
  1820 apply (auto simp add: abs_eqI2 tan_def)
  1821 apply (rule inverse_less_iff_less [THEN iffD1])
  1822 apply (auto simp add: divide_inverse)
  1823 apply (rule real_mult_order)
  1824 apply (subgoal_tac [3] "0 < sin e")
  1825 apply (subgoal_tac [3] "0 < cos e")
  1826 apply (auto intro: cos_gt_zero sin_gt_zero2 simp add: inverse_mult_distrib abs_mult)
  1827 apply (drule_tac a = "cos e" in positive_imp_inverse_positive)
  1828 apply (drule_tac x = "inverse (cos e) " in abs_eqI2)
  1829 apply (auto dest!: abs_eqI2 simp add: mult_ac)
  1830 done
  1831 
  1832 lemma tan_total_pos: "0 \<le> y ==> \<exists>x. 0 \<le> x & x < pi/2 & tan x = y"
  1833 apply (frule real_le_imp_less_or_eq, safe)
  1834  prefer 2 apply force
  1835 apply (drule lemma_tan_total, safe)
  1836 apply (cut_tac f = tan and a = 0 and b = x and y = y in IVT_objl)
  1837 apply (auto intro!: DERIV_tan [THEN DERIV_isCont])
  1838 apply (drule_tac y = xa in order_le_imp_less_or_eq)
  1839 apply (auto dest: cos_gt_zero)
  1840 done
  1841 
  1842 lemma lemma_tan_total1: "\<exists>x. -(pi/2) < x & x < (pi/2) & tan x = y"
  1843 apply (cut_tac linorder_linear [of 0 y], safe)
  1844 apply (drule tan_total_pos)
  1845 apply (cut_tac [2] y="-y" in tan_total_pos, safe)
  1846 apply (rule_tac [3] x = "-x" in exI)
  1847 apply (auto intro!: exI)
  1848 done
  1849 
  1850 lemma tan_total: "EX! x. -(pi/2) < x & x < (pi/2) & tan x = y"
  1851 apply (cut_tac y = y in lemma_tan_total1, auto)
  1852 apply (cut_tac x = xa and y = y in linorder_less_linear, auto)
  1853 apply (subgoal_tac [2] "\<exists>z. y < z & z < xa & DERIV tan z :> 0")
  1854 apply (subgoal_tac "\<exists>z. xa < z & z < y & DERIV tan z :> 0")
  1855 apply (rule_tac [4] Rolle)
  1856 apply (rule_tac [2] Rolle)
  1857 apply (auto intro!: DERIV_tan DERIV_isCont exI 
  1858             simp add: differentiable_def)
  1859 txt{*Now, simulate TRYALL*}
  1860 apply (rule_tac [!] DERIV_tan asm_rl)
  1861 apply (auto dest!: DERIV_unique [OF _ DERIV_tan]
  1862 	    simp add: cos_gt_zero_pi [THEN real_not_refl2, THEN not_sym]) 
  1863 done
  1864 
  1865 lemma arcsin_pi: "[| -1 \<le> y; y \<le> 1 |]  
  1866       ==> -(pi/2) \<le> arcsin y & arcsin y \<le> pi & sin(arcsin y) = y"
  1867 apply (drule sin_total, assumption)
  1868 apply (erule ex1E)
  1869 apply (unfold arcsin_def)
  1870 apply (rule someI2, blast) 
  1871 apply (force intro: order_trans) 
  1872 done
  1873 
  1874 lemma arcsin: "[| -1 \<le> y; y \<le> 1 |]  
  1875       ==> -(pi/2) \<le> arcsin y &  
  1876            arcsin y \<le> pi/2 & sin(arcsin y) = y"
  1877 apply (unfold arcsin_def)
  1878 apply (drule sin_total, assumption)
  1879 apply (fast intro: someI2)
  1880 done
  1881 
  1882 lemma sin_arcsin [simp]: "[| -1 \<le> y; y \<le> 1 |] ==> sin(arcsin y) = y"
  1883 by (blast dest: arcsin)
  1884       
  1885 lemma arcsin_bounded:
  1886      "[| -1 \<le> y; y \<le> 1 |] ==> -(pi/2) \<le> arcsin y & arcsin y \<le> pi/2"
  1887 by (blast dest: arcsin)
  1888 
  1889 lemma arcsin_lbound: "[| -1 \<le> y; y \<le> 1 |] ==> -(pi/2) \<le> arcsin y"
  1890 by (blast dest: arcsin)
  1891 
  1892 lemma arcsin_ubound: "[| -1 \<le> y; y \<le> 1 |] ==> arcsin y \<le> pi/2"
  1893 by (blast dest: arcsin)
  1894 
  1895 lemma arcsin_lt_bounded:
  1896      "[| -1 < y; y < 1 |] ==> -(pi/2) < arcsin y & arcsin y < pi/2"
  1897 apply (frule order_less_imp_le)
  1898 apply (frule_tac y = y in order_less_imp_le)
  1899 apply (frule arcsin_bounded)
  1900 apply (safe, simp)
  1901 apply (drule_tac y = "arcsin y" in order_le_imp_less_or_eq)
  1902 apply (drule_tac [2] y = "pi/2" in order_le_imp_less_or_eq, safe)
  1903 apply (drule_tac [!] f = sin in arg_cong, auto)
  1904 done
  1905 
  1906 lemma arcsin_sin: "[|-(pi/2) \<le> x; x \<le> pi/2 |] ==> arcsin(sin x) = x"
  1907 apply (unfold arcsin_def)
  1908 apply (rule some1_equality)
  1909 apply (rule sin_total, auto)
  1910 done
  1911 
  1912 lemma arcos: "[| -1 \<le> y; y \<le> 1 |]  
  1913       ==> 0 \<le> arcos y & arcos y \<le> pi & cos(arcos y) = y"
  1914 apply (unfold arcos_def)
  1915 apply (drule cos_total, assumption)
  1916 apply (fast intro: someI2)
  1917 done
  1918 
  1919 lemma cos_arcos [simp]: "[| -1 \<le> y; y \<le> 1 |] ==> cos(arcos y) = y"
  1920 by (blast dest: arcos)
  1921       
  1922 lemma arcos_bounded: "[| -1 \<le> y; y \<le> 1 |] ==> 0 \<le> arcos y & arcos y \<le> pi"
  1923 by (blast dest: arcos)
  1924 
  1925 lemma arcos_lbound: "[| -1 \<le> y; y \<le> 1 |] ==> 0 \<le> arcos y"
  1926 by (blast dest: arcos)
  1927 
  1928 lemma arcos_ubound: "[| -1 \<le> y; y \<le> 1 |] ==> arcos y \<le> pi"
  1929 by (blast dest: arcos)
  1930 
  1931 lemma arcos_lt_bounded: "[| -1 < y; y < 1 |]  
  1932       ==> 0 < arcos y & arcos y < pi"
  1933 apply (frule order_less_imp_le)
  1934 apply (frule_tac y = y in order_less_imp_le)
  1935 apply (frule arcos_bounded, auto)
  1936 apply (drule_tac y = "arcos y" in order_le_imp_less_or_eq)
  1937 apply (drule_tac [2] y = pi in order_le_imp_less_or_eq, auto)
  1938 apply (drule_tac [!] f = cos in arg_cong, auto)
  1939 done
  1940 
  1941 lemma arcos_cos: "[|0 \<le> x; x \<le> pi |] ==> arcos(cos x) = x"
  1942 apply (unfold arcos_def)
  1943 apply (auto intro!: some1_equality cos_total)
  1944 done
  1945 
  1946 lemma arcos_cos2: "[|x \<le> 0; -pi \<le> x |] ==> arcos(cos x) = -x"
  1947 apply (unfold arcos_def)
  1948 apply (auto intro!: some1_equality cos_total)
  1949 done
  1950 
  1951 lemma arctan [simp]:
  1952      "- (pi/2) < arctan y  & arctan y < pi/2 & tan (arctan y) = y"
  1953 apply (cut_tac y = y in tan_total)
  1954 apply (unfold arctan_def)
  1955 apply (fast intro: someI2)
  1956 done
  1957 
  1958 lemma tan_arctan: "tan(arctan y) = y"
  1959 by auto
  1960 
  1961 lemma arctan_bounded: "- (pi/2) < arctan y  & arctan y < pi/2"
  1962 by (auto simp only: arctan)
  1963 
  1964 lemma arctan_lbound: "- (pi/2) < arctan y"
  1965 by auto
  1966 
  1967 lemma arctan_ubound: "arctan y < pi/2"
  1968 by (auto simp only: arctan)
  1969 
  1970 lemma arctan_tan: 
  1971       "[|-(pi/2) < x; x < pi/2 |] ==> arctan(tan x) = x"
  1972 apply (unfold arctan_def)
  1973 apply (rule some1_equality)
  1974 apply (rule tan_total, auto)
  1975 done
  1976 
  1977 lemma arctan_zero_zero [simp]: "arctan 0 = 0"
  1978 by (insert arctan_tan [of 0], simp)
  1979 
  1980 lemma cos_arctan_not_zero [simp]: "cos(arctan x) \<noteq> 0"
  1981 apply (auto simp add: cos_zero_iff)
  1982 apply (case_tac "n")
  1983 apply (case_tac [3] "n")
  1984 apply (cut_tac [2] y = x in arctan_ubound)
  1985 apply (cut_tac [4] y = x in arctan_lbound) 
  1986 apply (auto simp add: real_of_nat_Suc left_distrib mult_less_0_iff)
  1987 done
  1988 
  1989 lemma tan_sec: "cos x \<noteq> 0 ==> 1 + tan(x) ^ 2 = inverse(cos x) ^ 2"
  1990 apply (rule power_inverse [THEN subst])
  1991 apply (rule_tac c1 = "(cos x)\<twosuperior>" in real_mult_right_cancel [THEN iffD1])
  1992 apply (auto dest: realpow_not_zero 
  1993         simp add: power_mult_distrib left_distrib realpow_divide tan_def 
  1994                   mult_assoc power_inverse [symmetric] 
  1995         simp del: realpow_Suc)
  1996 done
  1997 
  1998 text{*NEEDED??*}
  1999 lemma [simp]: "sin (xa + 1 / 2 * real (Suc m) * pi) =  
  2000       cos (xa + 1 / 2 * real  (m) * pi)"
  2001 apply (simp only: cos_add sin_add real_of_nat_Suc left_distrib right_distrib, auto)
  2002 done
  2003 
  2004 text{*NEEDED??*}
  2005 lemma [simp]: "sin (xa + real (Suc m) * pi / 2) =  
  2006       cos (xa + real (m) * pi / 2)"
  2007 apply (simp only: cos_add sin_add divide_inverse real_of_nat_Suc left_distrib right_distrib, auto)
  2008 done
  2009 
  2010 lemma DERIV_sin_add [simp]: "DERIV (%x. sin (x + k)) xa :> cos (xa + k)"
  2011 apply (rule lemma_DERIV_subst)
  2012 apply (rule_tac f = sin and g = "%x. x + k" in DERIV_chain2)
  2013 apply (best intro!: DERIV_intros intro: DERIV_chain2)+
  2014 apply (simp (no_asm))
  2015 done
  2016 
  2017 (* which further simplifies to (- 1 ^ m) !! *)
  2018 lemma sin_cos_npi [simp]: "sin ((real m + 1/2) * pi) = cos (real m * pi)"
  2019 by (auto simp add: right_distrib sin_add left_distrib mult_ac)
  2020 
  2021 lemma sin_cos_npi2 [simp]: "sin (real (Suc (2 * n)) * pi / 2) = (-1) ^ n"
  2022 apply (cut_tac m = n in sin_cos_npi)
  2023 apply (simp only: real_of_nat_Suc left_distrib divide_inverse, auto)
  2024 done
  2025 
  2026 lemma cos_2npi [simp]: "cos (2 * real (n::nat) * pi) = 1"
  2027 by (simp add: cos_double mult_assoc power_add [symmetric] numeral_2_eq_2)
  2028 
  2029 lemma cos_3over2_pi [simp]: "cos (3 / 2 * pi) = 0"
  2030 apply (subgoal_tac "3/2 = (1+1 / 2::real)")
  2031 apply (simp only: left_distrib) 
  2032 apply (auto simp add: cos_add mult_ac)
  2033 done
  2034 
  2035 lemma sin_2npi [simp]: "sin (2 * real (n::nat) * pi) = 0"
  2036 by (auto simp add: mult_assoc)
  2037 
  2038 lemma sin_3over2_pi [simp]: "sin (3 / 2 * pi) = - 1"
  2039 apply (subgoal_tac "3/2 = (1+1 / 2::real)")
  2040 apply (simp only: left_distrib) 
  2041 apply (auto simp add: sin_add mult_ac)
  2042 done
  2043 
  2044 (*NEEDED??*)
  2045 lemma [simp]: "cos(x + 1 / 2 * real(Suc m) * pi) = -sin (x + 1 / 2 * real m * pi)"
  2046 apply (simp only: cos_add sin_add real_of_nat_Suc right_distrib left_distrib minus_mult_right, auto)
  2047 done
  2048 
  2049 (*NEEDED??*)
  2050 lemma [simp]: "cos (x + real(Suc m) * pi / 2) = -sin (x + real m * pi / 2)"
  2051 apply (simp only: cos_add sin_add divide_inverse real_of_nat_Suc left_distrib right_distrib, auto)
  2052 done
  2053 
  2054 lemma cos_pi_eq_zero [simp]: "cos (pi * real (Suc (2 * m)) / 2) = 0"
  2055 by (simp only: cos_add sin_add divide_inverse real_of_nat_Suc left_distrib right_distrib, auto)
  2056 
  2057 lemma DERIV_cos_add [simp]: "DERIV (%x. cos (x + k)) xa :> - sin (xa + k)"
  2058 apply (rule lemma_DERIV_subst)
  2059 apply (rule_tac f = cos and g = "%x. x + k" in DERIV_chain2)
  2060 apply (best intro!: DERIV_intros intro: DERIV_chain2)+
  2061 apply (simp (no_asm))
  2062 done
  2063 
  2064 lemma isCont_cos [simp]: "isCont cos x"
  2065 by (rule DERIV_cos [THEN DERIV_isCont])
  2066 
  2067 lemma isCont_sin [simp]: "isCont sin x"
  2068 by (rule DERIV_sin [THEN DERIV_isCont])
  2069 
  2070 lemma isCont_exp [simp]: "isCont exp x"
  2071 by (rule DERIV_exp [THEN DERIV_isCont])
  2072 
  2073 lemma sin_zero_abs_cos_one: "sin x = 0 ==> \<bar>cos x\<bar> = 1"
  2074 by (auto simp add: sin_zero_iff even_mult_two_ex)
  2075 
  2076 lemma exp_eq_one_iff [simp]: "(exp x = 1) = (x = 0)"
  2077 apply auto
  2078 apply (drule_tac f = ln in arg_cong, auto)
  2079 done
  2080 
  2081 lemma cos_one_sin_zero: "cos x = 1 ==> sin x = 0"
  2082 by (cut_tac x = x in sin_cos_squared_add3, auto)
  2083 
  2084 
  2085 lemma real_root_less_mono: "[| 0 \<le> x; x < y |] ==> root(Suc n) x < root(Suc n) y"
  2086 apply (frule order_le_less_trans, assumption)
  2087 apply (frule_tac n1 = n in real_root_pow_pos2 [THEN ssubst])
  2088 apply (rotate_tac 1, assumption)
  2089 apply (frule_tac n1 = n in real_root_pow_pos [THEN ssubst])
  2090 apply (rotate_tac 3, assumption)
  2091 apply (drule_tac y = "root (Suc n) y ^ Suc n" in order_less_imp_le)
  2092 apply (frule_tac n = n in real_root_pos_pos_le)
  2093 apply (frule_tac n = n in real_root_pos_pos)
  2094 apply (drule_tac x = "root (Suc n) x" and y = "root (Suc n) y" in realpow_increasing)
  2095 apply (assumption, assumption)
  2096 apply (drule_tac x = "root (Suc n) x" in order_le_imp_less_or_eq)
  2097 apply auto
  2098 apply (drule_tac f = "%x. x ^ (Suc n) " in arg_cong)
  2099 apply (auto simp add: real_root_pow_pos2 simp del: realpow_Suc)
  2100 done
  2101 
  2102 lemma real_root_le_mono: "[| 0 \<le> x; x \<le> y |] ==> root(Suc n) x \<le> root(Suc n) y"
  2103 apply (drule_tac y = y in order_le_imp_less_or_eq)
  2104 apply (auto dest: real_root_less_mono intro: order_less_imp_le)
  2105 done
  2106 
  2107 lemma real_root_less_iff [simp]: "[| 0 \<le> x; 0 \<le> y |] ==> (root(Suc n) x < root(Suc n) y) = (x < y)"
  2108 apply (auto intro: real_root_less_mono)
  2109 apply (rule ccontr, drule linorder_not_less [THEN iffD1])
  2110 apply (drule_tac x = y and n = n in real_root_le_mono, auto)
  2111 done
  2112 
  2113 lemma real_root_le_iff [simp]: "[| 0 \<le> x; 0 \<le> y |] ==> (root(Suc n) x \<le> root(Suc n) y) = (x \<le> y)"
  2114 apply (auto intro: real_root_le_mono)
  2115 apply (simp (no_asm) add: linorder_not_less [symmetric])
  2116 apply auto
  2117 apply (drule_tac x = y and n = n in real_root_less_mono, auto)
  2118 done
  2119 
  2120 lemma real_root_eq_iff [simp]: "[| 0 \<le> x; 0 \<le> y |] ==> (root(Suc n) x = root(Suc n) y) = (x = y)"
  2121 apply (auto intro!: order_antisym)
  2122 apply (rule_tac n1 = n in real_root_le_iff [THEN iffD1])
  2123 apply (rule_tac [4] n1 = n in real_root_le_iff [THEN iffD1], auto)
  2124 done
  2125 
  2126 lemma real_root_pos_unique: "[| 0 \<le> x; 0 \<le> y; y ^ (Suc n) = x |] ==> root (Suc n) x = y"
  2127 by (auto dest: real_root_pos2 simp del: realpow_Suc)
  2128 
  2129 lemma real_root_mult: "[| 0 \<le> x; 0 \<le> y |] 
  2130       ==> root(Suc n) (x * y) = root(Suc n) x * root(Suc n) y"
  2131 apply (rule real_root_pos_unique)
  2132 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)
  2133 done
  2134 
  2135 lemma real_root_inverse: "0 \<le> x ==> (root(Suc n) (inverse x) = inverse(root(Suc n) x))"
  2136 apply (rule real_root_pos_unique)
  2137 apply (auto intro: real_root_pos_pos_le simp add: power_inverse [symmetric] real_root_pow_pos2 simp del: realpow_Suc)
  2138 done
  2139 
  2140 lemma real_root_divide: 
  2141      "[| 0 \<le> x; 0 \<le> y |]  
  2142       ==> (root(Suc n) (x / y) = root(Suc n) x / root(Suc n) y)"
  2143 apply (unfold real_divide_def)
  2144 apply (auto simp add: real_root_mult real_root_inverse)
  2145 done
  2146 
  2147 lemma real_sqrt_less_mono: "[| 0 \<le> x; x < y |] ==> sqrt(x) < sqrt(y)"
  2148 apply (unfold sqrt_def)
  2149 apply (auto intro: real_root_less_mono)
  2150 done
  2151 
  2152 lemma real_sqrt_le_mono: "[| 0 \<le> x; x \<le> y |] ==> sqrt(x) \<le> sqrt(y)"
  2153 apply (unfold sqrt_def)
  2154 apply (auto intro: real_root_le_mono)
  2155 done
  2156 
  2157 lemma real_sqrt_less_iff [simp]: "[| 0 \<le> x; 0 \<le> y |] ==> (sqrt(x) < sqrt(y)) = (x < y)"
  2158 by (unfold sqrt_def, auto)
  2159 
  2160 lemma real_sqrt_le_iff [simp]: "[| 0 \<le> x; 0 \<le> y |] ==> (sqrt(x) \<le> sqrt(y)) = (x \<le> y)"
  2161 by (unfold sqrt_def, auto)
  2162 
  2163 lemma real_sqrt_eq_iff [simp]: "[| 0 \<le> x; 0 \<le> y |] ==> (sqrt(x) = sqrt(y)) = (x = y)"
  2164 by (unfold sqrt_def, auto)
  2165 
  2166 lemma real_sqrt_sos_less_one_iff [simp]: "(sqrt(x\<twosuperior> + y\<twosuperior>) < 1) = (x\<twosuperior> + y\<twosuperior> < 1)"
  2167 apply (rule real_sqrt_one [THEN subst], safe)
  2168 apply (rule_tac [2] real_sqrt_less_mono)
  2169 apply (drule real_sqrt_less_iff [THEN [2] rev_iffD1], auto)
  2170 done
  2171 
  2172 lemma real_sqrt_sos_eq_one_iff [simp]: "(sqrt(x\<twosuperior> + y\<twosuperior>) = 1) = (x\<twosuperior> + y\<twosuperior> = 1)"
  2173 apply (rule real_sqrt_one [THEN subst], safe)
  2174 apply (drule real_sqrt_eq_iff [THEN [2] rev_iffD1], auto)
  2175 done
  2176 
  2177 lemma real_divide_square_eq [simp]: "(((r::real) * a) / (r * r)) = a / r"
  2178 apply (unfold real_divide_def)
  2179 apply (case_tac "r=0")
  2180 apply (auto simp add: inverse_mult_distrib mult_ac)
  2181 done
  2182 
  2183 
  2184 subsection{*Theorems About Sqrt, Transcendental Functions for Complex*}
  2185 
  2186 lemma lemma_real_divide_sqrt: 
  2187     "0 < x ==> 0 \<le> x/(sqrt (x * x + y * y))"
  2188 apply (unfold real_divide_def)
  2189 apply (rule real_mult_order [THEN order_less_imp_le], assumption)
  2190 apply (subgoal_tac "0 < inverse (sqrt (x\<twosuperior> + y\<twosuperior>))") 
  2191  apply (simp add: numeral_2_eq_2)
  2192 apply (simp add: real_sqrt_sum_squares_ge1 [THEN [2] order_less_le_trans]) 
  2193 done
  2194 
  2195 lemma lemma_real_divide_sqrt_ge_minus_one:
  2196      "0 < x ==> -1 \<le> x/(sqrt (x * x + y * y))"
  2197 apply (rule real_le_trans)
  2198 apply (rule_tac [2] lemma_real_divide_sqrt, auto)
  2199 done
  2200 
  2201 lemma real_sqrt_sum_squares_gt_zero1: "x < 0 ==> 0 < sqrt (x * x + y * y)"
  2202 apply (rule real_sqrt_gt_zero)
  2203 apply (subgoal_tac "0 < x*x & 0 \<le> y*y", arith) 
  2204 apply (auto simp add: zero_less_mult_iff)
  2205 done
  2206 
  2207 lemma real_sqrt_sum_squares_gt_zero2: "0 < x ==> 0 < sqrt (x * x + y * y)"
  2208 apply (rule real_sqrt_gt_zero)
  2209 apply (subgoal_tac "0 < x*x & 0 \<le> y*y", arith) 
  2210 apply (auto simp add: zero_less_mult_iff)
  2211 done
  2212 
  2213 lemma real_sqrt_sum_squares_gt_zero3: "x \<noteq> 0 ==> 0 < sqrt(x\<twosuperior> + y\<twosuperior>)"
  2214 apply (cut_tac x = x and y = 0 in linorder_less_linear)
  2215 apply (auto intro: real_sqrt_sum_squares_gt_zero2 real_sqrt_sum_squares_gt_zero1 simp add: numeral_2_eq_2)
  2216 done
  2217 
  2218 lemma real_sqrt_sum_squares_gt_zero3a: "y \<noteq> 0 ==> 0 < sqrt(x\<twosuperior> + y\<twosuperior>)"
  2219 apply (drule_tac y = x in real_sqrt_sum_squares_gt_zero3)
  2220 apply (auto simp add: real_add_commute)
  2221 done
  2222 
  2223 lemma real_sqrt_sum_squares_eq_cancel [simp]: "sqrt(x\<twosuperior> + y\<twosuperior>) = x ==> y = 0"
  2224 by (drule_tac f = "%x. x\<twosuperior>" in arg_cong, auto)
  2225 
  2226 lemma real_sqrt_sum_squares_eq_cancel2 [simp]: "sqrt(x\<twosuperior> + y\<twosuperior>) = y ==> x = 0"
  2227 apply (rule_tac x = y in real_sqrt_sum_squares_eq_cancel)
  2228 apply (simp add: real_add_commute)
  2229 done
  2230 
  2231 lemma lemma_real_divide_sqrt_le_one: "x < 0 ==> x/(sqrt (x * x + y * y)) \<le> 1"
  2232 by (insert lemma_real_divide_sqrt_ge_minus_one [of "-x" y], simp)
  2233 
  2234 lemma lemma_real_divide_sqrt_ge_minus_one2:
  2235      "x < 0 ==> -1 \<le> x/(sqrt (x * x + y * y))"
  2236 apply (case_tac "y = 0", auto)
  2237 apply (frule abs_minus_eqI2)
  2238 apply (auto simp add: inverse_minus_eq)
  2239 apply (rule order_less_imp_le)
  2240 apply (rule_tac z1 = "sqrt (x * x + y * y) " in real_mult_less_iff1 [THEN iffD1])
  2241 apply (frule_tac [2] y2 = y in
  2242        real_sqrt_sum_squares_gt_zero1 [THEN real_not_refl2, THEN not_sym])
  2243 apply (auto intro: real_sqrt_sum_squares_gt_zero1 simp add: mult_ac)
  2244 apply (cut_tac x = "-x" and y = y in real_sqrt_sum_squares_ge1)
  2245 apply (drule order_le_less [THEN iffD1], safe) 
  2246 apply (simp add: numeral_2_eq_2)
  2247 apply (drule sym [THEN real_sqrt_sum_squares_eq_cancel], simp)
  2248 done
  2249 
  2250 lemma lemma_real_divide_sqrt_le_one2: "0 < x ==> x/(sqrt (x * x + y * y)) \<le> 1"
  2251 by (cut_tac x = "-x" and y = y in lemma_real_divide_sqrt_ge_minus_one2, auto)
  2252 
  2253 
  2254 lemma cos_x_y_ge_minus_one: "-1 \<le> x / sqrt (x * x + y * y)"
  2255 apply (cut_tac x = x and y = 0 in linorder_less_linear, safe)
  2256 apply (rule lemma_real_divide_sqrt_ge_minus_one2)
  2257 apply (rule_tac [3] lemma_real_divide_sqrt_ge_minus_one, auto)
  2258 done
  2259 
  2260 lemma cos_x_y_ge_minus_one1a [simp]: "-1 \<le> y / sqrt (x * x + y * y)"
  2261 apply (cut_tac x = y and y = x in cos_x_y_ge_minus_one)
  2262 apply (simp add: real_add_commute)
  2263 done
  2264 
  2265 lemma cos_x_y_le_one [simp]: "x / sqrt (x * x + y * y) \<le> 1"
  2266 apply (cut_tac x = x and y = 0 in linorder_less_linear, safe)
  2267 apply (rule lemma_real_divide_sqrt_le_one)
  2268 apply (rule_tac [3] lemma_real_divide_sqrt_le_one2, auto)
  2269 done
  2270 
  2271 lemma cos_x_y_le_one2 [simp]: "y / sqrt (x * x + y * y) \<le> 1"
  2272 apply (cut_tac x = y and y = x in cos_x_y_le_one)
  2273 apply (simp add: real_add_commute)
  2274 done
  2275 
  2276 declare cos_arcos [OF cos_x_y_ge_minus_one cos_x_y_le_one, simp] 
  2277 declare arcos_bounded [OF cos_x_y_ge_minus_one cos_x_y_le_one, simp] 
  2278 
  2279 declare cos_arcos [OF cos_x_y_ge_minus_one1a cos_x_y_le_one2, simp] 
  2280 declare arcos_bounded [OF cos_x_y_ge_minus_one1a cos_x_y_le_one2, simp] 
  2281 
  2282 lemma cos_abs_x_y_ge_minus_one [simp]:
  2283      "-1 \<le> \<bar>x\<bar> / sqrt (x * x + y * y)"
  2284 apply (cut_tac x = x and y = 0 in linorder_less_linear)
  2285 apply (auto simp add: abs_minus_eqI2 abs_eqI2)
  2286 apply (drule lemma_real_divide_sqrt_ge_minus_one, force)
  2287 done
  2288 
  2289 lemma cos_abs_x_y_le_one [simp]: "\<bar>x\<bar> / sqrt (x * x + y * y) \<le> 1"
  2290 apply (cut_tac x = x and y = 0 in linorder_less_linear)
  2291 apply (auto simp add: abs_minus_eqI2 abs_eqI2)
  2292 apply (drule lemma_real_divide_sqrt_ge_minus_one2, force)
  2293 done
  2294 
  2295 declare cos_arcos [OF cos_abs_x_y_ge_minus_one cos_abs_x_y_le_one, simp] 
  2296 declare arcos_bounded [OF cos_abs_x_y_ge_minus_one cos_abs_x_y_le_one, simp] 
  2297 
  2298 lemma minus_pi_less_zero: "-pi < 0"
  2299 apply (simp (no_asm))
  2300 done
  2301 declare minus_pi_less_zero [simp]
  2302 declare minus_pi_less_zero [THEN order_less_imp_le, simp]
  2303 
  2304 lemma arcos_ge_minus_pi: "[| -1 \<le> y; y \<le> 1 |] ==> -pi \<le> arcos y"
  2305 apply (rule real_le_trans)
  2306 apply (rule_tac [2] arcos_lbound, auto)
  2307 done
  2308 
  2309 declare arcos_ge_minus_pi [OF cos_x_y_ge_minus_one cos_x_y_le_one, simp] 
  2310 
  2311 (* How tedious! *)
  2312 lemma lemma_divide_rearrange:
  2313      "[| x + (y::real) \<noteq> 0; 1 - z = x/(x + y) |] ==> z = y/(x + y)"
  2314 apply (rule_tac c1 = "x + y" in real_mult_right_cancel [THEN iffD1])
  2315 apply (frule_tac [2] c1 = "x + y" in real_mult_right_cancel [THEN iffD2])
  2316 prefer 2 apply assumption
  2317 apply (rotate_tac [2] 2)
  2318 apply (drule_tac [2] mult_assoc [THEN subst])
  2319 apply (rotate_tac [2] 2)
  2320 apply (frule_tac [2] left_inverse [THEN subst])
  2321 prefer 2 apply assumption
  2322 apply (erule_tac [2] V = " (1 - z) * (x + y) = x / (x + y) * (x + y) " in thin_rl)
  2323 apply (erule_tac [2] V = "1 - z = x / (x + y) " in thin_rl)
  2324 apply (auto simp add: mult_assoc)
  2325 apply (auto simp add: right_distrib left_diff_distrib)
  2326 done
  2327 
  2328 lemma lemma_cos_sin_eq:
  2329      "[| 0 < x * x + y * y;  
  2330          1 - (sin xa)\<twosuperior> = (x / sqrt (x * x + y * y)) ^ 2 |] 
  2331       ==> (sin xa)\<twosuperior> = (y / sqrt (x * x + y * y)) ^ 2"
  2332 by (auto intro: lemma_divide_rearrange
  2333          simp add: realpow_divide power2_eq_square [symmetric])
  2334 
  2335 
  2336 lemma lemma_sin_cos_eq:
  2337      "[| 0 < x * x + y * y;  
  2338          1 - (cos xa)\<twosuperior> = (y / sqrt (x * x + y * y)) ^ 2 |]
  2339       ==> (cos xa)\<twosuperior> = (x / sqrt (x * x + y * y)) ^ 2"
  2340 apply (auto simp add: realpow_divide power2_eq_square [symmetric])
  2341 apply (subst add_commute)
  2342 apply (rule lemma_divide_rearrange, simp add: real_add_eq_0_iff)
  2343 apply (simp add: add_commute)
  2344 done
  2345 
  2346 lemma sin_x_y_disj:
  2347      "[| x \<noteq> 0;  
  2348          cos xa = x / sqrt (x * x + y * y)  
  2349       |] ==>  sin xa = y / sqrt (x * x + y * y) |  
  2350               sin xa = - y / sqrt (x * x + y * y)"
  2351 apply (drule_tac f = "%x. x\<twosuperior>" in arg_cong)
  2352 apply (frule_tac y = y in real_sum_square_gt_zero)
  2353 apply (simp add: cos_squared_eq)
  2354 apply (subgoal_tac "(sin xa)\<twosuperior> = (y / sqrt (x * x + y * y)) ^ 2")
  2355 apply (rule_tac [2] lemma_cos_sin_eq)
  2356 apply (auto simp add: realpow_two_disj numeral_2_eq_2 simp del: realpow_Suc)
  2357 done
  2358 
  2359 lemma lemma_cos_not_eq_zero: "x \<noteq> 0 ==> x / sqrt (x * x + y * y) \<noteq> 0"
  2360 apply (unfold real_divide_def)
  2361 apply (frule_tac y3 = y in real_sqrt_sum_squares_gt_zero3 [THEN real_not_refl2, THEN not_sym, THEN nonzero_imp_inverse_nonzero])
  2362 apply (auto simp add: power2_eq_square)
  2363 done
  2364 
  2365 lemma cos_x_y_disj: "[| x \<noteq> 0;  
  2366          sin xa = y / sqrt (x * x + y * y)  
  2367       |] ==>  cos xa = x / sqrt (x * x + y * y) |  
  2368               cos xa = - x / sqrt (x * x + y * y)"
  2369 apply (drule_tac f = "%x. x\<twosuperior>" in arg_cong)
  2370 apply (frule_tac y = y in real_sum_square_gt_zero)
  2371 apply (simp add: sin_squared_eq del: realpow_Suc)
  2372 apply (subgoal_tac "(cos xa)\<twosuperior> = (x / sqrt (x * x + y * y)) ^ 2")
  2373 apply (rule_tac [2] lemma_sin_cos_eq)
  2374 apply (auto simp add: realpow_two_disj numeral_2_eq_2 simp del: realpow_Suc)
  2375 done
  2376 
  2377 lemma real_sqrt_divide_less_zero: "0 < y ==> - y / sqrt (x * x + y * y) < 0"
  2378 apply (case_tac "x = 0")
  2379 apply (auto simp add: abs_eqI2)
  2380 apply (drule_tac y = y in real_sqrt_sum_squares_gt_zero3)
  2381 apply (auto simp add: zero_less_mult_iff divide_inverse power2_eq_square)
  2382 done
  2383 
  2384 lemma polar_ex1: "[| x \<noteq> 0; 0 < y |] ==> \<exists>r a. x = r * cos a & y = r * sin a"
  2385 apply (rule_tac x = "sqrt (x\<twosuperior> + y\<twosuperior>) " in exI)
  2386 apply (rule_tac x = "arcos (x / sqrt (x * x + y * y))" in exI)
  2387 apply auto
  2388 apply (drule_tac y2 = y in real_sqrt_sum_squares_gt_zero3 [THEN real_not_refl2, THEN not_sym])
  2389 apply (auto simp add: power2_eq_square)
  2390 apply (unfold arcos_def)
  2391 apply (cut_tac x1 = x and y1 = y 
  2392        in cos_total [OF cos_x_y_ge_minus_one cos_x_y_le_one])
  2393 apply (rule someI2_ex, blast)
  2394 apply (erule_tac V = "EX! xa. 0 \<le> xa & xa \<le> pi & cos xa = x / sqrt (x * x + y * y) " in thin_rl)
  2395 apply (frule sin_x_y_disj, blast)
  2396 apply (drule_tac y2 = y in real_sqrt_sum_squares_gt_zero3 [THEN real_not_refl2, THEN not_sym])
  2397 apply (auto simp add: power2_eq_square)
  2398 apply (drule sin_ge_zero, assumption)
  2399 apply (drule_tac x = x in real_sqrt_divide_less_zero, auto)
  2400 done
  2401 
  2402 lemma real_sum_squares_cancel2a: "x * x = -(y * y) ==> y = (0::real)"
  2403 by (auto intro: real_sum_squares_cancel iff: real_add_eq_0_iff)
  2404 
  2405 lemma polar_ex2: "[| x \<noteq> 0; y < 0 |] ==> \<exists>r a. x = r * cos a & y = r * sin a"
  2406 apply (cut_tac x = 0 and y = x in linorder_less_linear, auto)
  2407 apply (rule_tac x = "sqrt (x\<twosuperior> + y\<twosuperior>) " in exI)
  2408 apply (rule_tac x = "arcsin (y / sqrt (x * x + y * y))" in exI)
  2409 apply (auto dest: real_sum_squares_cancel2a 
  2410             simp add: power2_eq_square real_0_le_add_iff real_add_eq_0_iff)
  2411 apply (unfold arcsin_def)
  2412 apply (cut_tac x1 = x and y1 = y 
  2413        in sin_total [OF cos_x_y_ge_minus_one1a cos_x_y_le_one2])
  2414 apply (rule someI2_ex, blast)
  2415 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)
  2416 apply (cut_tac x=x and y=y in cos_x_y_disj, simp, blast)
  2417 apply (auto simp add: real_0_le_add_iff real_add_eq_0_iff)
  2418 apply (drule cos_ge_zero, force)
  2419 apply (drule_tac x = y in real_sqrt_divide_less_zero)
  2420 apply (auto simp add: add_commute)
  2421 apply (insert polar_ex1 [of x "-y"], simp, clarify) 
  2422 apply (rule_tac x = r in exI)
  2423 apply (rule_tac x = "-a" in exI, simp) 
  2424 done
  2425 
  2426 lemma polar_Ex: "\<exists>r a. x = r * cos a & y = r * sin a"
  2427 apply (case_tac "x = 0", auto)
  2428 apply (rule_tac x = y in exI)
  2429 apply (rule_tac x = "pi/2" in exI, auto)
  2430 apply (cut_tac x = 0 and y = y in linorder_less_linear, auto)
  2431 apply (rule_tac [2] x = x in exI)
  2432 apply (rule_tac [2] x = 0 in exI, auto)
  2433 apply (blast intro: polar_ex1 polar_ex2)+
  2434 done
  2435 
  2436 lemma real_sqrt_ge_abs1 [simp]: "\<bar>x\<bar> \<le> sqrt (x\<twosuperior> + y\<twosuperior>)"
  2437 apply (rule_tac n = 1 in realpow_increasing)
  2438 apply (auto simp add: numeral_2_eq_2 [symmetric])
  2439 done
  2440 
  2441 lemma real_sqrt_ge_abs2 [simp]: "\<bar>y\<bar> \<le> sqrt (x\<twosuperior> + y\<twosuperior>)"
  2442 apply (rule real_add_commute [THEN subst])
  2443 apply (rule real_sqrt_ge_abs1)
  2444 done
  2445 declare real_sqrt_ge_abs1 [simp] real_sqrt_ge_abs2 [simp]
  2446 
  2447 lemma real_sqrt_two_gt_zero [simp]: "0 < sqrt 2"
  2448 by (auto intro: real_sqrt_gt_zero)
  2449 
  2450 lemma real_sqrt_two_ge_zero [simp]: "0 \<le> sqrt 2"
  2451 by (auto intro: real_sqrt_ge_zero)
  2452 
  2453 lemma real_sqrt_two_gt_one [simp]: "1 < sqrt 2"
  2454 apply (rule order_less_le_trans [of _ "7/5"], simp) 
  2455 apply (rule_tac n = 1 in realpow_increasing)
  2456   prefer 3 apply (simp add: numeral_2_eq_2 [symmetric] del: realpow_Suc)
  2457 apply (simp_all add: numeral_2_eq_2)
  2458 done
  2459 
  2460 lemma lemma_real_divide_sqrt_less: "0 < u ==> u / sqrt 2 < u"
  2461 apply (rule_tac z1 = "inverse u" in real_mult_less_iff1 [THEN iffD1], auto)
  2462 apply (rule_tac z1 = "sqrt 2" in real_mult_less_iff1 [THEN iffD1], auto)
  2463 done
  2464 
  2465 lemma four_x_squared: 
  2466   fixes x::real
  2467   shows "4 * x\<twosuperior> = (2 * x)\<twosuperior>"
  2468 by (simp add: power2_eq_square)
  2469 
  2470 
  2471 text{*Needed for the infinitely close relation over the nonstandard
  2472     complex numbers*}
  2473 lemma lemma_sqrt_hcomplex_capprox:
  2474      "[| 0 < u; x < u/2; y < u/2; 0 \<le> x; 0 \<le> y |] ==> sqrt (x\<twosuperior> + y\<twosuperior>) < u"
  2475 apply (rule_tac y = "u/sqrt 2" in order_le_less_trans)
  2476 apply (erule_tac [2] lemma_real_divide_sqrt_less)
  2477 apply (rule_tac n = 1 in realpow_increasing)
  2478 apply (auto simp add: real_0_le_divide_iff realpow_divide numeral_2_eq_2 [symmetric] 
  2479         simp del: realpow_Suc)
  2480 apply (rule_tac t = "u\<twosuperior>" in real_sum_of_halves [THEN subst])
  2481 apply (rule add_mono)
  2482 apply (auto simp add: four_x_squared simp del: realpow_Suc intro: power_mono)
  2483 done
  2484 
  2485 declare real_sqrt_sum_squares_ge_zero [THEN abs_eqI1, simp]
  2486 
  2487 
  2488 subsection{*A Few Theorems Involving Ln, Derivatives, etc.*}
  2489 
  2490 lemma lemma_DERIV_ln:
  2491      "DERIV ln z :> l ==> DERIV (%x. exp (ln x)) z :> exp (ln z) * l"
  2492 by (erule DERIV_fun_exp)
  2493 
  2494 lemma STAR_exp_ln: "0 < z ==> ( *f* (%x. exp (ln x))) z = z"
  2495 apply (rule_tac z = z in eq_Abs_hypreal)
  2496 apply (auto simp add: starfun hypreal_zero_def hypreal_less)
  2497 done
  2498 
  2499 lemma hypreal_add_Infinitesimal_gt_zero: "[|e : Infinitesimal; 0 < x |] ==> 0 < hypreal_of_real x + e"
  2500 apply (rule_tac c1 = "-e" in add_less_cancel_right [THEN iffD1])
  2501 apply (auto intro: Infinitesimal_less_SReal)
  2502 done
  2503 
  2504 lemma NSDERIV_exp_ln_one: "0 < z ==> NSDERIV (%x. exp (ln x)) z :> 1"
  2505 apply (unfold nsderiv_def NSLIM_def, auto)
  2506 apply (rule ccontr)
  2507 apply (subgoal_tac "0 < hypreal_of_real z + h")
  2508 apply (drule STAR_exp_ln)
  2509 apply (rule_tac [2] hypreal_add_Infinitesimal_gt_zero)
  2510 apply (subgoal_tac "h/h = 1")
  2511 apply (auto simp add: exp_ln_iff [symmetric] simp del: exp_ln_iff)
  2512 done
  2513 
  2514 lemma DERIV_exp_ln_one: "0 < z ==> DERIV (%x. exp (ln x)) z :> 1"
  2515 by (auto intro: NSDERIV_exp_ln_one simp add: NSDERIV_DERIV_iff [symmetric])
  2516 
  2517 lemma lemma_DERIV_ln2: "[| 0 < z; DERIV ln z :> l |] ==>  exp (ln z) * l = 1"
  2518 apply (rule DERIV_unique)
  2519 apply (rule lemma_DERIV_ln)
  2520 apply (rule_tac [2] DERIV_exp_ln_one, auto)
  2521 done
  2522 
  2523 lemma lemma_DERIV_ln3: "[| 0 < z; DERIV ln z :> l |] ==>  l = 1/(exp (ln z))"
  2524 apply (rule_tac c1 = "exp (ln z) " in real_mult_left_cancel [THEN iffD1])
  2525 apply (auto intro: lemma_DERIV_ln2)
  2526 done
  2527 
  2528 lemma lemma_DERIV_ln4: "[| 0 < z; DERIV ln z :> l |] ==>  l = 1/z"
  2529 apply (rule_tac t = z in exp_ln_iff [THEN iffD2, THEN subst])
  2530 apply (auto intro: lemma_DERIV_ln3)
  2531 done
  2532 
  2533 (* need to rename second isCont_inverse *)
  2534 
  2535 lemma isCont_inv_fun: "[| 0 < d; \<forall>z. \<bar>z - x\<bar> \<le> d --> g(f(z)) = z;  
  2536          \<forall>z. \<bar>z - x\<bar> \<le> d --> isCont f z |]  
  2537       ==> isCont g (f x)"
  2538 apply (simp (no_asm) add: isCont_iff LIM_def)
  2539 apply safe
  2540 apply (drule_tac ?d1.0 = r in real_lbound_gt_zero)
  2541 apply (assumption, safe)
  2542 apply (subgoal_tac "\<forall>z. \<bar>z - x\<bar> \<le> e --> (g (f z) = z) ")
  2543 prefer 2 apply force
  2544 apply (subgoal_tac "\<forall>z. \<bar>z - x\<bar> \<le> e --> isCont f z")
  2545 prefer 2 apply force
  2546 apply (drule_tac d = e in isCont_inj_range)
  2547 prefer 2 apply (assumption, assumption, safe)
  2548 apply (rule_tac x = ea in exI, auto)
  2549 apply (drule_tac x = "f (x) + xa" and P = "%y. \<bar>y - f x\<bar> \<le> ea \<longrightarrow> (\<exists>z. \<bar>z - x\<bar> \<le> e \<and> f z = y)" in spec)
  2550 apply auto
  2551 apply (drule sym, auto, arith)
  2552 done
  2553 
  2554 lemma isCont_inv_fun_inv:
  2555      "[| 0 < d;  
  2556          \<forall>z. \<bar>z - x\<bar> \<le> d --> g(f(z)) = z;  
  2557          \<forall>z. \<bar>z - x\<bar> \<le> d --> isCont f z |]  
  2558        ==> \<exists>e. 0 < e &  
  2559              (\<forall>y. 0 < \<bar>y - f(x)\<bar> & \<bar>y - f(x)\<bar> < e --> f(g(y)) = y)"
  2560 apply (drule isCont_inj_range)
  2561 prefer 2 apply (assumption, assumption, auto)
  2562 apply (rule_tac x = e in exI, auto)
  2563 apply (rotate_tac 2)
  2564 apply (drule_tac x = y in spec, auto)
  2565 done
  2566 
  2567 
  2568 text{*Bartle/Sherbert: Introduction to Real Analysis, Theorem 4.2.9, p. 110*}
  2569 lemma LIM_fun_gt_zero: "[| f -- c --> l; 0 < l |]  
  2570          ==> \<exists>r. 0 < r & (\<forall>x. x \<noteq> c & \<bar>c - x\<bar> < r --> 0 < f x)"
  2571 apply (auto simp add: LIM_def)
  2572 apply (drule_tac x = "l/2" in spec, safe, force)
  2573 apply (rule_tac x = s in exI)
  2574 apply (auto simp only: abs_interval_iff)
  2575 done
  2576 
  2577 lemma LIM_fun_less_zero: "[| f -- c --> l; l < 0 |]  
  2578          ==> \<exists>r. 0 < r & (\<forall>x. x \<noteq> c & \<bar>c - x\<bar> < r --> f x < 0)"
  2579 apply (auto simp add: LIM_def)
  2580 apply (drule_tac x = "-l/2" in spec, safe, force)
  2581 apply (rule_tac x = s in exI)
  2582 apply (auto simp only: abs_interval_iff)
  2583 done
  2584 
  2585 
  2586 lemma LIM_fun_not_zero:
  2587      "[| f -- c --> l; l \<noteq> 0 |] 
  2588       ==> \<exists>r. 0 < r & (\<forall>x. x \<noteq> c & \<bar>c - x\<bar> < r --> f x \<noteq> 0)"
  2589 apply (cut_tac x = l and y = 0 in linorder_less_linear, auto)
  2590 apply (drule LIM_fun_less_zero)
  2591 apply (drule_tac [3] LIM_fun_gt_zero, auto)
  2592 apply (rule_tac [!] x = r in exI, auto)
  2593 done
  2594 
  2595 ML
  2596 {*
  2597 val inverse_unique = thm "inverse_unique";
  2598 val real_root_zero = thm "real_root_zero";
  2599 val real_root_pow_pos = thm "real_root_pow_pos";
  2600 val real_root_pow_pos2 = thm "real_root_pow_pos2";
  2601 val real_root_pos = thm "real_root_pos";
  2602 val real_root_pos2 = thm "real_root_pos2";
  2603 val real_root_pos_pos = thm "real_root_pos_pos";
  2604 val real_root_pos_pos_le = thm "real_root_pos_pos_le";
  2605 val real_root_one = thm "real_root_one";
  2606 val root_2_eq = thm "root_2_eq";
  2607 val real_sqrt_zero = thm "real_sqrt_zero";
  2608 val real_sqrt_one = thm "real_sqrt_one";
  2609 val real_sqrt_pow2_iff = thm "real_sqrt_pow2_iff";
  2610 val real_sqrt_pow2 = thm "real_sqrt_pow2";
  2611 val real_sqrt_abs_abs = thm "real_sqrt_abs_abs";
  2612 val real_pow_sqrt_eq_sqrt_pow = thm "real_pow_sqrt_eq_sqrt_pow";
  2613 val real_pow_sqrt_eq_sqrt_abs_pow2 = thm "real_pow_sqrt_eq_sqrt_abs_pow2";
  2614 val real_sqrt_pow_abs = thm "real_sqrt_pow_abs";
  2615 val not_real_square_gt_zero = thm "not_real_square_gt_zero";
  2616 val real_mult_self_eq_zero_iff = thm "real_mult_self_eq_zero_iff";
  2617 val real_sqrt_gt_zero = thm "real_sqrt_gt_zero";
  2618 val real_sqrt_ge_zero = thm "real_sqrt_ge_zero";
  2619 val sqrt_eqI = thm "sqrt_eqI";
  2620 val real_sqrt_mult_distrib = thm "real_sqrt_mult_distrib";
  2621 val real_sqrt_mult_distrib2 = thm "real_sqrt_mult_distrib2";
  2622 val real_sqrt_sum_squares_ge_zero = thm "real_sqrt_sum_squares_ge_zero";
  2623 val real_sqrt_sum_squares_mult_ge_zero = thm "real_sqrt_sum_squares_mult_ge_zero";
  2624 val real_sqrt_sum_squares_mult_squared_eq = thm "real_sqrt_sum_squares_mult_squared_eq";
  2625 val real_sqrt_abs = thm "real_sqrt_abs";
  2626 val real_sqrt_abs2 = thm "real_sqrt_abs2";
  2627 val real_sqrt_pow2_gt_zero = thm "real_sqrt_pow2_gt_zero";
  2628 val real_sqrt_not_eq_zero = thm "real_sqrt_not_eq_zero";
  2629 val real_inv_sqrt_pow2 = thm "real_inv_sqrt_pow2";
  2630 val real_sqrt_eq_zero_cancel = thm "real_sqrt_eq_zero_cancel";
  2631 val real_sqrt_eq_zero_cancel_iff = thm "real_sqrt_eq_zero_cancel_iff";
  2632 val real_sqrt_sum_squares_ge1 = thm "real_sqrt_sum_squares_ge1";
  2633 val real_sqrt_sum_squares_ge2 = thm "real_sqrt_sum_squares_ge2";
  2634 val real_sqrt_ge_one = thm "real_sqrt_ge_one";
  2635 val summable_exp = thm "summable_exp";
  2636 val summable_sin = thm "summable_sin";
  2637 val summable_cos = thm "summable_cos";
  2638 val exp_converges = thm "exp_converges";
  2639 val sin_converges = thm "sin_converges";
  2640 val cos_converges = thm "cos_converges";
  2641 val powser_insidea = thm "powser_insidea";
  2642 val powser_inside = thm "powser_inside";
  2643 val diffs_minus = thm "diffs_minus";
  2644 val diffs_equiv = thm "diffs_equiv";
  2645 val less_add_one = thm "less_add_one";
  2646 val termdiffs_aux = thm "termdiffs_aux";
  2647 val termdiffs = thm "termdiffs";
  2648 val exp_fdiffs = thm "exp_fdiffs";
  2649 val sin_fdiffs = thm "sin_fdiffs";
  2650 val sin_fdiffs2 = thm "sin_fdiffs2";
  2651 val cos_fdiffs = thm "cos_fdiffs";
  2652 val cos_fdiffs2 = thm "cos_fdiffs2";
  2653 val DERIV_exp = thm "DERIV_exp";
  2654 val DERIV_sin = thm "DERIV_sin";
  2655 val DERIV_cos = thm "DERIV_cos";
  2656 val exp_zero = thm "exp_zero";
  2657 val exp_ge_add_one_self = thm "exp_ge_add_one_self";
  2658 val exp_gt_one = thm "exp_gt_one";
  2659 val DERIV_exp_add_const = thm "DERIV_exp_add_const";
  2660 val DERIV_exp_minus = thm "DERIV_exp_minus";
  2661 val DERIV_exp_exp_zero = thm "DERIV_exp_exp_zero";
  2662 val exp_add_mult_minus = thm "exp_add_mult_minus";
  2663 val exp_mult_minus = thm "exp_mult_minus";
  2664 val exp_mult_minus2 = thm "exp_mult_minus2";
  2665 val exp_minus = thm "exp_minus";
  2666 val exp_add = thm "exp_add";
  2667 val exp_ge_zero = thm "exp_ge_zero";
  2668 val exp_not_eq_zero = thm "exp_not_eq_zero";
  2669 val exp_gt_zero = thm "exp_gt_zero";
  2670 val inv_exp_gt_zero = thm "inv_exp_gt_zero";
  2671 val abs_exp_cancel = thm "abs_exp_cancel";
  2672 val exp_real_of_nat_mult = thm "exp_real_of_nat_mult";
  2673 val exp_diff = thm "exp_diff";
  2674 val exp_less_mono = thm "exp_less_mono";
  2675 val exp_less_cancel = thm "exp_less_cancel";
  2676 val exp_less_cancel_iff = thm "exp_less_cancel_iff";
  2677 val exp_le_cancel_iff = thm "exp_le_cancel_iff";
  2678 val exp_inj_iff = thm "exp_inj_iff";
  2679 val exp_total = thm "exp_total";
  2680 val ln_exp = thm "ln_exp";
  2681 val exp_ln_iff = thm "exp_ln_iff";
  2682 val ln_mult = thm "ln_mult";
  2683 val ln_inj_iff = thm "ln_inj_iff";
  2684 val ln_one = thm "ln_one";
  2685 val ln_inverse = thm "ln_inverse";
  2686 val ln_div = thm "ln_div";
  2687 val ln_less_cancel_iff = thm "ln_less_cancel_iff";
  2688 val ln_le_cancel_iff = thm "ln_le_cancel_iff";
  2689 val ln_realpow = thm "ln_realpow";
  2690 val ln_add_one_self_le_self = thm "ln_add_one_self_le_self";
  2691 val ln_less_self = thm "ln_less_self";
  2692 val ln_ge_zero = thm "ln_ge_zero";
  2693 val ln_gt_zero = thm "ln_gt_zero";
  2694 val ln_not_eq_zero = thm "ln_not_eq_zero";
  2695 val ln_less_zero = thm "ln_less_zero";
  2696 val exp_ln_eq = thm "exp_ln_eq";
  2697 val sin_zero = thm "sin_zero";
  2698 val cos_zero = thm "cos_zero";
  2699 val DERIV_sin_sin_mult = thm "DERIV_sin_sin_mult";
  2700 val DERIV_sin_sin_mult2 = thm "DERIV_sin_sin_mult2";
  2701 val DERIV_sin_realpow2 = thm "DERIV_sin_realpow2";
  2702 val DERIV_sin_realpow2a = thm "DERIV_sin_realpow2a";
  2703 val DERIV_cos_cos_mult = thm "DERIV_cos_cos_mult";
  2704 val DERIV_cos_cos_mult2 = thm "DERIV_cos_cos_mult2";
  2705 val DERIV_cos_realpow2 = thm "DERIV_cos_realpow2";
  2706 val DERIV_cos_realpow2a = thm "DERIV_cos_realpow2a";
  2707 val DERIV_cos_realpow2b = thm "DERIV_cos_realpow2b";
  2708 val DERIV_cos_cos_mult3 = thm "DERIV_cos_cos_mult3";
  2709 val DERIV_sin_circle_all = thm "DERIV_sin_circle_all";
  2710 val DERIV_sin_circle_all_zero = thm "DERIV_sin_circle_all_zero";
  2711 val sin_cos_squared_add = thm "sin_cos_squared_add";
  2712 val sin_cos_squared_add2 = thm "sin_cos_squared_add2";
  2713 val sin_cos_squared_add3 = thm "sin_cos_squared_add3";
  2714 val sin_squared_eq = thm "sin_squared_eq";
  2715 val cos_squared_eq = thm "cos_squared_eq";
  2716 val real_gt_one_ge_zero_add_less = thm "real_gt_one_ge_zero_add_less";
  2717 val abs_sin_le_one = thm "abs_sin_le_one";
  2718 val sin_ge_minus_one = thm "sin_ge_minus_one";
  2719 val sin_le_one = thm "sin_le_one";
  2720 val abs_cos_le_one = thm "abs_cos_le_one";
  2721 val cos_ge_minus_one = thm "cos_ge_minus_one";
  2722 val cos_le_one = thm "cos_le_one";
  2723 val DERIV_fun_pow = thm "DERIV_fun_pow";
  2724 val DERIV_fun_exp = thm "DERIV_fun_exp";
  2725 val DERIV_fun_sin = thm "DERIV_fun_sin";
  2726 val DERIV_fun_cos = thm "DERIV_fun_cos";
  2727 val DERIV_intros = thms "DERIV_intros";
  2728 val sin_cos_add = thm "sin_cos_add";
  2729 val sin_add = thm "sin_add";
  2730 val cos_add = thm "cos_add";
  2731 val sin_cos_minus = thm "sin_cos_minus";
  2732 val sin_minus = thm "sin_minus";
  2733 val cos_minus = thm "cos_minus";
  2734 val sin_diff = thm "sin_diff";
  2735 val sin_diff2 = thm "sin_diff2";
  2736 val cos_diff = thm "cos_diff";
  2737 val cos_diff2 = thm "cos_diff2";
  2738 val sin_double = thm "sin_double";
  2739 val cos_double = thm "cos_double";
  2740 val sin_paired = thm "sin_paired";
  2741 val sin_gt_zero = thm "sin_gt_zero";
  2742 val sin_gt_zero1 = thm "sin_gt_zero1";
  2743 val cos_double_less_one = thm "cos_double_less_one";
  2744 val cos_paired = thm "cos_paired";
  2745 val cos_two_less_zero = thm "cos_two_less_zero";
  2746 val cos_is_zero = thm "cos_is_zero";
  2747 val pi_half = thm "pi_half";
  2748 val cos_pi_half = thm "cos_pi_half";
  2749 val pi_half_gt_zero = thm "pi_half_gt_zero";
  2750 val pi_half_less_two = thm "pi_half_less_two";
  2751 val pi_gt_zero = thm "pi_gt_zero";
  2752 val pi_neq_zero = thm "pi_neq_zero";
  2753 val pi_not_less_zero = thm "pi_not_less_zero";
  2754 val pi_ge_zero = thm "pi_ge_zero";
  2755 val minus_pi_half_less_zero = thm "minus_pi_half_less_zero";
  2756 val sin_pi_half = thm "sin_pi_half";
  2757 val cos_pi = thm "cos_pi";
  2758 val sin_pi = thm "sin_pi";
  2759 val sin_cos_eq = thm "sin_cos_eq";
  2760 val minus_sin_cos_eq = thm "minus_sin_cos_eq";
  2761 val cos_sin_eq = thm "cos_sin_eq";
  2762 val sin_periodic_pi = thm "sin_periodic_pi";
  2763 val sin_periodic_pi2 = thm "sin_periodic_pi2";
  2764 val cos_periodic_pi = thm "cos_periodic_pi";
  2765 val sin_periodic = thm "sin_periodic";
  2766 val cos_periodic = thm "cos_periodic";
  2767 val cos_npi = thm "cos_npi";
  2768 val sin_npi = thm "sin_npi";
  2769 val sin_npi2 = thm "sin_npi2";
  2770 val cos_two_pi = thm "cos_two_pi";
  2771 val sin_two_pi = thm "sin_two_pi";
  2772 val sin_gt_zero2 = thm "sin_gt_zero2";
  2773 val sin_less_zero = thm "sin_less_zero";
  2774 val pi_less_4 = thm "pi_less_4";
  2775 val cos_gt_zero = thm "cos_gt_zero";
  2776 val cos_gt_zero_pi = thm "cos_gt_zero_pi";
  2777 val cos_ge_zero = thm "cos_ge_zero";
  2778 val sin_gt_zero_pi = thm "sin_gt_zero_pi";
  2779 val sin_ge_zero = thm "sin_ge_zero";
  2780 val cos_total = thm "cos_total";
  2781 val sin_total = thm "sin_total";
  2782 val reals_Archimedean4 = thm "reals_Archimedean4";
  2783 val cos_zero_lemma = thm "cos_zero_lemma";
  2784 val sin_zero_lemma = thm "sin_zero_lemma";
  2785 val cos_zero_iff = thm "cos_zero_iff";
  2786 val sin_zero_iff = thm "sin_zero_iff";
  2787 val tan_zero = thm "tan_zero";
  2788 val tan_pi = thm "tan_pi";
  2789 val tan_npi = thm "tan_npi";
  2790 val tan_minus = thm "tan_minus";
  2791 val tan_periodic = thm "tan_periodic";
  2792 val add_tan_eq = thm "add_tan_eq";
  2793 val tan_add = thm "tan_add";
  2794 val tan_double = thm "tan_double";
  2795 val tan_gt_zero = thm "tan_gt_zero";
  2796 val tan_less_zero = thm "tan_less_zero";
  2797 val DERIV_tan = thm "DERIV_tan";
  2798 val LIM_cos_div_sin = thm "LIM_cos_div_sin";
  2799 val tan_total_pos = thm "tan_total_pos";
  2800 val tan_total = thm "tan_total";
  2801 val arcsin_pi = thm "arcsin_pi";
  2802 val arcsin = thm "arcsin";
  2803 val sin_arcsin = thm "sin_arcsin";
  2804 val arcsin_bounded = thm "arcsin_bounded";
  2805 val arcsin_lbound = thm "arcsin_lbound";
  2806 val arcsin_ubound = thm "arcsin_ubound";
  2807 val arcsin_lt_bounded = thm "arcsin_lt_bounded";
  2808 val arcsin_sin = thm "arcsin_sin";
  2809 val arcos = thm "arcos";
  2810 val cos_arcos = thm "cos_arcos";
  2811 val arcos_bounded = thm "arcos_bounded";
  2812 val arcos_lbound = thm "arcos_lbound";
  2813 val arcos_ubound = thm "arcos_ubound";
  2814 val arcos_lt_bounded = thm "arcos_lt_bounded";
  2815 val arcos_cos = thm "arcos_cos";
  2816 val arcos_cos2 = thm "arcos_cos2";
  2817 val arctan = thm "arctan";
  2818 val tan_arctan = thm "tan_arctan";
  2819 val arctan_bounded = thm "arctan_bounded";
  2820 val arctan_lbound = thm "arctan_lbound";
  2821 val arctan_ubound = thm "arctan_ubound";
  2822 val arctan_tan = thm "arctan_tan";
  2823 val arctan_zero_zero = thm "arctan_zero_zero";
  2824 val cos_arctan_not_zero = thm "cos_arctan_not_zero";
  2825 val tan_sec = thm "tan_sec";
  2826 val DERIV_sin_add = thm "DERIV_sin_add";
  2827 val sin_cos_npi = thm "sin_cos_npi";
  2828 val sin_cos_npi2 = thm "sin_cos_npi2";
  2829 val cos_2npi = thm "cos_2npi";
  2830 val cos_3over2_pi = thm "cos_3over2_pi";
  2831 val sin_2npi = thm "sin_2npi";
  2832 val sin_3over2_pi = thm "sin_3over2_pi";
  2833 val cos_pi_eq_zero = thm "cos_pi_eq_zero";
  2834 val DERIV_cos_add = thm "DERIV_cos_add";
  2835 val isCont_cos = thm "isCont_cos";
  2836 val isCont_sin = thm "isCont_sin";
  2837 val isCont_exp = thm "isCont_exp";
  2838 val sin_zero_abs_cos_one = thm "sin_zero_abs_cos_one";
  2839 val exp_eq_one_iff = thm "exp_eq_one_iff";
  2840 val cos_one_sin_zero = thm "cos_one_sin_zero";
  2841 val real_root_less_mono = thm "real_root_less_mono";
  2842 val real_root_le_mono = thm "real_root_le_mono";
  2843 val real_root_less_iff = thm "real_root_less_iff";
  2844 val real_root_le_iff = thm "real_root_le_iff";
  2845 val real_root_eq_iff = thm "real_root_eq_iff";
  2846 val real_root_pos_unique = thm "real_root_pos_unique";
  2847 val real_root_mult = thm "real_root_mult";
  2848 val real_root_inverse = thm "real_root_inverse";
  2849 val real_root_divide = thm "real_root_divide";
  2850 val real_sqrt_less_mono = thm "real_sqrt_less_mono";
  2851 val real_sqrt_le_mono = thm "real_sqrt_le_mono";
  2852 val real_sqrt_less_iff = thm "real_sqrt_less_iff";
  2853 val real_sqrt_le_iff = thm "real_sqrt_le_iff";
  2854 val real_sqrt_eq_iff = thm "real_sqrt_eq_iff";
  2855 val real_sqrt_sos_less_one_iff = thm "real_sqrt_sos_less_one_iff";
  2856 val real_sqrt_sos_eq_one_iff = thm "real_sqrt_sos_eq_one_iff";
  2857 val real_divide_square_eq = thm "real_divide_square_eq";
  2858 val real_sqrt_sum_squares_gt_zero1 = thm "real_sqrt_sum_squares_gt_zero1";
  2859 val real_sqrt_sum_squares_gt_zero2 = thm "real_sqrt_sum_squares_gt_zero2";
  2860 val real_sqrt_sum_squares_gt_zero3 = thm "real_sqrt_sum_squares_gt_zero3";
  2861 val real_sqrt_sum_squares_gt_zero3a = thm "real_sqrt_sum_squares_gt_zero3a";
  2862 val real_sqrt_sum_squares_eq_cancel = thm "real_sqrt_sum_squares_eq_cancel";
  2863 val real_sqrt_sum_squares_eq_cancel2 = thm "real_sqrt_sum_squares_eq_cancel2";
  2864 val cos_x_y_ge_minus_one = thm "cos_x_y_ge_minus_one";
  2865 val cos_x_y_ge_minus_one1a = thm "cos_x_y_ge_minus_one1a";
  2866 val cos_x_y_le_one = thm "cos_x_y_le_one";
  2867 val cos_x_y_le_one2 = thm "cos_x_y_le_one2";
  2868 val cos_abs_x_y_ge_minus_one = thm "cos_abs_x_y_ge_minus_one";
  2869 val cos_abs_x_y_le_one = thm "cos_abs_x_y_le_one";
  2870 val minus_pi_less_zero = thm "minus_pi_less_zero";
  2871 val arcos_ge_minus_pi = thm "arcos_ge_minus_pi";
  2872 val sin_x_y_disj = thm "sin_x_y_disj";
  2873 val cos_x_y_disj = thm "cos_x_y_disj";
  2874 val real_sqrt_divide_less_zero = thm "real_sqrt_divide_less_zero";
  2875 val polar_ex1 = thm "polar_ex1";
  2876 val polar_ex2 = thm "polar_ex2";
  2877 val polar_Ex = thm "polar_Ex";
  2878 val real_sqrt_ge_abs1 = thm "real_sqrt_ge_abs1";
  2879 val real_sqrt_ge_abs2 = thm "real_sqrt_ge_abs2";
  2880 val real_sqrt_two_gt_zero = thm "real_sqrt_two_gt_zero";
  2881 val real_sqrt_two_ge_zero = thm "real_sqrt_two_ge_zero";
  2882 val real_sqrt_two_gt_one = thm "real_sqrt_two_gt_one";
  2883 val STAR_exp_ln = thm "STAR_exp_ln";
  2884 val hypreal_add_Infinitesimal_gt_zero = thm "hypreal_add_Infinitesimal_gt_zero";
  2885 val NSDERIV_exp_ln_one = thm "NSDERIV_exp_ln_one";
  2886 val DERIV_exp_ln_one = thm "DERIV_exp_ln_one";
  2887 val isCont_inv_fun = thm "isCont_inv_fun";
  2888 val isCont_inv_fun_inv = thm "isCont_inv_fun_inv";
  2889 val LIM_fun_gt_zero = thm "LIM_fun_gt_zero";
  2890 val LIM_fun_less_zero = thm "LIM_fun_less_zero";
  2891 val LIM_fun_not_zero = thm "LIM_fun_not_zero";
  2892 *}
  2893   
  2894 end