author  bulwahn 
Wed, 15 Dec 2010 08:34:01 +0100  
changeset 41120  74e41b2d48ea 
parent 36974  b877866b5b00 
child 41166  4b2a457b17e8 
permissions  rwrr 
28952
15a4b2cf8c34
made repository layout more coherent with logical distribution structure; stripped some $Id$s
haftmann
parents:
27239
diff
changeset

1 
(* Author : Jacques D. Fleuriot 
12224  2 
Copyright : 2001 University of Edinburgh 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

3 
Conversion to Isar and new proofs by Lawrence C Paulson, 2004 
41120
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

4 
Conversion of Mac Laurin to Isar by Lukas Bulwahn and Bernhard HÃ¤upler, 2005 
12224  5 
*) 
6 

15944  7 
header{*MacLaurin Series*} 
8 

15131  9 
theory MacLaurin 
29811
026b0f9f579f
fixed Proofs and dependencies ; Theory Dense_Linear_Order moved to Library
chaieb@chaieblaptop
parents:
29803
diff
changeset

10 
imports Transcendental 
15131  11 
begin 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

12 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

13 
subsection{*Maclaurin's Theorem with Lagrange Form of Remainder*} 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

14 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

15 
text{*This is a very long, messy proof even now that it's been broken down 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

16 
into lemmas.*} 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

17 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

18 
lemma Maclaurin_lemma: 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

19 
"0 < h ==> 
15539  20 
\<exists>B. f h = (\<Sum>m=0..<n. (j m / real (fact m)) * (h^m)) + 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

21 
(B * ((h^n) / real(fact n)))" 
41120
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

22 
by (rule_tac x = "(f h  (\<Sum>m=0..<n. (j m / real (fact m)) * h^m)) * 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

23 
real(fact n) / (h^n)" 
41120
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

24 
in exI, simp) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

25 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

26 
lemma eq_diff_eq': "(x = y  z) = (y = x + (z::real))" 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

27 
by arith 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

28 

32038  29 
lemma fact_diff_Suc [rule_format]: 
30 
"n < Suc m ==> fact (Suc m  n) = (Suc m  n) * fact (m  n)" 

31 
by (subst fact_reduce_nat, auto) 

32 

15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

33 
lemma Maclaurin_lemma2: 
41120
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

34 
assumes DERIV : "\<forall>m t. m < n \<and> 0\<le>t \<and> t\<le>h \<longrightarrow> DERIV (diff m) t :> diff (Suc m) t" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

35 
and INIT : "n = Suc k" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

36 
and DIFG_DEF: "difg = (\<lambda>m t. diff m t  ((\<Sum>p = 0..<n  m. diff (m + p) 0 / real (fact p) * t ^ p) + 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

37 
B * (t ^ (n  m) / real (fact (n  m)))))" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

38 
shows "\<forall>m t. m < n & 0 \<le> t & t \<le> h > DERIV (difg m) t :> difg (Suc m) t" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

39 
proof (rule allI)+ 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

40 
fix m 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

41 
fix t 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

42 
show "m < n \<and> 0 \<le> t \<and> t \<le> h \<longrightarrow> DERIV (difg m) t :> difg (Suc m) t" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

43 
proof 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

44 
assume INIT2: "m < n & 0 \<le> t & t \<le> h" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

45 
hence INTERV: "0 \<le> t & t \<le> h" .. 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

46 
from INIT2 and INIT have mtok: "m < Suc k" by arith 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

47 
have "DERIV (\<lambda>t. diff m t  
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

48 
((\<Sum>p = 0..<Suc k  m. diff (m + p) 0 / real (fact p) * t ^ p) + 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

49 
B * (t ^ (Suc k  m) / real (fact (Suc k  m))))) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

50 
t :> diff (Suc m) t  
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

51 
((\<Sum>p = 0..<Suc k  Suc m. diff (Suc m + p) 0 / real (fact p) * t ^ p) + 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

52 
B * (t ^ (Suc k  Suc m) / real (fact (Suc k  Suc m))))" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

53 
proof  
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

54 
from DERIV and INIT2 have "DERIV (diff m) t :> diff (Suc m) t" by simp 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

55 
moreover 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

56 
have " DERIV (\<lambda>x. (\<Sum>p = 0..<Suc k  m. diff (m + p) 0 / real (fact p) * x ^ p) + 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

57 
B * (x ^ (Suc k  m) / real (fact (Suc k  m)))) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

58 
t :> (\<Sum>p = 0..<Suc k  Suc m. diff (Suc m + p) 0 / real (fact p) * t ^ p) + 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

59 
B * (t ^ (Suc k  Suc m) / real (fact (Suc k  Suc m)))" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

60 
proof  
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

61 
have "DERIV (\<lambda>x. \<Sum>p = 0..<Suc k  m. diff (m + p) 0 / real (fact p) * x ^ p) t 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

62 
:> (\<Sum>p = 0..<Suc k  Suc m. diff (Suc m + p) 0 / real (fact p) * t ^ p)" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

63 
proof  
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

64 
have "\<exists> d. k = m + d" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

65 
proof  
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

66 
from INIT2 have "m < n" .. 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

67 
hence "\<exists> d. n = m + d + Suc 0" by arith 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

68 
with INIT show ?thesis by (simp del: setsum_op_ivl_Suc) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

69 
qed 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

70 
from this obtain d where kmd: "k = m + d" .. 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

71 
have "DERIV (\<lambda>x. (\<Sum>ma = 0..<d. diff (Suc (m + ma)) 0 * x ^ Suc ma / real (fact (Suc ma))) + 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

72 
diff m 0) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

73 
t :> (\<Sum>p = 0..<d. diff (Suc (m + p)) 0 * t ^ p / real (fact p))" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

74 

74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

75 
proof  
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

76 
have "DERIV (\<lambda>x. (\<Sum>ma = 0..<d. diff (Suc (m + ma)) 0 * x ^ Suc ma / real (fact (Suc ma))) + diff m 0) t :> (\<Sum>r = 0..<d. diff (Suc (m + r)) 0 * t ^ r / real (fact r)) + 0" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

77 
proof  
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

78 
from DERIV and INTERV have "DERIV (\<lambda>x. (\<Sum>ma = 0..<d. diff (Suc (m + ma)) 0 * x ^ Suc ma / real (fact (Suc ma)))) t :> (\<Sum>r = 0..<d. diff (Suc (m + r)) 0 * t ^ r / real (fact r))" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

79 
proof  
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

80 
have "\<forall>r. 0 \<le> r \<and> r < 0 + d \<longrightarrow> 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

81 
DERIV (\<lambda>x. diff (Suc (m + r)) 0 * x ^ Suc r / real (fact (Suc r))) t 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

82 
:> diff (Suc (m + r)) 0 * t ^ r / real (fact r)" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

83 
proof (rule allI) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

84 
fix r 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

85 
show " 0 \<le> r \<and> r < 0 + d \<longrightarrow> 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

86 
DERIV (\<lambda>x. diff (Suc (m + r)) 0 * x ^ Suc r / real (fact (Suc r))) t 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

