author  huffman 
Fri, 19 Aug 2011 10:46:54 0700  
changeset 44308  d2a6f9af02f4 
parent 44306  33572a766836 
child 44319  806e0390de53 
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)))" 
41166
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

22 
by (rule exI[where x = "(f h  (\<Sum>m=0..<n. (j m / real (fact m)) * h^m)) * 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

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

24 

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

25 
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

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

27 

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

30 
by (subst fact_reduce_nat, auto) 

31 

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

32 
lemma Maclaurin_lemma2: 
41166
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

33 
fixes B 
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" 
41166
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

35 
and INIT : "n = Suc k" 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

36 
defines "difg \<equiv> (\<lambda>m t. diff m t  ((\<Sum>p = 0..<n  m. diff (m + p) 0 / real (fact p) * t ^ p) + 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

37 
B * (t ^ (n  m) / real (fact (n  m)))))" (is "difg \<equiv> (\<lambda>m t. diff m t  ?difg m t)") 
41120
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" 
41166
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

39 
proof (rule allI impI)+ 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

40 
fix m t assume INIT2: "m < n & 0 \<le> t & t \<le> h" 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

41 
have "DERIV (difg m) t :> diff (Suc m) t  
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

42 
((\<Sum>x = 0..<n  m. real x * t ^ (x  Suc 0) * diff (m + x) 0 / real (fact x)) + 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

43 
real (n  m) * t ^ (n  Suc m) * B / real (fact (n  m)))" unfolding difg_def 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

44 
by (auto intro!: DERIV_intros DERIV[rule_format, OF INIT2]) 
41120
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

45 
moreover 
41166
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

46 
from INIT2 have intvl: "{..<n  m} = insert 0 (Suc ` {..<n  Suc m})" and "0 < n  m" 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

47 
unfolding atLeast0LessThan[symmetric] by auto 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

48 
have "(\<Sum>x = 0..<n  m. real x * t ^ (x  Suc 0) * diff (m + x) 0 / real (fact x)) = 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

49 
(\<Sum>x = 0..<n  Suc m. real (Suc x) * t ^ x * diff (Suc m + x) 0 / real (fact (Suc x)))" 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

50 
unfolding intvl atLeast0LessThan by (subst setsum.insert) (auto simp: setsum.reindex) 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

51 
moreover 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

52 
have fact_neq_0: "\<And>x::nat. real (fact x) + real x * real (fact x) \<noteq> 0" 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

53 
by (metis fact_gt_zero_nat not_add_less1 real_of_nat_add real_of_nat_mult real_of_nat_zero_iff) 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

54 
have "\<And>x. real (Suc x) * t ^ x * diff (Suc m + x) 0 / real (fact (Suc x)) = 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

55 
diff (Suc m + x) 0 * t^x / real (fact x)" 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

56 
by (auto simp: field_simps real_of_nat_Suc fact_neq_0 intro!: nonzero_divide_eq_eq[THEN iffD2]) 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

57 
moreover 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

58 
have "real (n  m) * t ^ (n  Suc m) * B / real (fact (n  m)) = 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

59 
B * (t ^ (n  Suc m) / real (fact (n  Suc m)))" 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

60 
using `0 < n  m` by (simp add: fact_reduce_nat) 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

61 
ultimately show "DERIV (difg m) t :> difg (Suc m) t" 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

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

63 
qed 
32038  64 

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

65 
lemma Maclaurin: 
29187  66 
assumes h: "0 < h" 
67 
assumes n: "0 < n" 

68 
assumes diff_0: "diff 0 = f" 

69 
assumes diff_Suc: 

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

71 
shows 

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

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

73 
f h = 
15539  74 
setsum (%m. (diff m 0 / real (fact m)) * h ^ m) {0..<n} + 
41166
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

75 
(diff n t / real (fact n)) * h ^ n" 
29187  76 
proof  
77 
from n obtain m where m: "n = Suc m" 

41166
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

78 
by (cases n) (simp add: n) 
29187  79 

80 
obtain B where f_h: "f h = 

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

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

