src/HOL/Hyperreal/Transcendental.thy
author huffman
Fri, 18 May 2007 16:11:13 +0200
changeset 23007 e025695d9b0e
parent 22998 97e1f9c2cc46
child 23011 3eae3140b4b2
permissions -rw-r--r--
use mult_strict_mono instead of real_mult_less_mono
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12196
a3be6b3a9c0b new theories from Jacques Fleuriot
paulson
parents:
diff changeset
     1
(*  Title       : Transcendental.thy
a3be6b3a9c0b new theories from Jacques Fleuriot
paulson
parents:
diff changeset
     2
    Author      : Jacques D. Fleuriot
a3be6b3a9c0b new theories from Jacques Fleuriot
paulson
parents:
diff changeset
     3
    Copyright   : 1998,1999 University of Cambridge
13958
c1c67582c9b5 New material on integration, etc. Moving Hyperreal/ex
paulson
parents: 12196
diff changeset
     4
                  1999,2001 University of Edinburgh
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
     5
    Conversion to Isar and new proofs by Lawrence C Paulson, 2004
12196
a3be6b3a9c0b new theories from Jacques Fleuriot
paulson
parents:
diff changeset
     6
*)
a3be6b3a9c0b new theories from Jacques Fleuriot
paulson
parents:
diff changeset
     7
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
     8
header{*Power Series, Transcendental Functions etc.*}
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
     9
15131
c69542757a4d New theory header syntax.
nipkow
parents: 15086
diff changeset
    10
theory Transcendental
22654
c2b6b5a9e136 new simp rule exp_ln; new standard proof of DERIV_exp_ln_one; changed imports
huffman
parents: 22653
diff changeset
    11
imports NthRoot Fact Series EvenOdd Deriv
15131
c69542757a4d New theory header syntax.
nipkow
parents: 15086
diff changeset
    12
begin
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    13
19765
dfe940911617 misc cleanup;
wenzelm
parents: 19279
diff changeset
    14
definition
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21165
diff changeset
    15
  exp :: "real => real" where
19765
dfe940911617 misc cleanup;
wenzelm
parents: 19279
diff changeset
    16
  "exp x = (\<Sum>n. inverse(real (fact n)) * (x ^ n))"
dfe940911617 misc cleanup;
wenzelm
parents: 19279
diff changeset
    17
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21165
diff changeset
    18
definition
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21165
diff changeset
    19
  sin :: "real => real" where
19765
dfe940911617 misc cleanup;
wenzelm
parents: 19279
diff changeset
    20
  "sin x = (\<Sum>n. (if even(n) then 0 else
dfe940911617 misc cleanup;
wenzelm
parents: 19279
diff changeset
    21
             ((- 1) ^ ((n - Suc 0) div 2))/(real (fact n))) * x ^ n)"
12196
a3be6b3a9c0b new theories from Jacques Fleuriot
paulson
parents:
diff changeset
    22
 
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21165
diff changeset
    23
definition
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21165
diff changeset
    24
  diffs :: "(nat => real) => nat => real" where
19765
dfe940911617 misc cleanup;
wenzelm
parents: 19279
diff changeset
    25
  "diffs c = (%n. real (Suc n) * c(Suc n))"
dfe940911617 misc cleanup;
wenzelm
parents: 19279
diff changeset
    26
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21165
diff changeset
    27
definition
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21165
diff changeset
    28
  cos :: "real => real" where
19765
dfe940911617 misc cleanup;
wenzelm
parents: 19279
diff changeset
    29
  "cos x = (\<Sum>n. (if even(n) then ((- 1) ^ (n div 2))/(real (fact n)) 
dfe940911617 misc cleanup;
wenzelm
parents: 19279
diff changeset
    30
                            else 0) * x ^ n)"
12196
a3be6b3a9c0b new theories from Jacques Fleuriot
paulson
parents:
diff changeset
    31
  
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21165
diff changeset
    32
definition
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21165
diff changeset
    33
  ln :: "real => real" where
19765
dfe940911617 misc cleanup;
wenzelm
parents: 19279
diff changeset
    34
  "ln x = (SOME u. exp u = x)"
dfe940911617 misc cleanup;
wenzelm
parents: 19279
diff changeset
    35
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21165
diff changeset
    36
definition
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21165
diff changeset
    37
  pi :: "real" where
19765
dfe940911617 misc cleanup;
wenzelm
parents: 19279
diff changeset
    38
  "pi = 2 * (@x. 0 \<le> (x::real) & x \<le> 2 & cos x = 0)"
dfe940911617 misc cleanup;
wenzelm
parents: 19279
diff changeset
    39
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21165
diff changeset
    40
definition
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21165
diff changeset
    41
  tan :: "real => real" where
19765
dfe940911617 misc cleanup;
wenzelm
parents: 19279
diff changeset
    42
  "tan x = (sin x)/(cos x)"
dfe940911617 misc cleanup;
wenzelm
parents: 19279
diff changeset
    43
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21165
diff changeset
    44
definition
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21165
diff changeset
    45
  arcsin :: "real => real" where
19765
dfe940911617 misc cleanup;
wenzelm
parents: 19279
diff changeset
    46
  "arcsin y = (SOME x. -(pi/2) \<le> x & x \<le> pi/2 & sin x = y)"
dfe940911617 misc cleanup;
wenzelm
parents: 19279
diff changeset
    47
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21165
diff changeset
    48
definition
22975
03085c441c14 spelling: rename arcos -> arccos
huffman
parents: 22969
diff changeset
    49
  arccos :: "real => real" where
03085c441c14 spelling: rename arcos -> arccos
huffman
parents: 22969
diff changeset
    50
  "arccos y = (SOME x. 0 \<le> x & x \<le> pi & cos x = y)"
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21165
diff changeset
    51
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21165
diff changeset
    52
definition     
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21165
diff changeset
    53
  arctan :: "real => real" where
19765
dfe940911617 misc cleanup;
wenzelm
parents: 19279
diff changeset
    54
  "arctan y = (SOME x. -(pi/2) < x & x < pi/2 & tan x = y)"
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    55
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    56
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    57
subsection{*Exponential Function*}
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    58
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    59
lemma summable_exp: "summable (%n. inverse (real (fact n)) * x ^ n)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    60
apply (cut_tac 'a = real in zero_less_one [THEN dense], safe)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    61
apply (cut_tac x = r in reals_Archimedean3, auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    62
apply (drule_tac x = "\<bar>x\<bar>" in spec, safe)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    63
apply (rule_tac N = n and c = r in ratio_test)
20849
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
    64
apply (safe, simp add: abs_mult mult_assoc [symmetric] del: fact_Suc)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    65
apply (rule mult_right_mono)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    66
apply (rule_tac b1 = "\<bar>x\<bar>" in mult_commute [THEN ssubst])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    67
apply (subst fact_Suc)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    68
apply (subst real_of_nat_mult)
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
    69
apply (auto)
20849
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
    70
apply (simp add: mult_assoc [symmetric] positive_imp_inverse_positive)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    71
apply (rule order_less_imp_le)
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
    72
apply (rule_tac z1 = "real (Suc na)" in real_mult_less_iff1 [THEN iffD1])
22998
97e1f9c2cc46 avoid using redundant lemmas from RealDef.thy
huffman
parents: 22978
diff changeset
    73
apply (auto simp add: mult_assoc)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    74
apply (erule order_less_trans)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    75
apply (auto simp add: mult_less_cancel_left mult_ac)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    76
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    77
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    78
lemma summable_sin: 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    79
     "summable (%n.  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    80
           (if even n then 0  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    81
           else (- 1) ^ ((n - Suc 0) div 2)/(real (fact n))) *  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    82
                x ^ n)"
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
    83
apply (rule_tac g = "(%n. inverse (real (fact n)) * \<bar>x\<bar> ^ n)" in summable_comparison_test)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    84
apply (rule_tac [2] summable_exp)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    85
apply (rule_tac x = 0 in exI)
16924
04246269386e removed the dependence on abs_mult
paulson
parents: 16819
diff changeset
    86
apply (auto simp add: divide_inverse abs_mult power_abs [symmetric] zero_le_mult_iff)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    87
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    88
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    89
lemma summable_cos: 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    90
      "summable (%n.  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    91
           (if even n then  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    92
           (- 1) ^ (n div 2)/(real (fact n)) else 0) * x ^ n)"
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
    93
apply (rule_tac g = "(%n. inverse (real (fact n)) * \<bar>x\<bar> ^ n)" in summable_comparison_test)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    94
apply (rule_tac [2] summable_exp)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    95
apply (rule_tac x = 0 in exI)
16924
04246269386e removed the dependence on abs_mult
paulson
parents: 16819
diff changeset
    96
apply (auto simp add: divide_inverse abs_mult power_abs [symmetric] zero_le_mult_iff)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    97
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
    98
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
    99
lemma lemma_STAR_sin [simp]:
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   100
     "(if even n then 0  
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   101
       else (- 1) ^ ((n - Suc 0) div 2)/(real (fact n))) * 0 ^ n = 0"
15251
bb6f072c8d10 converted some induct_tac to induct
paulson
parents: 15241
diff changeset
   102
by (induct "n", auto)
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   103
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   104
lemma lemma_STAR_cos [simp]:
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   105
     "0 < n -->  
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   106
      (- 1) ^ (n div 2)/(real (fact n)) * 0 ^ n = 0"
15251
bb6f072c8d10 converted some induct_tac to induct
paulson
parents: 15241
diff changeset
   107
by (induct "n", auto)
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   108
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   109
lemma lemma_STAR_cos1 [simp]:
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   110
     "0 < n -->  
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   111
      (-1) ^ (n div 2)/(real (fact n)) * 0 ^ n = 0"
15251
bb6f072c8d10 converted some induct_tac to induct
paulson
parents: 15241
diff changeset
   112
by (induct "n", auto)
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   113
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   114
lemma lemma_STAR_cos2 [simp]:
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
   115
  "(\<Sum>n=1..<n. if even n then (- 1) ^ (n div 2)/(real (fact n)) *  0 ^ n 
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
   116
                         else 0) = 0"
15251
bb6f072c8d10 converted some induct_tac to induct
paulson
parents: 15241
diff changeset
   117
apply (induct "n")
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   118
apply (case_tac [2] "n", auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   119
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   120
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   121
lemma exp_converges: "(%n. inverse (real (fact n)) * x ^ n) sums exp(x)"
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   122
apply (simp add: exp_def)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   123
apply (rule summable_exp [THEN summable_sums])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   124
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   125
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   126
lemma sin_converges: 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   127
      "(%n. (if even n then 0  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   128
            else (- 1) ^ ((n - Suc 0) div 2)/(real (fact n))) *  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   129
                 x ^ n) sums sin(x)"
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   130
apply (simp add: sin_def)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   131
apply (rule summable_sin [THEN summable_sums])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   132
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   133
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   134
lemma cos_converges: 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   135
      "(%n. (if even n then  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   136
           (- 1) ^ (n div 2)/(real (fact n))  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   137
           else 0) * x ^ n) sums cos(x)"
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   138
apply (simp add: cos_def)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   139
apply (rule summable_cos [THEN summable_sums])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   140
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   141
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   142
lemma lemma_realpow_diff [rule_format (no_asm)]:
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   143
     "p \<le> n --> y ^ (Suc n - p) = ((y::real) ^ (n - p)) * y"
15251
bb6f072c8d10 converted some induct_tac to induct
paulson
parents: 15241
diff changeset
   144