87 
:> diff (Suc (m + r)) 0 * t ^ r / real (fact r)" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

88 
proof 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

89 
assume "0 \<le> r & r < 0 + d" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

90 
have "DERIV (\<lambda>x. diff (Suc (m + r)) 0 * 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

91 
(x ^ Suc r * inverse (real (fact (Suc r))))) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

92 
t :> diff (Suc (m + r)) 0 * (t ^ r * inverse (real (fact r)))" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

93 
proof  
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

94 
have "(1 + real r) * real (fact r) \<noteq> 0" by auto 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

95 
from this have "real (fact r) + real r * real (fact r) \<noteq> 0" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

96 
by (metis add_nonneg_eq_0_iff mult_nonneg_nonneg real_of_nat_fact_not_zero real_of_nat_ge_zero) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

97 
from this have "DERIV (\<lambda>x. x ^ Suc r * inverse (real (fact (Suc r)))) t :> real (Suc r) * t ^ (Suc r  Suc 0) * inverse (real (fact (Suc r))) + 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

98 
0 * t ^ Suc r" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

99 
apply  by ( rule DERIV_intros  rule refl)+ auto 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

100 
moreover 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

101 
have "real (Suc r) * t ^ (Suc r  Suc 0) * inverse (real (fact (Suc r))) + 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

102 
0 * t ^ Suc r = 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

103 
t ^ r * inverse (real (fact r))" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

104 
proof  
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

105 

74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

106 
have " real (Suc r) * t ^ (Suc r  Suc 0) * 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

107 
inverse (real (Suc r) * real (fact r)) + 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

108 
0 * t ^ Suc r = 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

109 
t ^ r * inverse (real (fact r))" by (simp add: mult_ac) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

110 
hence "real (Suc r) * t ^ (Suc r  Suc 0) * inverse (real (Suc r * fact r)) + 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

111 
0 * t ^ Suc r = 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

112 
t ^ r * inverse (real (fact r))" by (subst real_of_nat_mult) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

113 
thus ?thesis by (subst fact_Suc) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

114 
qed 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

115 
ultimately have " DERIV (\<lambda>x. x ^ Suc r * inverse (real (fact (Suc r)))) t 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

116 
:> t ^ r * inverse (real (fact r))" by (rule lemma_DERIV_subst) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

117 
thus ?thesis by (rule DERIV_cmult) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

118 
qed 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

119 
thus "DERIV (\<lambda>x. diff (Suc (m + r)) 0 * x ^ Suc r / 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

120 
real (fact (Suc r))) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

121 
t :> diff (Suc (m + r)) 0 * t ^ r / real (fact r)" by (simp (no_asm) add: divide_inverse mult_assoc del: fact_Suc power_Suc) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

122 
qed 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

123 
qed 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

124 
thus ?thesis by (rule DERIV_sumr) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

125 
qed 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

126 
moreover 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

127 
from DERIV_const have "DERIV (\<lambda>x. diff m 0) t :> 0" . 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

128 
ultimately show ?thesis by (rule DERIV_add) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

129 
qed 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

130 
moreover 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

131 
have " (\<Sum>r = 0..<d. diff (Suc (m + r)) 0 * t ^ r / real (fact r)) + 0 = (\<Sum>p = 0..<d. diff (Suc (m + p)) 0 * t ^ p / real (fact p))" by simp 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

132 
ultimately show ?thesis by (rule lemma_DERIV_subst) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

133 
qed 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

134 
with kmd and sumr_offset4 [of 1] show ?thesis by (simp del: setsum_op_ivl_Suc fact_Suc power_Suc) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

135 
qed 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

136 
moreover 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

137 
have " DERIV (\<lambda>x. B * (x ^ (Suc k  m) / real (fact (Suc k  m)))) t 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

138 
:> B * (t ^ (Suc k  Suc m) / real (fact (Suc k  Suc m)))" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

139 
proof  
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

140 
have " DERIV (\<lambda>x. x ^ (Suc k  m) / real (fact (Suc k  m))) t 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

141 
:> t ^ (Suc k  Suc m) / real (fact (Suc k  Suc m))" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

142 
proof  
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

143 
have "DERIV (\<lambda>x. x ^ (Suc k  m)) t :> real (Suc k  m) * t ^ (Suc k  m  Suc 0)" by (rule DERIV_pow) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

144 
moreover 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

145 
have "DERIV (\<lambda>x. real (fact (Suc k  m))) t :> 0" by (rule DERIV_const) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

146 
moreover 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

147 
have "(\<lambda>x. real (fact (Suc k  m))) t \<noteq> 0" by simp 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

148 
ultimately have " DERIV (\<lambda>y. y ^ (Suc k  m) / real (fact (Suc k  m))) t 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

149 
:> ( real (Suc k  m) * t ^ (Suc k  m  Suc 0) * real (fact (Suc k  m)) +  (0 * t ^ (Suc k  m))) / 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

150 
real (fact (Suc k  m)) ^ Suc (Suc 0)" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

151 
apply  
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

152 
apply (rule DERIV_cong) by (rule DERIV_intros  rule refl)+ auto 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

153 
moreover 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

154 
from mtok and INIT have "( real (Suc k  m) * t ^ (Suc k  m  Suc 0) * real (fact (Suc k  m)) +  (0 * t ^ (Suc k  m))) / 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

155 
real (fact (Suc k  m)) ^ Suc (Suc 0) = t ^ (Suc k  Suc m) / real (fact (Suc k  Suc m))" by (simp add: fact_diff_Suc) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

156 
ultimately show ?thesis by (rule lemma_DERIV_subst) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

157 
qed 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

158 
moreover 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

159 
thus ?thesis by (rule DERIV_cmult) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

160 
qed 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

161 
ultimately show ?thesis by (rule DERIV_add) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

162 
qed 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

163 
ultimately show ?thesis by (rule DERIV_diff) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

164 
qed 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

165 
from INIT and this and DIFG_DEF show "DERIV (difg m) t :> difg (Suc m) t" by clarify 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

166 
qed 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

167 
qed 
32038  168 

15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

169 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

170 
lemma Maclaurin: 
29187  171 
assumes h: "0 < h" 
172 
assumes n: "0 < n" 

173 
assumes diff_0: "diff 0 = f" 

174 
assumes diff_Suc: 

175 
"\<forall>m t. m < n & 0 \<le> t & t \<le> h > DERIV (diff m) t :> diff (Suc m) t" 

176 
shows 

177 
"\<exists>t. 0 < t & t < h & 

15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

178 
f h = 
15539  179 
setsum (%m. (diff m 0 / real (fact m)) * h ^ m) {0..<n} + 
41120
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

180 
(diff n t / real (fact n)) * h ^ n" 
29187  181 
proof  
182 
from n obtain m where m: "n = Suc m" 

183 
by (cases n, simp add: n) 

184 

185 
obtain B where f_h: "f h = 

186 
(\<Sum>m = 0..<n. diff m (0\<Colon>real) / real (fact m) * h ^ m) + 