83 
using Maclaurin_lemma [OF h] .. 

84 

41166
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

85 
def g \<equiv> "(\<lambda>t. f t  
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

86 
(setsum (\<lambda>m. (diff m 0 / real(fact m)) * t^m) {0..<n} 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

87 
+ (B * (t^n / real(fact n)))))" 
29187  88 

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

90 
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

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

94 

41166
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

95 
def difg \<equiv> "(%m t. diff m t  
29187  96 
(setsum (%p. (diff (m + p) 0 / real (fact p)) * (t ^ p)) {0..<nm} 
41166
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

97 
+ (B * ((t ^ (n  m)) / real (fact (n  m))))))" 
29187  98 

99 
have difg_0: "difg 0 = g" 

100 
unfolding difg_def g_def by (simp add: diff_0) 

101 

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

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

41166
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

104 
using diff_Suc m unfolding difg_def by (rule Maclaurin_lemma2) 
29187  105 

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

107 
apply clarify 

108 
apply (simp add: m difg_def) 

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

110 
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

111 
apply (insert sumr_offset4 [of "Suc 0"]) 
32047  112 
apply (simp del: setsum_op_ivl_Suc fact_Suc) 
29187  113 
done 
114 

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

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

117 

118 
have differentiable_difg: 

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

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

121 

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

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

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

125 

126 
have "m < n" using m by simp 

127 

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

129 
using `m < n` 

130 
proof (induct m) 

41166
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

131 
case 0 
29187  132 
show ?case 
133 
proof (rule Rolle) 

134 
show "0 < h" by fact 

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

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

137 
by (simp add: isCont_difg n) 

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

139 
by (simp add: differentiable_difg n) 

140 
qed 

141 
next 

41166
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