apply (induct "n", auto)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   145
apply (subgoal_tac "p = Suc n")
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   146
apply (simp (no_asm_simp), auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   147
apply (drule sym)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   148
apply (simp add: Suc_diff_le mult_commute realpow_Suc [symmetric] 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   149
       del: realpow_Suc)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   150
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   151
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   152
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   153
subsection{*Properties of Power Series*}
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   154
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   155
lemma lemma_realpow_diff_sumr:
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
   156
     "(\<Sum>p=0..<Suc n. (x ^ p) * y ^ ((Suc n) - p)) =  
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
   157
      y * (\<Sum>p=0..<Suc n. (x ^ p) * (y ^ (n - p))::real)"
19279
48b527d0331b Renamed setsum_mult to setsum_right_distrib.
ballarin
parents: 18585
diff changeset
   158
by (auto simp add: setsum_right_distrib lemma_realpow_diff mult_ac
16641
fce796ad9c2b Simplified some proofs (thanks to strong_setsum_cong).
berghofe
parents: 15561
diff changeset
   159
  simp del: setsum_op_ivl_Suc cong: strong_setsum_cong)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   160
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   161
lemma lemma_realpow_diff_sumr2:
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   162
     "x ^ (Suc n) - y ^ (Suc n) =  
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
   163
      (x - y) * (\<Sum>p=0..<Suc n. (x ^ p) * (y ^(n - p))::real)"
15251
bb6f072c8d10 converted some induct_tac to induct
paulson
parents: 15241
diff changeset
   164
apply (induct "n", simp)
15561
045a07ac35a7 another reorganization of setsums and intervals
nipkow
parents: 15546
diff changeset
   165
apply (auto simp del: setsum_op_ivl_Suc)
045a07ac35a7 another reorganization of setsums and intervals
nipkow
parents: 15546
diff changeset
   166
apply (subst setsum_op_ivl_Suc)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   167
apply (drule sym)
15561
045a07ac35a7 another reorganization of setsums and intervals
nipkow
parents: 15546
diff changeset
   168
apply (auto simp add: lemma_realpow_diff_sumr right_distrib diff_minus mult_ac simp del: setsum_op_ivl_Suc)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   169
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   170
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   171
lemma lemma_realpow_rev_sumr:
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
   172
     "(\<Sum>p=0..<Suc n. (x ^ p) * (y ^ (n - p))) =  
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
   173
      (\<Sum>p=0..<Suc n. (x ^ (n - p)) * (y ^ p)::real)"
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   174
apply (case_tac "x = y")
15561
045a07ac35a7 another reorganization of setsums and intervals
nipkow
parents: 15546
diff changeset
   175
apply (auto simp add: mult_commute power_add [symmetric] simp del: setsum_op_ivl_Suc)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   176
apply (rule_tac c1 = "x - y" in real_mult_left_cancel [THEN iffD1])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   177
apply (rule_tac [2] minus_minus [THEN subst], simp)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   178
apply (subst minus_mult_left)
15561
045a07ac35a7 another reorganization of setsums and intervals
nipkow
parents: 15546
diff changeset
   179
apply (simp add: lemma_realpow_diff_sumr2 [symmetric] del: setsum_op_ivl_Suc)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   180
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   181
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   182
text{*Power series has a `circle` of convergence, i.e. if it sums for @{term
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   183
x}, then it sums absolutely for @{term z} with @{term "\<bar>z\<bar> < \<bar>x\<bar>"}.*}
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   184
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   185
lemma powser_insidea:
20849
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   186
  fixes x z :: real
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   187
  assumes 1: "summable (\<lambda>n. f n * x ^ n)"
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   188
  assumes 2: "\<bar>z\<bar> < \<bar>x\<bar>"
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   189
  shows "summable (\<lambda>n. \<bar>f n\<bar> * z ^ n)"
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   190
proof -
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   191
  from 2 have x_neq_0: "x \<noteq> 0" by clarsimp
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   192
  from 1 have "(\<lambda>n. f n * x ^ n) ----> 0"
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   193
    by (rule summable_LIMSEQ_zero)
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   194
  hence "convergent (\<lambda>n. f n * x ^ n)"
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   195
    by (rule convergentI)
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   196
  hence "Cauchy (\<lambda>n. f n * x ^ n)"
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   197
    by (simp add: Cauchy_convergent_iff)
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   198
  hence "Bseq (\<lambda>n. f n * x ^ n)"
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   199
    by (rule Cauchy_Bseq)
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   200
  then obtain K where 3: "0 < K" and 4: "\<forall>n. \<bar>f n * x ^ n\<bar> \<le> K"
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   201
    by (simp add: Bseq_def, safe)
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   202
  have "\<exists>N. \<forall>n\<ge>N. norm (\<bar>f n\<bar> * z ^ n) \<le> K * \<bar>z ^ n\<bar> * inverse \<bar>x ^ n\<bar>"
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   203
  proof (intro exI allI impI)
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   204
    fix n::nat assume "0 \<le> n"
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   205
    have "norm (\<bar>f n\<bar> * z ^ n) * \<bar>x ^ n\<bar> = \<bar>f n * x ^ n\<bar> * \<bar>z ^ n\<bar>"
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   206
      by (simp add: abs_mult)
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   207
    also have "\<dots> \<le> K * \<bar>z ^ n\<bar>"
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   208
      by (simp only: mult_right_mono 4 abs_ge_zero)
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   209
    also have "\<dots> = K * \<bar>z ^ n\<bar> * (inverse \<bar>x ^ n\<bar> * \<bar>x ^ n\<bar>)"
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   210
      by (simp add: x_neq_0)
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   211
    also have "\<dots> = K * \<bar>z ^ n\<bar> * inverse \<bar>x ^ n\<bar> * \<bar>x ^ n\<bar>"
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   212
      by (simp only: mult_assoc)
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   213
    finally show "norm (\<bar>f n\<bar> * z ^ n) \<le> K * \<bar>z ^ n\<bar> * inverse \<bar>x ^ n\<bar>"
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   214
      by (simp add: mult_le_cancel_right x_neq_0)
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   215
  qed
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   216
  moreover have "summable (\<lambda>n. K * \<bar>z ^ n\<bar> * inverse \<bar>x ^ n\<bar>)"
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   217
  proof -
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   218
    from 2 have "norm \<bar>z * inverse x\<bar> < 1"
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   219
      by (simp add: abs_mult divide_inverse [symmetric])
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   220
    hence "summable (\<lambda>n. \<bar>z * inverse x\<bar> ^ n)"
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   221
      by (rule summable_geometric)
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   222
    hence "summable (\<lambda>n. K * \<bar>z * inverse x\<bar> ^ n)"
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   223
      by (rule summable_mult)
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   224
    thus "summable (\<lambda>n. K * \<bar>z ^ n\<bar> * inverse \<bar>x ^ n\<bar>)"
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   225
      by (simp add: abs_mult power_mult_distrib power_abs
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   226
                    power_inverse mult_assoc)
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   227
  qed
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   228
  ultimately show "summable (\<lambda>n. \<bar>f n\<bar> * z ^ n)"
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   229
    by (rule summable_comparison_test)
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   230
qed
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   231
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   232
lemma powser_inside:
20849
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   233
  fixes f :: "nat \<Rightarrow> real" shows
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   234
     "[| summable (%n. f(n) * (x ^ n)); \<bar>z\<bar> < \<bar>x\<bar> |]  
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   235
      ==> summable (%n. f(n) * (z ^ n))"
20849
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   236
apply (drule_tac z = "\<bar>z\<bar>" in powser_insidea, simp)
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   237
apply (rule summable_rabs_cancel)
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   238
apply (simp add: abs_mult power_abs [symmetric])
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   239
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   240
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   241
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   242
subsection{*Differentiation of Power Series*}
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   243
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   244
text{*Lemma about distributing negation over it*}
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   245
lemma diffs_minus: "diffs (%n. - c n) = (%n. - diffs c n)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   246
by (simp add: diffs_def)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   247
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   248
text{*Show that we can shift the terms down one*}
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   249
lemma lemma_diffs:
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
   250
     "(\<Sum>n=0..<n. (diffs c)(n) * (x ^ n)) =  
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
   251
      (\<Sum>n=0..<n. real n * c(n) * (x ^ (n - Suc 0))) +  
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   252
      (real n * c(n) * x ^ (n - Suc 0))"
15251
bb6f072c8d10 converted some induct_tac to induct
paulson
parents: 15241
diff changeset
   253
apply (induct "n")
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   254
apply (auto simp add: mult_assoc add_assoc [symmetric] diffs_def)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   255
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   256
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   257
lemma lemma_diffs2:
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
   258
     "(\<Sum>n=0..<n. real n * c(n) * (x ^ (n - Suc 0))) =  
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
   259
      (\<Sum>n=0..<n. (diffs c)(n) * (x ^ n)) -  
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   260
      (real n * c(n) * x ^ (n - Suc 0))"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   261
by (auto simp add: lemma_diffs)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   262
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   263
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   264
lemma diffs_equiv:
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   265
     "summable (%n. (diffs c)(n) * (x ^ n)) ==>  
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   266
      (%n. real n * c(n) * (x ^ (n - Suc 0))) sums  
15546
5188ce7316b7 suminf -> \<Sum>
nipkow
parents: 15544
diff changeset
   267
         (\<Sum>n. (diffs c)(n) * (x ^ n))"
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   268
apply (subgoal_tac " (%n. real n * c (n) * (x ^ (n - Suc 0))) ----> 0")
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   269
apply (rule_tac [2] LIMSEQ_imp_Suc)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   270
apply (drule summable_sums) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   271
apply (auto simp add: sums_def)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   272
apply (drule_tac X="(\<lambda>n. \<Sum>n = 0..<n. diffs c n * x ^ n)" in LIMSEQ_diff)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   273
apply (auto simp add: lemma_diffs2 [symmetric] diffs_def [symmetric])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   274
apply (simp add: diffs_def summable_LIMSEQ_zero)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   275
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   276
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   277
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   278
subsection{*Term-by-Term Differentiability of Power Series*}
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   279
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   280
lemma lemma_termdiff1:
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
   281
  "(\<Sum>p=0..<m. (((z + h) ^ (m - p)) * (z ^ p)) - (z ^ m)) =  
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
   282
   (\<Sum>p=0..<m. (z ^ p) * (((z + h) ^ (m - p)) - (z ^ (m - p)))::real)"
16641
fce796ad9c2b Simplified some proofs (thanks to strong_setsum_cong).
berghofe
parents: 15561
diff changeset
   283
by (auto simp add: right_distrib diff_minus power_add [symmetric] mult_ac
fce796ad9c2b Simplified some proofs (thanks to strong_setsum_cong).
berghofe
parents: 15561
diff changeset
   284
  cong: strong_setsum_cong)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   285
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   286
lemma less_add_one: "m < n ==> (\<exists>d. n = m + d + Suc 0)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   287
by (simp add: less_iff_Suc_add)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   288
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   289
lemma sumdiff: "a + b - (c + d) = a - c + b - (d::real)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   290
by arith
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   291
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   292
lemma lemma_termdiff2:
20860
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   293
  assumes h: "h \<noteq> 0" shows
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   294
  "((z + h) ^ n - z ^ n) / h - real n * z ^ (n - Suc 0) =
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   295
   h * (\<Sum>p=0..< n - Suc 0. \<Sum>q=0..< n - Suc 0 - p.
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   296
        (z + h) ^ q * z ^ (n - 2 - q))"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   297
apply (rule real_mult_left_cancel [OF h, THEN iffD1])
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   298
apply (simp add: right_diff_distrib diff_divide_distrib h)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   299
apply (simp add: mult_assoc [symmetric])
20860
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   300
apply (cases "n", simp)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   301
apply (simp add: lemma_realpow_diff_sumr2 h
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   302
                 right_diff_distrib [symmetric] mult_assoc
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   303
            del: realpow_Suc setsum_op_ivl_Suc)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   304
apply (subst lemma_realpow_rev_sumr)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   305
apply (subst sumr_diff_mult_const)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   306
apply simp
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   307
apply (simp only: lemma_termdiff1 setsum_right_distrib)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   308
apply (rule setsum_cong [OF refl])
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
   309
apply (simp add: diff_minus [symmetric] less_iff_Suc_add)
20860
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   310
apply (clarify)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   311
apply (simp add: setsum_right_distrib lemma_realpow_diff_sumr2 mult_ac
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   312
            del: setsum_op_ivl_Suc realpow_Suc)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   313
apply (subst mult_assoc [symmetric], subst power_add [symmetric])
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   314
apply (simp add: mult_ac)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   315
done
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   316
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   317
lemma real_setsum_nat_ivl_bounded2:
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   318
  "\<lbrakk>\<And>p::nat. p < n \<Longrightarrow> f p \<le> K; 0 \<le> K\<rbrakk>
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   319
   \<Longrightarrow> setsum f {0..<n-k} \<le> real n * K"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   320
apply (rule order_trans [OF real_setsum_nat_ivl_bounded mult_right_mono])
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   321
apply simp_all
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   322
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   323
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   324
lemma lemma_termdiff3:
20860
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   325
  assumes 1: "h \<noteq> 0"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   326
  assumes 2: "\<bar>z\<bar> \<le> K"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   327
  assumes 3: "\<bar>z + h\<bar> \<le> K"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   328
  shows "\<bar>((z + h) ^ n - z ^ n) / h - real n * z ^ (n - Suc 0)\<bar>
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   329
          \<le> real n * real (n - Suc 0) * K ^ (n - 2) * \<bar>h\<bar>"
20860
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   330
proof -
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   331
  have "\<bar>((z + h) ^ n - z ^ n) / h - real n * z ^ (n - Suc 0)\<bar> =
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   332
        \<bar>\<Sum>p = 0..<n - Suc 0. \<Sum>q = 0..<n - Suc 0 - p.
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   333
          (z + h) ^ q * z ^ (n - 2 - q)\<bar> * \<bar>h\<bar>"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   334
    apply (subst lemma_termdiff2 [OF 1])
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   335
    apply (subst abs_mult)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   336
    apply (rule mult_commute)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   337
    done
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   338
  also have "\<dots> \<le> real n * (real (n - Suc 0) * K ^ (n - 2)) * \<bar>h\<bar>"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   339
  proof (rule mult_right_mono [OF _ abs_ge_zero])
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   340
    from abs_ge_zero 2 have K: "0 \<le> K" by (rule order_trans)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   341
    have le_Kn: "\<And>i j n. i + j = n \<Longrightarrow> \<bar>(z + h) ^ i * z ^ j\<bar> \<le> K ^ n"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   342
      apply (erule subst)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   343
      apply (simp only: abs_mult power_abs power_add)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   344
      apply (intro mult_mono power_mono 2 3 abs_ge_zero zero_le_power K)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   345
      done
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   346
    show "\<bar>\<Sum>p = 0..<n - Suc 0. \<Sum>q = 0..<n - Suc 0 - p.
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   347
              (z + h) ^ q * z ^ (n - 2 - q)\<bar>
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   348
          \<le> real n * (real (n - Suc 0) * K ^ (n - 2))"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   349
      apply (intro
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   350
         order_trans [OF setsum_abs]
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   351
         real_setsum_nat_ivl_bounded2
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   352
         mult_nonneg_nonneg
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   353
         real_of_nat_ge_zero
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   354
         zero_le_power K)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   355
      apply (rule le_Kn, simp)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   356
      done
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   357
  qed
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   358
  also have "\<dots> = real n * real (n - Suc 0) * K ^ (n - 2) * \<bar>h\<bar>"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   359
    by (simp only: mult_assoc)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   360
  finally show ?thesis .
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   361
qed
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   362
20860
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   363
lemma lemma_termdiff4:
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   364
  assumes k: "0 < (k::real)"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   365
  assumes le: "\<And>h. \<lbrakk>h \<noteq> 0; \<bar>h\<bar> < k\<rbrakk> \<Longrightarrow> \<bar>f h\<bar> \<le> K * \<bar>h\<bar>"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   366
  shows "f -- 0 --> 0"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   367
proof (simp add: LIM_def, safe)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   368
  fix r::real assume r: "0 < r"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   369
  have zero_le_K: "0 \<le> K"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   370
    apply (cut_tac k)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   371
    apply (cut_tac h="k/2" in le, simp, simp)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   372
    apply (subgoal_tac "0 \<le> K*k", simp add: zero_le_mult_iff) 
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   373
    apply (force intro: order_trans [of _ "\<bar>f (k / 2)\<bar> * 2"]) 
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   374
    done
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   375
  show "\<exists>s. 0 < s \<and> (\<forall>x. x \<noteq> 0 \<and> \<bar>x\<bar> < s \<longrightarrow> \<bar>f x\<bar> < r)"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   376
  proof (cases)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   377
    assume "K = 0"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   378
    with k r le have "0 < k \<and> (\<forall>x. x \<noteq> 0 \<and> \<bar>x\<bar> < k \<longrightarrow> \<bar>f x\<bar> < r)"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   379
      by simp
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   380
    thus "\<exists>s. 0 < s \<and> (\<forall>x. x \<noteq> 0 \<and> \<bar>x\<bar> < s \<longrightarrow> \<bar>f x\<bar> < r)" ..
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   381
  next
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   382
    assume K_neq_zero: "K \<noteq> 0"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   383
    with zero_le_K have K: "0 < K" by simp
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   384
    show "\<exists>s. 0 < s \<and> (\<forall>x. x \<noteq> 0 \<and> \<bar>x\<bar> < s \<longrightarrow> \<bar>f x\<bar> < r)"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   385
    proof (rule exI, safe)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   386
      from k r K show "0 < min k (r * inverse K / 2)"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   387
        by (simp add: mult_pos_pos positive_imp_inverse_positive)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   388
    next
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   389
      fix x::real
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   390
      assume x1: "x \<noteq> 0" and x2: "\<bar>x\<bar> < min k (r * inverse K / 2)"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   391
      from x2 have x3: "\<bar>x\<bar> < k" and x4: "\<bar>x\<bar> < r * inverse K / 2"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   392
        by simp_all
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   393
      from x1 x3 le have "\<bar>f x\<bar> \<le> K * \<bar>x\<bar>" by simp
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   394
      also from x4 K have "K * \<bar>x\<bar> < K * (r * inverse K / 2)"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   395
        by (rule mult_strict_left_mono)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   396
      also have "\<dots> = r / 2"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   397
        using K_neq_zero by simp
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   398
      also have "r / 2 < r"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   399
        using r by simp
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   400
      finally show "\<bar>f x\<bar> < r" .
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   401
    qed
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   402
  qed
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   403
qed
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   404
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   405
lemma lemma_termdiff5:
20860
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   406
  assumes k: "0 < (k::real)"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   407
  assumes f: "summable f"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   408
  assumes le: "\<And>h n. \<lbrakk>h \<noteq> 0; \<bar>h\<bar> < k\<rbrakk> \<Longrightarrow> \<bar>g h n\<bar> \<le> f n * \<bar>h\<bar>"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   409
  shows "(\<lambda>h. suminf (g h)) -- 0 --> 0"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   410
proof (rule lemma_termdiff4 [OF k])
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   411
  fix h assume "h \<noteq> 0" and "\<bar>h\<bar> < k"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   412
  hence A: "\<forall>n. \<bar>g h n\<bar> \<le> f n * \<bar>h\<bar>"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   413
    by (simp add: le)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   414
  hence "\<exists>N. \<forall>n\<ge>N. norm \<bar>g h n\<bar> \<le> f n * \<bar>h\<bar>"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   415
    by simp
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   416
  moreover from f have B: "summable (\<lambda>n. f n * \<bar>h\<bar>)"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   417
    by (rule summable_mult2)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   418
  ultimately have C: "summable (\<lambda>n. \<bar>g h n\<bar>)"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   419
    by (rule summable_comparison_test)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   420
  hence "\<bar>suminf (g h)\<bar> \<le> (\<Sum>n. \<bar>g h n\<bar>)"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   421
    by (rule summable_rabs)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   422
  also from A C B have "(\<Sum>n. \<bar>g h n\<bar>) \<le> (\<Sum>n. f n * \<bar>h\<bar>)"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   423
    by (rule summable_le)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   424
  also from f have "(\<Sum>n. f n * \<bar>h\<bar>) = suminf f * \<bar>h\<bar>"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   425
    by (rule suminf_mult2 [symmetric])
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   426
  finally show "\<bar>suminf (g h)\<bar> \<le> suminf f * \<bar>h\<bar>" .
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   427
qed
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   428
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   429
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   430
text{* FIXME: Long proofs*}
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   431
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   432
lemma termdiffs_aux:
20849
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   433
  assumes 1: "summable (\<lambda>n. diffs (diffs c) n * K ^ n)"
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   434
  assumes 2: "\<bar>x\<bar> < \<bar>K\<bar>"
20860
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   435
  shows "(\<lambda>h. \<Sum>n. c n * (((x + h) ^ n - x ^ n) / h
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   436
             - real n * x ^ (n - Suc 0))) -- 0 --> 0"
20849
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   437
proof -
20860
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   438
  from dense [OF 2]
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   439
  obtain r where r1: "\<bar>x\<bar> < r" and r2: "r < \<bar>K\<bar>" by fast
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   440
  from abs_ge_zero r1 have r: "0 < r"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   441
    by (rule order_le_less_trans)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   442
  hence r_neq_0: "r \<noteq> 0" by simp
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   443
  show ?thesis
20849
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   444
  proof (rule lemma_termdiff5)
20860
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   445
    show "0 < r - \<bar>x\<bar>" using r1 by simp
20849
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   446
  next
20860
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   447
    from r r2 have "\<bar>r\<bar> < \<bar>K\<bar>"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   448
      by (simp only: abs_of_nonneg order_less_imp_le)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   449
    with 1 have "summable (\<lambda>n. \<bar>diffs (diffs c) n\<bar> * (r ^ n))"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   450
      by (rule powser_insidea)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   451
    hence "summable (\<lambda>n. diffs (diffs (\<lambda>n. \<bar>c n\<bar>)) n * r ^ n)"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   452
      by (simp only: diffs_def abs_mult abs_real_of_nat_cancel)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   453
    hence "summable (\<lambda>n. real n * diffs (\<lambda>n. \<bar>c n\<bar>) n * r ^ (n - Suc 0))"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   454
      by (rule diffs_equiv [THEN sums_summable])
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   455
    also have "(\<lambda>n. real n * diffs (\<lambda>n. \<bar>c n\<bar>) n * r ^ (n - Suc 0))
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   456
      = (\<lambda>n. diffs (%m. real (m - Suc 0) * \<bar>c m\<bar> * inverse r) n * (r ^ n))"
20849
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   457
      apply (rule ext)
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   458
      apply (simp add: diffs_def)
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   459
      apply (case_tac n, simp_all add: r_neq_0)
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   460
      done
20860
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   461
    finally have "summable 
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   462
      (\<lambda>n. real n * (real (n - Suc 0) * \<bar>c n\<bar> * inverse r) * r ^ (n - Suc 0))"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   463
      by (rule diffs_equiv [THEN sums_summable])
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   464
    also have
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   465
      "(\<lambda>n. real n * (real (n - Suc 0) * \<bar>c n\<bar> * inverse r) *
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   466
           r ^ (n - Suc 0)) =
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   467
       (\<lambda>n. \<bar>c n\<bar> * real n * real (n - Suc 0) * r ^ (n - 2))"
20849
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   468
      apply (rule ext)
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   469
      apply (case_tac "n", simp)
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   470
      apply (case_tac "nat", simp)
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   471
      apply (simp add: r_neq_0)
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   472
      done
20860
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   473
    finally show
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   474
      "summable (\<lambda>n. \<bar>c n\<bar> * real n * real (n - Suc 0) * r ^ (n - 2))" .
20849
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   475
  next