187 
B * (h ^ n / real (fact n))" 

188 
using Maclaurin_lemma [OF h] .. 

189 

190 
obtain g where g_def: "g = (%t. f t  

191 
(setsum (%m. (diff m 0 / real(fact m)) * t^m) {0..<n} 

192 
+ (B * (t^n / real(fact n)))))" by blast 

193 

194 
have g2: "g 0 = 0 & g h = 0" 

195 
apply (simp add: m f_h g_def del: setsum_op_ivl_Suc) 

30082
43c5b7bfc791
make more proofs work whether or not One_nat_def is a simp rule
huffman
parents:
29811
diff
changeset

196 
apply (cut_tac n = m and k = "Suc 0" in sumr_offset2) 
29187  197 
apply (simp add: eq_diff_eq' diff_0 del: setsum_op_ivl_Suc) 
198 
done 

199 

200 
obtain difg where difg_def: "difg = (%m t. diff m t  

201 
(setsum (%p. (diff (m + p) 0 / real (fact p)) * (t ^ p)) {0..<nm} 

202 
+ (B * ((t ^ (n  m)) / real (fact (n  m))))))" by blast 

203 

204 
have difg_0: "difg 0 = g" 

205 
unfolding difg_def g_def by (simp add: diff_0) 

206 

207 
have difg_Suc: "\<forall>(m\<Colon>nat) t\<Colon>real. 

208 
m < n \<and> (0\<Colon>real) \<le> t \<and> t \<le> h \<longrightarrow> DERIV (difg m) t :> difg (Suc m) t" 

209 
using diff_Suc m difg_def by (rule Maclaurin_lemma2) 

210 

211 
have difg_eq_0: "\<forall>m. m < n > difg m 0 = 0" 

212 
apply clarify 

213 
apply (simp add: m difg_def) 

214 
apply (frule less_iff_Suc_add [THEN iffD1], clarify) 

215 
apply (simp del: setsum_op_ivl_Suc) 

30082
43c5b7bfc791
make more proofs work whether or not One_nat_def is a simp rule
huffman
parents:
29811
diff
changeset

216 
apply (insert sumr_offset4 [of "Suc 0"]) 
32047  217 
apply (simp del: setsum_op_ivl_Suc fact_Suc) 
29187  218 
done 
219 

220 
have isCont_difg: "\<And>m x. \<lbrakk>m < n; 0 \<le> x; x \<le> h\<rbrakk> \<Longrightarrow> isCont (difg m) x" 

221 
by (rule DERIV_isCont [OF difg_Suc [rule_format]]) simp 

222 

223 
have differentiable_difg: 

224 
"\<And>m x. \<lbrakk>m < n; 0 \<le> x; x \<le> h\<rbrakk> \<Longrightarrow> difg m differentiable x" 

225 
by (rule differentiableI [OF difg_Suc [rule_format]]) simp 

226 

227 
have difg_Suc_eq_0: "\<And>m t. \<lbrakk>m < n; 0 \<le> t; t \<le> h; DERIV (difg m) t :> 0\<rbrakk> 

228 
\<Longrightarrow> difg (Suc m) t = 0" 

229 
by (rule DERIV_unique [OF difg_Suc [rule_format]]) simp 

230 

231 
have "m < n" using m by simp 

232 

233 
have "\<exists>t. 0 < t \<and> t < h \<and> DERIV (difg m) t :> 0" 

234 
using `m < n` 

235 
proof (induct m) 

236 
case 0 

237 
show ?case 

238 
proof (rule Rolle) 

239 
show "0 < h" by fact 

240 
show "difg 0 0 = difg 0 h" by (simp add: difg_0 g2) 

241 
show "\<forall>x. 0 \<le> x \<and> x \<le> h \<longrightarrow> isCont (difg (0\<Colon>nat)) x" 

242 
by (simp add: isCont_difg n) 

243 
show "\<forall>x. 0 < x \<and> x < h \<longrightarrow> difg (0\<Colon>nat) differentiable x" 

244 
by (simp add: differentiable_difg n) 

245 
qed 

246 
next 