142 
case (Suc m') 
29187  143 
hence "\<exists>t. 0 < t \<and> t < h \<and> DERIV (difg m') t :> 0" by simp 
144 
then obtain t where t: "0 < t" "t < h" "DERIV (difg m') t :> 0" by fast 

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

146 
proof (rule Rolle) 

147 
show "0 < t" by fact 

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

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

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

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

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

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

154 
qed 

155 
thus ?case 

156 
using `t < h` by auto 

157 
qed 

158 

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

160 

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

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

163 

164 
show ?thesis 

165 
proof (intro exI conjI) 

166 
show "0 < t" by fact 

167 
show "t < h" by fact 

168 
show "f h = 

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

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

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

32047  172 
by (simp add: m f_h difg_def del: fact_Suc) 
29187  173 
qed 
174 
qed 

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

175 

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

176 
lemma Maclaurin_objl: 
25162  177 
"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

178 
(\<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

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

180 
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

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

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

183 

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

184 

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

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

186 
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

187 
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

188 
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

189 
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

190 
(\<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

191 
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

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

193 
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

194 
next 
41166
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

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

196 
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

197 
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

198 
f h = 
41166
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

199 
(\<Sum>m = 0..<n. diff m 0 / real (fact m) * h ^ m) + diff n t / 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

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

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

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

203 

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

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

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

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

207 
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

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

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

210 
f h = 
15539  211 
(\<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

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

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

214 

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

215 
lemma Maclaurin_minus: 
41166
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

216 
assumes "h < 0" "0 < n" "diff 0 = f" 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

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

218 
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

219 
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

220 
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

221 
proof  
41166
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

222 
txt "Transform @{text ABL'} into @{text DERIV_intros} format." 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

223 
note DERIV' = DERIV_chain'[OF _ DERIV[rule_format], THEN DERIV_cong] 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

224 
from assms 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

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

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

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

228 
( 1) ^ m * diff m ( 0) / real (fact m) * ( h) ^ m) + 
41166
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

229 
( 1) ^ n * diff n ( t) / real (fact n) * ( h) ^ n" 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

230 
by (intro Maclaurin) (auto intro!: DERIV_intros DERIV') 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

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

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

233 
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

234 
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

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

236 
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

237 
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

238 
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

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

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

241 
(\<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

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

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

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

245 

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

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

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

249 
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

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

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

252 
f h = 
15539  253 
(\<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

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

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

256 

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

257 

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

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

259 

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

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

261 

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

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

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

265 
(\<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

266 
diff n 0 * 0 ^ n / real (fact n)" 
41166
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

267 
by (induct "n") auto 
14738  268 

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

269 
lemma Maclaurin_bi_le: 
41166
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

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

271 
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

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

273 
f x = 
15539  274 
(\<Sum>m=0..<n. diff m 0 / real (fact m) * x ^ m) + 
41166
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

275 
diff n t / real (fact n) * x ^ n" (is "\<exists>t. _ \<and> f x = ?f x t") 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

276 
proof cases 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

277 
assume "n = 0" with `diff 0 = f` show ?thesis by force 
41120
74e41b2d48ea
adding an Isar version of the MacLaurin theorem from some students' work in 2005
bulwahn
parents:
36974
diff
changeset

278 
next 
41166
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

279 
assume "n \<noteq> 0" 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

280 
show ?thesis 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

281 
proof (cases rule: linorder_cases) 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

282 
assume "x = 0" with `n \<noteq> 0` `diff 0 = f` DERIV 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

283 
have "\<bar>0\<bar> \<le> \<bar>x\<bar> \<and> f x = ?f x 0" by (force simp add: Maclaurin_bi_le_lemma) 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

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

285 
next 
41166
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

286 
assume "x < 0" 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

287 
with `n \<noteq> 0` DERIV 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

288 
have "\<exists>t>x. t < 0 \<and> diff 0 x = ?f x t" by (intro Maclaurin_minus) auto 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

289 
then guess t .. 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

290 
with `x < 0` `diff 0 = f` have "\<bar>t\<bar> \<le> \<bar>x\<bar> \<and> f x = ?f x t" by simp 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

291 
thus ?thesis .. 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

292 
next 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

293 
assume "x > 0" 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

294 
with `n \<noteq> 0` `diff 0 = f` DERIV 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

295 
have "\<exists>t>0. t < x \<and> diff 0 x = ?f x t" by (intro Maclaurin) auto 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

296 
then guess t .. 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

297 
with `x > 0` `diff 0 = f` have "\<bar>t\<bar> \<le> \<bar>x\<bar> \<and> f x = ?f x t" by simp 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

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

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

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

301 

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

302 
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

303 
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

304 
and DERIV: "\<forall>m x. DERIV (diff m) x :> diff(Suc m) x" 
41166
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

305 
shows "\<exists>t. 0 < abs t & abs t < abs x & f x = 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

306 
(\<Sum>m=0..<n. (diff m 0 / real (fact m)) * x ^ m) + 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

307 
(diff n t / real (fact n)) * x ^ n" (is "\<exists>t. _ \<and> _ \<and> f x = ?f x t") 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

308 
proof (cases rule: linorder_cases) 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

309 
assume "x = 0" with INIT3 show "?thesis".. 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

310 
next 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

311 
assume "x < 0" 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

312 
with assms have "\<exists>t>x. t < 0 \<and> f x = ?f x t" by (intro Maclaurin_minus) auto 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

313 
then guess t .. 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

314 
with `x < 0` have "0 < \<bar>t\<bar> \<and> \<bar>t\<bar> < \<bar>x\<bar> \<and> f x = ?f x t" by simp 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

315 
thus ?thesis .. 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

316 
next 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

317 
assume "x > 0" 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

318 
with assms have "\<exists>t>0. t < x \<and> f x = ?f x t " by (intro Maclaurin) auto 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

319 
then guess t .. 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

320 
with `x > 0` have "0 < \<bar>t\<bar> \<and> \<bar>t\<bar> < \<bar>x\<bar> \<and> f x = ?f x t" by simp 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

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

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

323 

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

324 

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

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

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

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

329 
> (\<exists>t. 0 < abs t & abs t < abs x & 
15539  330 
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

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

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

333 

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

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

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

336 
==> n \<noteq> 0 > 
15539  337 
(\<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

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

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

340 

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

341 

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

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

343 
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

344 
and DERIV: "\<forall>m x. DERIV (diff m) x :> diff (Suc m) x" 
41166
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

345 
shows "\<exists>t. abs t \<le> abs x & f x = 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

346 
(\<Sum>m=0..<n. (diff m 0 / real (fact m)) * x ^ m) + 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

347 
(diff n t / real (fact n)) * x ^ n" (is "\<exists>t. _ \<and> f x = ?f x t") 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

348 
proof cases 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

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

350 
next 
41166
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

351 
assume "n \<noteq> 0" 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

352 
show ?thesis 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

353 
proof cases 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

354 
assume "x = 0" 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

355 
with `n \<noteq> 0` have "(\<Sum>m = 0..<n. diff m 0 / real (fact m) * x ^ m) = diff 0 0" 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

356 
by (intro Maclaurin_zero) auto 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

357 
with INIT `x = 0` `n \<noteq> 0` have " \<bar>0\<bar> \<le> \<bar>x\<bar> \<and> f x = ?f x 0" by force 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

358 
thus ?thesis .. 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

359 
next 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

360 
assume "x \<noteq> 0" 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

361 
with INIT `n \<noteq> 0` DERIV have "\<exists>t. 0 < \<bar>t\<bar> \<and> \<bar>t\<bar> < \<bar>x\<bar> \<and> f x = ?f x t" 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

362 
by (intro Maclaurin_all_lt) auto 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

363 
then guess t .. 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

364 
hence "\<bar>t\<bar> \<le> \<bar>x\<bar> \<and> f x = ?f x t" by simp 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

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

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

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

368 

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

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

370 
(\<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

371 
> (\<exists>t. abs t \<le> abs x & 
15539  372 
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

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

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

375 

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

376 

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

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

378 

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

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

381 
abs t < abs x & 
15539  382 
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

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

384 
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

385 

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

386 

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

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

388 
"\<exists>t. abs t \<le> abs x & 
15539  389 
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

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

391 
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

392 

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

393 

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

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

395 

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

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

397 
"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

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

399 

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

400 
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

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

403 

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

404 
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

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

407 

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

408 
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

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

411 

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

412 

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

413 
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

414 

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

415 
lemma sin_expansion_lemma: 
41166
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

416 
"sin (x + real (Suc m) * pi / 2) = 
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

417 
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

418 
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

419 

44306
33572a766836
fold definitions of sin_coeff and cos_coeff in Maclaurin lemmas
huffman
parents:
41166
diff
changeset

420 
lemma sin_coeff_0 [simp]: "sin_coeff 0 = 0" 
33572a766836
fold definitions of sin_coeff and cos_coeff in Maclaurin lemmas
huffman
parents:
41166
diff
changeset

421 
unfolding sin_coeff_def by simp (* TODO: move *) 
33572a766836
fold definitions of sin_coeff and cos_coeff in Maclaurin lemmas
huffman
parents:
41166
diff
changeset

422 

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

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

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

425 
sin x = 
44306
33572a766836
fold definitions of sin_coeff and cos_coeff in Maclaurin lemmas
huffman
parents:
41166
diff
changeset

426 
(\<Sum>m=0..<n. sin_coeff m * x ^ m) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

427 
+ ((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

428 
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

429 
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

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

431 
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

432 
apply (simp (no_asm) add: sin_expansion_lemma) 
44308
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
huffman
parents:
44306
diff
changeset

433 
apply (force intro!: DERIV_intros) 
44306
33572a766836
fold definitions of sin_coeff and cos_coeff in Maclaurin lemmas
huffman
parents:
41166
diff
changeset

434 
apply (subst (asm) setsum_0', clarify, case_tac "a", simp, simp) 
33572a766836
fold definitions of sin_coeff and cos_coeff in Maclaurin lemmas
huffman
parents:
41166
diff
changeset

435 
apply (cases n, simp, simp) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

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

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

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

439 
apply (rule_tac x = t in exI, simp) 
15536  440 
apply (rule setsum_cong[OF refl]) 
44306
33572a766836
fold definitions of sin_coeff and cos_coeff in Maclaurin lemmas
huffman
parents:
41166
diff
changeset

441 
apply (auto simp add: sin_coeff_def sin_zero_iff odd_Suc_mult_two_ex) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

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

443 

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

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

445 
"\<exists>t. sin x = 
44306
33572a766836
fold definitions of sin_coeff and cos_coeff in Maclaurin lemmas
huffman
parents:
41166
diff
changeset

446 
(\<Sum>m=0..<n. sin_coeff m * x ^ m) 
15234
ec91a90c604e
simplification tweaks for better arithmetic reasoning
paulson
parents:
15229
diff
changeset

447 
+ ((sin(t + 1/2 * real (n) *pi) / real (fact n)) * x ^ n)" 
41166
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

448 
apply (insert Maclaurin_sin_expansion2 [of x n]) 
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

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

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

451 

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

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

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

455 
sin x = 
44306
33572a766836
fold definitions of sin_coeff and cos_coeff in Maclaurin lemmas
huffman
parents:
41166
diff
changeset

456 
(\<Sum>m=0..<n. sin_coeff m * x ^ m) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

457 
+ ((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

458 
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

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

460 
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

461 
apply (simp (no_asm) add: sin_expansion_lemma) 
44308
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
huffman
parents:
44306
diff
changeset

462 
apply (force intro!: DERIV_intros) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

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

464 
apply (rule_tac x = t in exI, simp) 
15536  465 
apply (rule setsum_cong[OF refl]) 
44306
33572a766836
fold definitions of sin_coeff and cos_coeff in Maclaurin lemmas
huffman
parents:
41166
diff
changeset

466 
apply (auto simp add: sin_coeff_def sin_zero_iff odd_Suc_mult_two_ex) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

467 
done 
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_sin_expansion4: 
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

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

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

472 
sin x = 
44306
33572a766836
fold definitions of sin_coeff and cos_coeff in Maclaurin lemmas
huffman
parents:
41166
diff
changeset

473 
(\<Sum>m=0..<n. sin_coeff m * x ^ m) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

474 
+ ((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

475 
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

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

477 
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

478 
apply (simp (no_asm) add: sin_expansion_lemma) 
44308
d2a6f9af02f4
Transcendental.thy: remove several unused lemmas and simplify some proofs
huffman
parents:
44306
diff
changeset

479 
apply (force intro!: DERIV_intros) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

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

481 
apply (rule_tac x = t in exI, simp) 
15536  482 
apply (rule setsum_cong[OF refl]) 
44306
33572a766836
fold definitions of sin_coeff and cos_coeff in Maclaurin lemmas
huffman
parents:
41166
diff
changeset

483 
apply (auto simp add: sin_coeff_def sin_zero_iff odd_Suc_mult_two_ex) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

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

485 

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

486 

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

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

488 

44306
33572a766836
fold definitions of sin_coeff and cos_coeff in Maclaurin lemmas
huffman
parents:
41166
diff
changeset

489 
lemma cos_coeff_0 [simp]: "cos_coeff 0 = 1" 
33572a766836
fold definitions of sin_coeff and cos_coeff in Maclaurin lemmas
huffman
parents:
41166
diff
changeset

490 
unfolding cos_coeff_def by simp (* TODO: move *) 
33572a766836
fold definitions of sin_coeff and cos_coeff in Maclaurin lemmas
huffman
parents:
41166
diff
changeset

491 

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

492 
lemma sumr_cos_zero_one [simp]: 
44306
33572a766836
fold definitions of sin_coeff and cos_coeff in Maclaurin lemmas
huffman
parents:
41166
diff
changeset

493 
"(\<Sum>m=0..<(Suc n). cos_coeff m * 0 ^ m) = 1" 
15251  494 
by (induct "n", auto) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

495 

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

496 
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

497 
"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

498 
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

499 

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

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

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

502 
cos x = 
44306
33572a766836
fold definitions of sin_coeff and cos_coeff in Maclaurin lemmas
huffman
parents:
41166
diff
changeset

503 
(\<Sum>m=0..<n. cos_coeff m * x ^ m) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

504 
+ ((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

505 
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

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

507 
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

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

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

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

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

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

514 
apply (rule_tac x = t in exI, simp) 
15536  515 
apply (rule setsum_cong[OF refl]) 
44306
33572a766836
fold definitions of sin_coeff and cos_coeff in Maclaurin lemmas
huffman
parents:
41166
diff
changeset

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

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

518 

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

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

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

522 
cos x = 
44306
33572a766836
fold definitions of sin_coeff and cos_coeff in Maclaurin lemmas
huffman
parents:
41166
diff
changeset

523 
(\<Sum>m=0..<n. cos_coeff m * x ^ m) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

524 
+ ((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

525 
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

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

527 
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

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

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

530 
apply (rule_tac x = t in exI, simp) 
15536  531 
apply (rule setsum_cong[OF refl]) 
44306
33572a766836
fold definitions of sin_coeff and cos_coeff in Maclaurin lemmas
huffman
parents:
41166
diff
changeset

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

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

534 

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

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

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

538 
cos x = 
44306
33572a766836
fold definitions of sin_coeff and cos_coeff in Maclaurin lemmas
huffman
parents:
41166
diff
changeset

539 
(\<Sum>m=0..<n. cos_coeff m * x ^ m) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

540 
+ ((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

541 
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

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

543 
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

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

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

546 
apply (rule_tac x = t in exI, simp) 
15536  547 
apply (rule setsum_cong[OF refl]) 
44306
33572a766836
fold definitions of sin_coeff and cos_coeff in Maclaurin lemmas
huffman
parents:
41166
diff
changeset

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

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

550 

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

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

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

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

554 

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

555 
lemma sin_bound_lemma: 
15081  556 
"[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

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

558 

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

559 
lemma Maclaurin_sin_bound: 
44306
33572a766836
fold definitions of sin_coeff and cos_coeff in Maclaurin lemmas
huffman
parents:
41166
diff
changeset

560 
"abs(sin x  (\<Sum>m=0..<n. sin_coeff m * x ^ m)) 
33572a766836
fold definitions of sin_coeff and cos_coeff in Maclaurin lemmas
huffman
parents:
41166
diff
changeset

561 
\<le> inverse(real (fact n)) * \<bar>x\<bar> ^ n" 
14738  562 
proof  
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

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

22985  566 
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)" 
567 
have diff_0: "?diff 0 = sin" by simp 

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

569 
apply (clarify) 

570 
apply (subst (1 2 3) mod_Suc_eq_Suc_mod) 

571 
apply (cut_tac m=m in mod_exhaust_less_4) 

31881  572 
apply (safe, auto intro!: DERIV_intros) 
22985  573 
done 
574 
from Maclaurin_all_le [OF diff_0 DERIV_diff] 

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

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

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

578 
have diff_m_0: 

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

23177  580 
else 1 ^ ((m  Suc 0) div 2))" 
22985  581 
apply (subst even_even_mod_4_iff) 
582 
apply (cut_tac m=m in mod_exhaust_less_4) 

583 
apply (elim disjE, simp_all) 

584 
apply (safe dest!: mod_eqD, simp_all) 

585 
done 

14738  586 
show ?thesis 
44306
33572a766836
fold definitions of sin_coeff and cos_coeff in Maclaurin lemmas
huffman
parents:
41166
diff
changeset

587 
unfolding sin_coeff_def 
22985  588 
apply (subst t2) 
15079
2ef899e4526d
conversion of Hyperreal/MacLaurin_lemmas to Isar script
paulson
parents:
14738
diff
changeset

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

592 
apply (auto intro: mult_right_mono [where b=1, simplified] mult_right_mono 
41166
4b2a457b17e8
beautify MacLaurin proofs; make better use of DERIV_intros
hoelzl
parents:
41120
diff
changeset

593 
simp add: est mult_nonneg_nonneg mult_ac divide_inverse 
16924  594 
power_abs [symmetric] abs_mult) 
14738  595 
done 
596 
qed 

597 

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

598 
end 