20860
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   476
    fix h::real and n::nat
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   477
    assume h: "h \<noteq> 0"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   478
    assume "\<bar>h\<bar> < r - \<bar>x\<bar>"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   479
    hence "\<bar>x\<bar> + \<bar>h\<bar> < r" by simp
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   480
    with abs_triangle_ineq have xh: "\<bar>x + h\<bar> < r"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   481
      by (rule order_le_less_trans)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   482
    show "\<bar>c n * (((x + h) ^ n - x ^ n) / h - real n * x ^ (n - Suc 0))\<bar>
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   483
          \<le> \<bar>c n\<bar> * real n * real (n - Suc 0) * r ^ (n - 2) * \<bar>h\<bar>"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   484
      apply (simp only: abs_mult mult_assoc)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   485
      apply (rule mult_left_mono [OF _ abs_ge_zero])
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   486
      apply (simp (no_asm) add: mult_assoc [symmetric])
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   487
      apply (rule lemma_termdiff3)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   488
      apply (rule h)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   489
      apply (rule r1 [THEN order_less_imp_le])
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   490
      apply (rule xh [THEN order_less_imp_le])
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   491
      done
20849
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   492
  qed
389cd9c8cfe1 rewrite proofs of powser_insidea and termdiffs_aux
huffman
parents: 20692
diff changeset
   493
qed
20217
25b068a99d2b linear arithmetic splits certain operators (e.g. min, max, abs)
webertj
parents: 19765
diff changeset
   494
20860
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   495
lemma termdiffs:
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   496
  assumes 1: "summable (\<lambda>n. c n * K ^ n)"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   497
  assumes 2: "summable (\<lambda>n. (diffs c) n * K ^ n)"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   498
  assumes 3: "summable (\<lambda>n. (diffs (diffs c)) n * K ^ n)"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   499
  assumes 4: "\<bar>x\<bar> < \<bar>K\<bar>"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   500
  shows "DERIV (\<lambda>x. \<Sum>n. c n * x ^ n) x :> (\<Sum>n. (diffs c) n * x ^ n)"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   501
proof (simp add: deriv_def, rule LIM_zero_cancel)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   502
  show "(\<lambda>h. (suminf (\<lambda>n. c n * (x + h) ^ n) - suminf (\<lambda>n. c n * x ^ n)) / h
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   503
            - suminf (\<lambda>n. diffs c n * x ^ n)) -- 0 --> 0"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   504
  proof (rule LIM_equal2)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   505
    show "0 < \<bar>K\<bar> - \<bar>x\<bar>" by (simp add: less_diff_eq 4)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   506
  next
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   507
    fix h :: real
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   508
    assume "h \<noteq> 0"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   509
    assume "norm (h - 0) < \<bar>K\<bar> - \<bar>x\<bar>"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   510
    hence "\<bar>x\<bar> + \<bar>h\<bar> < \<bar>K\<bar>" by simp
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   511
    hence 5: "\<bar>x + h\<bar> < \<bar>K\<bar>"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   512
      by (rule abs_triangle_ineq [THEN order_le_less_trans])
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   513
    have A: "summable (\<lambda>n. c n * x ^ n)"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   514
      by (rule powser_inside [OF 1 4])
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   515
    have B: "summable (\<lambda>n. c n * (x + h) ^ n)"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   516
      by (rule powser_inside [OF 1 5])
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   517
    have C: "summable (\<lambda>n. diffs c n * x ^ n)"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   518
      by (rule powser_inside [OF 2 4])
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   519
    show "((\<Sum>n. c n * (x + h) ^ n) - (\<Sum>n. c n * x ^ n)) / h
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   520
             - (\<Sum>n. diffs c n * x ^ n) = 
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   521
          (\<Sum>n. c n * (((x + h) ^ n - x ^ n) / h - real n * x ^ (n - Suc 0)))"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   522
      apply (subst sums_unique [OF diffs_equiv [OF C]])
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   523
      apply (subst suminf_diff [OF B A])
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   524
      apply (subst suminf_divide [symmetric])
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   525
      apply (rule summable_diff [OF B A])
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   526
      apply (subst suminf_diff)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   527
      apply (rule summable_divide)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   528
      apply (rule summable_diff [OF B A])
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   529
      apply (rule sums_summable [OF diffs_equiv [OF C]])
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   530
      apply (rule_tac f="suminf" in arg_cong)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   531
      apply (rule ext)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   532
      apply (simp add: ring_eq_simps)
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   533
      done
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   534
  next
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   535
    show "(\<lambda>h. \<Sum>n. c n * (((x + h) ^ n - x ^ n) / h -
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   536
               real n * x ^ (n - Suc 0))) -- 0 --> 0"
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   537
        by (rule termdiffs_aux [OF 3 4])
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   538
  qed
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   539
qed
1a8efd618190 reorganize and speed up termdiffs proofs
huffman
parents: 20849
diff changeset
   540
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   541
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   542
subsection{*Formal Derivatives of Exp, Sin, and Cos Series*} 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   543
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   544
lemma exp_fdiffs: 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   545
      "diffs (%n. inverse(real (fact n))) = (%n. inverse(real (fact n)))"
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   546
by (simp add: diffs_def mult_assoc [symmetric] del: mult_Suc)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   547
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   548
lemma sin_fdiffs: 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   549
      "diffs(%n. if even n then 0  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   550
           else (- 1) ^ ((n - Suc 0) div 2)/(real (fact n)))  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   551
       = (%n. if even n then  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   552
                 (- 1) ^ (n div 2)/(real (fact n))  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   553
              else 0)"
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   554
by (auto intro!: ext 
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   555
         simp add: diffs_def divide_inverse simp del: mult_Suc)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   556
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   557
lemma sin_fdiffs2: 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   558
       "diffs(%n. if even n then 0  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   559
           else (- 1) ^ ((n - Suc 0) div 2)/(real (fact n))) n  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   560
       = (if even n then  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   561
                 (- 1) ^ (n div 2)/(real (fact n))  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   562
              else 0)"
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   563
by (auto intro!: ext 
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   564
         simp add: diffs_def divide_inverse simp del: mult_Suc)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   565
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   566
lemma cos_fdiffs: 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   567
      "diffs(%n. if even n then  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   568
                 (- 1) ^ (n div 2)/(real (fact n)) else 0)  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   569
       = (%n. - (if even n then 0  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   570
           else (- 1) ^ ((n - Suc 0)div 2)/(real (fact n))))"
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   571
by (auto intro!: ext 
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   572
         simp add: diffs_def divide_inverse odd_Suc_mult_two_ex
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   573
         simp del: mult_Suc)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   574
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   575
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   576
lemma cos_fdiffs2: 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   577
      "diffs(%n. if even n then  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   578
                 (- 1) ^ (n div 2)/(real (fact n)) else 0) n 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   579
       = - (if even n then 0  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   580
           else (- 1) ^ ((n - Suc 0)div 2)/(real (fact n)))"
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   581
by (auto intro!: ext 
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   582
         simp add: diffs_def divide_inverse odd_Suc_mult_two_ex
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   583
         simp del: mult_Suc)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   584
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   585
text{*Now at last we can get the derivatives of exp, sin and cos*}
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   586
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   587
lemma lemma_sin_minus:
15546
5188ce7316b7 suminf -> \<Sum>
nipkow
parents: 15544
diff changeset
   588
     "- sin x = (\<Sum>n. - ((if even n then 0 
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   589
                  else (- 1) ^ ((n - Suc 0) div 2)/(real (fact n))) * x ^ n))"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   590
by (auto intro!: sums_unique sums_minus sin_converges)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   591
15546
5188ce7316b7 suminf -> \<Sum>
nipkow
parents: 15544
diff changeset
   592
lemma lemma_exp_ext: "exp = (%x. \<Sum>n. inverse (real (fact n)) * x ^ n)"
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   593
by (auto intro!: ext simp add: exp_def)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   594
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   595
lemma DERIV_exp [simp]: "DERIV exp x :> exp(x)"
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   596
apply (simp add: exp_def)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   597
apply (subst lemma_exp_ext)
15546
5188ce7316b7 suminf -> \<Sum>
nipkow
parents: 15544
diff changeset
   598
apply (subgoal_tac "DERIV (%u. \<Sum>n. inverse (real (fact n)) * u ^ n) x :> (\<Sum>n. diffs (%n. inverse (real (fact n))) n * x ^ n)")
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   599
apply (rule_tac [2] K = "1 + \<bar>x\<bar>" in termdiffs)
20217
25b068a99d2b linear arithmetic splits certain operators (e.g. min, max, abs)
webertj
parents: 19765
diff changeset
   600
apply (auto intro: exp_converges [THEN sums_summable] simp add: exp_fdiffs)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   601
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   602
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   603
lemma lemma_sin_ext:
15546
5188ce7316b7 suminf -> \<Sum>
nipkow
parents: 15544
diff changeset
   604
     "sin = (%x. \<Sum>n. 
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   605
                   (if even n then 0  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   606
                       else (- 1) ^ ((n - Suc 0) div 2)/(real (fact n))) *  
15546
5188ce7316b7 suminf -> \<Sum>
nipkow
parents: 15544
diff changeset
   607
                   x ^ n)"
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   608
by (auto intro!: ext simp add: sin_def)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   609
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   610
lemma lemma_cos_ext:
15546
5188ce7316b7 suminf -> \<Sum>
nipkow
parents: 15544
diff changeset
   611
     "cos = (%x. \<Sum>n. 
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   612
                   (if even n then (- 1) ^ (n div 2)/(real (fact n)) else 0) *
15546
5188ce7316b7 suminf -> \<Sum>
nipkow
parents: 15544
diff changeset
   613
                   x ^ n)"
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   614
by (auto intro!: ext simp add: cos_def)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   615
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   616
lemma DERIV_sin [simp]: "DERIV sin x :> cos(x)"
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   617
apply (simp add: cos_def)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   618
apply (subst lemma_sin_ext)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   619
apply (auto simp add: sin_fdiffs2 [symmetric])
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   620
apply (rule_tac K = "1 + \<bar>x\<bar>" in termdiffs)
20217
25b068a99d2b linear arithmetic splits certain operators (e.g. min, max, abs)
webertj
parents: 19765
diff changeset
   621
apply (auto intro: sin_converges cos_converges sums_summable intro!: sums_minus [THEN sums_summable] simp add: cos_fdiffs sin_fdiffs)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   622
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   623
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   624
lemma DERIV_cos [simp]: "DERIV cos x :> -sin(x)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   625
apply (subst lemma_cos_ext)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   626
apply (auto simp add: lemma_sin_minus cos_fdiffs2 [symmetric] minus_mult_left)
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   627
apply (rule_tac K = "1 + \<bar>x\<bar>" in termdiffs)
20217
25b068a99d2b linear arithmetic splits certain operators (e.g. min, max, abs)
webertj
parents: 19765
diff changeset
   628
apply (auto intro: sin_converges cos_converges sums_summable intro!: sums_minus [THEN sums_summable] simp add: cos_fdiffs sin_fdiffs diffs_minus)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   629
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   630
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   631
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   632
subsection{*Properties of the Exponential Function*}
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   633
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   634
lemma exp_zero [simp]: "exp 0 = 1"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   635
proof -
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   636
  have "(\<Sum>n = 0..<1. inverse (real (fact n)) * 0 ^ n) =