247 
case (Suc m') 

248 
hence "\<exists>t. 0 < t \<and> t < h \<and> DERIV (difg m') t :> 0" by simp 

249 
then obtain t where t: "0 < t" "t < h" "DERIV (difg m') t :> 0" by fast 

250 
have "\<exists>t'. 0 < t' \<and> t' < t \<and> DERIV (difg (Suc m')) t' :> 0" 

251 
proof (rule Rolle) 

252 
show "0 < t" by fact 

253 
show "difg (Suc m') 0 = difg (Suc m') t" 

254 
using t `Suc m' < n` by (simp add: difg_Suc_eq_0 difg_eq_0) 

255 
show "\<forall>x. 0 \<le> x \<and> x \<le> t \<longrightarrow> isCont (difg (Suc m')) x" 

256 
using `t < h` `Suc m' < n` by (simp add: isCont_difg) 

257 
show "\<forall>x. 0 < x \<and> x < t \<longrightarrow> difg (Suc m') differentiable x" 

258 
using `t < h` `Suc m' < n` by (simp add: differentiable_difg) 

259 
qed 

260 
thus ?case 

261 
using `t < h` by auto 

262 
qed 

263 

264 
then obtain t where "0 < t" "t < h" "DERIV (difg m) t :> 0" by fast 

265 

266 
hence "difg (Suc m) t = 0" 

267 
using `m < n` by (simp add: difg_Suc_eq_0) 

268 

269 
show ?thesis 

270 
proof (intro exI conjI) 

271 
show "0 < t" by fact 

272 
show "t < h" by fact 

273 
show "f h = 

274 
(\<Sum>m = 0..<n. diff m 0 / real (fact m) * h ^ m) + 

275 
diff n t / real (fact n) * h ^ n" 

276 
using `difg (Suc m) t = 0` 

32047  277 
by (simp add: m f_h difg_def del: fact_Suc) 
29187  278 
qed 
279 

280 
qed 

15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

281 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

282 
lemma Maclaurin_objl: 
25162  283 
"0 < h & n>0 & diff 0 = f & 
25134
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents:
25112
diff
changeset

284 
(\<forall>m t. m < n & 0 \<le> t & t \<le> h > DERIV (diff m) t :> diff (Suc m) t) 
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents:
25112
diff
changeset

285 
> (\<exists>t. 0 < t & t < h & 
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents:
25112
diff
changeset

286 
f h = (\<Sum>m=0..<n. diff m 0 / real (fact m) * h ^ m) + 
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents:
25112
diff
changeset

287 
diff n t / real (fact n) * h ^ n)" 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

288 
by (blast intro: Maclaurin) 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

289 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

290 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

291 
lemma Maclaurin2: 
41120
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

292 
assumes INIT1: "0 < h " and INIT2: "diff 0 = f" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

293 
and DERIV: "\<forall>m t. 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

294 
m < n & 0 \<le> t & t \<le> h > DERIV (diff m) t :> diff (Suc m) t" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

295 
shows "\<exists>t. 0 < t \<and> t \<le> h \<and> f h = 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

296 
(\<Sum>m=0..<n. diff m 0 / real (fact m) * h ^ m) + 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

297 
diff n t / real (fact n) * h ^ n" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

298 
proof (cases "n") 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

299 
case 0 with INIT1 INIT2 show ?thesis by fastsimp 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

300 
next 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

301 
case Suc 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

302 
hence "n > 0" by simp 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

303 
from INIT1 this INIT2 DERIV have "\<exists>t>0. t < h \<and> 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

304 
f h = 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

305 
(\<Sum>m = 0..<n. diff m 0 / real (fact m) * h ^ m) + diff n t / real (fact n) * h ^ n" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

306 
by (rule Maclaurin) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

307 
thus ?thesis by fastsimp 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

308 
qed 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

309 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

310 
lemma Maclaurin2_objl: 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

311 
"0 < h & diff 0 = f & 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

312 
(\<forall>m t. 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

313 
m < n & 0 \<le> t & t \<le> h > DERIV (diff m) t :> diff (Suc m) t) 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

314 
> (\<exists>t. 0 < t & 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

315 
t \<le> h & 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

316 
f h = 
15539  317 
(\<Sum>m=0..<n. diff m 0 / real (fact m) * h ^ m) + 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

318 
diff n t / real (fact n) * h ^ n)" 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

319 
by (blast intro: Maclaurin2) 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

320 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

321 
lemma Maclaurin_minus: 
41120
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

322 
assumes INTERV : "h < 0" and 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

323 
INIT : "0 < n" "diff 0 = f" and 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

324 
ABL : "\<forall>m t. m < n & h \<le> t & t \<le> 0 > DERIV (diff m) t :> diff (Suc m) t" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

325 
shows "\<exists>t. h < t & t < 0 & 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

326 
f h = (\<Sum>m=0..<n. diff m 0 / real (fact m) * h ^ m) + 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

327 
diff n t / real (fact n) * h ^ n" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

328 
proof  
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

329 
from INTERV have "0 < h" by simp 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

330 
moreover 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

331 
from INIT have "0 < n" by simp 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

332 
moreover 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

333 
from INIT have "(% x. (  1) ^ 0 * diff 0 ( x)) = (% x. f ( x))" by simp 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

334 
moreover 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

335 
have "\<forall>m t. m < n \<and> 0 \<le> t \<and> t \<le>  h \<longrightarrow> 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

336 
DERIV (\<lambda>x. ( 1) ^ m * diff m ( x)) t :> ( 1) ^ Suc m * diff (Suc m) ( t)" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

337 
proof (rule allI impI)+ 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

338 
fix m t 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

339 
assume tINTERV:" m < n \<and> 0 \<le> t \<and> t \<le>  h" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

340 
with ABL show "DERIV (\<lambda>x. ( 1) ^ m * diff m ( x)) t :> ( 1) ^ Suc m * diff (Suc m) ( t)" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

341 
proof  
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

342 

74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

343 
from ABL and tINTERV have "DERIV (\<lambda>x. diff m ( x)) t :>  diff (Suc m) ( t)" (is ?tABL) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

344 
proof  
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

345 
from ABL and tINTERV have "DERIV (diff m) ( t) :> diff (Suc m) ( t)" by force 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

346 
moreover 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

347 
from DERIV_ident[of t] have "DERIV uminus t :> ( 1)" by (rule DERIV_minus) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

348 
ultimately have "DERIV (\<lambda>x. diff m ( x)) t :> diff (Suc m) ( t) *  1" by (rule DERIV_chain2) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

349 
thus ?thesis by simp 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

350 
qed 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

351 
thus ?thesis 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

352 
proof  
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

353 
assume ?tABL hence "DERIV (\<lambda>x. 1 ^ m * diff m ( x)) t :> 1 ^ m *  diff (Suc m) ( t)" by (rule DERIV_cmult) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

354 
hence "DERIV (\<lambda>x. 1 ^ m * diff m ( x)) t :>  (1 ^ m * diff (Suc m) ( t))" by (subst minus_mult_right) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

355 
thus ?thesis by simp 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

356 
qed 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

357 
qed 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

358 
qed 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

359 
ultimately have t_exists: "\<exists>t>0. t <  h \<and> 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

360 
f ( ( h)) = 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

361 
(\<Sum>m = 0..<n. 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

362 
( 1) ^ m * diff m ( 0) / real (fact m) * ( h) ^ m) + 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

363 
( 1) ^ n * diff n ( t) / real (fact n) * ( h) ^ n" (is "\<exists> t. ?P t") by (rule Maclaurin) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

364 
from this obtain t where t_def: "?P t" .. 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

365 
moreover 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

366 
have "1 ^ n * diff n ( t) * ( h) ^ n / real (fact n) = diff n ( t) * h ^ n / real (fact n)" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

367 
by (auto simp add: power_mult_distrib[symmetric]) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

368 
moreover 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

369 
have "(SUM m = 0..<n. 1 ^ m * diff m 0 * ( h) ^ m / real (fact m)) = (SUM m = 0..<n. diff m 0 * h ^ m / real (fact m))" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

370 
by (auto intro: setsum_cong simp add: power_mult_distrib[symmetric]) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

371 
ultimately have " h <  t \<and> 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

372 
 t < 0 \<and> 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

373 
f h = 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

374 
(\<Sum>m = 0..<n. diff m 0 / real (fact m) * h ^ m) + diff n ( t) / real (fact n) * h ^ n" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

375 
by auto 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

376 
thus ?thesis .. 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

377 
qed 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

378 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

379 
lemma Maclaurin_minus_objl: 
25162  380 
"(h < 0 & n > 0 & diff 0 = f & 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

381 
(\<forall>m t. 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

382 
m < n & h \<le> t & t \<le> 0 > DERIV (diff m) t :> diff (Suc m) t)) 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

383 
> (\<exists>t. h < t & 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

384 
t < 0 & 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

385 
f h = 
15539  386 
(\<Sum>m=0..<n. diff m 0 / real (fact m) * h ^ m) + 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

387 
diff n t / real (fact n) * h ^ n)" 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

388 
by (blast intro: Maclaurin_minus) 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

389 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

390 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

391 
subsection{*More Convenient "Bidirectional" Version.*} 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

392 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

393 
(* not good for PVS sin_approx, cos_approx *) 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

394 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

395 
lemma Maclaurin_bi_le_lemma [rule_format]: 
25162  396 
"n>0 \<longrightarrow> 
25134
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents:
25112
diff
changeset

397 
diff 0 0 = 
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents:
25112
diff
changeset

398 
(\<Sum>m = 0..<n. diff m 0 * 0 ^ m / real (fact m)) + 
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents:
25112
diff
changeset

399 
diff n 0 * 0 ^ n / real (fact n)" 
15251  400 
by (induct "n", auto) 
14738  401 

15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

402 
lemma Maclaurin_bi_le: 
41120
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

403 
assumes INIT : "diff 0 = f" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

404 
and DERIV : "\<forall>m t. m < n & abs t \<le> abs x > DERIV (diff m) t :> diff (Suc m) t" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

405 
shows "\<exists>t. abs t \<le> abs x & 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

406 
f x = 
15539  407 
(\<Sum>m=0..<n. diff m 0 / real (fact m) * x ^ m) + 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

408 
diff n t / real (fact n) * x ^ n" 
41120
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

409 
proof (cases "n = 0") 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

410 
case True from INIT True show ?thesis by force 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

411 
next 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

412 
case False 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

413 
from this have n_not_zero:"n \<noteq> 0" . 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

414 
from False INIT DERIV show ?thesis 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

415 
proof (cases "x = 0") 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

416 
case True show ?thesis 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

417 
proof  
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

418 
from n_not_zero True INIT DERIV have "\<bar>0\<bar> \<le> \<bar>x\<bar> \<and> 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

419 
f x = (\<Sum>m = 0..<n. diff m 0 / real (fact m) * x ^ m) + diff n 0 / real (fact n) * x ^ n" by(force simp add: Maclaurin_bi_le_lemma) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

420 
thus ?thesis .. 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

421 
qed 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

422 
next 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

423 
case False 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

424 
note linorder_less_linear [of "x" "0"] 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

425 
thus ?thesis 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

426 
proof (elim disjE) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

427 
assume "x = 0" with False show ?thesis .. 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

428 
next 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

429 
assume x_less_zero: "x < 0" moreover 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

430 
from n_not_zero have "0 < n" by simp moreover 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

431 
have "diff 0 = diff 0" by simp moreover 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

432 
have "\<forall>m t. m < n \<and> x \<le> t \<and> t \<le> 0 \<longrightarrow> DERIV (diff m) t :> diff (Suc m) t" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

433 
proof (rule allI, rule allI, rule impI) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

434 
fix m t 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

435 
assume "m < n & x \<le> t & t \<le> 0" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

436 
with DERIV show " DERIV (diff m) t :> diff (Suc m) t" by (fastsimp simp add: abs_if) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

437 
qed 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

438 
ultimately have t_exists:"\<exists>t>x. t < 0 \<and> 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

439 
diff 0 x = 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

440 
(\<Sum>m = 0..<n. diff m 0 / real (fact m) * x ^ m) + diff n t / real (fact n) * x ^ n" (is "\<exists> t. ?P t") by (rule Maclaurin_minus) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

441 
from this obtain t where t_def: "?P t" .. 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

442 
from t_def x_less_zero INIT have "\<bar>t\<bar> \<le> \<bar>x\<bar> \<and> 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

443 
f x = (\<Sum>m = 0..<n. diff m 0 / real (fact m) * x ^ m) + diff n t / real (fact n) * x ^ n" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

444 
by (simp add: abs_if order_less_le) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

445 
thus ?thesis by (rule exI) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

446 
next 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

447 
assume x_greater_zero: "x > 0" moreover 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

448 
from n_not_zero have "0 < n" by simp moreover 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

449 
have "diff 0 = diff 0" by simp moreover 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

450 
have "\<forall>m t. m < n \<and> 0 \<le> t \<and> t \<le> x \<longrightarrow> DERIV (diff m) t :> diff (Suc m) t" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

451 
proof (rule allI, rule allI, rule impI) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

452 
fix m t 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

453 
assume "m < n & 0 \<le> t & t \<le> x" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

454 
with DERIV show " DERIV (diff m) t :> diff (Suc m) t" by fastsimp 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

455 
qed 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

456 
ultimately have t_exists:"\<exists>t>0. t < x \<and> 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

457 
diff 0 x = 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

458 
(\<Sum>m = 0..<n. diff m 0 / real (fact m) * x ^ m) + diff n t / real (fact n) * x ^ n" (is "\<exists> t. ?P t") by (rule Maclaurin) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

459 
from this obtain t where t_def: "?P t" .. 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

460 
from t_def x_greater_zero INIT have "\<bar>t\<bar> \<le> \<bar>x\<bar> \<and> 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

461 
f x = (\<Sum>m = 0..<n. diff m 0 / real (fact m) * x ^ m) + diff n t / real (fact n) * x ^ n" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

462 
by fastsimp 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

463 
thus ?thesis .. 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

464 
qed 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

465 
qed 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

466 
qed 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

467 

15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

468 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

469 
lemma Maclaurin_all_lt: 
41120
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

470 
assumes INIT1: "diff 0 = f" and INIT2: "0 < n" and INIT3: "x \<noteq> 0" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

471 
and DERIV: "\<forall>m x. DERIV (diff m) x :> diff(Suc m) x" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

472 
shows "\<exists>t. 0 < abs t & abs t < abs x & 
15539  473 
f x = (\<Sum>m=0..<n. (diff m 0 / real (fact m)) * x ^ m) + 
41120
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

474 
(diff n t / real (fact n)) * x ^ n" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

475 
proof  
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

476 
have "(x = 0) \<Longrightarrow> ?thesis" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

477 
proof  
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

478 
assume "x = 0" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

479 
with INIT3 show "(x = 0) \<Longrightarrow> ?thesis".. 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

480 
qed 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

481 
moreover have "(x < 0) \<Longrightarrow> ?thesis" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

482 
proof  
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

483 
assume x_less_zero: "x < 0" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

484 
from DERIV have "\<forall>m t. m < n \<and> x \<le> t \<and> t \<le> 0 \<longrightarrow> DERIV (diff m) t :> diff (Suc m) t" by simp 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

485 
with x_less_zero INIT2 INIT1 have "\<exists>t>x. t < 0 \<and> f x = (\<Sum>m = 0..<n. diff m 0 / real (fact m) * x ^ m) + diff n t / real (fact n) * x ^ n" (is "\<exists> t. ?P t") by (rule Maclaurin_minus) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

486 
from this obtain t where "?P t" .. 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

487 
with x_less_zero have "0 < \<bar>t\<bar> \<and> 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

488 
\<bar>t\<bar> < \<bar>x\<bar> \<and> 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

489 
f x = (\<Sum>m = 0..<n. diff m 0 / real (fact m) * x ^ m) + diff n t / real (fact n) * x ^ n" by simp 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

490 
thus ?thesis .. 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

491 
qed 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

492 
moreover have "(x > 0) \<Longrightarrow> ?thesis" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

493 
proof  
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

494 
assume x_greater_zero: "x > 0" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

495 
from DERIV have "\<forall>m t. m < n \<and> 0 \<le> t \<and> t \<le> x \<longrightarrow> DERIV (diff m) t :> diff (Suc m) t" by simp 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

496 
with x_greater_zero INIT2 INIT1 have "\<exists>t>0. t < x \<and> f x = (\<Sum>m = 0..<n. diff m 0 / real (fact m) * x ^ m) + diff n t / real (fact n) * x ^ n" (is "\<exists> t. ?P t") by (rule Maclaurin) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

497 
from this obtain t where "?P t" .. 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