15546
5188ce7316b7 suminf -> \<Sum>
nipkow
parents: 15544
diff changeset
   637
        (\<Sum>n. inverse (real (fact n)) * 0 ^ n)"
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   638
    by (rule series_zero [rule_format, THEN sums_unique],
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   639
        case_tac "m", auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   640
  thus ?thesis by (simp add:  exp_def) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   641
qed
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   642
17014
ad5ceb90877d renamed exp_ge_add_one_self to exp_ge_add_one_self_aux
avigad
parents: 16924
diff changeset
   643
lemma exp_ge_add_one_self_aux: "0 \<le> x ==> (1 + x) \<le> exp(x)"
22998
97e1f9c2cc46 avoid using redundant lemmas from RealDef.thy
huffman
parents: 22978
diff changeset
   644
apply (drule order_le_imp_less_or_eq, auto)
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   645
apply (simp add: exp_def)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   646
apply (rule real_le_trans)
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   647
apply (rule_tac [2] n = 2 and f = "(%n. inverse (real (fact n)) * x ^ n)" in series_pos_le)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   648
apply (auto intro: summable_exp simp add: numeral_2_eq_2 zero_le_power zero_le_mult_iff)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   649
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   650
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   651
lemma exp_gt_one [simp]: "0 < x ==> 1 < exp x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   652
apply (rule order_less_le_trans)
17014
ad5ceb90877d renamed exp_ge_add_one_self to exp_ge_add_one_self_aux
avigad
parents: 16924
diff changeset
   653
apply (rule_tac [2] exp_ge_add_one_self_aux, auto)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   654
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   655
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   656
lemma DERIV_exp_add_const: "DERIV (%x. exp (x + y)) x :> exp(x + y)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   657
proof -
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   658
  have "DERIV (exp \<circ> (\<lambda>x. x + y)) x :> exp (x + y) * (1+0)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   659
    by (fast intro: DERIV_chain DERIV_add DERIV_exp DERIV_Id DERIV_const) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   660
  thus ?thesis by (simp add: o_def)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   661
qed
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   662
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   663
lemma DERIV_exp_minus [simp]: "DERIV (%x. exp (-x)) x :> - exp(-x)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   664
proof -
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   665
  have "DERIV (exp \<circ> uminus) x :> exp (- x) * - 1"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   666
    by (fast intro: DERIV_chain DERIV_minus DERIV_exp DERIV_Id) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   667
  thus ?thesis by (simp add: o_def)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   668
qed
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   669
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   670
lemma DERIV_exp_exp_zero [simp]: "DERIV (%x. exp (x + y) * exp (- x)) x :> 0"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   671
proof -
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   672
  have "DERIV (\<lambda>x. exp (x + y) * exp (- x)) x
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   673
       :> exp (x + y) * exp (- x) + - exp (- x) * exp (x + y)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   674
    by (fast intro: DERIV_exp_add_const DERIV_exp_minus DERIV_mult) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   675
  thus ?thesis by simp
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   676
qed
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   677
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   678
lemma exp_add_mult_minus [simp]: "exp(x + y)*exp(-x) = exp(y)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   679
proof -
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   680
  have "\<forall>x. DERIV (%x. exp (x + y) * exp (- x)) x :> 0" by simp
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   681
  hence "exp (x + y) * exp (- x) = exp (0 + y) * exp (- 0)" 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   682
    by (rule DERIV_isconst_all) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   683
  thus ?thesis by simp
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   684
qed
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   685
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   686
lemma exp_mult_minus [simp]: "exp x * exp(-x) = 1"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   687
proof -
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   688
  have "exp (x + 0) * exp (- x) = exp 0" by (rule exp_add_mult_minus) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   689
  thus ?thesis by simp
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   690
qed
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   691
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   692
lemma exp_mult_minus2 [simp]: "exp(-x)*exp(x) = 1"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   693
by (simp add: mult_commute)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   694
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   695
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   696
lemma exp_minus: "exp(-x) = inverse(exp(x))"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   697
by (auto intro: inverse_unique [symmetric])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   698
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   699
lemma exp_add: "exp(x + y) = exp(x) * exp(y)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   700
proof -
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   701
  have "exp x * exp y = exp x * (exp (x + y) * exp (- x))" by simp
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   702
  thus ?thesis by (simp (no_asm_simp) add: mult_ac)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   703
qed
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   704
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   705
text{*Proof: because every exponential can be seen as a square.*}
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   706
lemma exp_ge_zero [simp]: "0 \<le> exp x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   707
apply (rule_tac t = x in real_sum_of_halves [THEN subst])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   708
apply (subst exp_add, auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   709
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   710
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   711
lemma exp_not_eq_zero [simp]: "exp x \<noteq> 0"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   712
apply (cut_tac x = x in exp_mult_minus2)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   713
apply (auto simp del: exp_mult_minus2)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   714
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   715
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   716
lemma exp_gt_zero [simp]: "0 < exp x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   717
by (simp add: order_less_le)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   718
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   719
lemma inv_exp_gt_zero [simp]: "0 < inverse(exp x)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   720
by (auto intro: positive_imp_inverse_positive)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   721
15081
32402f5624d1 abs notation
paulson
parents: 15079
diff changeset
   722
lemma abs_exp_cancel [simp]: "\<bar>exp x\<bar> = exp x"
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   723
by auto
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   724
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   725
lemma exp_real_of_nat_mult: "exp(real n * x) = exp(x) ^ n"
15251
bb6f072c8d10 converted some induct_tac to induct
paulson
parents: 15241
diff changeset
   726
apply (induct "n")
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   727
apply (auto simp add: real_of_nat_Suc right_distrib exp_add mult_commute)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   728
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   729
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   730
lemma exp_diff: "exp(x - y) = exp(x)/(exp y)"
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   731
apply (simp add: diff_minus divide_inverse)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   732
apply (simp (no_asm) add: exp_add exp_minus)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   733
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   734
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   735
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   736
lemma exp_less_mono:
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   737
  assumes xy: "x < y" shows "exp x < exp y"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   738
proof -
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   739
  have "1 < exp (y + - x)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   740
    by (rule real_less_sum_gt_zero [THEN exp_gt_one])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   741
  hence "exp x * inverse (exp x) < exp y * inverse (exp x)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   742
    by (auto simp add: exp_add exp_minus)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   743
  thus ?thesis
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
   744
    by (simp add: divide_inverse [symmetric] pos_less_divide_eq
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15140
diff changeset
   745
             del: divide_self_if)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   746
qed
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   747
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   748
lemma exp_less_cancel: "exp x < exp y ==> x < y"
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15140
diff changeset
   749
apply (simp add: linorder_not_le [symmetric]) 
4d332d10fa3d revised simprules for division
paulson
parents: 15140
diff changeset
   750
apply (auto simp add: order_le_less exp_less_mono) 
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   751
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   752
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   753
lemma exp_less_cancel_iff [iff]: "(exp(x) < exp(y)) = (x < y)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   754
by (auto intro: exp_less_mono exp_less_cancel)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   755
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   756
lemma exp_le_cancel_iff [iff]: "(exp(x) \<le> exp(y)) = (x \<le> y)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   757
by (auto simp add: linorder_not_less [symmetric])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   758
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   759
lemma exp_inj_iff [iff]: "(exp x = exp y) = (x = y)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   760
by (simp add: order_eq_iff)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   761
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   762
lemma lemma_exp_total: "1 \<le> y ==> \<exists>x. 0 \<le> x & x \<le> y - 1 & exp(x) = y"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   763
apply (rule IVT)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   764
apply (auto intro: DERIV_exp [THEN DERIV_isCont] simp add: le_diff_eq)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   765
apply (subgoal_tac "1 + (y - 1) \<le> exp (y - 1)") 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   766
apply simp 
17014
ad5ceb90877d renamed exp_ge_add_one_self to exp_ge_add_one_self_aux
avigad
parents: 16924
diff changeset
   767
apply (rule exp_ge_add_one_self_aux, simp)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   768
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   769
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   770
lemma exp_total: "0 < y ==> \<exists>x. exp x = y"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   771
apply (rule_tac x = 1 and y = y in linorder_cases)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   772
apply (drule order_less_imp_le [THEN lemma_exp_total])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   773
apply (rule_tac [2] x = 0 in exI)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   774
apply (frule_tac [3] real_inverse_gt_one)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   775
apply (drule_tac [4] order_less_imp_le [THEN lemma_exp_total], auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   776
apply (rule_tac x = "-x" in exI)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   777
apply (simp add: exp_minus)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   778
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   779
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   780
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   781
subsection{*Properties of the Logarithmic Function*}
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   782
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   783
lemma ln_exp[simp]: "ln(exp x) = x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   784
by (simp add: ln_def)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   785
22654
c2b6b5a9e136 new simp rule exp_ln; new standard proof of DERIV_exp_ln_one; changed imports
huffman
parents: 22653
diff changeset
   786
lemma exp_ln [simp]: "0 < x \<Longrightarrow> exp (ln x) = x"
c2b6b5a9e136 new simp rule exp_ln; new standard proof of DERIV_exp_ln_one; changed imports
huffman
parents: 22653
diff changeset
   787
by (auto dest: exp_total)
c2b6b5a9e136 new simp rule exp_ln; new standard proof of DERIV_exp_ln_one; changed imports
huffman
parents: 22653
diff changeset
   788
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   789
lemma exp_ln_iff[simp]: "(exp(ln x) = x) = (0 < x)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   790
apply (auto dest: exp_total)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   791
apply (erule subst, simp) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   792
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   793
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   794
lemma ln_mult: "[| 0 < x; 0 < y |] ==> ln(x * y) = ln(x) + ln(y)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   795
apply (rule exp_inj_iff [THEN iffD1])
22654
c2b6b5a9e136 new simp rule exp_ln; new standard proof of DERIV_exp_ln_one; changed imports
huffman
parents: 22653
diff changeset
   796
apply (simp add: exp_add exp_ln mult_pos_pos)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   797
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   798
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   799
lemma ln_inj_iff[simp]: "[| 0 < x; 0 < y |] ==> (ln x = ln y) = (x = y)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   800
apply (simp only: exp_ln_iff [symmetric])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   801
apply (erule subst)+
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   802
apply simp 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   803
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   804
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   805
lemma ln_one[simp]: "ln 1 = 0"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   806
by (rule exp_inj_iff [THEN iffD1], auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   807
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   808
lemma ln_inverse: "0 < x ==> ln(inverse x) = - ln x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   809
apply (rule_tac a1 = "ln x" in add_left_cancel [THEN iffD1])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   810
apply (auto simp add: positive_imp_inverse_positive ln_mult [symmetric])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   811
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   812
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   813
lemma ln_div: 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   814
    "[|0 < x; 0 < y|] ==> ln(x/y) = ln x - ln y"
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   815
apply (simp add: divide_inverse)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   816
apply (auto simp add: positive_imp_inverse_positive ln_mult ln_inverse)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   817
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   818
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   819
lemma ln_less_cancel_iff[simp]: "[| 0 < x; 0 < y|] ==> (ln x < ln y) = (x < y)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   820
apply (simp only: exp_ln_iff [symmetric])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   821
apply (erule subst)+
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   822
apply simp 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   823
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   824
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   825
lemma ln_le_cancel_iff[simp]: "[| 0 < x; 0 < y|] ==> (ln x \<le> ln y) = (x \<le> y)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   826
by (auto simp add: linorder_not_less [symmetric])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   827
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   828
lemma ln_realpow: "0 < x ==> ln(x ^ n) = real n * ln(x)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   829
by (auto dest!: exp_total simp add: exp_real_of_nat_mult [symmetric])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   830
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   831
lemma ln_add_one_self_le_self [simp]: "0 \<le> x ==> ln(1 + x) \<le> x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   832
apply (rule ln_exp [THEN subst])
17014
ad5ceb90877d renamed exp_ge_add_one_self to exp_ge_add_one_self_aux
avigad
parents: 16924
diff changeset
   833
apply (rule ln_le_cancel_iff [THEN iffD2]) 
ad5ceb90877d renamed exp_ge_add_one_self to exp_ge_add_one_self_aux
avigad
parents: 16924
diff changeset
   834
apply (auto simp add: exp_ge_add_one_self_aux)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   835
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   836
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   837
lemma ln_less_self [simp]: "0 < x ==> ln x < x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   838
apply (rule order_less_le_trans)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   839
apply (rule_tac [2] ln_add_one_self_le_self)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   840
apply (rule ln_less_cancel_iff [THEN iffD2], auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   841
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   842
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   843
lemma ln_ge_zero [simp]:
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   844
  assumes x: "1 \<le> x" shows "0 \<le> ln x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   845
proof -
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   846
  have "0 < x" using x by arith
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   847
  hence "exp 0 \<le> exp (ln x)"
22915
bb8a928a6bfa fix proofs
huffman
parents: 22722
diff changeset
   848
    by (simp add: x)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   849
  thus ?thesis by (simp only: exp_le_cancel_iff)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   850
qed
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   851
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   852
lemma ln_ge_zero_imp_ge_one:
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   853
  assumes ln: "0 \<le> ln x" 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   854
      and x:  "0 < x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   855
  shows "1 \<le> x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   856
proof -
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   857
  from ln have "ln 1 \<le> ln x" by simp
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   858
  thus ?thesis by (simp add: x del: ln_one) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   859
qed
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   860
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   861
lemma ln_ge_zero_iff [simp]: "0 < x ==> (0 \<le> ln x) = (1 \<le> x)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   862
by (blast intro: ln_ge_zero ln_ge_zero_imp_ge_one)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   863
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   864
lemma ln_less_zero_iff [simp]: "0 < x ==> (ln x < 0) = (x < 1)"
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   865
by (insert ln_ge_zero_iff [of x], arith)
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   866
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   867
lemma ln_gt_zero:
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   868
  assumes x: "1 < x" shows "0 < ln x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   869
proof -
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   870
  have "0 < x" using x by arith
22915
bb8a928a6bfa fix proofs
huffman
parents: 22722
diff changeset
   871
  hence "exp 0 < exp (ln x)" by (simp add: x)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   872
  thus ?thesis  by (simp only: exp_less_cancel_iff)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   873
qed
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   874
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   875
lemma ln_gt_zero_imp_gt_one:
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   876
  assumes ln: "0 < ln x" 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   877
      and x:  "0 < x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   878
  shows "1 < x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   879
proof -
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   880
  from ln have "ln 1 < ln x" by simp
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   881
  thus ?thesis by (simp add: x del: ln_one) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   882
qed
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   883
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   884
lemma ln_gt_zero_iff [simp]: "0 < x ==> (0 < ln x) = (1 < x)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   885
by (blast intro: ln_gt_zero ln_gt_zero_imp_gt_one)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   886
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   887
lemma ln_eq_zero_iff [simp]: "0 < x ==> (ln x = 0) = (x = 1)"
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   888
by (insert ln_less_zero_iff [of x] ln_gt_zero_iff [of x], arith)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   889
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   890
lemma ln_less_zero: "[| 0 < x; x < 1 |] ==> ln x < 0"
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
   891
by simp
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   892
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   893
lemma exp_ln_eq: "exp u = x ==> ln x = u"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   894
by auto
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   895
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   896
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   897
subsection{*Basic Properties of the Trigonometric Functions*}
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   898
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   899
lemma sin_zero [simp]: "sin 0 = 0"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   900
by (auto intro!: sums_unique [symmetric] LIMSEQ_const 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   901
         simp add: sin_def sums_def simp del: power_0_left)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   902
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
   903
lemma lemma_series_zero2:
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
   904
 "(\<forall>m. n \<le> m --> f m = 0) --> f sums setsum f {0..<n}"
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   905
by (auto intro: series_zero)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   906
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   907
lemma cos_zero [simp]: "cos 0 = 1"
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   908
apply (simp add: cos_def)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   909
apply (rule sums_unique [symmetric])
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   910
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)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   911
apply auto
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   912
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   913
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   914
lemma DERIV_sin_sin_mult [simp]:
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   915
     "DERIV (%x. sin(x)*sin(x)) x :> cos(x) * sin(x) + cos(x) * sin(x)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   916
by (rule DERIV_mult, auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   917
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   918
lemma DERIV_sin_sin_mult2 [simp]:
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   919
     "DERIV (%x. sin(x)*sin(x)) x :> 2 * cos(x) * sin(x)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   920
apply (cut_tac x = x in DERIV_sin_sin_mult)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   921
apply (auto simp add: mult_assoc)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   922
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   923
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   924
lemma DERIV_sin_realpow2 [simp]:
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   925
     "DERIV (%x. (sin x)\<twosuperior>) x :> cos(x) * sin(x) + cos(x) * sin(x)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   926
by (auto simp add: numeral_2_eq_2 real_mult_assoc [symmetric])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   927
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   928
lemma DERIV_sin_realpow2a [simp]:
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   929
     "DERIV (%x. (sin x)\<twosuperior>) x :> 2 * cos(x) * sin(x)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   930
by (auto simp add: numeral_2_eq_2)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   931
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   932
lemma DERIV_cos_cos_mult [simp]:
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   933
     "DERIV (%x. cos(x)*cos(x)) x :> -sin(x) * cos(x) + -sin(x) * cos(x)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   934
by (rule DERIV_mult, auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   935
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   936
lemma DERIV_cos_cos_mult2 [simp]:
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   937
     "DERIV (%x. cos(x)*cos(x)) x :> -2 * cos(x) * sin(x)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   938
apply (cut_tac x = x in DERIV_cos_cos_mult)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   939
apply (auto simp add: mult_ac)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   940
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   941
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   942
lemma DERIV_cos_realpow2 [simp]:
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   943
     "DERIV (%x. (cos x)\<twosuperior>) x :> -sin(x) * cos(x) + -sin(x) * cos(x)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   944
by (auto simp add: numeral_2_eq_2 real_mult_assoc [symmetric])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   945
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   946
lemma DERIV_cos_realpow2a [simp]:
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   947
     "DERIV (%x. (cos x)\<twosuperior>) x :> -2 * cos(x) * sin(x)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   948
by (auto simp add: numeral_2_eq_2)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   949
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   950
lemma lemma_DERIV_subst: "[| DERIV f x :> D; D = E |] ==> DERIV f x :> E"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   951
by auto
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   952
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   953
lemma DERIV_cos_realpow2b: "DERIV (%x. (cos x)\<twosuperior>) x :> -(2 * cos(x) * sin(x))"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   954
apply (rule lemma_DERIV_subst)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   955
apply (rule DERIV_cos_realpow2a, auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   956
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   957
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   958
(* most useful *)
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   959
lemma DERIV_cos_cos_mult3 [simp]:
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   960
     "DERIV (%x. cos(x)*cos(x)) x :> -(2 * cos(x) * sin(x))"
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   961
apply (rule lemma_DERIV_subst)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   962
apply (rule DERIV_cos_cos_mult2, auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   963
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   964
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   965
lemma DERIV_sin_circle_all: 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   966
     "\<forall>x. DERIV (%x. (sin x)\<twosuperior> + (cos x)\<twosuperior>) x :>  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   967
             (2*cos(x)*sin(x) - 2*cos(x)*sin(x))"
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   968
apply (simp only: diff_minus, safe)
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   969
apply (rule DERIV_add) 
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   970
apply (auto simp add: numeral_2_eq_2)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   971
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   972
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   973
lemma DERIV_sin_circle_all_zero [simp]:
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   974
     "\<forall>x. DERIV (%x. (sin x)\<twosuperior> + (cos x)\<twosuperior>) x :> 0"
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   975
by (cut_tac DERIV_sin_circle_all, auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   976
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   977
lemma sin_cos_squared_add [simp]: "((sin x)\<twosuperior>) + ((cos x)\<twosuperior>) = 1"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   978
apply (cut_tac x = x and y = 0 in DERIV_sin_circle_all_zero [THEN DERIV_isconst_all])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   979
apply (auto simp add: numeral_2_eq_2)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   980
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   981
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   982
lemma sin_cos_squared_add2 [simp]: "((cos x)\<twosuperior>) + ((sin x)\<twosuperior>) = 1"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   983
apply (subst real_add_commute)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   984
apply (simp (no_asm) del: realpow_Suc)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   985
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   986
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   987
lemma sin_cos_squared_add3 [simp]: "cos x * cos x + sin x * sin x = 1"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   988
apply (cut_tac x = x in sin_cos_squared_add2)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   989
apply (auto simp add: numeral_2_eq_2)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   990
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   991
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   992
lemma sin_squared_eq: "(sin x)\<twosuperior> = 1 - (cos x)\<twosuperior>"
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
   993
apply (rule_tac a1 = "(cos x)\<twosuperior>" in add_right_cancel [THEN iffD1])
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   994
apply (simp del: realpow_Suc)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   995
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   996
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   997
lemma cos_squared_eq: "(cos x)\<twosuperior> = 1 - (sin x)\<twosuperior>"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   998
apply (rule_tac a1 = "(sin x)\<twosuperior>" in add_right_cancel [THEN iffD1])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
   999
apply (simp del: realpow_Suc)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1000
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1001
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1002
lemma real_gt_one_ge_zero_add_less: "[| 1 < x; 0 \<le> y |] ==> 1 < x + (y::real)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1003
by arith
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1004
15081
32402f5624d1 abs notation
paulson
parents: 15079
diff changeset
  1005
lemma abs_sin_le_one [simp]: "\<bar>sin x\<bar> \<le> 1"
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1006
apply (auto simp add: linorder_not_less [symmetric])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1007
apply (drule_tac n = "Suc 0" in power_gt1)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1008
apply (auto simp del: realpow_Suc)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1009
apply (drule_tac r1 = "cos x" in realpow_two_le [THEN [2] real_gt_one_ge_zero_add_less])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1010
apply (simp add: numeral_2_eq_2 [symmetric] del: realpow_Suc)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1011
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1012
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1013
lemma sin_ge_minus_one [simp]: "-1 \<le> sin x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1014
apply (insert abs_sin_le_one [of x]) 
22998
97e1f9c2cc46 avoid using redundant lemmas from RealDef.thy
huffman
parents: 22978
diff changeset
  1015
apply (simp add: abs_le_iff del: abs_sin_le_one) 
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1016
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1017
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1018
lemma sin_le_one [simp]: "sin x \<le> 1"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1019
apply (insert abs_sin_le_one [of x]) 
22998
97e1f9c2cc46 avoid using redundant lemmas from RealDef.thy
huffman
parents: 22978
diff changeset
  1020
apply (simp add: abs_le_iff del: abs_sin_le_one) 
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1021
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1022
15081
32402f5624d1 abs notation
paulson
parents: 15079
diff changeset
  1023
lemma abs_cos_le_one [simp]: "\<bar>cos x\<bar> \<le> 1"
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1024
apply (auto simp add: linorder_not_less [symmetric])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1025
apply (drule_tac n = "Suc 0" in power_gt1)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1026
apply (auto simp del: realpow_Suc)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1027
apply (drule_tac r1 = "sin x" in realpow_two_le [THEN [2] real_gt_one_ge_zero_add_less])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1028
apply (simp add: numeral_2_eq_2 [symmetric] del: realpow_Suc)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1029
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1030
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1031
lemma cos_ge_minus_one [simp]: "-1 \<le> cos x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1032
apply (insert abs_cos_le_one [of x]) 
22998
97e1f9c2cc46 avoid using redundant lemmas from RealDef.thy
huffman
parents: 22978
diff changeset
  1033
apply (simp add: abs_le_iff del: abs_cos_le_one) 
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1034
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1035
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1036
lemma cos_le_one [simp]: "cos x \<le> 1"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1037
apply (insert abs_cos_le_one [of x]) 
22998
97e1f9c2cc46 avoid using redundant lemmas from RealDef.thy
huffman
parents: 22978
diff changeset
  1038
apply (simp add: abs_le_iff del: abs_cos_le_one)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1039
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1040
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1041
lemma DERIV_fun_pow: "DERIV g x :> m ==>  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1042
      DERIV (%x. (g x) ^ n) x :> real n * (g x) ^ (n - 1) * m"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1043
apply (rule lemma_DERIV_subst)
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1044
apply (rule_tac f = "(%x. x ^ n)" in DERIV_chain2)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1045
apply (rule DERIV_pow, auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1046
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1047
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1048
lemma DERIV_fun_exp:
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1049
     "DERIV g x :> m ==> DERIV (%x. exp(g x)) x :> exp(g x) * m"
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1050
apply (rule lemma_DERIV_subst)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1051
apply (rule_tac f = exp in DERIV_chain2)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1052
apply (rule DERIV_exp, auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1053
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1054
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1055
lemma DERIV_fun_sin:
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1056
     "DERIV g x :> m ==> DERIV (%x. sin(g x)) x :> cos(g x) * m"
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1057
apply (rule lemma_DERIV_subst)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1058
apply (rule_tac f = sin in DERIV_chain2)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1059
apply (rule DERIV_sin, auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1060
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1061
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1062
lemma DERIV_fun_cos:
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1063
     "DERIV g x :> m ==> DERIV (%x. cos(g x)) x :> -sin(g x) * m"
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1064
apply (rule lemma_DERIV_subst)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1065
apply (rule_tac f = cos in DERIV_chain2)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1066
apply (rule DERIV_cos, auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1067
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1068
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1069
lemmas DERIV_intros = DERIV_Id DERIV_const DERIV_cos DERIV_cmult 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1070
                    DERIV_sin  DERIV_exp  DERIV_inverse DERIV_pow 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1071
                    DERIV_add  DERIV_diff  DERIV_mult  DERIV_minus 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1072
                    DERIV_inverse_fun DERIV_quotient DERIV_fun_pow 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1073
                    DERIV_fun_exp DERIV_fun_sin DERIV_fun_cos 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1074
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1075
(* lemma *)
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1076
lemma lemma_DERIV_sin_cos_add:
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1077
     "\<forall>x.  
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1078
         DERIV (%x. (sin (x + y) - (sin x * cos y + cos x * sin y)) ^ 2 +  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1079
               (cos (x + y) - (cos x * cos y - sin x * sin y)) ^ 2) x :> 0"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1080
apply (safe, rule lemma_DERIV_subst)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1081
apply (best intro!: DERIV_intros intro: DERIV_chain2) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1082
  --{*replaces the old @{text DERIV_tac}*}
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1083
apply (auto simp add: diff_minus left_distrib right_distrib mult_ac add_ac)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1084
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1085
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1086
lemma sin_cos_add [simp]:
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1087
     "(sin (x + y) - (sin x * cos y + cos x * sin y)) ^ 2 +  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1088
      (cos (x + y) - (cos x * cos y - sin x * sin y)) ^ 2 = 0"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1089
apply (cut_tac y = 0 and x = x and y7 = y 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1090
       in lemma_DERIV_sin_cos_add [THEN DERIV_isconst_all])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1091
apply (auto simp add: numeral_2_eq_2)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1092
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1093
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1094
lemma sin_add: "sin (x + y) = sin x * cos y + cos x * sin y"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1095
apply (cut_tac x = x and y = y in sin_cos_add)
22969
bf523cac9a05 tuned proofs
huffman
parents: 22960
diff changeset
  1096
apply (simp del: sin_cos_add)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1097
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1098
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1099
lemma cos_add: "cos (x + y) = cos x * cos y - sin x * sin y"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1100
apply (cut_tac x = x and y = y in sin_cos_add)
22969
bf523cac9a05 tuned proofs
huffman
parents: 22960
diff changeset
  1101
apply (simp del: sin_cos_add)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1102
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1103
15085
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15081
diff changeset
  1104
lemma lemma_DERIV_sin_cos_minus:
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15081
diff changeset
  1105
    "\<forall>x. DERIV (%x. (sin(-x) + (sin x)) ^ 2 + (cos(-x) - (cos x)) ^ 2) x :> 0"
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1106
apply (safe, rule lemma_DERIV_subst)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1107
apply (best intro!: DERIV_intros intro: DERIV_chain2) 
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1108
apply (auto simp add: diff_minus left_distrib right_distrib mult_ac add_ac)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1109
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1110
15085
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15081
diff changeset
  1111
lemma sin_cos_minus [simp]: 
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15081
diff changeset
  1112
    "(sin(-x) + (sin x)) ^ 2 + (cos(-x) - (cos x)) ^ 2 = 0"
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15081
diff changeset
  1113
apply (cut_tac y = 0 and x = x 
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15081
diff changeset
  1114
       in lemma_DERIV_sin_cos_minus [THEN DERIV_isconst_all])
22969
bf523cac9a05 tuned proofs
huffman
parents: 22960
diff changeset
  1115
apply simp
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1116
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1117
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1118
lemma sin_minus [simp]: "sin (-x) = -sin(x)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1119
apply (cut_tac x = x in sin_cos_minus)
22969
bf523cac9a05 tuned proofs
huffman
parents: 22960
diff changeset
  1120
apply (simp del: sin_cos_minus)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1121
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1122
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1123
lemma cos_minus [simp]: "cos (-x) = cos(x)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1124
apply (cut_tac x = x in sin_cos_minus)
22969
bf523cac9a05 tuned proofs
huffman
parents: 22960
diff changeset
  1125
apply (simp del: sin_cos_minus)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1126
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1127
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1128
lemma sin_diff: "sin (x - y) = sin x * cos y - cos x * sin y"
22969
bf523cac9a05 tuned proofs
huffman
parents: 22960
diff changeset
  1129
by (simp add: diff_minus sin_add)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1130
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1131
lemma sin_diff2: "sin (x - y) = cos y * sin x - sin y * cos x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1132
by (simp add: sin_diff mult_commute)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1133
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1134
lemma cos_diff: "cos (x - y) = cos x * cos y + sin x * sin y"
22969
bf523cac9a05 tuned proofs
huffman
parents: 22960
diff changeset
  1135
by (simp add: diff_minus cos_add)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1136
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1137
lemma cos_diff2: "cos (x - y) = cos y * cos x + sin y * sin x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1138
by (simp add: cos_diff mult_commute)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1139
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1140
lemma sin_double [simp]: "sin(2 * x) = 2* sin x * cos x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1141
by (cut_tac x = x and y = x in sin_add, auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1142
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1143
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1144
lemma cos_double: "cos(2* x) = ((cos x)\<twosuperior>) - ((sin x)\<twosuperior>)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1145
apply (cut_tac x = x and y = x in cos_add)
22969
bf523cac9a05 tuned proofs
huffman
parents: 22960
diff changeset
  1146
apply (simp add: power2_eq_square)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1147
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1148
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1149
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1150
subsection{*The Constant Pi*}
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1151
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1152
text{*Show that there's a least positive @{term x} with @{term "cos(x) = 0"}; 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1153
   hence define pi.*}
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1154
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1155
lemma sin_paired:
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1156
     "(%n. (- 1) ^ n /(real (fact (2 * n + 1))) * x ^ (2 * n + 1)) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1157
      sums  sin x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1158
proof -
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1159
  have "(\<lambda>n. \<Sum>k = n * 2..<n * 2 + 2.
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1160
            (if even k then 0
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1161
             else (- 1) ^ ((k - Suc 0) div 2) / real (fact k)) *
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1162
            x ^ k) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1163
	sums
15546
5188ce7316b7 suminf -> \<Sum>
nipkow
parents: 15544
diff changeset
  1164
	(\<Sum>n. (if even n then 0
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1165
		     else (- 1) ^ ((n - Suc 0) div 2) / real (fact n)) *
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1166
	            x ^ n)" 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1167
    by (rule sin_converges [THEN sums_summable, THEN sums_group], simp) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1168
  thus ?thesis by (simp add: mult_ac sin_def)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1169
qed
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1170
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1171
lemma sin_gt_zero: "[|0 < x; x < 2 |] ==> 0 < sin x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1172
apply (subgoal_tac 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1173
       "(\<lambda>n. \<Sum>k = n * 2..<n * 2 + 2.
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1174
              (- 1) ^ k / real (fact (2 * k + 1)) * x ^ (2 * k + 1)) 
15546
5188ce7316b7 suminf -> \<Sum>
nipkow
parents: 15544
diff changeset
  1175
     sums (\<Sum>n. (- 1) ^ n / real (fact (2 * n + 1)) * x ^ (2 * n + 1))")
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1176
 prefer 2
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1177
 apply (rule sin_paired [THEN sums_summable, THEN sums_group], simp) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1178
apply (rotate_tac 2)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1179
apply (drule sin_paired [THEN sums_unique, THEN ssubst])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1180
apply (auto simp del: fact_Suc realpow_Suc)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1181
apply (frule sums_unique)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1182
apply (auto simp del: fact_Suc realpow_Suc)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1183
apply (rule_tac n1 = 0 in series_pos_less [THEN [2] order_le_less_trans])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1184
apply (auto simp del: fact_Suc realpow_Suc)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1185
apply (erule sums_summable)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1186
apply (case_tac "m=0")
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1187
apply (simp (no_asm_simp))
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
  1188
apply (subgoal_tac "6 * (x * (x * x) / real (Suc (Suc (Suc (Suc (Suc (Suc 0))))))) < 6 * x") 
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
  1189
apply (simp only: mult_less_cancel_left, simp)  
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
  1190
apply (simp (no_asm_simp) add: numeral_2_eq_2 [symmetric] mult_assoc [symmetric])
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1191
apply (subgoal_tac "x*x < 2*3", simp) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1192
apply (rule mult_strict_mono)
15085
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15081
diff changeset
  1193
apply (auto simp add: real_0_less_add_iff real_of_nat_Suc simp del: fact_Suc)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1194
apply (subst fact_Suc)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1195
apply (subst fact_Suc)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1196
apply (subst fact_Suc)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1197
apply (subst fact_Suc)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1198
apply (subst real_of_nat_mult)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1199
apply (subst real_of_nat_mult)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1200
apply (subst real_of_nat_mult)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1201
apply (subst real_of_nat_mult)
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
  1202
apply (simp (no_asm) add: divide_inverse del: fact_Suc)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1203
apply (auto simp add: mult_assoc [symmetric] simp del: fact_Suc)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1204
apply (rule_tac c="real (Suc (Suc (4*m)))" in mult_less_imp_less_right) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1205
apply (auto simp add: mult_assoc simp del: fact_Suc)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1206
apply (rule_tac c="real (Suc (Suc (Suc (4*m))))" in mult_less_imp_less_right) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1207
apply (auto simp add: mult_assoc mult_less_cancel_left simp del: fact_Suc)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1208
apply (subgoal_tac "x * (x * x ^ (4*m)) = (x ^ (4*m)) * (x * x)") 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1209
apply (erule ssubst)+
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1210
apply (auto simp del: fact_Suc)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1211
apply (subgoal_tac "0 < x ^ (4 * m) ")
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1212
 prefer 2 apply (simp only: zero_less_power) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1213
apply (simp (no_asm_simp) add: mult_less_cancel_left)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1214
apply (rule mult_strict_mono)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1215
apply (simp_all (no_asm_simp))
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1216
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1217
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1218
lemma sin_gt_zero1: "[|0 < x; x < 2 |] ==> 0 < sin x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1219
by (auto intro: sin_gt_zero)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1220
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1221
lemma cos_double_less_one: "[| 0 < x; x < 2 |] ==> cos (2 * x) < 1"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1222
apply (cut_tac x = x in sin_gt_zero1)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1223
apply (auto simp add: cos_squared_eq cos_double)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1224
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1225
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1226
lemma cos_paired:
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1227
     "(%n. (- 1) ^ n /(real (fact (2 * n))) * x ^ (2 * n)) sums cos x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1228
proof -
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1229
  have "(\<lambda>n. \<Sum>k = n * 2..<n * 2 + 2.
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1230
            (if even k then (- 1) ^ (k div 2) / real (fact k) else 0) *
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1231
            x ^ k) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1232
        sums
15546
5188ce7316b7 suminf -> \<Sum>
nipkow
parents: 15544
diff changeset
  1233
	(\<Sum>n. (if even n then (- 1) ^ (n div 2) / real (fact n) else 0) *
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1234
	      x ^ n)" 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1235
    by (rule cos_converges [THEN sums_summable, THEN sums_group], simp) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1236
  thus ?thesis by (simp add: mult_ac cos_def)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1237
qed
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1238
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1239
declare zero_less_power [simp]
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1240
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1241
lemma fact_lemma: "real (n::nat) * 4 = real (4 * n)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1242
by simp
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1243
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1244
lemma cos_two_less_zero: "cos (2) < 0"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1245
apply (cut_tac x = 2 in cos_paired)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1246
apply (drule sums_minus)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1247
apply (rule neg_less_iff_less [THEN iffD1]) 
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
  1248
apply (frule sums_unique, auto)
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
  1249
apply (rule_tac y =
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
  1250
 "\<Sum>n=0..< Suc(Suc(Suc 0)). - ((- 1) ^ n / (real(fact (2*n))) * 2 ^ (2*n))"
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 15383
diff changeset
  1251
       in order_less_trans)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1252
apply (simp (no_asm) add: fact_num_eq_if realpow_num_eq_if del: fact_Suc realpow_Suc)
15561
045a07ac35a7 another reorganization of setsums and intervals
nipkow
parents: 15546
diff changeset
  1253
apply (simp (no_asm) add: mult_assoc del: setsum_op_ivl_Suc)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1254
apply (rule sumr_pos_lt_pair)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1255
apply (erule sums_summable, safe)
15085
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15081
diff changeset
  1256
apply (simp (no_asm) add: divide_inverse real_0_less_add_iff mult_assoc [symmetric] 
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15081
diff changeset
  1257
            del: fact_Suc)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1258
apply (rule real_mult_inverse_cancel2)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1259
apply (rule real_of_nat_fact_gt_zero)+
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1260
apply (simp (no_asm) add: mult_assoc [symmetric] del: fact_Suc)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1261
apply (subst fact_lemma) 
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 15383
diff changeset
  1262
apply (subst fact_Suc [of "Suc (Suc (Suc (Suc (Suc (Suc (Suc (4 * d)))))))"])
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 15383
diff changeset
  1263
apply (simp only: real_of_nat_mult)
23007
e025695d9b0e use mult_strict_mono instead of real_mult_less_mono
huffman
parents: 22998
diff changeset
  1264
apply (rule mult_strict_mono, force)
e025695d9b0e use mult_strict_mono instead of real_mult_less_mono
huffman
parents: 22998
diff changeset
  1265
  apply (rule_tac [3] real_of_nat_fact_ge_zero)
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 15383
diff changeset
  1266
 prefer 2 apply force
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1267
apply (rule real_of_nat_less_iff [THEN iffD2])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1268
apply (rule fact_less_mono, auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1269
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1270
declare cos_two_less_zero [simp]
22998
97e1f9c2cc46 avoid using redundant lemmas from RealDef.thy
huffman
parents: 22978
diff changeset
  1271
declare cos_two_less_zero [THEN less_imp_neq, simp]
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1272
declare cos_two_less_zero [THEN order_less_imp_le, simp]
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1273
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1274
lemma cos_is_zero: "EX! x. 0 \<le> x & x \<le> 2 & cos x = 0"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1275
apply (subgoal_tac "\<exists>x. 0 \<le> x & x \<le> 2 & cos x = 0")
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1276
apply (rule_tac [2] IVT2)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1277
apply (auto intro: DERIV_isCont DERIV_cos)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1278
apply (cut_tac x = xa and y = y in linorder_less_linear)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1279
apply (rule ccontr)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1280
apply (subgoal_tac " (\<forall>x. cos differentiable x) & (\<forall>x. isCont cos x) ")
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1281
apply (auto intro: DERIV_cos DERIV_isCont simp add: differentiable_def)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1282
apply (drule_tac f = cos in Rolle)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1283
apply (drule_tac [5] f = cos in Rolle)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1284
apply (auto dest!: DERIV_cos [THEN DERIV_unique] simp add: differentiable_def)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1285
apply (drule_tac y1 = xa in order_le_less_trans [THEN sin_gt_zero])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1286
apply (assumption, rule_tac y=y in order_less_le_trans, simp_all) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1287
apply (drule_tac y1 = y in order_le_less_trans [THEN sin_gt_zero], assumption, simp_all) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1288
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1289
    
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1290
lemma pi_half: "pi/2 = (@x. 0 \<le> x & x \<le> 2 & cos x = 0)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1291
by (simp add: pi_def)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1292
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1293
lemma cos_pi_half [simp]: "cos (pi / 2) = 0"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1294
apply (rule cos_is_zero [THEN ex1E])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1295
apply (auto intro!: someI2 simp add: pi_half)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1296
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1297
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1298
lemma pi_half_gt_zero: "0 < pi / 2"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1299
apply (rule cos_is_zero [THEN ex1E])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1300
apply (auto simp add: pi_half)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1301
apply (rule someI2, blast, safe)
22998
97e1f9c2cc46 avoid using redundant lemmas from RealDef.thy
huffman
parents: 22978
diff changeset
  1302
apply (drule_tac y = xa in order_le_imp_less_or_eq)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1303
apply (safe, simp)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1304
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1305
declare pi_half_gt_zero [simp]
22998
97e1f9c2cc46 avoid using redundant lemmas from RealDef.thy
huffman
parents: 22978
diff changeset
  1306
declare pi_half_gt_zero [THEN less_imp_neq, THEN not_sym, simp]
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1307
declare pi_half_gt_zero [THEN order_less_imp_le, simp]
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1308
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1309
lemma pi_half_less_two: "pi / 2 < 2"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1310
apply (rule cos_is_zero [THEN ex1E])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1311
apply (auto simp add: pi_half)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1312
apply (rule someI2, blast, safe)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1313
apply (drule_tac x = xa in order_le_imp_less_or_eq)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1314
apply (safe, simp)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1315
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1316
declare pi_half_less_two [simp]
22998
97e1f9c2cc46 avoid using redundant lemmas from RealDef.thy
huffman
parents: 22978
diff changeset
  1317
declare pi_half_less_two [THEN less_imp_neq, simp]
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1318
declare pi_half_less_two [THEN order_less_imp_le, simp]
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1319
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1320
lemma pi_gt_zero [simp]: "0 < pi"
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1321
apply (insert pi_half_gt_zero) 
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1322
apply (simp add: ); 
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1323
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1324
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1325
lemma pi_neq_zero [simp]: "pi \<noteq> 0"
22998
97e1f9c2cc46 avoid using redundant lemmas from RealDef.thy
huffman
parents: 22978
diff changeset
  1326
by (rule pi_gt_zero [THEN less_imp_neq, THEN not_sym])
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1327
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1328
lemma pi_not_less_zero [simp]: "~ (pi < 0)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1329
apply (insert pi_gt_zero)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1330
apply (blast elim: order_less_asym) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1331
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1332
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1333
lemma pi_ge_zero [simp]: "0 \<le> pi"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1334
by (auto intro: order_less_imp_le)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1335
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1336
lemma minus_pi_half_less_zero [simp]: "-(pi/2) < 0"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1337
by auto
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1338
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1339
lemma sin_pi_half [simp]: "sin(pi/2) = 1"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1340
apply (cut_tac x = "pi/2" in sin_cos_squared_add2)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1341
apply (cut_tac sin_gt_zero [OF pi_half_gt_zero pi_half_less_two])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1342
apply (auto simp add: numeral_2_eq_2)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1343
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1344
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1345
lemma cos_pi [simp]: "cos pi = -1"
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
  1346
by (cut_tac x = "pi/2" and y = "pi/2" in cos_add, simp)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1347
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1348
lemma sin_pi [simp]: "sin pi = 0"
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
  1349
by (cut_tac x = "pi/2" and y = "pi/2" in sin_add, simp)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1350
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1351
lemma sin_cos_eq: "sin x = cos (pi/2 - x)"
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1352
by (simp add: diff_minus cos_add)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1353
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1354
lemma minus_sin_cos_eq: "-sin x = cos (x + pi/2)"
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1355
by (simp add: cos_add)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1356
declare minus_sin_cos_eq [symmetric, simp]
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1357
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1358
lemma cos_sin_eq: "cos x = sin (pi/2 - x)"
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1359
by (simp add: diff_minus sin_add)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1360
declare sin_cos_eq [symmetric, simp] cos_sin_eq [symmetric, simp]
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1361
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1362
lemma sin_periodic_pi [simp]: "sin (x + pi) = - sin x"
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1363
by (simp add: sin_add)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1364
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1365
lemma sin_periodic_pi2 [simp]: "sin (pi + x) = - sin x"
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1366
by (simp add: sin_add)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1367
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1368
lemma cos_periodic_pi [simp]: "cos (x + pi) = - cos x"
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1369
by (simp add: cos_add)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1370
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1371
lemma sin_periodic [simp]: "sin (x + 2*pi) = sin x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1372
by (simp add: sin_add cos_double)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1373
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1374
lemma cos_periodic [simp]: "cos (x + 2*pi) = cos x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1375
by (simp add: cos_add cos_double)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1376
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1377
lemma cos_npi [simp]: "cos (real n * pi) = -1 ^ n"
15251
bb6f072c8d10 converted some induct_tac to induct
paulson
parents: 15241
diff changeset
  1378
apply (induct "n")
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1379
apply (auto simp add: real_of_nat_Suc left_distrib)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1380
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1381
15383
c49e4225ef4f made proofs more robust
paulson
parents: 15251
diff changeset
  1382
lemma cos_npi2 [simp]: "cos (pi * real n) = -1 ^ n"
c49e4225ef4f made proofs more robust
paulson
parents: 15251
diff changeset
  1383
proof -
c49e4225ef4f made proofs more robust
paulson
parents: 15251
diff changeset
  1384
  have "cos (pi * real n) = cos (real n * pi)" by (simp only: mult_commute)
c49e4225ef4f made proofs more robust
paulson
parents: 15251
diff changeset
  1385
  also have "... = -1 ^ n" by (rule cos_npi) 
c49e4225ef4f made proofs more robust
paulson
parents: 15251
diff changeset
  1386
  finally show ?thesis .
c49e4225ef4f made proofs more robust
paulson
parents: 15251
diff changeset
  1387
qed
c49e4225ef4f made proofs more robust
paulson
parents: 15251
diff changeset
  1388
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1389
lemma sin_npi [simp]: "sin (real (n::nat) * pi) = 0"
15251
bb6f072c8d10 converted some induct_tac to induct
paulson
parents: 15241
diff changeset
  1390
apply (induct "n")
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1391
apply (auto simp add: real_of_nat_Suc left_distrib)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1392
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1393
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1394
lemma sin_npi2 [simp]: "sin (pi * real (n::nat)) = 0"
15383
c49e4225ef4f made proofs more robust
paulson
parents: 15251
diff changeset
  1395
by (simp add: mult_commute [of pi]) 
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1396
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1397
lemma cos_two_pi [simp]: "cos (2 * pi) = 1"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1398
by (simp add: cos_double)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1399
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1400
lemma sin_two_pi [simp]: "sin (2 * pi) = 0"
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1401
by simp
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1402
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1403
lemma sin_gt_zero2: "[| 0 < x; x < pi/2 |] ==> 0 < sin x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1404
apply (rule sin_gt_zero, assumption)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1405
apply (rule order_less_trans, assumption)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1406
apply (rule pi_half_less_two)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1407
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1408
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1409
lemma sin_less_zero: 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1410
  assumes lb: "- pi/2 < x" and "x < 0" shows "sin x < 0"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1411
proof -
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1412
  have "0 < sin (- x)" using prems by (simp only: sin_gt_zero2) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1413
  thus ?thesis by simp
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1414
qed
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1415
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1416
lemma pi_less_4: "pi < 4"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1417
by (cut_tac pi_half_less_two, auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1418
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1419
lemma cos_gt_zero: "[| 0 < x; x < pi/2 |] ==> 0 < cos x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1420
apply (cut_tac pi_less_4)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1421
apply (cut_tac f = cos and a = 0 and b = x and y = 0 in IVT2_objl, safe, simp_all)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1422
apply (force intro: DERIV_isCont DERIV_cos)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1423
apply (cut_tac cos_is_zero, safe)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1424
apply (rename_tac y z)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1425
apply (drule_tac x = y in spec)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1426
apply (drule_tac x = "pi/2" in spec, simp) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1427
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1428
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1429
lemma cos_gt_zero_pi: "[| -(pi/2) < x; x < pi/2 |] ==> 0 < cos x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1430
apply (rule_tac x = x and y = 0 in linorder_cases)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1431
apply (rule cos_minus [THEN subst])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1432
apply (rule cos_gt_zero)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1433
apply (auto intro: cos_gt_zero)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1434
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1435
 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1436
lemma cos_ge_zero: "[| -(pi/2) \<le> x; x \<le> pi/2 |] ==> 0 \<le> cos x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1437
apply (auto simp add: order_le_less cos_gt_zero_pi)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1438
apply (subgoal_tac "x = pi/2", auto) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1439
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1440
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1441
lemma sin_gt_zero_pi: "[| 0 < x; x < pi  |] ==> 0 < sin x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1442
apply (subst sin_cos_eq)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1443
apply (rotate_tac 1)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1444
apply (drule real_sum_of_halves [THEN ssubst])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1445
apply (auto intro!: cos_gt_zero_pi simp del: sin_cos_eq [symmetric])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1446
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1447
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1448
lemma sin_ge_zero: "[| 0 \<le> x; x \<le> pi |] ==> 0 \<le> sin x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1449
by (auto simp add: order_le_less sin_gt_zero_pi)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1450
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1451
lemma cos_total: "[| -1 \<le> y; y \<le> 1 |] ==> EX! x. 0 \<le> x & x \<le> pi & (cos x = y)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1452
apply (subgoal_tac "\<exists>x. 0 \<le> x & x \<le> pi & cos x = y")
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1453
apply (rule_tac [2] IVT2)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1454
apply (auto intro: order_less_imp_le DERIV_isCont DERIV_cos)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1455
apply (cut_tac x = xa and y = y in linorder_less_linear)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1456
apply (rule ccontr, auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1457
apply (drule_tac f = cos in Rolle)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1458
apply (drule_tac [5] f = cos in Rolle)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1459
apply (auto intro: order_less_imp_le DERIV_isCont DERIV_cos
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1460
            dest!: DERIV_cos [THEN DERIV_unique] 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1461
            simp add: differentiable_def)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1462
apply (auto dest: sin_gt_zero_pi [OF order_le_less_trans order_less_le_trans])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1463
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1464
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1465
lemma sin_total:
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1466
     "[| -1 \<le> y; y \<le> 1 |] ==> EX! x. -(pi/2) \<le> x & x \<le> pi/2 & (sin x = y)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1467
apply (rule ccontr)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1468
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))")
18585
5d379fe2eb74 replaced swap by contrapos_np;
wenzelm
parents: 17318
diff changeset
  1469
apply (erule contrapos_np)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1470
apply (simp del: minus_sin_cos_eq [symmetric])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1471
apply (cut_tac y="-y" in cos_total, simp) apply simp 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1472
apply (erule ex1E)
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1473
apply (rule_tac a = "x - (pi/2)" in ex1I)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1474
apply (simp (no_asm) add: real_add_assoc)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1475
apply (rotate_tac 3)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1476
apply (drule_tac x = "xa + pi/2" in spec, safe, simp_all) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1477
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1478
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1479
lemma reals_Archimedean4:
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1480
     "[| 0 < y; 0 \<le> x |] ==> \<exists>n. real n * y \<le> x & x < real (Suc n) * y"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1481
apply (auto dest!: reals_Archimedean3)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1482
apply (drule_tac x = x in spec, clarify) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1483
apply (subgoal_tac "x < real(LEAST m::nat. x < real m * y) * y")
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1484
 prefer 2 apply (erule LeastI) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1485
apply (case_tac "LEAST m::nat. x < real m * y", simp) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1486
apply (subgoal_tac "~ x < real nat * y")
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1487
 prefer 2 apply (rule not_less_Least, simp, force)  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1488
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1489
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1490
(* Pre Isabelle99-2 proof was simpler- numerals arithmetic 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1491
   now causes some unwanted re-arrangements of literals!   *)
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1492
lemma cos_zero_lemma:
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1493
     "[| 0 \<le> x; cos x = 0 |] ==>  
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1494
      \<exists>n::nat. ~even n & x = real n * (pi/2)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1495
apply (drule pi_gt_zero [THEN reals_Archimedean4], safe)
15086
e6a2a98d5ef5 removal of more iff-rules from RealDef.thy
paulson
parents: 15085
diff changeset
  1496
apply (subgoal_tac "0 \<le> x - real n * pi & 
e6a2a98d5ef5 removal of more iff-rules from RealDef.thy
paulson
parents: 15085
diff changeset
  1497
                    (x - real n * pi) \<le> pi & (cos (x - real n * pi) = 0) ")
e6a2a98d5ef5 removal of more iff-rules from RealDef.thy
paulson
parents: 15085
diff changeset
  1498
apply (auto simp add: compare_rls) 
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1499
  prefer 3 apply (simp add: cos_diff) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1500
 prefer 2 apply (simp add: real_of_nat_Suc left_distrib) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1501
apply (simp add: cos_diff)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1502
apply (subgoal_tac "EX! x. 0 \<le> x & x \<le> pi & cos x = 0")
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1503
apply (rule_tac [2] cos_total, safe)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1504
apply (drule_tac x = "x - real n * pi" in spec)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1505
apply (drule_tac x = "pi/2" in spec)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1506
apply (simp add: cos_diff)
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1507
apply (rule_tac x = "Suc (2 * n)" in exI)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1508
apply (simp add: real_of_nat_Suc left_distrib, auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1509
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1510
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1511
lemma sin_zero_lemma:
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1512
     "[| 0 \<le> x; sin x = 0 |] ==>  
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1513
      \<exists>n::nat. even n & x = real n * (pi/2)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1514
apply (subgoal_tac "\<exists>n::nat. ~ even n & x + pi/2 = real n * (pi/2) ")
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1515
 apply (clarify, rule_tac x = "n - 1" in exI)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1516
 apply (force simp add: odd_Suc_mult_two_ex real_of_nat_Suc left_distrib)
15085
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15081
diff changeset
  1517
apply (rule cos_zero_lemma)
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15081
diff changeset
  1518
apply (simp_all add: add_increasing)  
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1519
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1520
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1521
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1522
lemma cos_zero_iff:
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1523
     "(cos x = 0) =  
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1524
      ((\<exists>n::nat. ~even n & (x = real n * (pi/2))) |    
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1525
       (\<exists>n::nat. ~even n & (x = -(real n * (pi/2)))))"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1526
apply (rule iffI)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1527
apply (cut_tac linorder_linear [of 0 x], safe)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1528
apply (drule cos_zero_lemma, assumption+)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1529
apply (cut_tac x="-x" in cos_zero_lemma, simp, simp) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1530
apply (force simp add: minus_equation_iff [of x]) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1531
apply (auto simp only: odd_Suc_mult_two_ex real_of_nat_Suc left_distrib) 
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
  1532
apply (auto simp add: cos_add)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1533
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1534
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1535
(* ditto: but to a lesser extent *)
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1536
lemma sin_zero_iff:
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1537
     "(sin x = 0) =  
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1538
      ((\<exists>n::nat. even n & (x = real n * (pi/2))) |    
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1539
       (\<exists>n::nat. even n & (x = -(real n * (pi/2)))))"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1540
apply (rule iffI)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1541
apply (cut_tac linorder_linear [of 0 x], safe)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1542
apply (drule sin_zero_lemma, assumption+)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1543
apply (cut_tac x="-x" in sin_zero_lemma, simp, simp, safe)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1544
apply (force simp add: minus_equation_iff [of x]) 
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
  1545
apply (auto simp add: even_mult_two_ex)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1546
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1547
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1548
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1549
subsection{*Tangent*}
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1550
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1551
lemma tan_zero [simp]: "tan 0 = 0"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1552
by (simp add: tan_def)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1553
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1554
lemma tan_pi [simp]: "tan pi = 0"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1555
by (simp add: tan_def)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1556
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1557
lemma tan_npi [simp]: "tan (real (n::nat) * pi) = 0"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1558
by (simp add: tan_def)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1559
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1560
lemma tan_minus [simp]: "tan (-x) = - tan x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1561
by (simp add: tan_def minus_mult_left)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1562
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1563
lemma tan_periodic [simp]: "tan (x + 2*pi) = tan x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1564
by (simp add: tan_def)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1565
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1566
lemma lemma_tan_add1: 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1567
      "[| cos x \<noteq> 0; cos y \<noteq> 0 |]  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1568
        ==> 1 - tan(x)*tan(y) = cos (x + y)/(cos x * cos y)"
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1569
apply (simp add: tan_def divide_inverse)
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1570
apply (auto simp del: inverse_mult_distrib 
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1571
            simp add: inverse_mult_distrib [symmetric] mult_ac)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1572
apply (rule_tac c1 = "cos x * cos y" in real_mult_right_cancel [THEN subst])
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1573
apply (auto simp del: inverse_mult_distrib 
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1574
            simp add: mult_assoc left_diff_distrib cos_add)
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15229
diff changeset
  1575
done  
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1576
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1577
lemma add_tan_eq: 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1578
      "[| cos x \<noteq> 0; cos y \<noteq> 0 |]  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1579
       ==> tan x + tan y = sin(x + y)/(cos x * cos y)"
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1580
apply (simp add: tan_def)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1581
apply (rule_tac c1 = "cos x * cos y" in real_mult_right_cancel [THEN subst])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1582
apply (auto simp add: mult_assoc left_distrib)
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
  1583
apply (simp add: sin_add)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1584
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1585
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1586
lemma tan_add:
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1587
     "[| cos x \<noteq> 0; cos y \<noteq> 0; cos (x + y) \<noteq> 0 |]  
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1588
      ==> tan(x + y) = (tan(x) + tan(y))/(1 - tan(x) * tan(y))"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1589
apply (simp (no_asm_simp) add: add_tan_eq lemma_tan_add1)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1590
apply (simp add: tan_def)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1591
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1592
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1593
lemma tan_double:
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1594
     "[| cos x \<noteq> 0; cos (2 * x) \<noteq> 0 |]  
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1595
      ==> tan (2 * x) = (2 * tan x)/(1 - (tan(x) ^ 2))"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1596
apply (insert tan_add [of x x]) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1597
apply (simp add: mult_2 [symmetric])  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1598
apply (auto simp add: numeral_2_eq_2)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1599
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1600
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1601
lemma tan_gt_zero: "[| 0 < x; x < pi/2 |] ==> 0 < tan x"
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1602
by (simp add: tan_def zero_less_divide_iff sin_gt_zero2 cos_gt_zero_pi) 
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1603
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1604
lemma tan_less_zero: 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1605
  assumes lb: "- pi/2 < x" and "x < 0" shows "tan x < 0"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1606
proof -
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1607
  have "0 < tan (- x)" using prems by (simp only: tan_gt_zero) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1608
  thus ?thesis by simp
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1609
qed
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1610
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1611
lemma lemma_DERIV_tan:
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1612
     "cos x \<noteq> 0 ==> DERIV (%x. sin(x)/cos(x)) x :> inverse((cos x)\<twosuperior>)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1613
apply (rule lemma_DERIV_subst)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1614
apply (best intro!: DERIV_intros intro: DERIV_chain2) 
15079
2ef899e4526d conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents: 15077
diff changeset
  1615
apply (auto simp add: divide_inverse numeral_2_eq_2)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1616
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1617
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1618
lemma DERIV_tan [simp]: "cos x \<noteq> 0 ==> DERIV tan x :> inverse((cos x)\<twosuperior>)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1619
by (auto dest: lemma_DERIV_tan simp add: tan_def [symmetric])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1620
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1621
lemma LIM_cos_div_sin [simp]: "(%x. cos(x)/sin(x)) -- pi/2 --> 0"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1622
apply (subgoal_tac "(\<lambda>x. cos x * inverse (sin x)) -- pi * inverse 2 --> 0*1")
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1623
apply (simp add: divide_inverse [symmetric])
22613
2f119f54d150 remove redundant lemmas
huffman
parents: 21404
diff changeset
  1624
apply (rule LIM_mult)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1625
apply (rule_tac [2] inverse_1 [THEN subst])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1626
apply (rule_tac [2] LIM_inverse)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1627
apply (simp_all add: divide_inverse [symmetric]) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1628
apply (simp_all only: isCont_def [symmetric] cos_pi_half [symmetric] sin_pi_half [symmetric]) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1629
apply (blast intro!: DERIV_isCont DERIV_sin DERIV_cos)+
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1630
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1631
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1632
lemma lemma_tan_total: "0 < y ==> \<exists>x. 0 < x & x < pi/2 & y < tan x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1633
apply (cut_tac LIM_cos_div_sin)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1634
apply (simp only: LIM_def)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1635
apply (drule_tac x = "inverse y" in spec, safe, force)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1636
apply (drule_tac ?d1.0 = s in pi_half_gt_zero [THEN [2] real_lbound_gt_zero], safe)
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1637
apply (rule_tac x = "(pi/2) - e" in exI)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1638
apply (simp (no_asm_simp))
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1639
apply (drule_tac x = "(pi/2) - e" in spec)
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1640
apply (auto simp add: tan_def)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1641
apply (rule inverse_less_iff_less [THEN iffD1])
15079
2ef899e4526d conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents: 15077
diff changeset
  1642
apply (auto simp add: divide_inverse)
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1643
apply (rule real_mult_order) 
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1644
apply (subgoal_tac [3] "0 < sin e & 0 < cos e")
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1645
apply (auto intro: cos_gt_zero sin_gt_zero2 simp add: mult_commute) 
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1646
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1647
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1648
lemma tan_total_pos: "0 \<le> y ==> \<exists>x. 0 \<le> x & x < pi/2 & tan x = y"
22998
97e1f9c2cc46 avoid using redundant lemmas from RealDef.thy
huffman
parents: 22978
diff changeset
  1649
apply (frule order_le_imp_less_or_eq, safe)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1650
 prefer 2 apply force
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1651
apply (drule lemma_tan_total, safe)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1652
apply (cut_tac f = tan and a = 0 and b = x and y = y in IVT_objl)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1653
apply (auto intro!: DERIV_tan [THEN DERIV_isCont])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1654
apply (drule_tac y = xa in order_le_imp_less_or_eq)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1655
apply (auto dest: cos_gt_zero)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1656
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1657
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1658
lemma lemma_tan_total1: "\<exists>x. -(pi/2) < x & x < (pi/2) & tan x = y"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1659
apply (cut_tac linorder_linear [of 0 y], safe)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1660
apply (drule tan_total_pos)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1661
apply (cut_tac [2] y="-y" in tan_total_pos, safe)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1662
apply (rule_tac [3] x = "-x" in exI)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1663
apply (auto intro!: exI)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1664
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1665
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1666
lemma tan_total: "EX! x. -(pi/2) < x & x < (pi/2) & tan x = y"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1667
apply (cut_tac y = y in lemma_tan_total1, auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1668
apply (cut_tac x = xa and y = y in linorder_less_linear, auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1669
apply (subgoal_tac [2] "\<exists>z. y < z & z < xa & DERIV tan z :> 0")
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1670
apply (subgoal_tac "\<exists>z. xa < z & z < y & DERIV tan z :> 0")
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1671
apply (rule_tac [4] Rolle)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1672
apply (rule_tac [2] Rolle)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1673
apply (auto intro!: DERIV_tan DERIV_isCont exI 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1674
            simp add: differentiable_def)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1675
txt{*Now, simulate TRYALL*}
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1676
apply (rule_tac [!] DERIV_tan asm_rl)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1677
apply (auto dest!: DERIV_unique [OF _ DERIV_tan]
22998
97e1f9c2cc46 avoid using redundant lemmas from RealDef.thy
huffman
parents: 22978
diff changeset
  1678
	    simp add: cos_gt_zero_pi [THEN less_imp_neq, THEN not_sym]) 
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1679
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1680
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1681
lemma arcsin_pi:
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1682
     "[| -1 \<le> y; y \<le> 1 |]  
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1683
      ==> -(pi/2) \<le> arcsin y & arcsin y \<le> pi & sin(arcsin y) = y"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1684
apply (drule sin_total, assumption)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1685
apply (erule ex1E)
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1686
apply (simp add: arcsin_def)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1687
apply (rule someI2, blast) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1688
apply (force intro: order_trans) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1689
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1690
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1691
lemma arcsin:
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1692
     "[| -1 \<le> y; y \<le> 1 |]  
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1693
      ==> -(pi/2) \<le> arcsin y &  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1694
           arcsin y \<le> pi/2 & sin(arcsin y) = y"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1695
apply (unfold arcsin_def)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1696
apply (drule sin_total, assumption)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1697
apply (fast intro: someI2)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1698
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1699
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1700
lemma sin_arcsin [simp]: "[| -1 \<le> y; y \<le> 1 |] ==> sin(arcsin y) = y"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1701
by (blast dest: arcsin)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1702
      
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1703
lemma arcsin_bounded:
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1704
     "[| -1 \<le> y; y \<le> 1 |] ==> -(pi/2) \<le> arcsin y & arcsin y \<le> pi/2"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1705
by (blast dest: arcsin)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1706
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1707
lemma arcsin_lbound: "[| -1 \<le> y; y \<le> 1 |] ==> -(pi/2) \<le> arcsin y"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1708
by (blast dest: arcsin)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1709
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1710
lemma arcsin_ubound: "[| -1 \<le> y; y \<le> 1 |] ==> arcsin y \<le> pi/2"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1711
by (blast dest: arcsin)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1712
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1713
lemma arcsin_lt_bounded:
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1714
     "[| -1 < y; y < 1 |] ==> -(pi/2) < arcsin y & arcsin y < pi/2"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1715
apply (frule order_less_imp_le)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1716
apply (frule_tac y = y in order_less_imp_le)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1717
apply (frule arcsin_bounded)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1718
apply (safe, simp)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1719
apply (drule_tac y = "arcsin y" in order_le_imp_less_or_eq)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1720
apply (drule_tac [2] y = "pi/2" in order_le_imp_less_or_eq, safe)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1721
apply (drule_tac [!] f = sin in arg_cong, auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1722
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1723
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1724
lemma arcsin_sin: "[|-(pi/2) \<le> x; x \<le> pi/2 |] ==> arcsin(sin x) = x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1725
apply (unfold arcsin_def)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1726
apply (rule some1_equality)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1727
apply (rule sin_total, auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1728
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1729
22975
03085c441c14 spelling: rename arcos -> arccos
huffman
parents: 22969
diff changeset
  1730
lemma arccos:
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1731
     "[| -1 \<le> y; y \<le> 1 |]  
22975
03085c441c14 spelling: rename arcos -> arccos
huffman
parents: 22969
diff changeset
  1732
      ==> 0 \<le> arccos y & arccos y \<le> pi & cos(arccos y) = y"
03085c441c14 spelling: rename arcos -> arccos
huffman
parents: 22969
diff changeset
  1733
apply (simp add: arccos_def)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1734
apply (drule cos_total, assumption)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1735
apply (fast intro: someI2)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1736
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1737
22975
03085c441c14 spelling: rename arcos -> arccos
huffman
parents: 22969
diff changeset
  1738
lemma cos_arccos [simp]: "[| -1 \<le> y; y \<le> 1 |] ==> cos(arccos y) = y"
03085c441c14 spelling: rename arcos -> arccos
huffman
parents: 22969
diff changeset
  1739
by (blast dest: arccos)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1740
      
22975
03085c441c14 spelling: rename arcos -> arccos
huffman
parents: 22969
diff changeset
  1741
lemma arccos_bounded: "[| -1 \<le> y; y \<le> 1 |] ==> 0 \<le> arccos y & arccos y \<le> pi"
03085c441c14 spelling: rename arcos -> arccos
huffman
parents: 22969
diff changeset
  1742
by (blast dest: arccos)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1743
22975
03085c441c14 spelling: rename arcos -> arccos
huffman
parents: 22969
diff changeset
  1744
lemma arccos_lbound: "[| -1 \<le> y; y \<le> 1 |] ==> 0 \<le> arccos y"
03085c441c14 spelling: rename arcos -> arccos
huffman
parents: 22969
diff changeset
  1745
by (blast dest: arccos)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1746
22975
03085c441c14 spelling: rename arcos -> arccos
huffman
parents: 22969
diff changeset
  1747
lemma arccos_ubound: "[| -1 \<le> y; y \<le> 1 |] ==> arccos y \<le> pi"
03085c441c14 spelling: rename arcos -> arccos
huffman
parents: 22969
diff changeset
  1748
by (blast dest: arccos)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1749
22975
03085c441c14 spelling: rename arcos -> arccos
huffman
parents: 22969
diff changeset
  1750
lemma arccos_lt_bounded:
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1751
     "[| -1 < y; y < 1 |]  
22975
03085c441c14 spelling: rename arcos -> arccos
huffman
parents: 22969
diff changeset
  1752
      ==> 0 < arccos y & arccos y < pi"
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1753
apply (frule order_less_imp_le)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1754
apply (frule_tac y = y in order_less_imp_le)
22975
03085c441c14 spelling: rename arcos -> arccos
huffman
parents: 22969
diff changeset
  1755
apply (frule arccos_bounded, auto)
03085c441c14 spelling: rename arcos -> arccos
huffman
parents: 22969
diff changeset
  1756
apply (drule_tac y = "arccos y" in order_le_imp_less_or_eq)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1757
apply (drule_tac [2] y = pi in order_le_imp_less_or_eq, auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1758
apply (drule_tac [!] f = cos in arg_cong, auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1759
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1760
22975
03085c441c14 spelling: rename arcos -> arccos
huffman
parents: 22969
diff changeset
  1761
lemma arccos_cos: "[|0 \<le> x; x \<le> pi |] ==> arccos(cos x) = x"
03085c441c14 spelling: rename arcos -> arccos
huffman
parents: 22969
diff changeset
  1762
apply (simp add: arccos_def)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1763
apply (auto intro!: some1_equality cos_total)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1764
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1765
22975
03085c441c14 spelling: rename arcos -> arccos
huffman
parents: 22969
diff changeset
  1766
lemma arccos_cos2: "[|x \<le> 0; -pi \<le> x |] ==> arccos(cos x) = -x"
03085c441c14 spelling: rename arcos -> arccos
huffman
parents: 22969
diff changeset
  1767
apply (simp add: arccos_def)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1768
apply (auto intro!: some1_equality cos_total)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1769
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1770
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1771
lemma arctan [simp]:
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1772
     "- (pi/2) < arctan y  & arctan y < pi/2 & tan (arctan y) = y"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1773
apply (cut_tac y = y in tan_total)
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1774
apply (simp add: arctan_def)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1775
apply (fast intro: someI2)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1776
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1777
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1778
lemma tan_arctan: "tan(arctan y) = y"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1779
by auto
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1780
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1781
lemma arctan_bounded: "- (pi/2) < arctan y  & arctan y < pi/2"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1782
by (auto simp only: arctan)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1783
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1784
lemma arctan_lbound: "- (pi/2) < arctan y"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1785
by auto
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1786
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1787
lemma arctan_ubound: "arctan y < pi/2"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1788
by (auto simp only: arctan)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1789
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1790
lemma arctan_tan: 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1791
      "[|-(pi/2) < x; x < pi/2 |] ==> arctan(tan x) = x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1792
apply (unfold arctan_def)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1793
apply (rule some1_equality)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1794
apply (rule tan_total, auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1795
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1796
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1797
lemma arctan_zero_zero [simp]: "arctan 0 = 0"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1798
by (insert arctan_tan [of 0], simp)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1799
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1800
lemma cos_arctan_not_zero [simp]: "cos(arctan x) \<noteq> 0"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1801
apply (auto simp add: cos_zero_iff)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1802
apply (case_tac "n")
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1803
apply (case_tac [3] "n")
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1804
apply (cut_tac [2] y = x in arctan_ubound)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1805
apply (cut_tac [4] y = x in arctan_lbound) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1806
apply (auto simp add: real_of_nat_Suc left_distrib mult_less_0_iff)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1807
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1808
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1809
lemma tan_sec: "cos x \<noteq> 0 ==> 1 + tan(x) ^ 2 = inverse(cos x) ^ 2"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1810
apply (rule power_inverse [THEN subst])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1811
apply (rule_tac c1 = "(cos x)\<twosuperior>" in real_mult_right_cancel [THEN iffD1])
22960
114cf1906681 remove redundant lemmas
huffman
parents: 22956
diff changeset
  1812
apply (auto dest: field_power_not_zero
20516
2d2e1d323a05 realpow_divide -> power_divide
huffman
parents: 20432
diff changeset
  1813
        simp add: power_mult_distrib left_distrib power_divide tan_def 
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1814
                  mult_assoc power_inverse [symmetric] 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1815
        simp del: realpow_Suc)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1816
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1817
15085
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15081
diff changeset
  1818
text{*NEEDED??*}
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1819
lemma [simp]:
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1820
     "sin (x + 1 / 2 * real (Suc m) * pi) =  
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1821
      cos (x + 1 / 2 * real  (m) * pi)"
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1822
by (simp only: cos_add sin_add real_of_nat_Suc left_distrib right_distrib, auto)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1823
15085
5693a977a767 removed some [iff] declarations from RealDef.thy, concerning inequalities
paulson
parents: 15081
diff changeset
  1824
text{*NEEDED??*}
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1825
lemma [simp]:
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1826
     "sin (x + real (Suc m) * pi / 2) =  
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1827
      cos (x + real (m) * pi / 2)"
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1828
by (simp only: cos_add sin_add real_of_nat_Suc add_divide_distrib left_distrib, auto)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1829
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1830
lemma DERIV_sin_add [simp]: "DERIV (%x. sin (x + k)) xa :> cos (xa + k)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1831
apply (rule lemma_DERIV_subst)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1832
apply (rule_tac f = sin and g = "%x. x + k" in DERIV_chain2)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1833
apply (best intro!: DERIV_intros intro: DERIV_chain2)+
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1834
apply (simp (no_asm))
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1835
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1836
15383
c49e4225ef4f made proofs more robust
paulson
parents: 15251
diff changeset
  1837
lemma sin_cos_npi [simp]: "sin (real (Suc (2 * n)) * pi / 2) = (-1) ^ n"
c49e4225ef4f made proofs more robust
paulson
parents: 15251
diff changeset
  1838
proof -
c49e4225ef4f made proofs more robust
paulson
parents: 15251
diff changeset
  1839
  have "sin ((real n + 1/2) * pi) = cos (real n * pi)"
c49e4225ef4f made proofs more robust
paulson
parents: 15251
diff changeset
  1840
    by (auto simp add: right_distrib sin_add left_distrib mult_ac)
c49e4225ef4f made proofs more robust
paulson
parents: 15251
diff changeset
  1841
  thus ?thesis
c49e4225ef4f made proofs more robust
paulson
parents: 15251
diff changeset
  1842
    by (simp add: real_of_nat_Suc left_distrib add_divide_distrib 
c49e4225ef4f made proofs more robust
paulson
parents: 15251
diff changeset
  1843
                  mult_commute [of pi])
c49e4225ef4f made proofs more robust
paulson
parents: 15251
diff changeset
  1844
qed
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1845
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1846
lemma cos_2npi [simp]: "cos (2 * real (n::nat) * pi) = 1"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1847
by (simp add: cos_double mult_assoc power_add [symmetric] numeral_2_eq_2)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1848
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1849
lemma cos_3over2_pi [simp]: "cos (3 / 2 * pi) = 0"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1850
apply (subgoal_tac "3/2 = (1+1 / 2::real)")
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1851
apply (simp only: left_distrib) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1852
apply (auto simp add: cos_add mult_ac)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1853
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1854
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1855
lemma sin_2npi [simp]: "sin (2 * real (n::nat) * pi) = 0"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1856
by (auto simp add: mult_assoc)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1857
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1858
lemma sin_3over2_pi [simp]: "sin (3 / 2 * pi) = - 1"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1859
apply (subgoal_tac "3/2 = (1+1 / 2::real)")
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1860
apply (simp only: left_distrib) 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1861
apply (auto simp add: sin_add mult_ac)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1862
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1863
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1864
(*NEEDED??*)
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1865
lemma [simp]:
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1866
     "cos(x + 1 / 2 * real(Suc m) * pi) = -sin (x + 1 / 2 * real m * pi)"
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1867
apply (simp only: cos_add sin_add real_of_nat_Suc right_distrib left_distrib minus_mult_right, auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1868
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1869
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1870
(*NEEDED??*)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1871
lemma [simp]: "cos (x + real(Suc m) * pi / 2) = -sin (x + real m * pi / 2)"
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1872
by (simp only: cos_add sin_add real_of_nat_Suc left_distrib add_divide_distrib, auto)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1873
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1874
lemma cos_pi_eq_zero [simp]: "cos (pi * real (Suc (2 * m)) / 2) = 0"
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1875
by (simp only: cos_add sin_add real_of_nat_Suc left_distrib right_distrib add_divide_distrib, auto)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1876
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1877
lemma DERIV_cos_add [simp]: "DERIV (%x. cos (x + k)) xa :> - sin (xa + k)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1878
apply (rule lemma_DERIV_subst)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1879
apply (rule_tac f = cos and g = "%x. x + k" in DERIV_chain2)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1880
apply (best intro!: DERIV_intros intro: DERIV_chain2)+
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1881
apply (simp (no_asm))
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1882
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1883
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1884
lemma isCont_cos [simp]: "isCont cos x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1885
by (rule DERIV_cos [THEN DERIV_isCont])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1886
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1887
lemma isCont_sin [simp]: "isCont sin x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1888
by (rule DERIV_sin [THEN DERIV_isCont])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1889
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1890
lemma isCont_exp [simp]: "isCont exp x"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1891
by (rule DERIV_exp [THEN DERIV_isCont])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1892
15081
32402f5624d1 abs notation
paulson
parents: 15079
diff changeset
  1893
lemma sin_zero_abs_cos_one: "sin x = 0 ==> \<bar>cos x\<bar> = 1"
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
  1894
by (auto simp add: sin_zero_iff even_mult_two_ex)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1895
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1896
lemma exp_eq_one_iff [simp]: "(exp x = 1) = (x = 0)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1897
apply auto
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1898
apply (drule_tac f = ln in arg_cong, auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1899
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1900
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1901
lemma cos_one_sin_zero: "cos x = 1 ==> sin x = 0"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1902
by (cut_tac x = x in sin_cos_squared_add3, auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1903
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1904
22978
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1905
subsection {* Existence of Polar Coordinates *}
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1906
22978
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1907
lemma cos_x_y_le_one: "\<bar>x / sqrt (x\<twosuperior> + y\<twosuperior>)\<bar> \<le> 1"
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1908
apply (rule power2_le_imp_le [OF _ zero_le_one])
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1909
apply (simp add: abs_divide power_divide divide_le_eq not_sum_power2_lt_zero)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1910
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1911
22978
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1912
lemma cos_arccos_abs: "\<bar>y\<bar> \<le> 1 \<Longrightarrow> cos (arccos y) = y"
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1913
by (simp add: abs_le_iff)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1914
22978
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1915
lemma cos_total_abs: "\<bar>y\<bar> \<le> 1 \<Longrightarrow> \<exists>!x. 0 \<le> x \<and> x \<le> pi \<and> cos x = y"
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1916
by (simp add: abs_le_iff cos_total)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1917
22978
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1918
lemmas cos_arccos_lemma1 = cos_arccos_abs [OF cos_x_y_le_one]
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15140
diff changeset
  1919
22978
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1920
lemmas cos_total_lemma1 = cos_total_abs [OF cos_x_y_le_one]
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1921
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1922
(* How tedious! *)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1923
lemma lemma_divide_rearrange:
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1924
     "[| x + (y::real) \<noteq> 0; 1 - z = x/(x + y) |] ==> z = y/(x + y)"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1925
apply (rule_tac c1 = "x + y" in real_mult_right_cancel [THEN iffD1])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1926
apply (frule_tac [2] c1 = "x + y" in real_mult_right_cancel [THEN iffD2])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1927
prefer 2 apply assumption
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1928
apply (rotate_tac [2] 2)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1929
apply (drule_tac [2] mult_assoc [THEN subst])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1930
apply (rotate_tac [2] 2)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1931
apply (frule_tac [2] left_inverse [THEN subst])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1932
prefer 2 apply assumption
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1933
apply (erule_tac [2] V = "(1 - z) * (x + y) = x / (x + y) * (x + y)" in thin_rl)
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1934
apply (erule_tac [2] V = "1 - z = x / (x + y)" in thin_rl)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1935
apply (auto simp add: mult_assoc)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1936
apply (auto simp add: right_distrib left_diff_distrib)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1937
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1938
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1939
lemma lemma_cos_sin_eq:
22978
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1940
     "[| 0 < x\<twosuperior> + y\<twosuperior>;  
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1941
         1 - (sin xa)\<twosuperior> = (x / sqrt (x\<twosuperior> + y\<twosuperior>))\<twosuperior> |] 
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1942
      ==> (sin xa)\<twosuperior> = (y / sqrt (x\<twosuperior> + y\<twosuperior>))\<twosuperior>"
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1943
by (auto intro: lemma_divide_rearrange simp add: power_divide)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1944
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1945
lemma sin_x_y_disj:
22978
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1946
     "[| 0 < y;
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1947
         cos xa = x / sqrt (x\<twosuperior> + y\<twosuperior>)  
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1948
      |] ==>  sin xa = y / sqrt (x\<twosuperior> + y\<twosuperior>) |  
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1949
              sin xa = - y / sqrt (x\<twosuperior> + y\<twosuperior>)"
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1950
apply (drule_tac f = "%x. x\<twosuperior>" in arg_cong)
22978
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1951
apply (subgoal_tac "0 < x\<twosuperior> + y\<twosuperior>")
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1952
apply (simp add: cos_squared_eq)
22978
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1953
apply (subgoal_tac "(sin xa)\<twosuperior> = (y / sqrt (x\<twosuperior> + y\<twosuperior>))\<twosuperior>")
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1954
apply (rule_tac [2] lemma_cos_sin_eq)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1955
apply (auto simp add: realpow_two_disj numeral_2_eq_2 simp del: realpow_Suc)
22969
bf523cac9a05 tuned proofs
huffman
parents: 22960
diff changeset
  1956
apply (auto simp add: sum_squares_gt_zero_iff)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1957
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1958
22978
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1959
lemma real_sqrt_divide_less_zero: "0 < y ==> - y / sqrt (x\<twosuperior> + y\<twosuperior>) < 0"
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1960
by (simp add: divide_pos_pos sum_power2_gt_zero_iff)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1961
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1962
lemma polar_ex1:
22978
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1963
     "0 < y ==> \<exists>r a. x = r * cos a & y = r * sin a"
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1964
apply (rule_tac x = "sqrt (x\<twosuperior> + y\<twosuperior>)" in exI)
22978
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1965
apply (rule_tac x = "arccos (x / sqrt (x\<twosuperior> + y\<twosuperior>))" in exI)
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1966
apply (simp add: cos_arccos_lemma1)
22975
03085c441c14 spelling: rename arcos -> arccos
huffman
parents: 22969
diff changeset
  1967
apply (simp add: arccos_def)
22978
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1968
apply (cut_tac x1 = x and y1 = y in cos_total_lemma1)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1969
apply (rule someI2_ex, blast)
22978
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1970
apply (erule_tac V = "Ex1 ?P" in thin_rl)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1971
apply (frule sin_x_y_disj, blast)
22978
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1972
apply (auto)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1973
apply (drule sin_ge_zero, assumption)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1974
apply (drule_tac x = x in real_sqrt_divide_less_zero, auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1975
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1976
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  1977
lemma polar_ex2:
22978
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1978
     "y < 0 ==> \<exists>r a. x = r * cos a & y = r * sin a"
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1979
apply (insert polar_ex1 [where x=x and y="-y"], simp, clarify)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1980
apply (rule_tac x = r in exI)
22978
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1981
apply (rule_tac x = "-a" in exI, simp)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1982
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1983
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1984
lemma polar_Ex: "\<exists>r a. x = r * cos a & y = r * sin a"
22978
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1985
apply (rule_tac x=0 and y=y in linorder_cases)
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1986
apply (erule polar_ex1)
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1987
apply (rule_tac x=x in exI, rule_tac x=0 in exI, simp)
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1988
apply (erule polar_ex2)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1989
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  1990
22978
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1991
subsection {* Theorems About Sqrt *}
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1992
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1993
lemma le_real_sqrt_sumsq [simp]: "x \<le> sqrt (x * x + y * y)"
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1994
by (simp add: power2_eq_square [symmetric])
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1995
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1996
lemma real_sqrt_sum_squares_eq_cancel: "sqrt(x\<twosuperior> + y\<twosuperior>) = x ==> y = 0"
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1997
by (drule_tac f = "%x. x\<twosuperior>" in arg_cong, simp)
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1998
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  1999
lemma real_sqrt_sum_squares_eq_cancel2: "sqrt(x\<twosuperior> + y\<twosuperior>) = y ==> x = 0"
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  2000
by (drule_tac f = "%x. x\<twosuperior>" in arg_cong, simp)
1cd8cc21a7c3 clean up polar_Ex proofs; remove unnecessary lemmas
huffman
parents: 22977
diff changeset
  2001
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2002
lemma real_sqrt_ge_abs1 [simp]: "\<bar>x\<bar> \<le> sqrt (x\<twosuperior> + y\<twosuperior>)"
22960
114cf1906681 remove redundant lemmas
huffman
parents: 22956
diff changeset
  2003
by (rule power2_le_imp_le, simp_all)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2004
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2005
lemma real_sqrt_ge_abs2 [simp]: "\<bar>y\<bar> \<le> sqrt (x\<twosuperior> + y\<twosuperior>)"
22960
114cf1906681 remove redundant lemmas
huffman
parents: 22956
diff changeset
  2006
by (rule power2_le_imp_le, simp_all)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2007
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2008
lemma real_sqrt_two_gt_zero [simp]: "0 < sqrt 2"
22956
617140080e6a define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents: 22915
diff changeset
  2009
by simp
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2010
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2011
lemma real_sqrt_two_ge_zero [simp]: "0 \<le> sqrt 2"
22956
617140080e6a define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents: 22915
diff changeset
  2012
by simp
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2013
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2014
lemma real_sqrt_two_gt_one [simp]: "1 < sqrt 2"
22956
617140080e6a define roots of negative reals so that many lemmas no longer require side conditions; simplification solves more goals than previously
huffman
parents: 22915
diff changeset
  2015
by simp
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2016
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2017
lemma lemma_real_divide_sqrt_less: "0 < u ==> u / sqrt 2 < u"
22969
bf523cac9a05 tuned proofs
huffman
parents: 22960
diff changeset
  2018
by (simp add: divide_less_eq mult_compare_simps)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2019
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2020
lemma four_x_squared: 
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2021
  fixes x::real
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2022
  shows "4 * x\<twosuperior> = (2 * x)\<twosuperior>"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2023
by (simp add: power2_eq_square)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2024
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2025
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2026
text{*Needed for the infinitely close relation over the nonstandard
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2027
    complex numbers*}
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2028
lemma lemma_sqrt_hcomplex_capprox:
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2029
     "[| 0 < u; x < u/2; y < u/2; 0 \<le> x; 0 \<le> y |] ==> sqrt (x\<twosuperior> + y\<twosuperior>) < u"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2030
apply (rule_tac y = "u/sqrt 2" in order_le_less_trans)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2031
apply (erule_tac [2] lemma_real_divide_sqrt_less)
22960
114cf1906681 remove redundant lemmas
huffman
parents: 22956
diff changeset
  2032
apply (rule power2_le_imp_le)
114cf1906681 remove redundant lemmas
huffman
parents: 22956
diff changeset
  2033
apply (auto simp add: real_0_le_divide_iff power_divide)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2034
apply (rule_tac t = "u\<twosuperior>" in real_sum_of_halves [THEN subst])
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2035
apply (rule add_mono)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2036
apply (auto simp add: four_x_squared simp del: realpow_Suc intro: power_mono)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2037
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2038
16775
c1b87ef4a1c3 added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents: 16641
diff changeset
  2039
declare real_sqrt_sum_squares_ge_zero [THEN abs_of_nonneg, simp]
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2040
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2041
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2042
subsection{*A Few Theorems Involving Ln, Derivatives, etc.*}
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2043
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2044
lemma lemma_DERIV_ln:
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2045
     "DERIV ln z :> l ==> DERIV (%x. exp (ln x)) z :> exp (ln z) * l"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2046
by (erule DERIV_fun_exp)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2047
22654
c2b6b5a9e136 new simp rule exp_ln; new standard proof of DERIV_exp_ln_one; changed imports
huffman
parents: 22653
diff changeset
  2048
lemma DERIV_exp_ln_one: "0 < z ==> DERIV (%x. exp (ln x)) z :> 1"
c2b6b5a9e136 new simp rule exp_ln; new standard proof of DERIV_exp_ln_one; changed imports
huffman
parents: 22653
diff changeset
  2049
apply (simp add: deriv_def)
c2b6b5a9e136 new simp rule exp_ln; new standard proof of DERIV_exp_ln_one; changed imports
huffman
parents: 22653
diff changeset
  2050
apply (rule LIM_equal2 [OF _ _ LIM_const], assumption)
c2b6b5a9e136 new simp rule exp_ln; new standard proof of DERIV_exp_ln_one; changed imports
huffman
parents: 22653
diff changeset
  2051
apply simp
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2052
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2053
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  2054
lemma lemma_DERIV_ln2:
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  2055
     "[| 0 < z; DERIV ln z :> l |] ==>  exp (ln z) * l = 1"
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2056
apply (rule DERIV_unique)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2057
apply (rule lemma_DERIV_ln)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2058
apply (rule_tac [2] DERIV_exp_ln_one, auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2059
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2060
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  2061
lemma lemma_DERIV_ln3:
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  2062
     "[| 0 < z; DERIV ln z :> l |] ==>  l = 1/(exp (ln z))"
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  2063
apply (rule_tac c1 = "exp (ln z)" in real_mult_left_cancel [THEN iffD1])
22654
c2b6b5a9e136 new simp rule exp_ln; new standard proof of DERIV_exp_ln_one; changed imports
huffman
parents: 22653
diff changeset
  2064
apply (auto intro: lemma_DERIV_ln2 simp del: exp_ln)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2065
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2066
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2067
lemma lemma_DERIV_ln4: "[| 0 < z; DERIV ln z :> l |] ==>  l = 1/z"
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2068
apply (rule_tac t = z in exp_ln_iff [THEN iffD2, THEN subst])
22654
c2b6b5a9e136 new simp rule exp_ln; new standard proof of DERIV_exp_ln_one; changed imports
huffman
parents: 22653
diff changeset
  2069
apply (auto intro: lemma_DERIV_ln3 simp del: exp_ln)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2070
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2071
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2072
(* need to rename second isCont_inverse *)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2073
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  2074
lemma isCont_inv_fun:
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
  2075
  fixes f g :: "real \<Rightarrow> real"
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
  2076
  shows "[| 0 < d; \<forall>z. \<bar>z - x\<bar> \<le> d --> g(f(z)) = z;  
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2077
         \<forall>z. \<bar>z - x\<bar> \<le> d --> isCont f z |]  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2078
      ==> isCont g (f x)"
22722
704de05715b4 lemma isCont_inv_fun is same as isCont_inverse_function
huffman
parents: 22721
diff changeset
  2079
by (rule isCont_inverse_function)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2080
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2081
lemma isCont_inv_fun_inv:
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20516
diff changeset
  2082
  fixes f g :: "real \<Rightarrow> real"
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20516
diff changeset
  2083
  shows "[| 0 < d;  
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2084
         \<forall>z. \<bar>z - x\<bar> \<le> d --> g(f(z)) = z;  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2085
         \<forall>z. \<bar>z - x\<bar> \<le> d --> isCont f z |]  
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2086
       ==> \<exists>e. 0 < e &  
15081
32402f5624d1 abs notation
paulson
parents: 15079
diff changeset
  2087
             (\<forall>y. 0 < \<bar>y - f(x)\<bar> & \<bar>y - f(x)\<bar> < e --> f(g(y)) = y)"
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2088
apply (drule isCont_inj_range)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2089
prefer 2 apply (assumption, assumption, auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2090
apply (rule_tac x = e in exI, auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2091
apply (rotate_tac 2)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2092
apply (drule_tac x = y in spec, auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2093
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2094
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2095
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2096
text{*Bartle/Sherbert: Introduction to Real Analysis, Theorem 4.2.9, p. 110*}
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  2097
lemma LIM_fun_gt_zero:
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20516
diff changeset
  2098
     "[| f -- c --> (l::real); 0 < l |]  
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
  2099
         ==> \<exists>r. 0 < r & (\<forall>x::real. x \<noteq> c & \<bar>c - x\<bar> < r --> 0 < f x)"
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2100
apply (auto simp add: LIM_def)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2101
apply (drule_tac x = "l/2" in spec, safe, force)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2102
apply (rule_tac x = s in exI)
22998
97e1f9c2cc46 avoid using redundant lemmas from RealDef.thy
huffman
parents: 22978
diff changeset
  2103
apply (auto simp only: abs_less_iff)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2104
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2105
15229
1eb23f805c06 new simprules for abs and for things like a/b<1
paulson
parents: 15228
diff changeset
  2106
lemma LIM_fun_less_zero:
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20516
diff changeset
  2107
     "[| f -- c --> (l::real); l < 0 |]  
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
  2108
      ==> \<exists>r. 0 < r & (\<forall>x::real. x \<noteq> c & \<bar>c - x\<bar> < r --> f x < 0)"
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2109
apply (auto simp add: LIM_def)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2110
apply (drule_tac x = "-l/2" in spec, safe, force)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2111
apply (rule_tac x = s in exI)
22998
97e1f9c2cc46 avoid using redundant lemmas from RealDef.thy
huffman
parents: 22978
diff changeset
  2112
apply (auto simp only: abs_less_iff)
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2113
done
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2114
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2115
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2116
lemma LIM_fun_not_zero:
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20516
diff changeset
  2117
     "[| f -- c --> (l::real); l \<noteq> 0 |] 
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
  2118
      ==> \<exists>r. 0 < r & (\<forall>x::real. x \<noteq> c & \<bar>c - x\<bar> < r --> f x \<noteq> 0)"
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2119
apply (cut_tac x = l and y = 0 in linorder_less_linear, auto)
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2120
apply (drule LIM_fun_less_zero)
15241
a3949068537e tweaks concerned with poly bug-fixing
paulson
parents: 15234
diff changeset
  2121
apply (drule_tac [3] LIM_fun_gt_zero)
a3949068537e tweaks concerned with poly bug-fixing
paulson
parents: 15234
diff changeset
  2122
apply force+
15077
89840837108e converting Hyperreal/Transcendental to Isar script
paulson
parents: 15013
diff changeset
  2123
done
20432
07ec57376051 lin_arith_prover: splitting reverted because of performance loss
webertj
parents: 20256
diff changeset
  2124
  
12196
a3be6b3a9c0b new theories from Jacques Fleuriot
paulson
parents:
diff changeset
  2125
end