498 
with x_greater_zero have "0 < \<bar>t\<bar> \<and> 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

499 
\<bar>t\<bar> < \<bar>x\<bar> \<and> 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

500 
f x = (\<Sum>m = 0..<n. diff m 0 / real (fact m) * x ^ m) + diff n t / real (fact n) * x ^ n" by fastsimp 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

501 
thus ?thesis .. 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

502 
qed 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

503 
ultimately show ?thesis by (fastsimp) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

504 
qed 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

505 

15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

506 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

507 
lemma Maclaurin_all_lt_objl: 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

508 
"diff 0 = f & 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

509 
(\<forall>m x. DERIV (diff m) x :> diff(Suc m) x) & 
25162  510 
x ~= 0 & n > 0 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

511 
> (\<exists>t. 0 < abs t & abs t < abs x & 
15539  512 
f x = (\<Sum>m=0..<n. (diff m 0 / real (fact m)) * x ^ m) + 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

513 
(diff n t / real (fact n)) * x ^ n)" 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

514 
by (blast intro: Maclaurin_all_lt) 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

515 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

516 
lemma Maclaurin_zero [rule_format]: 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

517 
"x = (0::real) 
25134
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents:
25112
diff
changeset

518 
==> n \<noteq> 0 > 
15539  519 
(\<Sum>m=0..<n. (diff m (0::real) / real (fact m)) * x ^ m) = 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

520 
diff 0 0" 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

521 
by (induct n, auto) 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

522 

41120
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

523 

74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

524 
lemma Maclaurin_all_le: 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

525 
assumes INIT: "diff 0 = f" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

526 
and DERIV: "\<forall>m x. DERIV (diff m) x :> diff (Suc m) x" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

527 
shows "\<exists>t. abs t \<le> abs x & 
15539  528 
f x = (\<Sum>m=0..<n. (diff m 0 / real (fact m)) * x ^ m) + 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

529 
(diff n t / real (fact n)) * x ^ n" 
41120
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

530 
proof  
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

531 
note linorder_le_less_linear [of n 0] 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

532 
thus ?thesis 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

533 
proof 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

534 
assume "n\<le> 0" with INIT show ?thesis by force 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

535 
next 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

536 
assume n_greater_zero: "n > 0" show ?thesis 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

537 
proof (cases "x = 0") 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

538 
case True 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

539 
from n_greater_zero have "n \<noteq> 0" by auto 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

540 
from True this have f_0:"(\<Sum>m = 0..<n. diff m 0 / real (fact m) * x ^ m) = diff 0 0" by (rule Maclaurin_zero) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

541 
from n_greater_zero have "n \<noteq> 0" by (rule gr_implies_not0) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

542 
hence "\<exists> m. n = Suc m" by (rule not0_implies_Suc) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

543 
with f_0 True INIT have " \<bar>0\<bar> \<le> \<bar>x\<bar> \<and> 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

544 
f x = (\<Sum>m = 0..<n. diff m 0 / real (fact m) * x ^ m) + diff n 0 / real (fact n) * x ^ n" 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

545 
by force 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

546 
thus ?thesis .. 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

547 
next 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

548 
case False 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

549 
from INIT n_greater_zero this DERIV have "\<exists>t. 0 < \<bar>t\<bar> \<and> 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

550 
\<bar>t\<bar> < \<bar>x\<bar> \<and> f x = (\<Sum>m = 0..<n. diff m 0 / real (fact m) * x ^ m) + diff n t / real (fact n) * x ^ n" (is "\<exists> t. ?P t") by (rule Maclaurin_all_lt) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

551 
from this obtain t where "?P t" .. 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

552 
hence "\<bar>t\<bar> \<le> \<bar>x\<bar> \<and> 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

553 
f x = (\<Sum>m = 0..<n. diff m 0 / real (fact m) * x ^ m) + diff n t / real (fact n) * x ^ n" by (simp add: order_less_le) 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

554 
thus ?thesis .. 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

555 
qed 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

556 
qed 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

557 
qed 
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

558 

15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

559 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

560 
lemma Maclaurin_all_le_objl: "diff 0 = f & 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

561 
(\<forall>m x. DERIV (diff m) x :> diff (Suc m) x) 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

562 
> (\<exists>t. abs t \<le> abs x & 
15539  563 
f x = (\<Sum>m=0..<n. (diff m 0 / real (fact m)) * x ^ m) + 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

564 
(diff n t / real (fact n)) * x ^ n)" 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

565 
by (blast intro: Maclaurin_all_le) 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

566 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

567 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

568 
subsection{*Version for Exponential Function*} 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

569 

25162  570 
lemma Maclaurin_exp_lt: "[ x ~= 0; n > 0 ] 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

571 
==> (\<exists>t. 0 < abs t & 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

572 
abs t < abs x & 
15539  573 
exp x = (\<Sum>m=0..<n. (x ^ m) / real (fact m)) + 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

574 
(exp t / real (fact n)) * x ^ n)" 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

575 
by (cut_tac diff = "%n. exp" and f = exp and x = x and n = n in Maclaurin_all_lt_objl, auto) 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

576 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

577 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

578 
lemma Maclaurin_exp_le: 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

579 
"\<exists>t. abs t \<le> abs x & 
15539  580 
exp x = (\<Sum>m=0..<n. (x ^ m) / real (fact m)) + 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

581 
(exp t / real (fact n)) * x ^ n" 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

582 
by (cut_tac diff = "%n. exp" and f = exp and x = x and n = n in Maclaurin_all_le_objl, auto) 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

583 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

584 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

585 
subsection{*Version for Sine Function*} 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

586 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

587 
lemma mod_exhaust_less_4: 
25134
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents:
25112
diff
changeset

588 
"m mod 4 = 0  m mod 4 = 1  m mod 4 = 2  m mod 4 = (3::nat)" 
20217
25b068a99d2b
linear arithmetic splits certain operators (e.g. min, max, abs)
webertj
parents:
19765
diff
changeset

589 
by auto 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

590 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

591 
lemma Suc_Suc_mult_two_diff_two [rule_format, simp]: 
25134
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents:
25112
diff
changeset

592 
"n\<noteq>0 > Suc (Suc (2 * n  2)) = 2*n" 
15251  593 
by (induct "n", auto) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

594 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

595 
lemma lemma_Suc_Suc_4n_diff_2 [rule_format, simp]: 
25134
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents:
25112
diff
changeset

596 
"n\<noteq>0 > Suc (Suc (4*n  2)) = 4*n" 
15251  597 
by (induct "n", auto) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

598 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

599 
lemma Suc_mult_two_diff_one [rule_format, simp]: 
25134
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents:
25112
diff
changeset

600 
"n\<noteq>0 > Suc (2 * n  1) = 2*n" 
15251  601 
by (induct "n", auto) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

602 

15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

603 

ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

604 
text{*It is unclear why so many variant results are needed.*} 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

605 

36974
b877866b5b00
remove some unnamed simp rules from Transcendental.thy; move the needed ones to MacLaurin.thy where they are used
huffman
parents:
32047
diff
changeset

606 
lemma sin_expansion_lemma: 
b877866b5b00
remove some unnamed simp rules from Transcendental.thy; move the needed ones to MacLaurin.thy where they are used
huffman
parents:
32047
diff
changeset

607 
"sin (x + real (Suc m) * pi / 2) = 
b877866b5b00
remove some unnamed simp rules from Transcendental.thy; move the needed ones to MacLaurin.thy where they are used
huffman
parents:
32047
diff
changeset

608 
cos (x + real (m) * pi / 2)" 
b877866b5b00
remove some unnamed simp rules from Transcendental.thy; move the needed ones to MacLaurin.thy where they are used
huffman
parents:
32047
diff
changeset

609 
by (simp only: cos_add sin_add real_of_nat_Suc add_divide_distrib left_distrib, auto) 
b877866b5b00
remove some unnamed simp rules from Transcendental.thy; move the needed ones to MacLaurin.thy where they are used
huffman
parents:
32047
diff
changeset

610 

15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

611 
lemma Maclaurin_sin_expansion2: 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

612 
"\<exists>t. abs t \<le> abs x & 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

613 
sin x = 
15539  614 
(\<Sum>m=0..<n. (if even m then 0 
23177  615 
else (1 ^ ((m  Suc 0) div 2)) / real (fact m)) * 
15539  616 
x ^ m) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

617 
+ ((sin(t + 1/2 * real (n) *pi) / real (fact n)) * x ^ n)" 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

618 
apply (cut_tac f = sin and n = n and x = x 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

619 
and diff = "%n x. sin (x + 1/2*real n * pi)" in Maclaurin_all_lt_objl) 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

620 
apply safe 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

621 
apply (simp (no_asm)) 
36974
b877866b5b00
remove some unnamed simp rules from Transcendental.thy; move the needed ones to MacLaurin.thy where they are used
huffman
parents:
32047
diff
changeset

622 
apply (simp (no_asm) add: sin_expansion_lemma) 
23242  623 
apply (case_tac "n", clarify, simp, simp add: lemma_STAR_sin) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

624 
apply (rule ccontr, simp) 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

625 
apply (drule_tac x = x in spec, simp) 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

626 
apply (erule ssubst) 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

627 
apply (rule_tac x = t in exI, simp) 
15536  628 
apply (rule setsum_cong[OF refl]) 
15539  629 
apply (auto simp add: sin_zero_iff odd_Suc_mult_two_ex) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

630 
done 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

631 

15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

632 
lemma Maclaurin_sin_expansion: 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

633 
"\<exists>t. sin x = 
15539  634 
(\<Sum>m=0..<n. (if even m then 0 
23177  635 
else (1 ^ ((m  Suc 0) div 2)) / real (fact m)) * 
15539  636 
x ^ m) 
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

637 
+ ((sin(t + 1/2 * real (n) *pi) / real (fact n)) * x ^ n)" 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

638 
apply (insert Maclaurin_sin_expansion2 [of x n]) 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

639 
apply (blast intro: elim:); 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

640 
done 
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

641 

15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

642 
lemma Maclaurin_sin_expansion3: 
25162  643 
"[ n > 0; 0 < x ] ==> 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

644 
\<exists>t. 0 < t & t < x & 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

645 
sin x = 
15539  646 
(\<Sum>m=0..<n. (if even m then 0 
23177  647 
else (1 ^ ((m  Suc 0) div 2)) / real (fact m)) * 
15539  648 
x ^ m) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

649 
+ ((sin(t + 1/2 * real(n) *pi) / real (fact n)) * x ^ n)" 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

650 
apply (cut_tac f = sin and n = n and h = x and diff = "%n x. sin (x + 1/2*real (n) *pi)" in Maclaurin_objl) 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

651 
apply safe 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

652 
apply simp 
36974
b877866b5b00
remove some unnamed simp rules from Transcendental.thy; move the needed ones to MacLaurin.thy where they are used
huffman
parents:
32047
diff
changeset

653 
apply (simp (no_asm) add: sin_expansion_lemma) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

654 
apply (erule ssubst) 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

655 
apply (rule_tac x = t in exI, simp) 
15536  656 
apply (rule setsum_cong[OF refl]) 
15539  657 
apply (auto simp add: sin_zero_iff odd_Suc_mult_two_ex) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

658 
done 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

659 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

660 
lemma Maclaurin_sin_expansion4: 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

661 
"0 < x ==> 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

662 
\<exists>t. 0 < t & t \<le> x & 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

663 
sin x = 
15539  664 
(\<Sum>m=0..<n. (if even m then 0 
23177  665 
else (1 ^ ((m  Suc 0) div 2)) / real (fact m)) * 
15539  666 
x ^ m) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

667 
+ ((sin(t + 1/2 * real (n) *pi) / real (fact n)) * x ^ n)" 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

668 
apply (cut_tac f = sin and n = n and h = x and diff = "%n x. sin (x + 1/2*real (n) *pi)" in Maclaurin2_objl) 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

669 
apply safe 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

670 
apply simp 
36974
b877866b5b00
remove some unnamed simp rules from Transcendental.thy; move the needed ones to MacLaurin.thy where they are used
huffman
parents:
32047
diff
changeset

671 
apply (simp (no_asm) add: sin_expansion_lemma) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

672 
apply (erule ssubst) 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

673 
apply (rule_tac x = t in exI, simp) 
15536  674 
apply (rule setsum_cong[OF refl]) 
15539  675 
apply (auto simp add: sin_zero_iff odd_Suc_mult_two_ex) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

676 
done 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

677 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

678 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

679 
subsection{*Maclaurin Expansion for Cosine Function*} 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

680 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

681 
lemma sumr_cos_zero_one [simp]: 
15539  682 
"(\<Sum>m=0..<(Suc n). 
23177  683 
(if even m then 1 ^ (m div 2)/(real (fact m)) else 0) * 0 ^ m) = 1" 
15251  684 
by (induct "n", auto) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

685 

36974
b877866b5b00
remove some unnamed simp rules from Transcendental.thy; move the needed ones to MacLaurin.thy where they are used
huffman
parents:
32047
diff
changeset

686 
lemma cos_expansion_lemma: 
b877866b5b00
remove some unnamed simp rules from Transcendental.thy; move the needed ones to MacLaurin.thy where they are used
huffman
parents:
32047
diff
changeset

687 
"cos (x + real(Suc m) * pi / 2) = sin (x + real m * pi / 2)" 
b877866b5b00
remove some unnamed simp rules from Transcendental.thy; move the needed ones to MacLaurin.thy where they are used
huffman
parents:
32047
diff
changeset

688 
by (simp only: cos_add sin_add real_of_nat_Suc left_distrib add_divide_distrib, auto) 
b877866b5b00
remove some unnamed simp rules from Transcendental.thy; move the needed ones to MacLaurin.thy where they are used
huffman
parents:
32047
diff
changeset

689 

15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

690 
lemma Maclaurin_cos_expansion: 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

691 
"\<exists>t. abs t \<le> abs x & 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

692 
cos x = 
15539  693 
(\<Sum>m=0..<n. (if even m 
23177  694 
then 1 ^ (m div 2)/(real (fact m)) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

695 
else 0) * 
15539  696 
x ^ m) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

697 
+ ((cos(t + 1/2 * real (n) *pi) / real (fact n)) * x ^ n)" 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

698 
apply (cut_tac f = cos and n = n and x = x and diff = "%n x. cos (x + 1/2*real (n) *pi)" in Maclaurin_all_lt_objl) 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

699 
apply safe 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

700 
apply (simp (no_asm)) 
36974
b877866b5b00
remove some unnamed simp rules from Transcendental.thy; move the needed ones to MacLaurin.thy where they are used
huffman
parents:
32047
diff
changeset

701 
apply (simp (no_asm) add: cos_expansion_lemma) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

702 
apply (case_tac "n", simp) 
15561  703 
apply (simp del: setsum_op_ivl_Suc) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

704 
apply (rule ccontr, simp) 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

705 
apply (drule_tac x = x in spec, simp) 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

706 
apply (erule ssubst) 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

707 
apply (rule_tac x = t in exI, simp) 
15536  708 
apply (rule setsum_cong[OF refl]) 
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

709 
apply (auto simp add: cos_zero_iff even_mult_two_ex) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

710 
done 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

711 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

712 
lemma Maclaurin_cos_expansion2: 
25162  713 
"[ 0 < x; n > 0 ] ==> 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

714 
\<exists>t. 0 < t & t < x & 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

715 
cos x = 
15539  716 
(\<Sum>m=0..<n. (if even m 
23177  717 
then 1 ^ (m div 2)/(real (fact m)) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

718 
else 0) * 
15539  719 
x ^ m) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

720 
+ ((cos(t + 1/2 * real (n) *pi) / real (fact n)) * x ^ n)" 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

721 
apply (cut_tac f = cos and n = n and h = x and diff = "%n x. cos (x + 1/2*real (n) *pi)" in Maclaurin_objl) 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

722 
apply safe 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

723 
apply simp 
36974
b877866b5b00
remove some unnamed simp rules from Transcendental.thy; move the needed ones to MacLaurin.thy where they are used
huffman
parents:
32047
diff
changeset

724 
apply (simp (no_asm) add: cos_expansion_lemma) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

725 
apply (erule ssubst) 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

726 
apply (rule_tac x = t in exI, simp) 
15536  727 
apply (rule setsum_cong[OF refl]) 
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

728 
apply (auto simp add: cos_zero_iff even_mult_two_ex) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

729 
done 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

730 

15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

731 
lemma Maclaurin_minus_cos_expansion: 
25162  732 
"[ x < 0; n > 0 ] ==> 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

733 
\<exists>t. x < t & t < 0 & 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

734 
cos x = 
15539  735 
(\<Sum>m=0..<n. (if even m 
23177  736 
then 1 ^ (m div 2)/(real (fact m)) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

737 
else 0) * 
15539  738 
x ^ m) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

739 
+ ((cos(t + 1/2 * real (n) *pi) / real (fact n)) * x ^ n)" 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

740 
apply (cut_tac f = cos and n = n and h = x and diff = "%n x. cos (x + 1/2*real (n) *pi)" in Maclaurin_minus_objl) 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

741 
apply safe 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

742 
apply simp 
36974
b877866b5b00
remove some unnamed simp rules from Transcendental.thy; move the needed ones to MacLaurin.thy where they are used
huffman
parents:
32047
diff
changeset

743 
apply (simp (no_asm) add: cos_expansion_lemma) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

744 
apply (erule ssubst) 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

745 
apply (rule_tac x = t in exI, simp) 
15536  746 
apply (rule setsum_cong[OF refl]) 
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

747 
apply (auto simp add: cos_zero_iff even_mult_two_ex) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

748 
done 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

749 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

750 
(*  *) 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

751 
(* Version for ln(1 +/ x). Where is it?? *) 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

752 
(*  *) 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

753 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

754 
lemma sin_bound_lemma: 
15081  755 
"[x = y; abs u \<le> (v::real) ] ==> \<bar>(x + u)  y\<bar> \<le> v" 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

756 
by auto 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

757 

2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

758 
lemma Maclaurin_sin_bound: 
23177  759 
"abs(sin x  (\<Sum>m=0..<n. (if even m then 0 else (1 ^ ((m  Suc 0) div 2)) / real (fact m)) * 
15081  760 
x ^ m)) \<le> inverse(real (fact n)) * \<bar>x\<bar> ^ n" 
14738  761 
proof  
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

762 
have "!! x (y::real). x \<le> 1 \<Longrightarrow> 0 \<le> y \<Longrightarrow> x * y \<le> 1 * y" 
14738  763 
by (rule_tac mult_right_mono,simp_all) 
764 
note est = this[simplified] 

22985  765 
let ?diff = "\<lambda>(n::nat) x. if n mod 4 = 0 then sin(x) else if n mod 4 = 1 then cos(x) else if n mod 4 = 2 then sin(x) else cos(x)" 
766 
have diff_0: "?diff 0 = sin" by simp 

767 
have DERIV_diff: "\<forall>m x. DERIV (?diff m) x :> ?diff (Suc m) x" 

768 
apply (clarify) 

769 
apply (subst (1 2 3) mod_Suc_eq_Suc_mod) 

770 
apply (cut_tac m=m in mod_exhaust_less_4) 

31881  771 
apply (safe, auto intro!: DERIV_intros) 
22985  772 
done 
773 
from Maclaurin_all_le [OF diff_0 DERIV_diff] 

774 
obtain t where t1: "\<bar>t\<bar> \<le> \<bar>x\<bar>" and 

775 
t2: "sin x = (\<Sum>m = 0..<n. ?diff m 0 / real (fact m) * x ^ m) + 

776 
?diff n t / real (fact n) * x ^ n" by fast 

777 
have diff_m_0: 

778 
"\<And>m. ?diff m 0 = (if even m then 0 

23177  779 
else 1 ^ ((m  Suc 0) div 2))" 
22985  780 
apply (subst even_even_mod_4_iff) 
781 
apply (cut_tac m=m in mod_exhaust_less_4) 

782 
apply (elim disjE, simp_all) 

783 
apply (safe dest!: mod_eqD, simp_all) 

784 
done 

14738  785 
show ?thesis 
22985  786 
apply (subst t2) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

787 
apply (rule sin_bound_lemma) 
15536  788 
apply (rule setsum_cong[OF refl]) 
22985  789 
apply (subst diff_m_0, simp) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

790 
apply (auto intro: mult_right_mono [where b=1, simplified] mult_right_mono 
16775
c1b87ef4a1c3
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities)
avigad
parents:
15944
diff
changeset

791 
simp add: est mult_nonneg_nonneg mult_ac divide_inverse 
16924  792 
power_abs [symmetric] abs_mult) 
14738  793 
done 
794 
qed 

795 

15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

796 
end 