--- a/src/HOL/Deriv.thy Thu Jul 28 17:16:16 2016 +0200
+++ b/src/HOL/Deriv.thy Thu Jul 28 20:39:51 2016 +0200
@@ -1,26 +1,23 @@
-(* Title : Deriv.thy
- Author : Jacques D. Fleuriot
- Copyright : 1998 University of Cambridge
- Author : Brian Huffman
- Conversion to Isar and new proofs by Lawrence C Paulson, 2004
- GMVT by Benjamin Porter, 2005
+(* Title: HOL/Deriv.thy
+ Author: Jacques D. Fleuriot, University of Cambridge, 1998
+ Author: Brian Huffman
+ Author: Lawrence C Paulson, 2004
+ Author: Benjamin Porter, 2005
*)
-section\<open>Differentiation\<close>
+section \<open>Differentiation\<close>
theory Deriv
-imports Limits
+ imports Limits
begin
subsection \<open>Frechet derivative\<close>
-definition
- has_derivative :: "('a::real_normed_vector \<Rightarrow> 'b::real_normed_vector) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'a filter \<Rightarrow> bool"
- (infix "(has'_derivative)" 50)
-where
- "(f has_derivative f') F \<longleftrightarrow>
- (bounded_linear f' \<and>
- ((\<lambda>y. ((f y - f (Lim F (\<lambda>x. x))) - f' (y - Lim F (\<lambda>x. x))) /\<^sub>R norm (y - Lim F (\<lambda>x. x))) \<longlongrightarrow> 0) F)"
+definition has_derivative :: "('a::real_normed_vector \<Rightarrow> 'b::real_normed_vector) \<Rightarrow>
+ ('a \<Rightarrow> 'b) \<Rightarrow> 'a filter \<Rightarrow> bool" (infix "(has'_derivative)" 50)
+ where "(f has_derivative f') F \<longleftrightarrow>
+ bounded_linear f' \<and>
+ ((\<lambda>y. ((f y - f (Lim F (\<lambda>x. x))) - f' (y - Lim F (\<lambda>x. x))) /\<^sub>R norm (y - Lim F (\<lambda>x. x))) \<longlongrightarrow> 0) F"
text \<open>
Usually the filter @{term F} is @{term "at x within s"}. @{term "(f has_derivative D)
@@ -32,22 +29,19 @@
lemma has_derivative_eq_rhs: "(f has_derivative f') F \<Longrightarrow> f' = g' \<Longrightarrow> (f has_derivative g') F"
by simp
-definition
- has_field_derivative :: "('a::real_normed_field \<Rightarrow> 'a) \<Rightarrow> 'a \<Rightarrow> 'a filter \<Rightarrow> bool"
- (infix "(has'_field'_derivative)" 50)
-where
- "(f has_field_derivative D) F \<longleftrightarrow> (f has_derivative op * D) F"
+definition has_field_derivative :: "('a::real_normed_field \<Rightarrow> 'a) \<Rightarrow> 'a \<Rightarrow> 'a filter \<Rightarrow> bool"
+ (infix "(has'_field'_derivative)" 50)
+ where "(f has_field_derivative D) F \<longleftrightarrow> (f has_derivative op * D) F"
lemma DERIV_cong: "(f has_field_derivative X) F \<Longrightarrow> X = Y \<Longrightarrow> (f has_field_derivative Y) F"
by simp
-definition
- has_vector_derivative :: "(real \<Rightarrow> 'b::real_normed_vector) \<Rightarrow> 'b \<Rightarrow> real filter \<Rightarrow> bool"
- (infix "has'_vector'_derivative" 50)
-where
- "(f has_vector_derivative f') net \<longleftrightarrow> (f has_derivative (\<lambda>x. x *\<^sub>R f')) net"
+definition has_vector_derivative :: "(real \<Rightarrow> 'b::real_normed_vector) \<Rightarrow> 'b \<Rightarrow> real filter \<Rightarrow> bool"
+ (infix "has'_vector'_derivative" 50)
+ where "(f has_vector_derivative f') net \<longleftrightarrow> (f has_derivative (\<lambda>x. x *\<^sub>R f')) net"
-lemma has_vector_derivative_eq_rhs: "(f has_vector_derivative X) F \<Longrightarrow> X = Y \<Longrightarrow> (f has_vector_derivative Y) F"
+lemma has_vector_derivative_eq_rhs:
+ "(f has_vector_derivative X) F \<Longrightarrow> X = Y \<Longrightarrow> (f has_vector_derivative Y) F"
by simp
named_theorems derivative_intros "structural introduction rules for derivatives"
@@ -70,8 +64,7 @@
abbreviation (input)
FDERIV :: "('a::real_normed_vector \<Rightarrow> 'b::real_normed_vector) \<Rightarrow> 'a \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> bool"
("(FDERIV (_)/ (_)/ :> (_))" [1000, 1000, 60] 60)
-where
- "FDERIV f x :> f' \<equiv> (f has_derivative f') (at x)"
+ where "FDERIV f x :> f' \<equiv> (f has_derivative f') (at x)"
lemma has_derivative_bounded_linear: "(f has_derivative f') F \<Longrightarrow> bounded_linear f'"
by (simp add: has_derivative_def)
@@ -94,7 +87,7 @@
"(g has_derivative g') F \<Longrightarrow> ((\<lambda>x. f (g x)) has_derivative (\<lambda>x. f (g' x))) F"
unfolding has_derivative_def
apply safe
- apply (erule bounded_linear_compose [OF bounded_linear])
+ apply (erule bounded_linear_compose [OF bounded_linear])
apply (drule tendsto)
apply (simp add: scaleR diff add zero)
done
@@ -112,7 +105,8 @@
bounded_linear.has_derivative [OF bounded_linear_mult_left]
lemma has_derivative_add[simp, derivative_intros]:
- assumes f: "(f has_derivative f') F" and g: "(g has_derivative g') F"
+ assumes f: "(f has_derivative f') F"
+ and g: "(g has_derivative g') F"
shows "((\<lambda>x. f x + g x) has_derivative (\<lambda>x. f' x + g' x)) F"
unfolding has_derivative_def
proof safe
@@ -127,16 +121,22 @@
lemma has_derivative_setsum[simp, derivative_intros]:
assumes f: "\<And>i. i \<in> I \<Longrightarrow> (f i has_derivative f' i) F"
shows "((\<lambda>x. \<Sum>i\<in>I. f i x) has_derivative (\<lambda>x. \<Sum>i\<in>I. f' i x)) F"
-proof cases
- assume "finite I" from this f show ?thesis
+proof (cases "finite I")
+ case True
+ from this f show ?thesis
by induct (simp_all add: f)
-qed simp
+next
+ case False
+ then show ?thesis by simp
+qed
-lemma has_derivative_minus[simp, derivative_intros]: "(f has_derivative f') F \<Longrightarrow> ((\<lambda>x. - f x) has_derivative (\<lambda>x. - f' x)) F"
+lemma has_derivative_minus[simp, derivative_intros]:
+ "(f has_derivative f') F \<Longrightarrow> ((\<lambda>x. - f x) has_derivative (\<lambda>x. - f' x)) F"
using has_derivative_scaleR_right[of f f' F "-1"] by simp
lemma has_derivative_diff[simp, derivative_intros]:
- "(f has_derivative f') F \<Longrightarrow> (g has_derivative g') F \<Longrightarrow> ((\<lambda>x. f x - g x) has_derivative (\<lambda>x. f' x - g' x)) F"
+ "(f has_derivative f') F \<Longrightarrow> (g has_derivative g') F \<Longrightarrow>
+ ((\<lambda>x. f x - g x) has_derivative (\<lambda>x. f' x - g' x)) F"
by (simp only: diff_conv_add_uminus has_derivative_add has_derivative_minus)
lemma has_derivative_at_within:
@@ -146,12 +146,13 @@
lemma has_derivative_iff_norm:
"(f has_derivative f') (at x within s) \<longleftrightarrow>
- (bounded_linear f' \<and> ((\<lambda>y. norm ((f y - f x) - f' (y - x)) / norm (y - x)) \<longlongrightarrow> 0) (at x within s))"
+ bounded_linear f' \<and> ((\<lambda>y. norm ((f y - f x) - f' (y - x)) / norm (y - x)) \<longlongrightarrow> 0) (at x within s)"
using tendsto_norm_zero_iff[of _ "at x within s", where 'b="'b", symmetric]
by (simp add: has_derivative_at_within divide_inverse ac_simps)
lemma has_derivative_at:
- "(f has_derivative D) (at x) \<longleftrightarrow> (bounded_linear D \<and> (\<lambda>h. norm (f (x + h) - f x - D h) / norm h) \<midarrow>0\<rightarrow> 0)"
+ "(f has_derivative D) (at x) \<longleftrightarrow>
+ (bounded_linear D \<and> (\<lambda>h. norm (f (x + h) - f x - D h) / norm h) \<midarrow>0\<rightarrow> 0)"
unfolding has_derivative_iff_norm LIM_offset_zero_iff[of _ _ x] by simp
lemma field_has_derivative_at:
@@ -167,13 +168,16 @@
done
lemma has_derivativeI:
- "bounded_linear f' \<Longrightarrow> ((\<lambda>y. ((f y - f x) - f' (y - x)) /\<^sub>R norm (y - x)) \<longlongrightarrow> 0) (at x within s) \<Longrightarrow>
- (f has_derivative f') (at x within s)"
+ "bounded_linear f' \<Longrightarrow>
+ ((\<lambda>y. ((f y - f x) - f' (y - x)) /\<^sub>R norm (y - x)) \<longlongrightarrow> 0) (at x within s) \<Longrightarrow>
+ (f has_derivative f') (at x within s)"
by (simp add: has_derivative_at_within)
lemma has_derivativeI_sandwich:
- assumes e: "0 < e" and bounded: "bounded_linear f'"
- and sandwich: "(\<And>y. y \<in> s \<Longrightarrow> y \<noteq> x \<Longrightarrow> dist y x < e \<Longrightarrow> norm ((f y - f x) - f' (y - x)) / norm (y - x) \<le> H y)"
+ assumes e: "0 < e"
+ and bounded: "bounded_linear f'"
+ and sandwich: "(\<And>y. y \<in> s \<Longrightarrow> y \<noteq> x \<Longrightarrow> dist y x < e \<Longrightarrow>
+ norm ((f y - f x) - f' (y - x)) / norm (y - x) \<le> H y)"
and "(H \<longlongrightarrow> 0) (at x within s)"
shows "(f has_derivative f') (at x within s)"
unfolding has_derivative_iff_norm
@@ -186,10 +190,11 @@
qed (auto simp: le_divide_eq)
qed fact
-lemma has_derivative_subset: "(f has_derivative f') (at x within s) \<Longrightarrow> t \<subseteq> s \<Longrightarrow> (f has_derivative f') (at x within t)"
+lemma has_derivative_subset:
+ "(f has_derivative f') (at x within s) \<Longrightarrow> t \<subseteq> s \<Longrightarrow> (f has_derivative f') (at x within t)"
by (auto simp add: has_derivative_iff_norm intro: tendsto_within_subset)
-lemmas has_derivative_within_subset = has_derivative_subset
+lemmas has_derivative_within_subset = has_derivative_subset
subsection \<open>Continuity\<close>
@@ -198,7 +203,8 @@
assumes f: "(f has_derivative f') (at x within s)"
shows "continuous (at x within s) f"
proof -
- from f interpret F: bounded_linear f' by (rule has_derivative_bounded_linear)
+ from f interpret F: bounded_linear f'
+ by (rule has_derivative_bounded_linear)
note F.tendsto[tendsto_intros]
let ?L = "\<lambda>f. (f \<longlongrightarrow> 0) (at x within s)"
have "?L (\<lambda>y. norm ((f y - f x) - f' (y - x)) / norm (y - x))"
@@ -217,21 +223,27 @@
by (simp add: continuous_within)
qed
+
subsection \<open>Composition\<close>
-lemma tendsto_at_iff_tendsto_nhds_within: "f x = y \<Longrightarrow> (f \<longlongrightarrow> y) (at x within s) \<longleftrightarrow> (f \<longlongrightarrow> y) (inf (nhds x) (principal s))"
+lemma tendsto_at_iff_tendsto_nhds_within:
+ "f x = y \<Longrightarrow> (f \<longlongrightarrow> y) (at x within s) \<longleftrightarrow> (f \<longlongrightarrow> y) (inf (nhds x) (principal s))"
unfolding tendsto_def eventually_inf_principal eventually_at_filter
by (intro ext all_cong imp_cong) (auto elim!: eventually_mono)
lemma has_derivative_in_compose:
assumes f: "(f has_derivative f') (at x within s)"
- assumes g: "(g has_derivative g') (at (f x) within (f`s))"
+ and g: "(g has_derivative g') (at (f x) within (f`s))"
shows "((\<lambda>x. g (f x)) has_derivative (\<lambda>x. g' (f' x))) (at x within s)"
proof -
- from f interpret F: bounded_linear f' by (rule has_derivative_bounded_linear)
- from g interpret G: bounded_linear g' by (rule has_derivative_bounded_linear)
- from F.bounded obtain kF where kF: "\<And>x. norm (f' x) \<le> norm x * kF" by fast
- from G.bounded obtain kG where kG: "\<And>x. norm (g' x) \<le> norm x * kG" by fast
+ from f interpret F: bounded_linear f'
+ by (rule has_derivative_bounded_linear)
+ from g interpret G: bounded_linear g'
+ by (rule has_derivative_bounded_linear)
+ from F.bounded obtain kF where kF: "\<And>x. norm (f' x) \<le> norm x * kF"
+ by fast
+ from G.bounded obtain kG where kG: "\<And>x. norm (g' x) \<le> norm x * kG"
+ by fast
note G.tendsto[tendsto_intros]
let ?L = "\<lambda>f. (f \<longlongrightarrow> 0) (at x within s)"
@@ -246,7 +258,8 @@
show "bounded_linear (\<lambda>x. g' (f' x))"
using f g by (blast intro: bounded_linear_compose has_derivative_bounded_linear)
next
- fix y::'a assume neq: "y \<noteq> x"
+ fix y :: 'a
+ assume neq: "y \<noteq> x"
have "?N ?gf ?gf' x y = norm (g' (?D f f' x y) + ?D g g' (f x) (f y)) / norm (y - x)"
by (simp add: G.diff G.add field_simps)
also have "\<dots> \<le> norm (g' (?D f f' x y)) / norm (y - x) + Ng y * (norm (f y - f x) / norm (y - x))"
@@ -261,7 +274,7 @@
using kF by (intro add_mono) simp
finally show "norm (f y - f x) / norm (y - x) \<le> Nf y + kF"
by (simp add: neq Nf_def field_simps)
- qed (insert kG, simp_all add: Ng_def Nf_def neq zero_le_divide_iff field_simps)
+ qed (use kG in \<open>simp_all add: Ng_def Nf_def neq zero_le_divide_iff field_simps\<close>)
finally show "?N ?gf ?gf' x y \<le> Nf y * kG + Ng y * (Nf y + kF)" .
next
have [tendsto_intros]: "?L Nf"
@@ -296,8 +309,9 @@
from bounded_linear.bounded [OF has_derivative_bounded_linear [OF f]]
obtain KF where norm_F: "\<And>x. norm (f' x) \<le> norm x * KF" by fast
- from pos_bounded obtain K where K: "0 < K" and norm_prod:
- "\<And>a b. norm (a ** b) \<le> norm a * norm b * K" by fast
+ from pos_bounded obtain K
+ where K: "0 < K" and norm_prod: "\<And>a b. norm (a ** b) \<le> norm a * norm b * K"
+ by fast
let ?D = "\<lambda>f f' y. f y - f x - f' (y - x)"
let ?N = "\<lambda>f f' y. norm (?D f f' y) / norm (y - x)"
define Ng where "Ng = ?N g g'"
@@ -323,8 +337,10 @@
then show "(?fun2 \<longlongrightarrow> 0) ?F"
by simp
next
- fix y::'d assume "y \<noteq> x"
- have "?fun1 y = norm (f x ** ?D g g' y + ?D f f' y ** g y + f' (y - x) ** (g y - g x)) / norm (y - x)"
+ fix y :: 'd
+ assume "y \<noteq> x"
+ have "?fun1 y =
+ norm (f x ** ?D g g' y + ?D f f' y ** g y + f' (y - x) ** (g y - g x)) / norm (y - x)"
by (simp add: diff_left diff_right add_left add_right field_simps)
also have "\<dots> \<le> (norm (f x) * norm (?D g g' y) * K + norm (?D f f' y) * norm (g y) * K +
norm (y - x) * KF * norm (g y - g x) * K) / norm (y - x)"
@@ -343,22 +359,30 @@
lemmas has_derivative_scaleR[simp, derivative_intros] = bounded_bilinear.FDERIV[OF bounded_bilinear_scaleR]
lemma has_derivative_setprod[simp, derivative_intros]:
- fixes f :: "'i \<Rightarrow> 'a :: real_normed_vector \<Rightarrow> 'b :: real_normed_field"
+ fixes f :: "'i \<Rightarrow> 'a::real_normed_vector \<Rightarrow> 'b::real_normed_field"
assumes f: "\<And>i. i \<in> I \<Longrightarrow> (f i has_derivative f' i) (at x within s)"
shows "((\<lambda>x. \<Prod>i\<in>I. f i x) has_derivative (\<lambda>y. \<Sum>i\<in>I. f' i y * (\<Prod>j\<in>I - {i}. f j x))) (at x within s)"
-proof cases
- assume "finite I" from this f show ?thesis
+proof (cases "finite I")
+ case True
+ from this f show ?thesis
proof induct
+ case empty
+ then show ?case by simp
+ next
case (insert i I)
let ?P = "\<lambda>y. f i x * (\<Sum>i\<in>I. f' i y * (\<Prod>j\<in>I - {i}. f j x)) + (f' i y) * (\<Prod>i\<in>I. f i x)"
have "((\<lambda>x. f i x * (\<Prod>i\<in>I. f i x)) has_derivative ?P) (at x within s)"
using insert by (intro has_derivative_mult) auto
also have "?P = (\<lambda>y. \<Sum>i'\<in>insert i I. f' i' y * (\<Prod>j\<in>insert i I - {i'}. f j x))"
- using insert(1,2) by (auto simp add: setsum_right_distrib insert_Diff_if intro!: ext setsum.cong)
+ using insert(1,2)
+ by (auto simp add: setsum_right_distrib insert_Diff_if intro!: ext setsum.cong)
finally show ?case
using insert by simp
- qed simp
-qed simp
+ qed
+next
+ case False
+ then show ?thesis by simp
+qed
lemma has_derivative_power[simp, derivative_intros]:
fixes f :: "'a :: real_normed_vector \<Rightarrow> 'b :: real_normed_field"
@@ -370,7 +394,7 @@
fixes x :: "'a::real_normed_div_algebra"
assumes x: "x \<noteq> 0"
shows "(inverse has_derivative (\<lambda>h. - (inverse x * h * inverse x))) (at x within s)"
- (is "(?inv has_derivative ?f) _")
+ (is "(?inv has_derivative ?f) _")
proof (rule has_derivativeI_sandwich)
show "bounded_linear (\<lambda>h. - (?inv x * h * ?inv x))"
apply (rule bounded_linear_minus)
@@ -378,21 +402,21 @@
apply (rule bounded_linear_const_mult)
apply (rule bounded_linear_ident)
done
-next
show "0 < norm x" using x by simp
-next
show "((\<lambda>y. norm (?inv y - ?inv x) * norm (?inv x)) \<longlongrightarrow> 0) (at x within s)"
apply (rule tendsto_mult_left_zero)
apply (rule tendsto_norm_zero)
apply (rule LIM_zero)
apply (rule tendsto_inverse)
- apply (rule tendsto_ident_at)
+ apply (rule tendsto_ident_at)
apply (rule x)
done
next
- fix y::'a assume h: "y \<noteq> x" "dist y x < norm x"
+ fix y :: 'a
+ assume h: "y \<noteq> x" "dist y x < norm x"
then have "y \<noteq> 0" by auto
- have "norm (?inv y - ?inv x - ?f (y -x)) / norm (y - x) = norm ((?inv y - ?inv x) * (y - x) * ?inv x) / norm (y - x)"
+ have "norm (?inv y - ?inv x - ?f (y -x)) / norm (y - x) =
+ norm ((?inv y - ?inv x) * (y - x) * ?inv x) / norm (y - x)"
apply (subst inverse_diff_inverse [OF \<open>y \<noteq> 0\<close> x])
apply (subst minus_diff_minus)
apply (subst norm_minus_cancel)
@@ -407,52 +431,56 @@
also have "\<dots> = norm (?inv y - ?inv x) * norm (?inv x)"
by simp
finally show "norm (?inv y - ?inv x - ?f (y -x)) / norm (y - x) \<le>
- norm (?inv y - ?inv x) * norm (?inv x)" .
+ norm (?inv y - ?inv x) * norm (?inv x)" .
qed
lemma has_derivative_inverse[simp, derivative_intros]:
fixes f :: "_ \<Rightarrow> 'a::real_normed_div_algebra"
- assumes x: "f x \<noteq> 0" and f: "(f has_derivative f') (at x within s)"
- shows "((\<lambda>x. inverse (f x)) has_derivative (\<lambda>h. - (inverse (f x) * f' h * inverse (f x)))) (at x within s)"
+ assumes x: "f x \<noteq> 0"
+ and f: "(f has_derivative f') (at x within s)"
+ shows "((\<lambda>x. inverse (f x)) has_derivative (\<lambda>h. - (inverse (f x) * f' h * inverse (f x))))
+ (at x within s)"
using has_derivative_compose[OF f has_derivative_inverse', OF x] .
lemma has_derivative_divide[simp, derivative_intros]:
fixes f :: "_ \<Rightarrow> 'a::real_normed_div_algebra"
- assumes f: "(f has_derivative f') (at x within s)" and g: "(g has_derivative g') (at x within s)"
+ assumes f: "(f has_derivative f') (at x within s)"
+ and g: "(g has_derivative g') (at x within s)"
assumes x: "g x \<noteq> 0"
shows "((\<lambda>x. f x / g x) has_derivative
(\<lambda>h. - f x * (inverse (g x) * g' h * inverse (g x)) + f' h / g x)) (at x within s)"
using has_derivative_mult[OF f has_derivative_inverse[OF x g]]
by (simp add: field_simps)
-text\<open>Conventional form requires mult-AC laws. Types real and complex only.\<close>
+
+text \<open>Conventional form requires mult-AC laws. Types real and complex only.\<close>
-lemma has_derivative_divide'[derivative_intros]:
+lemma has_derivative_divide'[derivative_intros]:
fixes f :: "_ \<Rightarrow> 'a::real_normed_field"
- assumes f: "(f has_derivative f') (at x within s)" and g: "(g has_derivative g') (at x within s)" and x: "g x \<noteq> 0"
+ assumes f: "(f has_derivative f') (at x within s)"
+ and g: "(g has_derivative g') (at x within s)"
+ and x: "g x \<noteq> 0"
shows "((\<lambda>x. f x / g x) has_derivative (\<lambda>h. (f' h * g x - f x * g' h) / (g x * g x))) (at x within s)"
proof -
- { fix h
- have "f' h / g x - f x * (inverse (g x) * g' h * inverse (g x)) =
- (f' h * g x - f x * g' h) / (g x * g x)"
- by (simp add: field_simps x)
- }
+ have "f' h / g x - f x * (inverse (g x) * g' h * inverse (g x)) =
+ (f' h * g x - f x * g' h) / (g x * g x)" for h
+ by (simp add: field_simps x)
then show ?thesis
using has_derivative_divide [OF f g] x
by simp
qed
+
subsection \<open>Uniqueness\<close>
text \<open>
-
This can not generally shown for @{const has_derivative}, as we need to approach the point from
all directions. There is a proof in \<open>Multivariate_Analysis\<close> for \<open>euclidean_space\<close>.
-
\<close>
lemma has_derivative_zero_unique:
- assumes "((\<lambda>x. 0) has_derivative F) (at x)" shows "F = (\<lambda>h. 0)"
+ assumes "((\<lambda>x. 0) has_derivative F) (at x)"
+ shows "F = (\<lambda>h. 0)"
proof -
interpret F: bounded_linear F
using assms by (rule has_derivative_bounded_linear)
@@ -461,42 +489,50 @@
using assms unfolding has_derivative_at by simp
show "F = (\<lambda>h. 0)"
proof
- fix h show "F h = 0"
+ show "F h = 0" for h
proof (rule ccontr)
- assume **: "F h \<noteq> 0"
- hence h: "h \<noteq> 0" by (clarsimp simp add: F.zero)
- with ** have "0 < ?r h" by simp
- from LIM_D [OF * this] obtain s where s: "0 < s"
- and r: "\<And>x. x \<noteq> 0 \<Longrightarrow> norm x < s \<Longrightarrow> ?r x < ?r h" by auto
+ assume **: "\<not> ?thesis"
+ then have h: "h \<noteq> 0"
+ by (auto simp add: F.zero)
+ with ** have "0 < ?r h"
+ by simp
+ from LIM_D [OF * this] obtain s
+ where s: "0 < s" and r: "\<And>x. x \<noteq> 0 \<Longrightarrow> norm x < s \<Longrightarrow> ?r x < ?r h"
+ by auto
from dense [OF s] obtain t where t: "0 < t \<and> t < s" ..
let ?x = "scaleR (t / norm h) h"
- have "?x \<noteq> 0" and "norm ?x < s" using t h by simp_all
- hence "?r ?x < ?r h" by (rule r)
- thus "False" using t h by (simp add: F.scaleR)
+ have "?x \<noteq> 0" and "norm ?x < s"
+ using t h by simp_all
+ then have "?r ?x < ?r h"
+ by (rule r)
+ then show False
+ using t h by (simp add: F.scaleR)
qed
qed
qed
lemma has_derivative_unique:
- assumes "(f has_derivative F) (at x)" and "(f has_derivative F') (at x)" shows "F = F'"
+ assumes "(f has_derivative F) (at x)"
+ and "(f has_derivative F') (at x)"
+ shows "F = F'"
proof -
have "((\<lambda>x. 0) has_derivative (\<lambda>h. F h - F' h)) (at x)"
using has_derivative_diff [OF assms] by simp
- hence "(\<lambda>h. F h - F' h) = (\<lambda>h. 0)"
+ then have "(\<lambda>h. F h - F' h) = (\<lambda>h. 0)"
by (rule has_derivative_zero_unique)
- thus "F = F'"
+ then show "F = F'"
unfolding fun_eq_iff right_minus_eq .
qed
+
subsection \<open>Differentiability predicate\<close>
-definition
- differentiable :: "('a::real_normed_vector \<Rightarrow> 'b::real_normed_vector) \<Rightarrow> 'a filter \<Rightarrow> bool"
- (infix "differentiable" 50)
-where
- "f differentiable F \<longleftrightarrow> (\<exists>D. (f has_derivative D) F)"
+definition differentiable :: "('a::real_normed_vector \<Rightarrow> 'b::real_normed_vector) \<Rightarrow> 'a filter \<Rightarrow> bool"
+ (infix "differentiable" 50)
+ where "f differentiable F \<longleftrightarrow> (\<exists>D. (f has_derivative D) F)"
-lemma differentiable_subset: "f differentiable (at x within s) \<Longrightarrow> t \<subseteq> s \<Longrightarrow> f differentiable (at x within t)"
+lemma differentiable_subset:
+ "f differentiable (at x within s) \<Longrightarrow> t \<subseteq> s \<Longrightarrow> f differentiable (at x within t)"
unfolding differentiable_def by (blast intro: has_derivative_subset)
lemmas differentiable_within_subset = differentiable_subset
@@ -508,11 +544,13 @@
unfolding differentiable_def by (blast intro: has_derivative_const)
lemma differentiable_in_compose:
- "f differentiable (at (g x) within (g`s)) \<Longrightarrow> g differentiable (at x within s) \<Longrightarrow> (\<lambda>x. f (g x)) differentiable (at x within s)"
+ "f differentiable (at (g x) within (g`s)) \<Longrightarrow> g differentiable (at x within s) \<Longrightarrow>
+ (\<lambda>x. f (g x)) differentiable (at x within s)"
unfolding differentiable_def by (blast intro: has_derivative_in_compose)
lemma differentiable_compose:
- "f differentiable (at (g x)) \<Longrightarrow> g differentiable (at x within s) \<Longrightarrow> (\<lambda>x. f (g x)) differentiable (at x within s)"
+ "f differentiable (at (g x)) \<Longrightarrow> g differentiable (at x within s) \<Longrightarrow>
+ (\<lambda>x. f (g x)) differentiable (at x within s)"
by (blast intro: differentiable_in_compose differentiable_subset)
lemma differentiable_sum [simp, derivative_intros]:
@@ -528,57 +566,59 @@
unfolding differentiable_def by (blast intro: has_derivative_diff)
lemma differentiable_mult [simp, derivative_intros]:
- fixes f g :: "'a :: real_normed_vector \<Rightarrow> 'b :: real_normed_algebra"
- shows "f differentiable (at x within s) \<Longrightarrow> g differentiable (at x within s) \<Longrightarrow> (\<lambda>x. f x * g x) differentiable (at x within s)"
+ fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_algebra"
+ shows "f differentiable (at x within s) \<Longrightarrow> g differentiable (at x within s) \<Longrightarrow>
+ (\<lambda>x. f x * g x) differentiable (at x within s)"
unfolding differentiable_def by (blast intro: has_derivative_mult)
lemma differentiable_inverse [simp, derivative_intros]:
- fixes f :: "'a :: real_normed_vector \<Rightarrow> 'b :: real_normed_field"
- shows "f differentiable (at x within s) \<Longrightarrow> f x \<noteq> 0 \<Longrightarrow> (\<lambda>x. inverse (f x)) differentiable (at x within s)"
+ fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_field"
+ shows "f differentiable (at x within s) \<Longrightarrow> f x \<noteq> 0 \<Longrightarrow>
+ (\<lambda>x. inverse (f x)) differentiable (at x within s)"
unfolding differentiable_def by (blast intro: has_derivative_inverse)
lemma differentiable_divide [simp, derivative_intros]:
- fixes f g :: "'a :: real_normed_vector \<Rightarrow> 'b :: real_normed_field"
- shows "f differentiable (at x within s) \<Longrightarrow> g differentiable (at x within s) \<Longrightarrow> g x \<noteq> 0 \<Longrightarrow> (\<lambda>x. f x / g x) differentiable (at x within s)"
+ fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_field"
+ shows "f differentiable (at x within s) \<Longrightarrow> g differentiable (at x within s) \<Longrightarrow>
+ g x \<noteq> 0 \<Longrightarrow> (\<lambda>x. f x / g x) differentiable (at x within s)"
unfolding divide_inverse by simp
lemma differentiable_power [simp, derivative_intros]:
- fixes f g :: "'a :: real_normed_vector \<Rightarrow> 'b :: real_normed_field"
+ fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_field"
shows "f differentiable (at x within s) \<Longrightarrow> (\<lambda>x. f x ^ n) differentiable (at x within s)"
unfolding differentiable_def by (blast intro: has_derivative_power)
lemma differentiable_scaleR [simp, derivative_intros]:
- "f differentiable (at x within s) \<Longrightarrow> g differentiable (at x within s) \<Longrightarrow> (\<lambda>x. f x *\<^sub>R g x) differentiable (at x within s)"
+ "f differentiable (at x within s) \<Longrightarrow> g differentiable (at x within s) \<Longrightarrow>
+ (\<lambda>x. f x *\<^sub>R g x) differentiable (at x within s)"
unfolding differentiable_def by (blast intro: has_derivative_scaleR)
lemma has_derivative_imp_has_field_derivative:
"(f has_derivative D) F \<Longrightarrow> (\<And>x. x * D' = D x) \<Longrightarrow> (f has_field_derivative D') F"
- unfolding has_field_derivative_def
+ unfolding has_field_derivative_def
by (rule has_derivative_eq_rhs[of f D]) (simp_all add: fun_eq_iff mult.commute)
-lemma has_field_derivative_imp_has_derivative: "(f has_field_derivative D) F \<Longrightarrow> (f has_derivative op * D) F"
+lemma has_field_derivative_imp_has_derivative:
+ "(f has_field_derivative D) F \<Longrightarrow> (f has_derivative op * D) F"
by (simp add: has_field_derivative_def)
-lemma DERIV_subset:
- "(f has_field_derivative f') (at x within s) \<Longrightarrow> t \<subseteq> s
- \<Longrightarrow> (f has_field_derivative f') (at x within t)"
+lemma DERIV_subset:
+ "(f has_field_derivative f') (at x within s) \<Longrightarrow> t \<subseteq> s \<Longrightarrow>
+ (f has_field_derivative f') (at x within t)"
by (simp add: has_field_derivative_def has_derivative_within_subset)
lemma has_field_derivative_at_within:
- "(f has_field_derivative f') (at x) \<Longrightarrow> (f has_field_derivative f') (at x within s)"
+ "(f has_field_derivative f') (at x) \<Longrightarrow> (f has_field_derivative f') (at x within s)"
using DERIV_subset by blast
abbreviation (input)
DERIV :: "('a::real_normed_field \<Rightarrow> 'a) \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> bool"
- ("(DERIV (_)/ (_)/ :> (_))" [1000, 1000, 60] 60)
-where
- "DERIV f x :> D \<equiv> (f has_field_derivative D) (at x)"
+ ("(DERIV (_)/ (_)/ :> (_))" [1000, 1000, 60] 60)
+ where "DERIV f x :> D \<equiv> (f has_field_derivative D) (at x)"
-abbreviation
- has_real_derivative :: "(real \<Rightarrow> real) \<Rightarrow> real \<Rightarrow> real filter \<Rightarrow> bool"
- (infix "(has'_real'_derivative)" 50)
-where
- "(f has_real_derivative D) F \<equiv> (f has_field_derivative D) F"
+abbreviation has_real_derivative :: "(real \<Rightarrow> real) \<Rightarrow> real \<Rightarrow> real filter \<Rightarrow> bool"
+ (infix "(has'_real'_derivative)" 50)
+ where "(f has_real_derivative D) F \<equiv> (f has_field_derivative D) F"
lemma real_differentiable_def:
"f differentiable at x within s \<longleftrightarrow> (\<exists>D. (f has_real_derivative D) (at x within s))"
@@ -593,31 +633,36 @@
qed (auto simp: differentiable_def has_field_derivative_def)
lemma real_differentiableE [elim?]:
- assumes f: "f differentiable (at x within s)" obtains df where "(f has_real_derivative df) (at x within s)"
+ assumes f: "f differentiable (at x within s)"
+ obtains df where "(f has_real_derivative df) (at x within s)"
using assms by (auto simp: real_differentiable_def)
-lemma differentiableD: "f differentiable (at x within s) \<Longrightarrow> \<exists>D. (f has_real_derivative D) (at x within s)"
+lemma differentiableD:
+ "f differentiable (at x within s) \<Longrightarrow> \<exists>D. (f has_real_derivative D) (at x within s)"
by (auto elim: real_differentiableE)
-lemma differentiableI: "(f has_real_derivative D) (at x within s) \<Longrightarrow> f differentiable (at x within s)"
+lemma differentiableI:
+ "(f has_real_derivative D) (at x within s) \<Longrightarrow> f differentiable (at x within s)"
by (force simp add: real_differentiable_def)
lemma has_field_derivative_iff:
"(f has_field_derivative D) (at x within S) \<longleftrightarrow>
((\<lambda>y. (f y - f x) / (y - x)) \<longlongrightarrow> D) (at x within S)"
apply (simp add: has_field_derivative_def has_derivative_iff_norm bounded_linear_mult_right
- LIM_zero_iff[symmetric, of _ D])
+ LIM_zero_iff[symmetric, of _ D])
apply (subst (2) tendsto_norm_zero_iff[symmetric])
apply (rule filterlim_cong)
- apply (simp_all add: eventually_at_filter field_simps nonzero_norm_divide)
+ apply (simp_all add: eventually_at_filter field_simps nonzero_norm_divide)
done
lemma DERIV_def: "DERIV f x :> D \<longleftrightarrow> (\<lambda>h. (f (x + h) - f x) / h) \<midarrow>0\<rightarrow> D"
unfolding field_has_derivative_at has_field_derivative_def has_field_derivative_iff ..
-lemma mult_commute_abs: "(\<lambda>x. x * c) = op * (c::'a::ab_semigroup_mult)"
+lemma mult_commute_abs: "(\<lambda>x. x * c) = op * c"
+ for c :: "'a::ab_semigroup_mult"
by (simp add: fun_eq_iff mult.commute)
+
subsection \<open>Vector derivative\<close>
lemma has_field_derivative_iff_has_vector_derivative:
@@ -625,7 +670,8 @@
unfolding has_vector_derivative_def has_field_derivative_def real_scaleR_def mult_commute_abs ..
lemma has_field_derivative_subset:
- "(f has_field_derivative y) (at x within s) \<Longrightarrow> t \<subseteq> s \<Longrightarrow> (f has_field_derivative y) (at x within t)"
+ "(f has_field_derivative y) (at x within s) \<Longrightarrow> t \<subseteq> s \<Longrightarrow>
+ (f has_field_derivative y) (at x within t)"
unfolding has_field_derivative_def by (rule has_derivative_subset)
lemma has_vector_derivative_const[simp, derivative_intros]: "((\<lambda>x. c) has_vector_derivative 0) net"
@@ -654,16 +700,18 @@
by (auto simp: has_vector_derivative_def scaleR_diff_right)
lemma has_vector_derivative_add_const:
- "((\<lambda>t. g t + z) has_vector_derivative f') net = ((\<lambda>t. g t) has_vector_derivative f') net"
-apply (intro iffI)
-apply (drule has_vector_derivative_diff [where g = "\<lambda>t. z", OF _ has_vector_derivative_const], simp)
-apply (drule has_vector_derivative_add [OF _ has_vector_derivative_const], simp)
-done
+ "((\<lambda>t. g t + z) has_vector_derivative f') net = ((\<lambda>t. g t) has_vector_derivative f') net"
+ apply (intro iffI)
+ apply (drule has_vector_derivative_diff [where g = "\<lambda>t. z", OF _ has_vector_derivative_const])
+ apply simp
+ apply (drule has_vector_derivative_add [OF _ has_vector_derivative_const])
+ apply simp
+ done
lemma has_vector_derivative_diff_const:
- "((\<lambda>t. g t - z) has_vector_derivative f') net = ((\<lambda>t. g t) has_vector_derivative f') net"
-using has_vector_derivative_add_const [where z = "-z"]
-by simp
+ "((\<lambda>t. g t - z) has_vector_derivative f') net = ((\<lambda>t. g t) has_vector_derivative f') net"
+ using has_vector_derivative_add_const [where z = "-z"]
+ by simp
lemma (in bounded_linear) has_vector_derivative:
assumes "(g has_vector_derivative g') F"
@@ -686,24 +734,26 @@
lemma has_vector_derivative_mult[derivative_intros]:
"(f has_vector_derivative f') (at x within s) \<Longrightarrow> (g has_vector_derivative g') (at x within s) \<Longrightarrow>
- ((\<lambda>x. f x * g x) has_vector_derivative (f x * g' + f' * g x :: 'a :: real_normed_algebra)) (at x within s)"
+ ((\<lambda>x. f x * g x) has_vector_derivative (f x * g' + f' * g x)) (at x within s)"
+ for f g :: "real \<Rightarrow> 'a::real_normed_algebra"
by (rule bounded_bilinear.has_vector_derivative[OF bounded_bilinear_mult])
lemma has_vector_derivative_of_real[derivative_intros]:
"(f has_field_derivative D) F \<Longrightarrow> ((\<lambda>x. of_real (f x)) has_vector_derivative (of_real D)) F"
by (rule bounded_linear.has_vector_derivative[OF bounded_linear_of_real])
- (simp add: has_field_derivative_iff_has_vector_derivative)
+ (simp add: has_field_derivative_iff_has_vector_derivative)
-lemma has_vector_derivative_continuous: "(f has_vector_derivative D) (at x within s) \<Longrightarrow> continuous (at x within s) f"
+lemma has_vector_derivative_continuous:
+ "(f has_vector_derivative D) (at x within s) \<Longrightarrow> continuous (at x within s) f"
by (auto intro: has_derivative_continuous simp: has_vector_derivative_def)
lemma has_vector_derivative_mult_right[derivative_intros]:
- fixes a :: "'a :: real_normed_algebra"
+ fixes a :: "'a::real_normed_algebra"
shows "(f has_vector_derivative x) F \<Longrightarrow> ((\<lambda>x. a * f x) has_vector_derivative (a * x)) F"
by (rule bounded_linear.has_vector_derivative[OF bounded_linear_mult_right])
lemma has_vector_derivative_mult_left[derivative_intros]:
- fixes a :: "'a :: real_normed_algebra"
+ fixes a :: "'a::real_normed_algebra"
shows "(f has_vector_derivative x) F \<Longrightarrow> ((\<lambda>x. f x * a) has_vector_derivative (x * a)) F"
by (rule bounded_linear.has_vector_derivative[OF bounded_linear_mult_left])
@@ -725,14 +775,14 @@
by (rule has_derivative_imp_has_field_derivative[OF has_derivative_ident]) auto
lemma field_differentiable_add[derivative_intros]:
- "(f has_field_derivative f') F \<Longrightarrow> (g has_field_derivative g') F \<Longrightarrow>
+ "(f has_field_derivative f') F \<Longrightarrow> (g has_field_derivative g') F \<Longrightarrow>
((\<lambda>z. f z + g z) has_field_derivative f' + g') F"
by (rule has_derivative_imp_has_field_derivative[OF has_derivative_add])
(auto simp: has_field_derivative_def field_simps mult_commute_abs)
corollary DERIV_add:
"(f has_field_derivative D) (at x within s) \<Longrightarrow> (g has_field_derivative E) (at x within s) \<Longrightarrow>
- ((\<lambda>x. f x + g x) has_field_derivative D + E) (at x within s)"
+ ((\<lambda>x. f x + g x) has_field_derivative D + E) (at x within s)"
by (rule field_differentiable_add)
lemma field_differentiable_minus[derivative_intros]:
@@ -740,16 +790,20 @@
by (rule has_derivative_imp_has_field_derivative[OF has_derivative_minus])
(auto simp: has_field_derivative_def field_simps mult_commute_abs)
-corollary DERIV_minus: "(f has_field_derivative D) (at x within s) \<Longrightarrow> ((\<lambda>x. - f x) has_field_derivative -D) (at x within s)"
+corollary DERIV_minus:
+ "(f has_field_derivative D) (at x within s) \<Longrightarrow>
+ ((\<lambda>x. - f x) has_field_derivative -D) (at x within s)"
by (rule field_differentiable_minus)
lemma field_differentiable_diff[derivative_intros]:
- "(f has_field_derivative f') F \<Longrightarrow> (g has_field_derivative g') F \<Longrightarrow> ((\<lambda>z. f z - g z) has_field_derivative f' - g') F"
+ "(f has_field_derivative f') F \<Longrightarrow>
+ (g has_field_derivative g') F \<Longrightarrow> ((\<lambda>z. f z - g z) has_field_derivative f' - g') F"
by (simp only: diff_conv_add_uminus field_differentiable_add field_differentiable_minus)
corollary DERIV_diff:
- "(f has_field_derivative D) (at x within s) \<Longrightarrow> (g has_field_derivative E) (at x within s) \<Longrightarrow>
- ((\<lambda>x. f x - g x) has_field_derivative D - E) (at x within s)"
+ "(f has_field_derivative D) (at x within s) \<Longrightarrow>
+ (g has_field_derivative E) (at x within s) \<Longrightarrow>
+ ((\<lambda>x. f x - g x) has_field_derivative D - E) (at x within s)"
by (rule field_differentiable_diff)
lemma DERIV_continuous: "(f has_field_derivative D) (at x within s) \<Longrightarrow> continuous (at x within s) f"
@@ -761,51 +815,54 @@
lemma DERIV_continuous_on:
"(\<And>x. x \<in> s \<Longrightarrow> (f has_field_derivative (D x)) (at x within s)) \<Longrightarrow> continuous_on s f"
unfolding continuous_on_eq_continuous_within
- by (intro continuous_at_imp_continuous_on ballI DERIV_continuous)
+ by (intro continuous_at_imp_continuous_on ballI DERIV_continuous)
lemma DERIV_mult':
"(f has_field_derivative D) (at x within s) \<Longrightarrow> (g has_field_derivative E) (at x within s) \<Longrightarrow>
- ((\<lambda>x. f x * g x) has_field_derivative f x * E + D * g x) (at x within s)"
+ ((\<lambda>x. f x * g x) has_field_derivative f x * E + D * g x) (at x within s)"
by (rule has_derivative_imp_has_field_derivative[OF has_derivative_mult])
(auto simp: field_simps mult_commute_abs dest: has_field_derivative_imp_has_derivative)
lemma DERIV_mult[derivative_intros]:
"(f has_field_derivative Da) (at x within s) \<Longrightarrow> (g has_field_derivative Db) (at x within s) \<Longrightarrow>
- ((\<lambda>x. f x * g x) has_field_derivative Da * g x + Db * f x) (at x within s)"
+ ((\<lambda>x. f x * g x) has_field_derivative Da * g x + Db * f x) (at x within s)"
by (rule has_derivative_imp_has_field_derivative[OF has_derivative_mult])
(auto simp: field_simps dest: has_field_derivative_imp_has_derivative)
text \<open>Derivative of linear multiplication\<close>
lemma DERIV_cmult:
- "(f has_field_derivative D) (at x within s) ==> ((\<lambda>x. c * f x) has_field_derivative c * D) (at x within s)"
- by (drule DERIV_mult' [OF DERIV_const], simp)
+ "(f has_field_derivative D) (at x within s) \<Longrightarrow>
+ ((\<lambda>x. c * f x) has_field_derivative c * D) (at x within s)"
+ by (drule DERIV_mult' [OF DERIV_const]) simp
lemma DERIV_cmult_right:
- "(f has_field_derivative D) (at x within s) ==> ((\<lambda>x. f x * c) has_field_derivative D * c) (at x within s)"
- using DERIV_cmult by (force simp add: ac_simps)
+ "(f has_field_derivative D) (at x within s) \<Longrightarrow>
+ ((\<lambda>x. f x * c) has_field_derivative D * c) (at x within s)"
+ using DERIV_cmult by (auto simp add: ac_simps)
lemma DERIV_cmult_Id [simp]: "(op * c has_field_derivative c) (at x within s)"
- by (cut_tac c = c and x = x in DERIV_ident [THEN DERIV_cmult], simp)
+ using DERIV_ident [THEN DERIV_cmult, where c = c and x = x] by simp
lemma DERIV_cdivide:
- "(f has_field_derivative D) (at x within s) \<Longrightarrow> ((\<lambda>x. f x / c) has_field_derivative D / c) (at x within s)"
+ "(f has_field_derivative D) (at x within s) \<Longrightarrow>
+ ((\<lambda>x. f x / c) has_field_derivative D / c) (at x within s)"
using DERIV_cmult_right[of f D x s "1 / c"] by simp
-lemma DERIV_unique:
- "DERIV f x :> D \<Longrightarrow> DERIV f x :> E \<Longrightarrow> D = E"
- unfolding DERIV_def by (rule LIM_unique)
+lemma DERIV_unique: "DERIV f x :> D \<Longrightarrow> DERIV f x :> E \<Longrightarrow> D = E"
+ unfolding DERIV_def by (rule LIM_unique)
lemma DERIV_setsum[derivative_intros]:
- "(\<And> n. n \<in> S \<Longrightarrow> ((\<lambda>x. f x n) has_field_derivative (f' x n)) F) \<Longrightarrow>
+ "(\<And> n. n \<in> S \<Longrightarrow> ((\<lambda>x. f x n) has_field_derivative (f' x n)) F) \<Longrightarrow>
((\<lambda>x. setsum (f x) S) has_field_derivative setsum (f' x) S) F"
- by (rule has_derivative_imp_has_field_derivative[OF has_derivative_setsum])
+ by (rule has_derivative_imp_has_field_derivative [OF has_derivative_setsum])
(auto simp: setsum_right_distrib mult_commute_abs dest: has_field_derivative_imp_has_derivative)
lemma DERIV_inverse'[derivative_intros]:
assumes "(f has_field_derivative D) (at x within s)"
and "f x \<noteq> 0"
- shows "((\<lambda>x. inverse (f x)) has_field_derivative - (inverse (f x) * D * inverse (f x))) (at x within s)"
+ shows "((\<lambda>x. inverse (f x)) has_field_derivative - (inverse (f x) * D * inverse (f x)))
+ (at x within s)"
proof -
have "(f has_derivative (\<lambda>x. x * D)) = (f has_derivative op * D)"
by (rule arg_cong [of "\<lambda>x. x * D"]) (simp add: fun_eq_iff)
@@ -825,40 +882,40 @@
lemma DERIV_inverse_fun:
"(f has_field_derivative d) (at x within s) \<Longrightarrow> f x \<noteq> 0 \<Longrightarrow>
- ((\<lambda>x. inverse (f x)) has_field_derivative (- (d * inverse(f x ^ Suc (Suc 0))))) (at x within s)"
+ ((\<lambda>x. inverse (f x)) has_field_derivative (- (d * inverse(f x ^ Suc (Suc 0))))) (at x within s)"
by (drule (1) DERIV_inverse') (simp add: ac_simps nonzero_inverse_mult_distrib)
text \<open>Derivative of quotient\<close>
lemma DERIV_divide[derivative_intros]:
"(f has_field_derivative D) (at x within s) \<Longrightarrow>
- (g has_field_derivative E) (at x within s) \<Longrightarrow> g x \<noteq> 0 \<Longrightarrow>
- ((\<lambda>x. f x / g x) has_field_derivative (D * g x - f x * E) / (g x * g x)) (at x within s)"
+ (g has_field_derivative E) (at x within s) \<Longrightarrow> g x \<noteq> 0 \<Longrightarrow>
+ ((\<lambda>x. f x / g x) has_field_derivative (D * g x - f x * E) / (g x * g x)) (at x within s)"
by (rule has_derivative_imp_has_field_derivative[OF has_derivative_divide])
(auto dest: has_field_derivative_imp_has_derivative simp: field_simps)
lemma DERIV_quotient:
"(f has_field_derivative d) (at x within s) \<Longrightarrow>
- (g has_field_derivative e) (at x within s)\<Longrightarrow> g x \<noteq> 0 \<Longrightarrow>
- ((\<lambda>y. f y / g y) has_field_derivative (d * g x - (e * f x)) / (g x ^ Suc (Suc 0))) (at x within s)"
+ (g has_field_derivative e) (at x within s)\<Longrightarrow> g x \<noteq> 0 \<Longrightarrow>
+ ((\<lambda>y. f y / g y) has_field_derivative (d * g x - (e * f x)) / (g x ^ Suc (Suc 0))) (at x within s)"
by (drule (2) DERIV_divide) (simp add: mult.commute)
lemma DERIV_power_Suc:
"(f has_field_derivative D) (at x within s) \<Longrightarrow>
- ((\<lambda>x. f x ^ Suc n) has_field_derivative (1 + of_nat n) * (D * f x ^ n)) (at x within s)"
+ ((\<lambda>x. f x ^ Suc n) has_field_derivative (1 + of_nat n) * (D * f x ^ n)) (at x within s)"
by (rule has_derivative_imp_has_field_derivative[OF has_derivative_power])
(auto simp: has_field_derivative_def)
lemma DERIV_power[derivative_intros]:
"(f has_field_derivative D) (at x within s) \<Longrightarrow>
- ((\<lambda>x. f x ^ n) has_field_derivative of_nat n * (D * f x ^ (n - Suc 0))) (at x within s)"
+ ((\<lambda>x. f x ^ n) has_field_derivative of_nat n * (D * f x ^ (n - Suc 0))) (at x within s)"
by (rule has_derivative_imp_has_field_derivative[OF has_derivative_power])
(auto simp: has_field_derivative_def)
lemma DERIV_pow: "((\<lambda>x. x ^ n) has_field_derivative real n * (x ^ (n - Suc 0))) (at x within s)"
using DERIV_power [OF DERIV_ident] by simp
-lemma DERIV_chain': "(f has_field_derivative D) (at x within s) \<Longrightarrow> DERIV g (f x) :> E \<Longrightarrow>
+lemma DERIV_chain': "(f has_field_derivative D) (at x within s) \<Longrightarrow> DERIV g (f x) :> E \<Longrightarrow>
((\<lambda>x. g (f x)) has_field_derivative E * D) (at x within s)"
using has_derivative_compose[of f "op * D" x s g "op * E"]
by (simp only: has_field_derivative_def mult_commute_abs ac_simps)
@@ -870,42 +927,42 @@
text \<open>Standard version\<close>
lemma DERIV_chain:
- "DERIV f (g x) :> Da \<Longrightarrow> (g has_field_derivative Db) (at x within s) \<Longrightarrow>
- (f o g has_field_derivative Da * Db) (at x within s)"
+ "DERIV f (g x) :> Da \<Longrightarrow> (g has_field_derivative Db) (at x within s) \<Longrightarrow>
+ (f \<circ> g has_field_derivative Da * Db) (at x within s)"
by (drule (1) DERIV_chain', simp add: o_def mult.commute)
-lemma DERIV_image_chain:
- "(f has_field_derivative Da) (at (g x) within (g ` s)) \<Longrightarrow> (g has_field_derivative Db) (at x within s) \<Longrightarrow>
- (f o g has_field_derivative Da * Db) (at x within s)"
+lemma DERIV_image_chain:
+ "(f has_field_derivative Da) (at (g x) within (g ` s)) \<Longrightarrow>
+ (g has_field_derivative Db) (at x within s) \<Longrightarrow>
+ (f \<circ> g has_field_derivative Da * Db) (at x within s)"
using has_derivative_in_compose [of g "op * Db" x s f "op * Da "]
by (simp add: has_field_derivative_def o_def mult_commute_abs ac_simps)
(*These two are from HOL Light: HAS_COMPLEX_DERIVATIVE_CHAIN*)
lemma DERIV_chain_s:
assumes "(\<And>x. x \<in> s \<Longrightarrow> DERIV g x :> g'(x))"
- and "DERIV f x :> f'"
- and "f x \<in> s"
- shows "DERIV (\<lambda>x. g(f x)) x :> f' * g'(f x)"
+ and "DERIV f x :> f'"
+ and "f x \<in> s"
+ shows "DERIV (\<lambda>x. g(f x)) x :> f' * g'(f x)"
by (metis (full_types) DERIV_chain' mult.commute assms)
lemma DERIV_chain3: (*HAS_COMPLEX_DERIVATIVE_CHAIN_UNIV*)
assumes "(\<And>x. DERIV g x :> g'(x))"
- and "DERIV f x :> f'"
- shows "DERIV (\<lambda>x. g(f x)) x :> f' * g'(f x)"
+ and "DERIV f x :> f'"
+ shows "DERIV (\<lambda>x. g(f x)) x :> f' * g'(f x)"
by (metis UNIV_I DERIV_chain_s [of UNIV] assms)
-text\<open>Alternative definition for differentiability\<close>
+text \<open>Alternative definition for differentiability\<close>
lemma DERIV_LIM_iff:
- fixes f :: "'a::{real_normed_vector,inverse} \<Rightarrow> 'a" shows
- "((%h. (f(a + h) - f(a)) / h) \<midarrow>0\<rightarrow> D) =
- ((%x. (f(x)-f(a)) / (x-a)) \<midarrow>a\<rightarrow> D)"
-apply (rule iffI)
-apply (drule_tac k="- a" in LIM_offset)
-apply simp
-apply (drule_tac k="a" in LIM_offset)
-apply (simp add: add.commute)
-done
+ fixes f :: "'a::{real_normed_vector,inverse} \<Rightarrow> 'a"
+ shows "((\<lambda>h. (f (a + h) - f a) / h) \<midarrow>0\<rightarrow> D) = ((\<lambda>x. (f x - f a) / (x - a)) \<midarrow>a\<rightarrow> D)"
+ apply (rule iffI)
+ apply (drule_tac k="- a" in LIM_offset)
+ apply simp
+ apply (drule_tac k="a" in LIM_offset)
+ apply (simp add: add.commute)
+ done
lemmas DERIV_iff2 = has_field_derivative_iff
@@ -913,16 +970,18 @@
assumes "x = y"
and *: "eventually (\<lambda>x. x \<in> s \<longrightarrow> f x = g x) (nhds x)"
and "u = v" "s = t" "x \<in> s"
- shows "(f has_field_derivative u) (at x within s) = (g has_field_derivative v) (at y within t)"
+ shows "(f has_field_derivative u) (at x within s) = (g has_field_derivative v) (at y within t)"
unfolding DERIV_iff2
proof (rule filterlim_cong)
- from assms have "f y = g y" by (auto simp: eventually_nhds)
+ from assms have "f y = g y"
+ by (auto simp: eventually_nhds)
with * show "\<forall>\<^sub>F xa in at x within s. (f xa - f x) / (xa - x) = (g xa - g y) / (xa - y)"
unfolding eventually_at_filter
by eventually_elim (auto simp: assms \<open>f y = g y\<close>)
qed (simp_all add: assms)
-lemma DERIV_cong_ev: "x = y \<Longrightarrow> eventually (\<lambda>x. f x = g x) (nhds x) \<Longrightarrow> u = v \<Longrightarrow>
+lemma DERIV_cong_ev:
+ "x = y \<Longrightarrow> eventually (\<lambda>x. f x = g x) (nhds x) \<Longrightarrow> u = v \<Longrightarrow>
DERIV f x :> u \<longleftrightarrow> DERIV g y :> v"
by (rule has_field_derivative_cong_ev) simp_all
@@ -930,18 +989,19 @@
"(f has_field_derivative y) (at (x + z)) = ((\<lambda>x. f (x + z)) has_field_derivative y) (at x)"
by (simp add: DERIV_def field_simps)
-lemma DERIV_mirror:
- "(DERIV f (- x) :> y) \<longleftrightarrow> (DERIV (\<lambda>x. f (- x::real) :: real) x :> - y)"
+lemma DERIV_mirror: "(DERIV f (- x) :> y) \<longleftrightarrow> (DERIV (\<lambda>x. f (- x)) x :> - y)"
+ for f :: "real \<Rightarrow> real" and x y :: real
by (simp add: DERIV_def filterlim_at_split filterlim_at_left_to_right
- tendsto_minus_cancel_left field_simps conj_commute)
+ tendsto_minus_cancel_left field_simps conj_commute)
lemma floor_has_real_derivative:
- fixes f::"real \<Rightarrow> 'a::{floor_ceiling,order_topology}"
+ fixes f :: "real \<Rightarrow> 'a::{floor_ceiling,order_topology}"
assumes "isCont f x"
- assumes "f x \<notin> \<int>"
+ and "f x \<notin> \<int>"
shows "((\<lambda>x. floor (f x)) has_real_derivative 0) (at x)"
proof (subst DERIV_cong_ev[OF refl _ refl])
- show "((\<lambda>_. floor (f x)) has_real_derivative 0) (at x)" by simp
+ show "((\<lambda>_. floor (f x)) has_real_derivative 0) (at x)"
+ by simp
have "\<forall>\<^sub>F y in at x. \<lfloor>f y\<rfloor> = \<lfloor>f x\<rfloor>"
by (rule eventually_floor_eq[OF assms[unfolded continuous_at]])
then show "\<forall>\<^sub>F y in nhds x. real_of_int \<lfloor>f y\<rfloor> = real_of_int \<lfloor>f x\<rfloor>"
@@ -954,382 +1014,387 @@
lemma CARAT_DERIV: (*FIXME: SUPERSEDED BY THE ONE IN Deriv.thy. But still used by NSA/HDeriv.thy*)
"(DERIV f x :> l) \<longleftrightarrow> (\<exists>g. (\<forall>z. f z - f x = g z * (z - x)) \<and> isCont g x \<and> g x = l)"
- (is "?lhs = ?rhs")
+ (is "?lhs = ?rhs")
proof
- assume der: "DERIV f x :> l"
- show "\<exists>g. (\<forall>z. f z - f x = g z * (z-x)) \<and> isCont g x \<and> g x = l"
+ assume ?lhs
+ show "\<exists>g. (\<forall>z. f z - f x = g z * (z - x)) \<and> isCont g x \<and> g x = l"
proof (intro exI conjI)
- let ?g = "(%z. if z = x then l else (f z - f x) / (z-x))"
- show "\<forall>z. f z - f x = ?g z * (z-x)" by simp
- show "isCont ?g x" using der
- by (simp add: isCont_iff DERIV_def cong: LIM_equal [rule_format])
- show "?g x = l" by simp
+ let ?g = "(\<lambda>z. if z = x then l else (f z - f x) / (z-x))"
+ show "\<forall>z. f z - f x = ?g z * (z - x)"
+ by simp
+ show "isCont ?g x"
+ using \<open>?lhs\<close> by (simp add: isCont_iff DERIV_def cong: LIM_equal [rule_format])
+ show "?g x = l"
+ by simp
qed
next
- assume "?rhs"
- then obtain g where
- "(\<forall>z. f z - f x = g z * (z-x))" and "isCont g x" and "g x = l" by blast
- thus "(DERIV f x :> l)"
- by (auto simp add: isCont_iff DERIV_def cong: LIM_cong)
+ assume ?rhs
+ then obtain g where "(\<forall>z. f z - f x = g z * (z - x))" and "isCont g x" and "g x = l"
+ by blast
+ then show ?lhs
+ by (auto simp add: isCont_iff DERIV_def cong: LIM_cong)
qed
subsection \<open>Local extrema\<close>
-text\<open>If @{term "0 < f'(x)"} then @{term x} is Locally Strictly Increasing At The Right\<close>
+text \<open>If @{term "0 < f' x"} then @{term x} is Locally Strictly Increasing At The Right.\<close>
lemma has_real_derivative_pos_inc_right:
- fixes f :: "real => real"
+ fixes f :: "real \<Rightarrow> real"
assumes der: "(f has_real_derivative l) (at x within S)"
- and l: "0 < l"
+ and l: "0 < l"
shows "\<exists>d > 0. \<forall>h > 0. x + h \<in> S \<longrightarrow> h < d \<longrightarrow> f x < f (x + h)"
using assms
proof -
from der [THEN has_field_derivativeD, THEN tendstoD, OF l, unfolded eventually_at]
- obtain s where s: "0 < s"
- and all: "\<And>xa. xa\<in>S \<Longrightarrow> xa \<noteq> x \<and> dist xa x < s \<longrightarrow> abs ((f xa - f x) / (xa - x) - l) < l"
+ obtain s where s: "0 < s"
+ and all: "\<And>xa. xa\<in>S \<Longrightarrow> xa \<noteq> x \<and> dist xa x < s \<longrightarrow> \<bar>(f xa - f x) / (xa - x) - l\<bar> < l"
by (auto simp: dist_real_def)
then show ?thesis
proof (intro exI conjI strip)
- show "0<s" using s .
- fix h::real
+ show "0 < s" by (rule s)
+ next
+ fix h :: real
assume "0 < h" "h < s" "x + h \<in> S"
with all [of "x + h"] show "f x < f (x+h)"
proof (simp add: abs_if dist_real_def pos_less_divide_eq split: if_split_asm)
- assume "\<not> (f (x+h) - f x) / h < l" and h: "0 < h"
- with l
- have "0 < (f (x+h) - f x) / h" by arith
- thus "f x < f (x+h)"
+ assume "\<not> (f (x + h) - f x) / h < l" and h: "0 < h"
+ with l have "0 < (f (x + h) - f x) / h"
+ by arith
+ then show "f x < f (x + h)"
by (simp add: pos_less_divide_eq h)
qed
qed
qed
lemma DERIV_pos_inc_right:
- fixes f :: "real => real"
+ fixes f :: "real \<Rightarrow> real"
assumes der: "DERIV f x :> l"
- and l: "0 < l"
- shows "\<exists>d > 0. \<forall>h > 0. h < d --> f(x) < f(x + h)"
+ and l: "0 < l"
+ shows "\<exists>d > 0. \<forall>h > 0. h < d \<longrightarrow> f x < f (x + h)"
using has_real_derivative_pos_inc_right[OF assms]
by auto
lemma has_real_derivative_neg_dec_left:
- fixes f :: "real => real"
+ fixes f :: "real \<Rightarrow> real"
assumes der: "(f has_real_derivative l) (at x within S)"
- and "l < 0"
+ and "l < 0"
shows "\<exists>d > 0. \<forall>h > 0. x - h \<in> S \<longrightarrow> h < d \<longrightarrow> f x < f (x - h)"
proof -
- from \<open>l < 0\<close> have l: "- l > 0" by simp
+ from \<open>l < 0\<close> have l: "- l > 0"
+ by simp
from der [THEN has_field_derivativeD, THEN tendstoD, OF l, unfolded eventually_at]
- obtain s where s: "0 < s"
- and all: "\<And>xa. xa\<in>S \<Longrightarrow> xa \<noteq> x \<and> dist xa x < s \<longrightarrow> abs ((f xa - f x) / (xa - x) - l) < - l"
+ obtain s where s: "0 < s"
+ and all: "\<And>xa. xa\<in>S \<Longrightarrow> xa \<noteq> x \<and> dist xa x < s \<longrightarrow> \<bar>(f xa - f x) / (xa - x) - l\<bar> < - l"
by (auto simp: dist_real_def)
- thus ?thesis
+ then show ?thesis
proof (intro exI conjI strip)
- show "0<s" using s .
- fix h::real
+ show "0 < s" by (rule s)
+ next
+ fix h :: real
assume "0 < h" "h < s" "x - h \<in> S"
with all [of "x - h"] show "f x < f (x-h)"
proof (simp add: abs_if pos_less_divide_eq dist_real_def split add: if_split_asm)
- assume " - ((f (x-h) - f x) / h) < l" and h: "0 < h"
- with l
- have "0 < (f (x-h) - f x) / h" by arith
- thus "f x < f (x-h)"
+ assume "- ((f (x-h) - f x) / h) < l" and h: "0 < h"
+ with l have "0 < (f (x-h) - f x) / h"
+ by arith
+ then show "f x < f (x - h)"
by (simp add: pos_less_divide_eq h)
qed
qed
qed
lemma DERIV_neg_dec_left:
- fixes f :: "real => real"
+ fixes f :: "real \<Rightarrow> real"
assumes der: "DERIV f x :> l"
- and l: "l < 0"
- shows "\<exists>d > 0. \<forall>h > 0. h < d --> f(x) < f(x-h)"
+ and l: "l < 0"
+ shows "\<exists>d > 0. \<forall>h > 0. h < d \<longrightarrow> f x < f (x - h)"
using has_real_derivative_neg_dec_left[OF assms]
by auto
lemma has_real_derivative_pos_inc_left:
- fixes f :: "real => real"
- shows "(f has_real_derivative l) (at x within S) \<Longrightarrow> 0 < l \<Longrightarrow> \<exists>d>0. \<forall>h>0. x - h \<in> S \<longrightarrow> h < d \<longrightarrow> f (x - h) < f x"
- by (rule has_real_derivative_neg_dec_left [of "%x. - f x" "-l" x S, simplified])
+ fixes f :: "real \<Rightarrow> real"
+ shows "(f has_real_derivative l) (at x within S) \<Longrightarrow> 0 < l \<Longrightarrow>
+ \<exists>d>0. \<forall>h>0. x - h \<in> S \<longrightarrow> h < d \<longrightarrow> f (x - h) < f x"
+ by (rule has_real_derivative_neg_dec_left [of "\<lambda>x. - f x" "-l" x S, simplified])
(auto simp add: DERIV_minus)
lemma DERIV_pos_inc_left:
- fixes f :: "real => real"
- shows "DERIV f x :> l \<Longrightarrow> 0 < l \<Longrightarrow> \<exists>d > 0. \<forall>h > 0. h < d --> f(x - h) < f(x)"
+ fixes f :: "real \<Rightarrow> real"
+ shows "DERIV f x :> l \<Longrightarrow> 0 < l \<Longrightarrow> \<exists>d > 0. \<forall>h > 0. h < d \<longrightarrow> f (x - h) < f x"
using has_real_derivative_pos_inc_left
by blast
lemma has_real_derivative_neg_dec_right:
- fixes f :: "real => real"
- shows "(f has_real_derivative l) (at x within S) \<Longrightarrow> l < 0 \<Longrightarrow> \<exists>d > 0. \<forall>h > 0. x + h \<in> S \<longrightarrow> h < d \<longrightarrow> f(x) > f(x + h)"
- by (rule has_real_derivative_pos_inc_right [of "%x. - f x" "-l" x S, simplified])
+ fixes f :: "real \<Rightarrow> real"
+ shows "(f has_real_derivative l) (at x within S) \<Longrightarrow> l < 0 \<Longrightarrow>
+ \<exists>d > 0. \<forall>h > 0. x + h \<in> S \<longrightarrow> h < d \<longrightarrow> f x > f (x + h)"
+ by (rule has_real_derivative_pos_inc_right [of "\<lambda>x. - f x" "-l" x S, simplified])
(auto simp add: DERIV_minus)
lemma DERIV_neg_dec_right:
- fixes f :: "real => real"
- shows "DERIV f x :> l \<Longrightarrow> l < 0 \<Longrightarrow> \<exists>d > 0. \<forall>h > 0. h < d --> f(x) > f(x + h)"
+ fixes f :: "real \<Rightarrow> real"
+ shows "DERIV f x :> l \<Longrightarrow> l < 0 \<Longrightarrow> \<exists>d > 0. \<forall>h > 0. h < d \<longrightarrow> f x > f (x + h)"
using has_real_derivative_neg_dec_right by blast
lemma DERIV_local_max:
- fixes f :: "real => real"
+ fixes f :: "real \<Rightarrow> real"
assumes der: "DERIV f x :> l"
- and d: "0 < d"
- and le: "\<forall>y. \<bar>x-y\<bar> < d --> f(y) \<le> f(x)"
+ and d: "0 < d"
+ and le: "\<forall>y. \<bar>x - y\<bar> < d \<longrightarrow> f y \<le> f x"
shows "l = 0"
proof (cases rule: linorder_cases [of l 0])
- case equal thus ?thesis .
+ case equal
+ then show ?thesis .
next
case less
from DERIV_neg_dec_left [OF der less]
- obtain d' where d': "0 < d'"
- and lt: "\<forall>h > 0. h < d' \<longrightarrow> f x < f (x-h)" by blast
- from real_lbound_gt_zero [OF d d']
- obtain e where "0 < e \<and> e < d \<and> e < d'" ..
- with lt le [THEN spec [where x="x-e"]]
- show ?thesis by (auto simp add: abs_if)
+ obtain d' where d': "0 < d'" and lt: "\<forall>h > 0. h < d' \<longrightarrow> f x < f (x - h)"
+ by blast
+ obtain e where "0 < e \<and> e < d \<and> e < d'"
+ using real_lbound_gt_zero [OF d d'] ..
+ with lt le [THEN spec [where x="x - e"]] show ?thesis
+ by (auto simp add: abs_if)
next
case greater
from DERIV_pos_inc_right [OF der greater]
- obtain d' where d': "0 < d'"
- and lt: "\<forall>h > 0. h < d' \<longrightarrow> f x < f (x + h)" by blast
- from real_lbound_gt_zero [OF d d']
- obtain e where "0 < e \<and> e < d \<and> e < d'" ..
- with lt le [THEN spec [where x="x+e"]]
- show ?thesis by (auto simp add: abs_if)
+ obtain d' where d': "0 < d'" and lt: "\<forall>h > 0. h < d' \<longrightarrow> f x < f (x + h)"
+ by blast
+ obtain e where "0 < e \<and> e < d \<and> e < d'"
+ using real_lbound_gt_zero [OF d d'] ..
+ with lt le [THEN spec [where x="x + e"]] show ?thesis
+ by (auto simp add: abs_if)
qed
-
-text\<open>Similar theorem for a local minimum\<close>
+text \<open>Similar theorem for a local minimum\<close>
lemma DERIV_local_min:
- fixes f :: "real => real"
- shows "[| DERIV f x :> l; 0 < d; \<forall>y. \<bar>x-y\<bar> < d --> f(x) \<le> f(y) |] ==> l = 0"
-by (drule DERIV_minus [THEN DERIV_local_max], auto)
+ fixes f :: "real \<Rightarrow> real"
+ shows "DERIV f x :> l \<Longrightarrow> 0 < d \<Longrightarrow> \<forall>y. \<bar>x - y\<bar> < d \<longrightarrow> f x \<le> f y \<Longrightarrow> l = 0"
+ by (drule DERIV_minus [THEN DERIV_local_max]) auto
text\<open>In particular, if a function is locally flat\<close>
lemma DERIV_local_const:
- fixes f :: "real => real"
- shows "[| DERIV f x :> l; 0 < d; \<forall>y. \<bar>x-y\<bar> < d --> f(x) = f(y) |] ==> l = 0"
-by (auto dest!: DERIV_local_max)
+ fixes f :: "real \<Rightarrow> real"
+ shows "DERIV f x :> l \<Longrightarrow> 0 < d \<Longrightarrow> \<forall>y. \<bar>x - y\<bar> < d \<longrightarrow> f x = f y \<Longrightarrow> l = 0"
+ by (auto dest!: DERIV_local_max)
subsection \<open>Rolle's Theorem\<close>
-text\<open>Lemma about introducing open ball in open interval\<close>
-lemma lemma_interval_lt:
- "[| a < x; x < b |]
- ==> \<exists>d::real. 0 < d & (\<forall>y. \<bar>x-y\<bar> < d --> a < y & y < b)"
+text \<open>Lemma about introducing open ball in open interval\<close>
+lemma lemma_interval_lt: "a < x \<Longrightarrow> x < b \<Longrightarrow> \<exists>d. 0 < d \<and> (\<forall>y. \<bar>x - y\<bar> < d \<longrightarrow> a < y \<and> y < b)"
+ for a b x :: real
+ apply (simp add: abs_less_iff)
+ apply (insert linorder_linear [of "x - a" "b - x"])
+ apply safe
+ apply (rule_tac x = "x - a" in exI)
+ apply (rule_tac [2] x = "b - x" in exI)
+ apply auto
+ done
-apply (simp add: abs_less_iff)
-apply (insert linorder_linear [of "x-a" "b-x"], safe)
-apply (rule_tac x = "x-a" in exI)
-apply (rule_tac [2] x = "b-x" in exI, auto)
-done
+lemma lemma_interval: "a < x \<Longrightarrow> x < b \<Longrightarrow> \<exists>d. 0 < d \<and> (\<forall>y. \<bar>x - y\<bar> < d \<longrightarrow> a \<le> y \<and> y \<le> b)"
+ for a b x :: real
+ apply (drule lemma_interval_lt)
+ apply auto
+ apply force
+ done
-lemma lemma_interval: "[| a < x; x < b |] ==>
- \<exists>d::real. 0 < d & (\<forall>y. \<bar>x-y\<bar> < d --> a \<le> y & y \<le> b)"
-apply (drule lemma_interval_lt, auto)
-apply force
-done
-
-text\<open>Rolle's Theorem.
+text \<open>Rolle's Theorem.
If @{term f} is defined and continuous on the closed interval
\<open>[a,b]\<close> and differentiable on the open interval \<open>(a,b)\<close>,
- and @{term "f(a) = f(b)"},
- then there exists \<open>x0 \<in> (a,b)\<close> such that @{term "f'(x0) = 0"}\<close>
+ and @{term "f a = f b"},
+ then there exists \<open>x0 \<in> (a,b)\<close> such that @{term "f' x0 = 0"}\<close>
theorem Rolle:
+ fixes a b :: real
assumes lt: "a < b"
- and eq: "f(a) = f(b)"
- and con: "\<forall>x. a \<le> x & x \<le> b --> isCont f x"
- and dif [rule_format]: "\<forall>x. a < x & x < b --> f differentiable (at x)"
- shows "\<exists>z::real. a < z & z < b & DERIV f z :> 0"
+ and eq: "f a = f b"
+ and con: "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont f x"
+ and dif [rule_format]: "\<forall>x. a < x \<and> x < b \<longrightarrow> f differentiable (at x)"
+ shows "\<exists>z. a < z \<and> z < b \<and> DERIV f z :> 0"
proof -
- have le: "a \<le> b" using lt by simp
+ have le: "a \<le> b"
+ using lt by simp
from isCont_eq_Ub [OF le con]
- obtain x where x_max: "\<forall>z. a \<le> z \<and> z \<le> b \<longrightarrow> f z \<le> f x"
- and alex: "a \<le> x" and xleb: "x \<le> b"
+ obtain x where x_max: "\<forall>z. a \<le> z \<and> z \<le> b \<longrightarrow> f z \<le> f x" and "a \<le> x" "x \<le> b"
by blast
from isCont_eq_Lb [OF le con]
- obtain x' where x'_min: "\<forall>z. a \<le> z \<and> z \<le> b \<longrightarrow> f x' \<le> f z"
- and alex': "a \<le> x'" and x'leb: "x' \<le> b"
+ obtain x' where x'_min: "\<forall>z. a \<le> z \<and> z \<le> b \<longrightarrow> f x' \<le> f z" and "a \<le> x'" "x' \<le> b"
by blast
- show ?thesis
+ consider "a < x" "x < b" | "x = a \<or> x = b"
+ using \<open>a \<le> x\<close> \<open>x \<le> b\<close> by arith
+ then show ?thesis
proof cases
- assume axb: "a < x & x < b"
- \<comment>\<open>@{term f} attains its maximum within the interval\<close>
- hence ax: "a<x" and xb: "x<b" by arith +
- from lemma_interval [OF ax xb]
- obtain d where d: "0<d" and bound: "\<forall>y. \<bar>x-y\<bar> < d \<longrightarrow> a \<le> y \<and> y \<le> b"
- by blast
- hence bound': "\<forall>y. \<bar>x-y\<bar> < d \<longrightarrow> f y \<le> f x" using x_max
- by blast
- from differentiableD [OF dif [OF axb]]
- obtain l where der: "DERIV f x :> l" ..
- have "l=0" by (rule DERIV_local_max [OF der d bound'])
- \<comment>\<open>the derivative at a local maximum is zero\<close>
- thus ?thesis using ax xb der by auto
+ case 1
+ \<comment>\<open>@{term f} attains its maximum within the interval\<close>
+ obtain d where d: "0 < d" and bound: "\<forall>y. \<bar>x - y\<bar> < d \<longrightarrow> a \<le> y \<and> y \<le> b"
+ using lemma_interval [OF 1] by blast
+ then have bound': "\<forall>y. \<bar>x - y\<bar> < d \<longrightarrow> f y \<le> f x"
+ using x_max by blast
+ obtain l where der: "DERIV f x :> l"
+ using differentiableD [OF dif [OF conjI [OF 1]]] ..
+ \<comment>\<open>the derivative at a local maximum is zero\<close>
+ have "l = 0"
+ by (rule DERIV_local_max [OF der d bound'])
+ with 1 der show ?thesis by auto
next
- assume notaxb: "~ (a < x & x < b)"
- hence xeqab: "x=a | x=b" using alex xleb by arith
- hence fb_eq_fx: "f b = f x" by (auto simp add: eq)
- show ?thesis
+ case 2
+ then have fx: "f b = f x" by (auto simp add: eq)
+ consider "a < x'" "x' < b" | "x' = a \<or> x' = b"
+ using \<open>a \<le> x'\<close> \<open>x' \<le> b\<close> by arith
+ then show ?thesis
proof cases
- assume ax'b: "a < x' & x' < b"
- \<comment>\<open>@{term f} attains its minimum within the interval\<close>
- hence ax': "a<x'" and x'b: "x'<b" by arith+
- from lemma_interval [OF ax' x'b]
+ case 1
+ \<comment> \<open>@{term f} attains its minimum within the interval\<close>
+ from lemma_interval [OF 1]
obtain d where d: "0<d" and bound: "\<forall>y. \<bar>x'-y\<bar> < d \<longrightarrow> a \<le> y \<and> y \<le> b"
- by blast
- hence bound': "\<forall>y. \<bar>x'-y\<bar> < d \<longrightarrow> f x' \<le> f y" using x'_min
- by blast
- from differentiableD [OF dif [OF ax'b]]
+ by blast
+ then have bound': "\<forall>y. \<bar>x' - y\<bar> < d \<longrightarrow> f x' \<le> f y"
+ using x'_min by blast
+ from differentiableD [OF dif [OF conjI [OF 1]]]
obtain l where der: "DERIV f x' :> l" ..
- have "l=0" by (rule DERIV_local_min [OF der d bound'])
- \<comment>\<open>the derivative at a local minimum is zero\<close>
- thus ?thesis using ax' x'b der by auto
+ have "l = 0" by (rule DERIV_local_min [OF der d bound'])
+ \<comment> \<open>the derivative at a local minimum is zero\<close>
+ then show ?thesis using 1 der by auto
next
- assume notax'b: "~ (a < x' & x' < b)"
- \<comment>\<open>@{term f} is constant througout the interval\<close>
- hence x'eqab: "x'=a | x'=b" using alex' x'leb by arith
- hence fb_eq_fx': "f b = f x'" by (auto simp add: eq)
- from dense [OF lt]
- obtain r where ar: "a < r" and rb: "r < b" by blast
- from lemma_interval [OF ar rb]
- obtain d where d: "0<d" and bound: "\<forall>y. \<bar>r-y\<bar> < d \<longrightarrow> a \<le> y \<and> y \<le> b"
- by blast
- have eq_fb: "\<forall>z. a \<le> z --> z \<le> b --> f z = f b"
- proof (clarify)
- fix z::real
- assume az: "a \<le> z" and zb: "z \<le> b"
- show "f z = f b"
- proof (rule order_antisym)
- show "f z \<le> f b" by (simp add: fb_eq_fx x_max az zb)
- show "f b \<le> f z" by (simp add: fb_eq_fx' x'_min az zb)
- qed
+ case 2
+ \<comment> \<open>@{term f} is constant throughout the interval\<close>
+ then have fx': "f b = f x'" by (auto simp: eq)
+ from dense [OF lt] obtain r where r: "a < r" "r < b" by blast
+ obtain d where d: "0 < d" and bound: "\<forall>y. \<bar>r - y\<bar> < d \<longrightarrow> a \<le> y \<and> y \<le> b"
+ using lemma_interval [OF r] by blast
+ have eq_fb: "f z = f b" if "a \<le> z" and "z \<le> b" for z
+ proof (rule order_antisym)
+ show "f z \<le> f b" by (simp add: fx x_max that)
+ show "f b \<le> f z" by (simp add: fx' x'_min that)
qed
- have bound': "\<forall>y. \<bar>r-y\<bar> < d \<longrightarrow> f r = f y"
+ have bound': "\<forall>y. \<bar>r - y\<bar> < d \<longrightarrow> f r = f y"
proof (intro strip)
- fix y::real
- assume lt: "\<bar>r-y\<bar> < d"
- hence "f y = f b" by (simp add: eq_fb bound)
- thus "f r = f y" by (simp add: eq_fb ar rb order_less_imp_le)
+ fix y :: real
+ assume lt: "\<bar>r - y\<bar> < d"
+ then have "f y = f b" by (simp add: eq_fb bound)
+ then show "f r = f y" by (simp add: eq_fb r order_less_imp_le)
qed
- from differentiableD [OF dif [OF conjI [OF ar rb]]]
- obtain l where der: "DERIV f r :> l" ..
- have "l=0" by (rule DERIV_local_const [OF der d bound'])
- \<comment>\<open>the derivative of a constant function is zero\<close>
- thus ?thesis using ar rb der by auto
+ obtain l where der: "DERIV f r :> l"
+ using differentiableD [OF dif [OF conjI [OF r]]] ..
+ have "l = 0"
+ by (rule DERIV_local_const [OF der d bound'])
+ \<comment> \<open>the derivative of a constant function is zero\<close>
+ with r der show ?thesis by auto
qed
qed
qed
-subsection\<open>Mean Value Theorem\<close>
+subsection \<open>Mean Value Theorem\<close>
-lemma lemma_MVT:
- "f a - (f b - f a)/(b-a) * a = f b - (f b - f a)/(b-a) * (b::real)"
+lemma lemma_MVT: "f a - (f b - f a) / (b - a) * a = f b - (f b - f a) / (b - a) * b"
+ for a b :: real
by (cases "a = b") (simp_all add: field_simps)
theorem MVT:
- assumes lt: "a < b"
- and con: "\<forall>x. a \<le> x & x \<le> b --> isCont f x"
- and dif [rule_format]: "\<forall>x. a < x & x < b --> f differentiable (at x)"
- shows "\<exists>l z::real. a < z & z < b & DERIV f z :> l &
- (f(b) - f(a) = (b-a) * l)"
+ fixes a b :: real
+ assumes lt: "a < b"
+ and con: "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont f x"
+ and dif [rule_format]: "\<forall>x. a < x \<and> x < b \<longrightarrow> f differentiable (at x)"
+ shows "\<exists>l z. a < z \<and> z < b \<and> DERIV f z :> l \<and> f b - f a = (b - a) * l"
proof -
- let ?F = "%x. f x - ((f b - f a) / (b-a)) * x"
- have contF: "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont ?F x"
+ let ?F = "\<lambda>x. f x - ((f b - f a) / (b - a)) * x"
+ have cont_f: "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont ?F x"
using con by (fast intro: continuous_intros)
- have difF: "\<forall>x. a < x \<and> x < b \<longrightarrow> ?F differentiable (at x)"
- proof (clarify)
- fix x::real
- assume ax: "a < x" and xb: "x < b"
- from differentiableD [OF dif [OF conjI [OF ax xb]]]
- obtain l where der: "DERIV f x :> l" ..
+ have dif_f: "\<forall>x. a < x \<and> x < b \<longrightarrow> ?F differentiable (at x)"
+ proof clarify
+ fix x :: real
+ assume x: "a < x" "x < b"
+ obtain l where der: "DERIV f x :> l"
+ using differentiableD [OF dif [OF conjI [OF x]]] ..
show "?F differentiable (at x)"
- by (rule differentiableI [where D = "l - (f b - f a)/(b-a)"],
+ by (rule differentiableI [where D = "l - (f b - f a) / (b - a)"],
blast intro: DERIV_diff DERIV_cmult_Id der)
qed
- from Rolle [where f = ?F, OF lt lemma_MVT contF difF]
- obtain z where az: "a < z" and zb: "z < b" and der: "DERIV ?F z :> 0"
+ from Rolle [where f = ?F, OF lt lemma_MVT cont_f dif_f]
+ obtain z where z: "a < z" "z < b" and der: "DERIV ?F z :> 0"
by blast
- have "DERIV (%x. ((f b - f a)/(b-a)) * x) z :> (f b - f a)/(b-a)"
+ have "DERIV (\<lambda>x. ((f b - f a) / (b - a)) * x) z :> (f b - f a) / (b - a)"
by (rule DERIV_cmult_Id)
- hence derF: "DERIV (\<lambda>x. ?F x + (f b - f a) / (b - a) * x) z
- :> 0 + (f b - f a) / (b - a)"
+ then have der_f: "DERIV (\<lambda>x. ?F x + (f b - f a) / (b - a) * x) z :> 0 + (f b - f a) / (b - a)"
by (rule DERIV_add [OF der])
show ?thesis
proof (intro exI conjI)
- show "a < z" using az .
- show "z < b" using zb .
- show "f b - f a = (b - a) * ((f b - f a)/(b-a))" by (simp)
- show "DERIV f z :> ((f b - f a)/(b-a))" using derF by simp
+ show "a < z" and "z < b" using z .
+ show "f b - f a = (b - a) * ((f b - f a) / (b - a))" by simp
+ show "DERIV f z :> ((f b - f a) / (b - a))" using der_f by simp
qed
qed
lemma MVT2:
- "[| a < b; \<forall>x. a \<le> x & x \<le> b --> DERIV f x :> f'(x) |]
- ==> \<exists>z::real. a < z & z < b & (f b - f a = (b - a) * f'(z))"
-apply (drule MVT)
-apply (blast intro: DERIV_isCont)
-apply (force dest: order_less_imp_le simp add: real_differentiable_def)
-apply (blast dest: DERIV_unique order_less_imp_le)
-done
+ "a < b \<Longrightarrow> \<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> DERIV f x :> f' x \<Longrightarrow>
+ \<exists>z::real. a < z \<and> z < b \<and> (f b - f a = (b - a) * f' z)"
+ apply (drule MVT)
+ apply (blast intro: DERIV_isCont)
+ apply (force dest: order_less_imp_le simp add: real_differentiable_def)
+ apply (blast dest: DERIV_unique order_less_imp_le)
+ done
-text\<open>A function is constant if its derivative is 0 over an interval.\<close>
+text \<open>A function is constant if its derivative is 0 over an interval.\<close>
lemma DERIV_isconst_end:
- fixes f :: "real => real"
- shows "[| a < b;
- \<forall>x. a \<le> x & x \<le> b --> isCont f x;
- \<forall>x. a < x & x < b --> DERIV f x :> 0 |]
- ==> f b = f a"
-apply (drule MVT, assumption)
-apply (blast intro: differentiableI)
-apply (auto dest!: DERIV_unique simp add: diff_eq_eq)
-done
+ fixes f :: "real \<Rightarrow> real"
+ shows "a < b \<Longrightarrow>
+ \<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont f x \<Longrightarrow>
+ \<forall>x. a < x \<and> x < b \<longrightarrow> DERIV f x :> 0 \<Longrightarrow> f b = f a"
+ apply (drule (1) MVT)
+ apply (blast intro: differentiableI)
+ apply (auto dest!: DERIV_unique simp add: diff_eq_eq)
+ done
lemma DERIV_isconst1:
- fixes f :: "real => real"
- shows "[| a < b;
- \<forall>x. a \<le> x & x \<le> b --> isCont f x;
- \<forall>x. a < x & x < b --> DERIV f x :> 0 |]
- ==> \<forall>x. a \<le> x & x \<le> b --> f x = f a"
-apply safe
-apply (drule_tac x = a in order_le_imp_less_or_eq, safe)
-apply (drule_tac b = x in DERIV_isconst_end, auto)
-done
+ fixes f :: "real \<Rightarrow> real"
+ shows "a < b \<Longrightarrow>
+ \<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont f x \<Longrightarrow>
+ \<forall>x. a < x \<and> x < b \<longrightarrow> DERIV f x :> 0 \<Longrightarrow>
+ \<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> f x = f a"
+ apply safe
+ apply (drule_tac x = a in order_le_imp_less_or_eq)
+ apply safe
+ apply (drule_tac b = x in DERIV_isconst_end)
+ apply auto
+ done
lemma DERIV_isconst2:
- fixes f :: "real => real"
- shows "[| a < b;
- \<forall>x. a \<le> x & x \<le> b --> isCont f x;
- \<forall>x. a < x & x < b --> DERIV f x :> 0;
- a \<le> x; x \<le> b |]
- ==> f x = f a"
-apply (blast dest: DERIV_isconst1)
-done
+ fixes f :: "real \<Rightarrow> real"
+ shows "a < b \<Longrightarrow>
+ \<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont f x \<Longrightarrow>
+ \<forall>x. a < x \<and> x < b \<longrightarrow> DERIV f x :> 0 \<Longrightarrow>
+ a \<le> x \<Longrightarrow> x \<le> b \<Longrightarrow> f x = f a"
+ by (blast dest: DERIV_isconst1)
-lemma DERIV_isconst3: fixes a b x y :: real
- assumes "a < b" and "x \<in> {a <..< b}" and "y \<in> {a <..< b}"
- assumes derivable: "\<And>x. x \<in> {a <..< b} \<Longrightarrow> DERIV f x :> 0"
+lemma DERIV_isconst3:
+ fixes a b x y :: real
+ assumes "a < b"
+ and "x \<in> {a <..< b}"
+ and "y \<in> {a <..< b}"
+ and derivable: "\<And>x. x \<in> {a <..< b} \<Longrightarrow> DERIV f x :> 0"
shows "f x = f y"
proof (cases "x = y")
case False
let ?a = "min x y"
let ?b = "max x y"
-
+
have "\<forall>z. ?a \<le> z \<and> z \<le> ?b \<longrightarrow> DERIV f z :> 0"
proof (rule allI, rule impI)
- fix z :: real assume "?a \<le> z \<and> z \<le> ?b"
- hence "a < z" and "z < b" using \<open>x \<in> {a <..< b}\<close> and \<open>y \<in> {a <..< b}\<close> by auto
- hence "z \<in> {a<..<b}" by auto
- thus "DERIV f z :> 0" by (rule derivable)
+ fix z :: real
+ assume "?a \<le> z \<and> z \<le> ?b"
+ then have "a < z" and "z < b"
+ using \<open>x \<in> {a <..< b}\<close> and \<open>y \<in> {a <..< b}\<close> by auto
+ then have "z \<in> {a<..<b}" by auto
+ then show "DERIV f z :> 0" by (rule derivable)
qed
- hence isCont: "\<forall>z. ?a \<le> z \<and> z \<le> ?b \<longrightarrow> isCont f z"
- and DERIV: "\<forall>z. ?a < z \<and> z < ?b \<longrightarrow> DERIV f z :> 0" using DERIV_isCont by auto
+ then have isCont: "\<forall>z. ?a \<le> z \<and> z \<le> ?b \<longrightarrow> isCont f z"
+ and DERIV: "\<forall>z. ?a < z \<and> z < ?b \<longrightarrow> DERIV f z :> 0"
+ using DERIV_isCont by auto
have "?a < ?b" using \<open>x \<noteq> y\<close> by auto
from DERIV_isconst2[OF this isCont DERIV, of x] and DERIV_isconst2[OF this isCont DERIV, of y]
@@ -1337,184 +1402,196 @@
qed auto
lemma DERIV_isconst_all:
- fixes f :: "real => real"
- shows "\<forall>x. DERIV f x :> 0 ==> f(x) = f(y)"
-apply (rule linorder_cases [of x y])
-apply (blast intro: sym DERIV_isCont DERIV_isconst_end)+
-done
+ fixes f :: "real \<Rightarrow> real"
+ shows "\<forall>x. DERIV f x :> 0 \<Longrightarrow> f x = f y"
+ apply (rule linorder_cases [of x y])
+ apply (blast intro: sym DERIV_isCont DERIV_isconst_end)+
+ done
lemma DERIV_const_ratio_const:
- fixes f :: "real => real"
- shows "[|a \<noteq> b; \<forall>x. DERIV f x :> k |] ==> (f(b) - f(a)) = (b-a) * k"
-apply (rule linorder_cases [of a b], auto)
-apply (drule_tac [!] f = f in MVT)
-apply (auto dest: DERIV_isCont DERIV_unique simp add: real_differentiable_def)
-apply (auto dest: DERIV_unique simp add: ring_distribs)
-done
+ fixes f :: "real \<Rightarrow> real"
+ shows "a \<noteq> b \<Longrightarrow> \<forall>x. DERIV f x :> k \<Longrightarrow> f b - f a = (b - a) * k"
+ apply (rule linorder_cases [of a b])
+ apply auto
+ apply (drule_tac [!] f = f in MVT)
+ apply (auto dest: DERIV_isCont DERIV_unique simp: real_differentiable_def)
+ apply (auto dest: DERIV_unique simp: ring_distribs)
+ done
lemma DERIV_const_ratio_const2:
- fixes f :: "real => real"
- shows "[|a \<noteq> b; \<forall>x. DERIV f x :> k |] ==> (f(b) - f(a))/(b-a) = k"
-apply (rule_tac c1 = "b-a" in mult_right_cancel [THEN iffD1])
-apply (auto dest!: DERIV_const_ratio_const simp add: mult.assoc)
-done
+ fixes f :: "real \<Rightarrow> real"
+ shows "a \<noteq> b \<Longrightarrow> \<forall>x. DERIV f x :> k \<Longrightarrow> (f b - f a) / (b - a) = k"
+ apply (rule_tac c1 = "b-a" in mult_right_cancel [THEN iffD1])
+ apply (auto dest!: DERIV_const_ratio_const simp add: mult.assoc)
+ done
-lemma real_average_minus_first [simp]: "((a + b) /2 - a) = (b-a)/(2::real)"
-by (simp)
+lemma real_average_minus_first [simp]: "(a + b) / 2 - a = (b - a) / 2"
+ for a b :: real
+ by simp
-lemma real_average_minus_second [simp]: "((b + a)/2 - a) = (b-a)/(2::real)"
-by (simp)
+lemma real_average_minus_second [simp]: "(b + a) / 2 - a = (b - a) / 2"
+ for a b :: real
+ by simp
-text\<open>Gallileo's "trick": average velocity = av. of end velocities\<close>
+text \<open>Gallileo's "trick": average velocity = av. of end velocities.\<close>
lemma DERIV_const_average:
- fixes v :: "real => real"
- assumes neq: "a \<noteq> (b::real)"
- and der: "\<forall>x. DERIV v x :> k"
- shows "v ((a + b)/2) = (v a + v b)/2"
+ fixes v :: "real \<Rightarrow> real"
+ and a b :: real
+ assumes neq: "a \<noteq> b"
+ and der: "\<forall>x. DERIV v x :> k"
+ shows "v ((a + b) / 2) = (v a + v b) / 2"
proof (cases rule: linorder_cases [of a b])
- case equal with neq show ?thesis by simp
+ case equal
+ with neq show ?thesis by simp
next
case less
have "(v b - v a) / (b - a) = k"
by (rule DERIV_const_ratio_const2 [OF neq der])
- hence "(b-a) * ((v b - v a) / (b-a)) = (b-a) * k" by simp
+ then have "(b - a) * ((v b - v a) / (b - a)) = (b - a) * k"
+ by simp
moreover have "(v ((a + b) / 2) - v a) / ((a + b) / 2 - a) = k"
- by (rule DERIV_const_ratio_const2 [OF _ der], simp add: neq)
- ultimately show ?thesis using neq by force
+ by (rule DERIV_const_ratio_const2 [OF _ der]) (simp add: neq)
+ ultimately show ?thesis
+ using neq by force
next
case greater
have "(v b - v a) / (b - a) = k"
by (rule DERIV_const_ratio_const2 [OF neq der])
- hence "(b-a) * ((v b - v a) / (b-a)) = (b-a) * k" by simp
+ then have "(b - a) * ((v b - v a) / (b - a)) = (b - a) * k"
+ by simp
moreover have " (v ((b + a) / 2) - v a) / ((b + a) / 2 - a) = k"
- by (rule DERIV_const_ratio_const2 [OF _ der], simp add: neq)
- ultimately show ?thesis using neq by (force simp add: add.commute)
+ by (rule DERIV_const_ratio_const2 [OF _ der]) (simp add: neq)
+ ultimately show ?thesis
+ using neq by (force simp add: add.commute)
qed
-(* A function with positive derivative is increasing.
- A simple proof using the MVT, by Jeremy Avigad. And variants.
-*)
+text \<open>
+ A function with positive derivative is increasing.
+ A simple proof using the MVT, by Jeremy Avigad. And variants.
+\<close>
lemma DERIV_pos_imp_increasing_open:
- fixes a::real and b::real and f::"real => real"
- assumes "a < b" and "\<And>x. a < x \<Longrightarrow> x < b \<Longrightarrow> (EX y. DERIV f x :> y & y > 0)"
- and con: "\<And>x. a \<le> x \<Longrightarrow> x \<le> b \<Longrightarrow> isCont f x"
+ fixes a b :: real
+ and f :: "real \<Rightarrow> real"
+ assumes "a < b"
+ and "\<And>x. a < x \<Longrightarrow> x < b \<Longrightarrow> (\<exists>y. DERIV f x :> y \<and> y > 0)"
+ and con: "\<And>x. a \<le> x \<Longrightarrow> x \<le> b \<Longrightarrow> isCont f x"
shows "f a < f b"
proof (rule ccontr)
- assume f: "~ f a < f b"
- have "EX l z. a < z & z < b & DERIV f z :> l
- & f b - f a = (b - a) * l"
- apply (rule MVT)
- using assms Deriv.differentiableI
- apply force+
- done
- then obtain l z where z: "a < z" "z < b" "DERIV f z :> l"
- and "f b - f a = (b - a) * l"
+ assume f: "\<not> ?thesis"
+ have "\<exists>l z. a < z \<and> z < b \<and> DERIV f z :> l \<and> f b - f a = (b - a) * l"
+ by (rule MVT) (use assms Deriv.differentiableI in \<open>force+\<close>)
+ then obtain l z where z: "a < z" "z < b" "DERIV f z :> l" and "f b - f a = (b - a) * l"
by auto
- with assms f have "~(l > 0)"
+ with assms f have "\<not> l > 0"
by (metis linorder_not_le mult_le_0_iff diff_le_0_iff_le)
with assms z show False
by (metis DERIV_unique)
qed
lemma DERIV_pos_imp_increasing:
- fixes a::real and b::real and f::"real => real"
- assumes "a < b" and "\<forall>x. a \<le> x & x \<le> b --> (EX y. DERIV f x :> y & y > 0)"
+ fixes a b :: real
+ and f :: "real \<Rightarrow> real"
+ assumes "a < b"
+ and "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> (\<exists>y. DERIV f x :> y \<and> y > 0)"
shows "f a < f b"
-by (metis DERIV_pos_imp_increasing_open [of a b f] assms DERIV_continuous less_imp_le)
+ by (metis DERIV_pos_imp_increasing_open [of a b f] assms DERIV_continuous less_imp_le)
lemma DERIV_nonneg_imp_nondecreasing:
- fixes a::real and b::real and f::"real => real"
- assumes "a \<le> b" and
- "\<forall>x. a \<le> x & x \<le> b --> (\<exists>y. DERIV f x :> y & y \<ge> 0)"
+ fixes a b :: real
+ and f :: "real \<Rightarrow> real"
+ assumes "a \<le> b"
+ and "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> (\<exists>y. DERIV f x :> y \<and> y \<ge> 0)"
shows "f a \<le> f b"
proof (rule ccontr, cases "a = b")
- assume "~ f a \<le> f b" and "a = b"
+ assume "\<not> ?thesis" and "a = b"
then show False by auto
next
- assume A: "~ f a \<le> f b"
- assume B: "a ~= b"
- with assms have "EX l z. a < z & z < b & DERIV f z :> l
- & f b - f a = (b - a) * l"
+ assume *: "\<not> ?thesis"
+ assume "a \<noteq> b"
+ with assms have "\<exists>l z. a < z \<and> z < b \<and> DERIV f z :> l \<and> f b - f a = (b - a) * l"
apply -
apply (rule MVT)
apply auto
- apply (metis DERIV_isCont)
- apply (metis differentiableI less_le)
+ apply (metis DERIV_isCont)
+ apply (metis differentiableI less_le)
done
- then obtain l z where z: "a < z" "z < b" "DERIV f z :> l"
- and C: "f b - f a = (b - a) * l"
+ then obtain l z where lz: "a < z" "z < b" "DERIV f z :> l" and **: "f b - f a = (b - a) * l"
by auto
- with A have "a < b" "f b < f a" by auto
- with C have "\<not> l \<ge> 0" by (auto simp add: not_le algebra_simps)
- (metis A add_le_cancel_right assms(1) less_eq_real_def mult_right_mono add_left_mono linear order_refl)
- with assms z show False
+ with * have "a < b" "f b < f a" by auto
+ with ** have "\<not> l \<ge> 0" by (auto simp add: not_le algebra_simps)
+ (metis * add_le_cancel_right assms(1) less_eq_real_def mult_right_mono add_left_mono linear order_refl)
+ with assms lz show False
by (metis DERIV_unique order_less_imp_le)
qed
lemma DERIV_neg_imp_decreasing_open:
- fixes a::real and b::real and f::"real => real"
- assumes "a < b" and "\<And>x. a < x \<Longrightarrow> x < b \<Longrightarrow> (EX y. DERIV f x :> y & y < 0)"
- and con: "\<And>x. a \<le> x \<Longrightarrow> x \<le> b \<Longrightarrow> isCont f x"
+ fixes a b :: real
+ and f :: "real \<Rightarrow> real"
+ assumes "a < b"
+ and "\<And>x. a < x \<Longrightarrow> x < b \<Longrightarrow> (\<exists>y. DERIV f x :> y \<and> y < 0)"
+ and con: "\<And>x. a \<le> x \<Longrightarrow> x \<le> b \<Longrightarrow> isCont f x"
shows "f a > f b"
proof -
- have "(%x. -f x) a < (%x. -f x) b"
- apply (rule DERIV_pos_imp_increasing_open [of a b "%x. -f x"])
+ have "(\<lambda>x. -f x) a < (\<lambda>x. -f x) b"
+ apply (rule DERIV_pos_imp_increasing_open [of a b "\<lambda>x. -f x"])
using assms
- apply auto
+ apply auto
apply (metis field_differentiable_minus neg_0_less_iff_less)
done
- thus ?thesis
+ then show ?thesis
by simp
qed
lemma DERIV_neg_imp_decreasing:
- fixes a::real and b::real and f::"real => real"
- assumes "a < b" and
- "\<forall>x. a \<le> x & x \<le> b --> (\<exists>y. DERIV f x :> y & y < 0)"
+ fixes a b :: real
+ and f :: "real \<Rightarrow> real"
+ assumes "a < b"
+ and "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> (\<exists>y. DERIV f x :> y \<and> y < 0)"
shows "f a > f b"
-by (metis DERIV_neg_imp_decreasing_open [of a b f] assms DERIV_continuous less_imp_le)
+ by (metis DERIV_neg_imp_decreasing_open [of a b f] assms DERIV_continuous less_imp_le)
lemma DERIV_nonpos_imp_nonincreasing:
- fixes a::real and b::real and f::"real => real"
- assumes "a \<le> b" and
- "\<forall>x. a \<le> x & x \<le> b --> (\<exists>y. DERIV f x :> y & y \<le> 0)"
+ fixes a b :: real
+ and f :: "real \<Rightarrow> real"
+ assumes "a \<le> b"
+ and "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> (\<exists>y. DERIV f x :> y \<and> y \<le> 0)"
shows "f a \<ge> f b"
proof -
- have "(%x. -f x) a \<le> (%x. -f x) b"
- apply (rule DERIV_nonneg_imp_nondecreasing [of a b "%x. -f x"])
+ have "(\<lambda>x. -f x) a \<le> (\<lambda>x. -f x) b"
+ apply (rule DERIV_nonneg_imp_nondecreasing [of a b "\<lambda>x. -f x"])
using assms
- apply auto
+ apply auto
apply (metis DERIV_minus neg_0_le_iff_le)
done
- thus ?thesis
+ then show ?thesis
by simp
qed
lemma DERIV_pos_imp_increasing_at_bot:
- fixes f :: "real => real"
- assumes "\<And>x. x \<le> b \<Longrightarrow> (EX y. DERIV f x :> y & y > 0)"
- and lim: "(f \<longlongrightarrow> flim) at_bot"
+ fixes f :: "real \<Rightarrow> real"
+ assumes "\<And>x. x \<le> b \<Longrightarrow> (\<exists>y. DERIV f x :> y \<and> y > 0)"
+ and lim: "(f \<longlongrightarrow> flim) at_bot"
shows "flim < f b"
proof -
have "flim \<le> f (b - 1)"
apply (rule tendsto_ge_const [OF _ lim])
- apply (auto simp: trivial_limit_at_bot_linorder eventually_at_bot_linorder)
+ apply (auto simp: trivial_limit_at_bot_linorder eventually_at_bot_linorder)
apply (rule_tac x="b - 2" in exI)
apply (force intro: order.strict_implies_order DERIV_pos_imp_increasing [where f=f] assms)
done
- also have "... < f b"
+ also have "\<dots> < f b"
by (force intro: DERIV_pos_imp_increasing [where f=f] assms)
finally show ?thesis .
qed
lemma DERIV_neg_imp_decreasing_at_top:
- fixes f :: "real => real"
- assumes der: "\<And>x. x \<ge> b \<Longrightarrow> (EX y. DERIV f x :> y & y < 0)"
- and lim: "(f \<longlongrightarrow> flim) at_top"
+ fixes f :: "real \<Rightarrow> real"
+ assumes der: "\<And>x. x \<ge> b \<Longrightarrow> (\<exists>y. DERIV f x :> y \<and> y < 0)"
+ and lim: "(f \<longlongrightarrow> flim) at_top"
shows "flim < f b"
apply (rule DERIV_pos_imp_increasing_at_bot [where f = "\<lambda>i. f (-i)" and b = "-b", simplified])
- apply (metis DERIV_mirror der le_minus_iff neg_0_less_iff_less)
+ apply (metis DERIV_mirror der le_minus_iff neg_0_less_iff_less)
apply (metis filterlim_at_top_mirror lim)
done
@@ -1523,47 +1600,45 @@
lemma DERIV_inverse_function:
fixes f g :: "real \<Rightarrow> real"
assumes der: "DERIV f (g x) :> D"
- assumes neq: "D \<noteq> 0"
- assumes a: "a < x" and b: "x < b"
- assumes inj: "\<forall>y. a < y \<and> y < b \<longrightarrow> f (g y) = y"
- assumes cont: "isCont g x"
+ and neq: "D \<noteq> 0"
+ and x: "a < x" "x < b"
+ and inj: "\<forall>y. a < y \<and> y < b \<longrightarrow> f (g y) = y"
+ and cont: "isCont g x"
shows "DERIV g x :> inverse D"
unfolding DERIV_iff2
proof (rule LIM_equal2)
show "0 < min (x - a) (b - x)"
- using a b by arith
+ using x by arith
next
fix y
assume "norm (y - x) < min (x - a) (b - x)"
- hence "a < y" and "y < b"
+ then have "a < y" and "y < b"
by (simp_all add: abs_less_iff)
- thus "(g y - g x) / (y - x) =
- inverse ((f (g y) - x) / (g y - g x))"
+ then show "(g y - g x) / (y - x) = inverse ((f (g y) - x) / (g y - g x))"
by (simp add: inj)
next
have "(\<lambda>z. (f z - f (g x)) / (z - g x)) \<midarrow>g x\<rightarrow> D"
by (rule der [unfolded DERIV_iff2])
- hence 1: "(\<lambda>z. (f z - x) / (z - g x)) \<midarrow>g x\<rightarrow> D"
- using inj a b by simp
+ then have 1: "(\<lambda>z. (f z - x) / (z - g x)) \<midarrow>g x\<rightarrow> D"
+ using inj x by simp
have 2: "\<exists>d>0. \<forall>y. y \<noteq> x \<and> norm (y - x) < d \<longrightarrow> g y \<noteq> g x"
proof (rule exI, safe)
show "0 < min (x - a) (b - x)"
- using a b by simp
+ using x by simp
next
fix y
assume "norm (y - x) < min (x - a) (b - x)"
- hence y: "a < y" "y < b"
+ then have y: "a < y" "y < b"
by (simp_all add: abs_less_iff)
assume "g y = g x"
- hence "f (g y) = f (g x)" by simp
- hence "y = x" using inj y a b by simp
+ then have "f (g y) = f (g x)" by simp
+ then have "y = x" using inj y x by simp
also assume "y \<noteq> x"
finally show False by simp
qed
have "(\<lambda>y. (f (g y) - x) / (g y - g x)) \<midarrow>x\<rightarrow> D"
using cont 1 2 by (rule isCont_LIM_compose2)
- thus "(\<lambda>y. inverse ((f (g y) - x) / (g y - g x)))
- \<midarrow>x\<rightarrow> inverse D"
+ then show "(\<lambda>y. inverse ((f (g y) - x) / (g y - g x))) \<midarrow>x\<rightarrow> inverse D"
using neq by (rule tendsto_inverse)
qed
@@ -1577,65 +1652,67 @@
and gc: "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont g x"
and gd: "\<forall>x. a < x \<and> x < b \<longrightarrow> g differentiable (at x)"
shows "\<exists>g'c f'c c.
- DERIV g c :> g'c \<and> DERIV f c :> f'c \<and> a < c \<and> c < b \<and> ((f b - f a) * g'c) = ((g b - g a) * f'c)"
+ DERIV g c :> g'c \<and> DERIV f c :> f'c \<and> a < c \<and> c < b \<and> (f b - f a) * g'c = (g b - g a) * f'c"
proof -
- let ?h = "\<lambda>x. (f b - f a)*(g x) - (g b - g a)*(f x)"
- from assms have "a < b" by simp
- moreover have "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont ?h x"
- using fc gc by simp
- moreover have "\<forall>x. a < x \<and> x < b \<longrightarrow> ?h differentiable (at x)"
- using fd gd by simp
- ultimately have "\<exists>l z. a < z \<and> z < b \<and> DERIV ?h z :> l \<and> ?h b - ?h a = (b - a) * l" by (rule MVT)
- then obtain l where ldef: "\<exists>z. a < z \<and> z < b \<and> DERIV ?h z :> l \<and> ?h b - ?h a = (b - a) * l" ..
- then obtain c where cdef: "a < c \<and> c < b \<and> DERIV ?h c :> l \<and> ?h b - ?h a = (b - a) * l" ..
+ let ?h = "\<lambda>x. (f b - f a) * g x - (g b - g a) * f x"
+ have "\<exists>l z. a < z \<and> z < b \<and> DERIV ?h z :> l \<and> ?h b - ?h a = (b - a) * l"
+ proof (rule MVT)
+ from assms show "a < b" by simp
+ show "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont ?h x"
+ using fc gc by simp
+ show "\<forall>x. a < x \<and> x < b \<longrightarrow> ?h differentiable (at x)"
+ using fd gd by simp
+ qed
+ then obtain l where l: "\<exists>z. a < z \<and> z < b \<and> DERIV ?h z :> l \<and> ?h b - ?h a = (b - a) * l" ..
+ then obtain c where c: "a < c \<and> c < b \<and> DERIV ?h c :> l \<and> ?h b - ?h a = (b - a) * l" ..
- from cdef have cint: "a < c \<and> c < b" by auto
+ from c have cint: "a < c \<and> c < b" by auto
with gd have "g differentiable (at c)" by simp
- hence "\<exists>D. DERIV g c :> D" by (rule differentiableD)
- then obtain g'c where g'cdef: "DERIV g c :> g'c" ..
+ then have "\<exists>D. DERIV g c :> D" by (rule differentiableD)
+ then obtain g'c where g'c: "DERIV g c :> g'c" ..
- from cdef have "a < c \<and> c < b" by auto
+ from c have "a < c \<and> c < b" by auto
with fd have "f differentiable (at c)" by simp
- hence "\<exists>D. DERIV f c :> D" by (rule differentiableD)
- then obtain f'c where f'cdef: "DERIV f c :> f'c" ..
+ then have "\<exists>D. DERIV f c :> D" by (rule differentiableD)
+ then obtain f'c where f'c: "DERIV f c :> f'c" ..
- from cdef have "DERIV ?h c :> l" by auto
+ from c have "DERIV ?h c :> l" by auto
moreover have "DERIV ?h c :> g'c * (f b - f a) - f'c * (g b - g a)"
- using g'cdef f'cdef by (auto intro!: derivative_eq_intros)
+ using g'c f'c by (auto intro!: derivative_eq_intros)
ultimately have leq: "l = g'c * (f b - f a) - f'c * (g b - g a)" by (rule DERIV_unique)
- {
- from cdef have "?h b - ?h a = (b - a) * l" by auto
+ have "?h b - ?h a = (b - a) * (g'c * (f b - f a) - f'c * (g b - g a))"
+ proof -
+ from c have "?h b - ?h a = (b - a) * l" by auto
also from leq have "\<dots> = (b - a) * (g'c * (f b - f a) - f'c * (g b - g a))" by simp
- finally have "?h b - ?h a = (b - a) * (g'c * (f b - f a) - f'c * (g b - g a))" by simp
- }
- moreover
- {
+ finally show ?thesis by simp
+ qed
+ moreover have "?h b - ?h a = 0"
+ proof -
have "?h b - ?h a =
- ((f b)*(g b) - (f a)*(g b) - (g b)*(f b) + (g a)*(f b)) -
- ((f b)*(g a) - (f a)*(g a) - (g b)*(f a) + (g a)*(f a))"
+ ((f b)*(g b) - (f a)*(g b) - (g b)*(f b) + (g a)*(f b)) -
+ ((f b)*(g a) - (f a)*(g a) - (g b)*(f a) + (g a)*(f a))"
by (simp add: algebra_simps)
- hence "?h b - ?h a = 0" by auto
- }
+ then show ?thesis by auto
+ qed
ultimately have "(b - a) * (g'c * (f b - f a) - f'c * (g b - g a)) = 0" by auto
with alb have "g'c * (f b - f a) - f'c * (g b - g a) = 0" by simp
- hence "g'c * (f b - f a) = f'c * (g b - g a)" by simp
- hence "(f b - f a) * g'c = (g b - g a) * f'c" by (simp add: ac_simps)
-
- with g'cdef f'cdef cint show ?thesis by auto
+ then have "g'c * (f b - f a) = f'c * (g b - g a)" by simp
+ then have "(f b - f a) * g'c = (g b - g a) * f'c" by (simp add: ac_simps)
+ with g'c f'c cint show ?thesis by auto
qed
lemma GMVT':
fixes f g :: "real \<Rightarrow> real"
assumes "a < b"
- assumes isCont_f: "\<And>z. a \<le> z \<Longrightarrow> z \<le> b \<Longrightarrow> isCont f z"
- assumes isCont_g: "\<And>z. a \<le> z \<Longrightarrow> z \<le> b \<Longrightarrow> isCont g z"
- assumes DERIV_g: "\<And>z. a < z \<Longrightarrow> z < b \<Longrightarrow> DERIV g z :> (g' z)"
- assumes DERIV_f: "\<And>z. a < z \<Longrightarrow> z < b \<Longrightarrow> DERIV f z :> (f' z)"
+ and isCont_f: "\<And>z. a \<le> z \<Longrightarrow> z \<le> b \<Longrightarrow> isCont f z"
+ and isCont_g: "\<And>z. a \<le> z \<Longrightarrow> z \<le> b \<Longrightarrow> isCont g z"
+ and DERIV_g: "\<And>z. a < z \<Longrightarrow> z < b \<Longrightarrow> DERIV g z :> (g' z)"
+ and DERIV_f: "\<And>z. a < z \<Longrightarrow> z < b \<Longrightarrow> DERIV f z :> (f' z)"
shows "\<exists>c. a < c \<and> c < b \<and> (f b - f a) * g' c = (g b - g a) * f' c"
proof -
have "\<exists>g'c f'c c. DERIV g c :> g'c \<and> DERIV f c :> f'c \<and>
- a < c \<and> c < b \<and> (f b - f a) * g'c = (g b - g a) * f'c"
+ a < c \<and> c < b \<and> (f b - f a) * g'c = (g b - g a) * f'c"
using assms by (intro GMVT) (force simp: real_differentiable_def)+
then obtain c where "a < c" "c < b" "(f b - f a) * g' c = (g b - g a) * f' c"
using DERIV_f DERIV_g by (force dest: DERIV_unique)
@@ -1648,25 +1725,26 @@
lemma isCont_If_ge:
fixes a :: "'a :: linorder_topology"
- shows "continuous (at_left a) g \<Longrightarrow> (f \<longlongrightarrow> g a) (at_right a) \<Longrightarrow> isCont (\<lambda>x. if x \<le> a then g x else f x) a"
+ shows "continuous (at_left a) g \<Longrightarrow> (f \<longlongrightarrow> g a) (at_right a) \<Longrightarrow>
+ isCont (\<lambda>x. if x \<le> a then g x else f x) a"
unfolding isCont_def continuous_within
apply (intro filterlim_split_at)
- apply (subst filterlim_cong[OF refl refl, where g=g])
- apply (simp_all add: eventually_at_filter less_le)
+ apply (subst filterlim_cong[OF refl refl, where g=g])
+ apply (simp_all add: eventually_at_filter less_le)
apply (subst filterlim_cong[OF refl refl, where g=f])
- apply (simp_all add: eventually_at_filter less_le)
+ apply (simp_all add: eventually_at_filter less_le)
done
lemma lhopital_right_0:
fixes f0 g0 :: "real \<Rightarrow> real"
assumes f_0: "(f0 \<longlongrightarrow> 0) (at_right 0)"
- assumes g_0: "(g0 \<longlongrightarrow> 0) (at_right 0)"
- assumes ev:
- "eventually (\<lambda>x. g0 x \<noteq> 0) (at_right 0)"
- "eventually (\<lambda>x. g' x \<noteq> 0) (at_right 0)"
- "eventually (\<lambda>x. DERIV f0 x :> f' x) (at_right 0)"
- "eventually (\<lambda>x. DERIV g0 x :> g' x) (at_right 0)"
- assumes lim: "((\<lambda> x. (f' x / g' x)) \<longlongrightarrow> x) (at_right 0)"
+ and g_0: "(g0 \<longlongrightarrow> 0) (at_right 0)"
+ and ev:
+ "eventually (\<lambda>x. g0 x \<noteq> 0) (at_right 0)"
+ "eventually (\<lambda>x. g' x \<noteq> 0) (at_right 0)"
+ "eventually (\<lambda>x. DERIV f0 x :> f' x) (at_right 0)"
+ "eventually (\<lambda>x. DERIV g0 x :> g' x) (at_right 0)"
+ and lim: "((\<lambda> x. (f' x / g' x)) \<longlongrightarrow> x) (at_right 0)"
shows "((\<lambda> x. f0 x / g0 x) \<longlongrightarrow> x) (at_right 0)"
proof -
define f where [abs_def]: "f x = (if x \<le> 0 then 0 else f0 x)" for x
@@ -1688,15 +1766,15 @@
have g_neq_0: "\<And>x. 0 < x \<Longrightarrow> x < a \<Longrightarrow> g x \<noteq> 0"
using g0_neq_0 by (simp add: g_def)
- { fix x assume x: "0 < x" "x < a" then have "DERIV f x :> (f' x)"
- by (intro DERIV_cong_ev[THEN iffD1, OF _ _ _ f0[OF x]])
- (auto simp: f_def eventually_nhds_metric dist_real_def intro!: exI[of _ x]) }
- note f = this
+ have f: "DERIV f x :> (f' x)" if x: "0 < x" "x < a" for x
+ using that
+ by (intro DERIV_cong_ev[THEN iffD1, OF _ _ _ f0[OF x]])
+ (auto simp: f_def eventually_nhds_metric dist_real_def intro!: exI[of _ x])
- { fix x assume x: "0 < x" "x < a" then have "DERIV g x :> (g' x)"
- by (intro DERIV_cong_ev[THEN iffD1, OF _ _ _ g0[OF x]])
- (auto simp: g_def eventually_nhds_metric dist_real_def intro!: exI[of _ x]) }
- note g = this
+ have g: "DERIV g x :> (g' x)" if x: "0 < x" "x < a" for x
+ using that
+ by (intro DERIV_cong_ev[THEN iffD1, OF _ _ _ g0[OF x]])
+ (auto simp: g_def eventually_nhds_metric dist_real_def intro!: exI[of _ x])
have "isCont f 0"
unfolding f_def by (intro isCont_If_ge f_0 continuous_const)
@@ -1705,8 +1783,9 @@
unfolding g_def by (intro isCont_If_ge g_0 continuous_const)
have "\<exists>\<zeta>. \<forall>x\<in>{0 <..< a}. 0 < \<zeta> x \<and> \<zeta> x < x \<and> f x / g x = f' (\<zeta> x) / g' (\<zeta> x)"
- proof (rule bchoice, rule)
- fix x assume "x \<in> {0 <..< a}"
+ proof (rule bchoice, rule ballI)
+ fix x
+ assume "x \<in> {0 <..< a}"
then have x[arith]: "0 < x" "x < a" by auto
with g'_neq_0 g_neq_0 \<open>g 0 = 0\<close> have g': "\<And>x. 0 < x \<Longrightarrow> x < a \<Longrightarrow> 0 \<noteq> g' x" "g 0 \<noteq> g x"
by auto
@@ -1747,53 +1826,57 @@
qed
lemma lhopital_right:
- "((f::real \<Rightarrow> real) \<longlongrightarrow> 0) (at_right x) \<Longrightarrow> (g \<longlongrightarrow> 0) (at_right x) \<Longrightarrow>
+ "(f \<longlongrightarrow> 0) (at_right x) \<Longrightarrow> (g \<longlongrightarrow> 0) (at_right x) \<Longrightarrow>
eventually (\<lambda>x. g x \<noteq> 0) (at_right x) \<Longrightarrow>
eventually (\<lambda>x. g' x \<noteq> 0) (at_right x) \<Longrightarrow>
eventually (\<lambda>x. DERIV f x :> f' x) (at_right x) \<Longrightarrow>
eventually (\<lambda>x. DERIV g x :> g' x) (at_right x) \<Longrightarrow>
((\<lambda> x. (f' x / g' x)) \<longlongrightarrow> y) (at_right x) \<Longrightarrow>
((\<lambda> x. f x / g x) \<longlongrightarrow> y) (at_right x)"
+ for x :: real
unfolding eventually_at_right_to_0[of _ x] filterlim_at_right_to_0[of _ _ x] DERIV_shift
by (rule lhopital_right_0)
lemma lhopital_left:
- "((f::real \<Rightarrow> real) \<longlongrightarrow> 0) (at_left x) \<Longrightarrow> (g \<longlongrightarrow> 0) (at_left x) \<Longrightarrow>
+ "(f \<longlongrightarrow> 0) (at_left x) \<Longrightarrow> (g \<longlongrightarrow> 0) (at_left x) \<Longrightarrow>
eventually (\<lambda>x. g x \<noteq> 0) (at_left x) \<Longrightarrow>
eventually (\<lambda>x. g' x \<noteq> 0) (at_left x) \<Longrightarrow>
eventually (\<lambda>x. DERIV f x :> f' x) (at_left x) \<Longrightarrow>
eventually (\<lambda>x. DERIV g x :> g' x) (at_left x) \<Longrightarrow>
((\<lambda> x. (f' x / g' x)) \<longlongrightarrow> y) (at_left x) \<Longrightarrow>
((\<lambda> x. f x / g x) \<longlongrightarrow> y) (at_left x)"
+ for x :: real
unfolding eventually_at_left_to_right filterlim_at_left_to_right DERIV_mirror
by (rule lhopital_right[where f'="\<lambda>x. - f' (- x)"]) (auto simp: DERIV_mirror)
lemma lhopital:
- "((f::real \<Rightarrow> real) \<longlongrightarrow> 0) (at x) \<Longrightarrow> (g \<longlongrightarrow> 0) (at x) \<Longrightarrow>
+ "(f \<longlongrightarrow> 0) (at x) \<Longrightarrow> (g \<longlongrightarrow> 0) (at x) \<Longrightarrow>
eventually (\<lambda>x. g x \<noteq> 0) (at x) \<Longrightarrow>
eventually (\<lambda>x. g' x \<noteq> 0) (at x) \<Longrightarrow>
eventually (\<lambda>x. DERIV f x :> f' x) (at x) \<Longrightarrow>
eventually (\<lambda>x. DERIV g x :> g' x) (at x) \<Longrightarrow>
((\<lambda> x. (f' x / g' x)) \<longlongrightarrow> y) (at x) \<Longrightarrow>
((\<lambda> x. f x / g x) \<longlongrightarrow> y) (at x)"
+ for x :: real
unfolding eventually_at_split filterlim_at_split
by (auto intro!: lhopital_right[of f x g g' f'] lhopital_left[of f x g g' f'])
lemma lhopital_right_0_at_top:
fixes f g :: "real \<Rightarrow> real"
assumes g_0: "LIM x at_right 0. g x :> at_top"
- assumes ev:
- "eventually (\<lambda>x. g' x \<noteq> 0) (at_right 0)"
- "eventually (\<lambda>x. DERIV f x :> f' x) (at_right 0)"
- "eventually (\<lambda>x. DERIV g x :> g' x) (at_right 0)"
- assumes lim: "((\<lambda> x. (f' x / g' x)) \<longlongrightarrow> x) (at_right 0)"
+ and ev:
+ "eventually (\<lambda>x. g' x \<noteq> 0) (at_right 0)"
+ "eventually (\<lambda>x. DERIV f x :> f' x) (at_right 0)"
+ "eventually (\<lambda>x. DERIV g x :> g' x) (at_right 0)"
+ and lim: "((\<lambda> x. (f' x / g' x)) \<longlongrightarrow> x) (at_right 0)"
shows "((\<lambda> x. f x / g x) \<longlongrightarrow> x) (at_right 0)"
unfolding tendsto_iff
proof safe
- fix e :: real assume "0 < e"
-
+ fix e :: real
+ assume "0 < e"
with lim[unfolded tendsto_iff, rule_format, of "e / 4"]
- have "eventually (\<lambda>t. dist (f' t / g' t) x < e / 4) (at_right 0)" by simp
+ have "eventually (\<lambda>t. dist (f' t / g' t) x < e / 4) (at_right 0)"
+ by simp
from eventually_conj[OF eventually_conj[OF ev(1) ev(2)] eventually_conj[OF ev(3) this]]
obtain a where [arith]: "0 < a"
and g'_neq_0: "\<And>x. 0 < x \<Longrightarrow> x < a \<Longrightarrow> g' x \<noteq> 0"
@@ -1801,10 +1884,8 @@
and g0: "\<And>x. 0 < x \<Longrightarrow> x \<le> a \<Longrightarrow> DERIV g x :> (g' x)"
and Df: "\<And>t. 0 < t \<Longrightarrow> t < a \<Longrightarrow> dist (f' t / g' t) x < e / 4"
unfolding eventually_at_le by (auto simp: dist_real_def)
-
- from Df have
- "eventually (\<lambda>t. t < a) (at_right 0)" "eventually (\<lambda>t::real. 0 < t) (at_right 0)"
+ from Df have "eventually (\<lambda>t. t < a) (at_right 0)" "eventually (\<lambda>t::real. 0 < t) (at_right 0)"
unfolding eventually_at by (auto intro!: exI[of _ a] simp: dist_real_def)
moreover
@@ -1824,7 +1905,8 @@
by (auto elim!: eventually_mono simp: dist_real_def)
moreover
- from inv_g have "((\<lambda>t. norm ((f a - x * g a) * inverse (g t))) \<longlongrightarrow> norm ((f a - x * g a) * 0)) (at_right 0)"
+ from inv_g have "((\<lambda>t. norm ((f a - x * g a) * inverse (g t))) \<longlongrightarrow> norm ((f a - x * g a) * 0))
+ (at_right 0)"
by (intro tendsto_intros)
then have "((\<lambda>t. norm (f a - x * g a) / norm (g t)) \<longlongrightarrow> 0) (at_right 0)"
by (simp add: inverse_eq_divide)
@@ -1870,12 +1952,13 @@
by (rule lhopital_right_0_at_top)
lemma lhopital_left_at_top:
- "LIM x at_left x. (g::real \<Rightarrow> real) x :> at_top \<Longrightarrow>
+ "LIM x at_left x. g x :> at_top \<Longrightarrow>
eventually (\<lambda>x. g' x \<noteq> 0) (at_left x) \<Longrightarrow>
eventually (\<lambda>x. DERIV f x :> f' x) (at_left x) \<Longrightarrow>
eventually (\<lambda>x. DERIV g x :> g' x) (at_left x) \<Longrightarrow>
((\<lambda> x. (f' x / g' x)) \<longlongrightarrow> y) (at_left x) \<Longrightarrow>
((\<lambda> x. f x / g x) \<longlongrightarrow> y) (at_left x)"
+ for x :: real
unfolding eventually_at_left_to_right filterlim_at_left_to_right DERIV_mirror
by (rule lhopital_right_at_top[where f'="\<lambda>x. - f' (- x)"]) (auto simp: DERIV_mirror)
@@ -1892,10 +1975,10 @@
lemma lhospital_at_top_at_top:
fixes f g :: "real \<Rightarrow> real"
assumes g_0: "LIM x at_top. g x :> at_top"
- assumes g': "eventually (\<lambda>x. g' x \<noteq> 0) at_top"
- assumes Df: "eventually (\<lambda>x. DERIV f x :> f' x) at_top"
- assumes Dg: "eventually (\<lambda>x. DERIV g x :> g' x) at_top"
- assumes lim: "((\<lambda> x. (f' x / g' x)) \<longlongrightarrow> x) at_top"
+ and g': "eventually (\<lambda>x. g' x \<noteq> 0) at_top"
+ and Df: "eventually (\<lambda>x. DERIV f x :> f' x) at_top"
+ and Dg: "eventually (\<lambda>x. DERIV g x :> g' x) at_top"
+ and lim: "((\<lambda> x. (f' x / g' x)) \<longlongrightarrow> x) at_top"
shows "((\<lambda> x. f x / g x) \<longlongrightarrow> x) at_top"
unfolding filterlim_at_top_to_right
proof (rule lhopital_right_0_at_top)
@@ -1903,37 +1986,32 @@
let ?G = "\<lambda>x. g (inverse x)"
let ?R = "at_right (0::real)"
let ?D = "\<lambda>f' x. f' (inverse x) * - (inverse x ^ Suc (Suc 0))"
-
show "LIM x ?R. ?G x :> at_top"
using g_0 unfolding filterlim_at_top_to_right .
-
show "eventually (\<lambda>x. DERIV ?G x :> ?D g' x) ?R"
unfolding eventually_at_right_to_top
- using Dg eventually_ge_at_top[where c="1::real"]
+ using Dg eventually_ge_at_top[where c=1]
apply eventually_elim
apply (rule DERIV_cong)
- apply (rule DERIV_chain'[where f=inverse])
- apply (auto intro!: DERIV_inverse)
+ apply (rule DERIV_chain'[where f=inverse])
+ apply (auto intro!: DERIV_inverse)
done
-
show "eventually (\<lambda>x. DERIV ?F x :> ?D f' x) ?R"
unfolding eventually_at_right_to_top
- using Df eventually_ge_at_top[where c="1::real"]
+ using Df eventually_ge_at_top[where c=1]
apply eventually_elim
apply (rule DERIV_cong)
- apply (rule DERIV_chain'[where f=inverse])
- apply (auto intro!: DERIV_inverse)
+ apply (rule DERIV_chain'[where f=inverse])
+ apply (auto intro!: DERIV_inverse)
done
-
show "eventually (\<lambda>x. ?D g' x \<noteq> 0) ?R"
unfolding eventually_at_right_to_top
- using g' eventually_ge_at_top[where c="1::real"]
+ using g' eventually_ge_at_top[where c=1]
by eventually_elim auto
-
show "((\<lambda>x. ?D f' x / ?D g' x) \<longlongrightarrow> x) ?R"
unfolding filterlim_at_right_to_top
apply (intro filterlim_cong[THEN iffD2, OF refl refl _ lim])
- using eventually_ge_at_top[where c="1::real"]
+ using eventually_ge_at_top[where c=1]
by eventually_elim simp
qed
--- a/src/HOL/Transcendental.thy Thu Jul 28 17:16:16 2016 +0200
+++ b/src/HOL/Transcendental.thy Thu Jul 28 20:39:51 2016 +0200
@@ -4,7 +4,7 @@
Author: Jeremy Avigad
*)
-section\<open>Power Series, Transcendental Functions etc.\<close>
+section \<open>Power Series, Transcendental Functions etc.\<close>
theory Transcendental
imports Binomial Series Deriv NthRoot
@@ -79,8 +79,7 @@
proof -
have "(\<Sum>n<1. f n * 0 ^ n) = (\<Sum>n. f n * 0 ^ n)"
by (subst suminf_finite[where N="{0}"]) (auto simp: power_0_left)
- then show ?thesis
- by (simp add: One_nat_def)
+ then show ?thesis by simp
qed
lemma powser_sums_zero: "(\<lambda>n. a n * 0^n) sums a 0"
@@ -105,18 +104,17 @@
from 2 have x_neq_0: "x \<noteq> 0" by clarsimp
from 1 have "(\<lambda>n. f n * x^n) \<longlonglongrightarrow> 0"
by (rule summable_LIMSEQ_zero)
- hence "convergent (\<lambda>n. f n * x^n)"
+ then have "convergent (\<lambda>n. f n * x^n)"
by (rule convergentI)
- hence "Cauchy (\<lambda>n. f n * x^n)"
+ then have "Cauchy (\<lambda>n. f n * x^n)"
by (rule convergent_Cauchy)
- hence "Bseq (\<lambda>n. f n * x^n)"
+ then have "Bseq (\<lambda>n. f n * x^n)"
by (rule Cauchy_Bseq)
then obtain K where 3: "0 < K" and 4: "\<forall>n. norm (f n * x^n) \<le> K"
- by (simp add: Bseq_def, safe)
- have "\<exists>N. \<forall>n\<ge>N. norm (norm (f n * z ^ n)) \<le>
- K * norm (z ^ n) * inverse (norm (x^n))"
+ by (auto simp add: Bseq_def)
+ have "\<exists>N. \<forall>n\<ge>N. norm (norm (f n * z ^ n)) \<le> K * norm (z ^ n) * inverse (norm (x^n))"
proof (intro exI allI impI)
- fix n::nat
+ fix n :: nat
assume "0 \<le> n"
have "norm (norm (f n * z ^ n)) * norm (x^n) =
norm (f n * x^n) * norm (z ^ n)"
@@ -127,8 +125,7 @@
by (simp add: x_neq_0)
also have "\<dots> = K * norm (z ^ n) * inverse (norm (x^n)) * norm (x^n)"
by (simp only: mult.assoc)
- finally show "norm (norm (f n * z ^ n)) \<le>
- K * norm (z ^ n) * inverse (norm (x^n))"
+ finally show "norm (norm (f n * z ^ n)) \<le> K * norm (z ^ n) * inverse (norm (x^n))"
by (simp add: mult_le_cancel_right x_neq_0)
qed
moreover have "summable (\<lambda>n. K * norm (z ^ n) * inverse (norm (x^n)))"
@@ -136,14 +133,14 @@
from 2 have "norm (norm (z * inverse x)) < 1"
using x_neq_0
by (simp add: norm_mult nonzero_norm_inverse divide_inverse [where 'a=real, symmetric])
- hence "summable (\<lambda>n. norm (z * inverse x) ^ n)"
+ then have "summable (\<lambda>n. norm (z * inverse x) ^ n)"
by (rule summable_geometric)
- hence "summable (\<lambda>n. K * norm (z * inverse x) ^ n)"
+ then have "summable (\<lambda>n. K * norm (z * inverse x) ^ n)"
by (rule summable_mult)
- thus "summable (\<lambda>n. K * norm (z ^ n) * inverse (norm (x^n)))"
+ then show "summable (\<lambda>n. K * norm (z ^ n) * inverse (norm (x^n)))"
using x_neq_0
by (simp add: norm_mult nonzero_norm_inverse power_mult_distrib
- power_inverse norm_power mult.assoc)
+ power_inverse norm_power mult.assoc)
qed
ultimately show "summable (\<lambda>n. norm (f n * z ^ n))"
by (rule summable_comparison_test)
@@ -162,45 +159,38 @@
shows "(\<lambda>n. of_nat n * x ^ n) \<longlonglongrightarrow> 0"
proof -
have "norm x / (1 - norm x) \<ge> 0"
- using assms
- by (auto simp: divide_simps)
+ using assms by (auto simp: divide_simps)
moreover obtain N where N: "norm x / (1 - norm x) < of_int N"
- using ex_le_of_int
- by (meson ex_less_of_int)
+ using ex_le_of_int by (meson ex_less_of_int)
ultimately have N0: "N>0"
by auto
then have *: "real_of_int (N + 1) * norm x / real_of_int N < 1"
- using N assms
- by (auto simp: field_simps)
- { fix n::nat
- assume "N \<le> int n"
- then have "real_of_int N * real_of_nat (Suc n) \<le> real_of_nat n * real_of_int (1 + N)"
+ using N assms by (auto simp: field_simps)
+ have **: "real_of_int N * (norm x * (real_of_nat (Suc n) * norm (x ^ n))) \<le>
+ real_of_nat n * (norm x * ((1 + N) * norm (x ^ n)))" if "N \<le> int n" for n :: nat
+ proof -
+ from that have "real_of_int N * real_of_nat (Suc n) \<le> real_of_nat n * real_of_int (1 + N)"
by (simp add: algebra_simps)
- then have "(real_of_int N * real_of_nat (Suc n)) * (norm x * norm (x ^ n))
- \<le> (real_of_nat n * (1 + N)) * (norm x * norm (x ^ n))"
+ then have "(real_of_int N * real_of_nat (Suc n)) * (norm x * norm (x ^ n)) \<le>
+ (real_of_nat n * (1 + N)) * (norm x * norm (x ^ n))"
using N0 mult_mono by fastforce
- then have "real_of_int N * (norm x * (real_of_nat (Suc n) * norm (x ^ n)))
- \<le> real_of_nat n * (norm x * ((1 + N) * norm (x ^ n)))"
+ then show ?thesis
by (simp add: algebra_simps)
- } note ** = this
+ qed
show ?thesis using *
- apply (rule summable_LIMSEQ_zero [OF summable_ratio_test, where N1="nat N"])
- apply (simp add: N0 norm_mult field_simps **
- del: of_nat_Suc of_int_add)
- done
+ by (rule summable_LIMSEQ_zero [OF summable_ratio_test, where N1="nat N"])
+ (simp add: N0 norm_mult field_simps ** del: of_nat_Suc of_int_add)
qed
corollary lim_n_over_pown:
fixes x :: "'a::{real_normed_field,banach}"
shows "1 < norm x \<Longrightarrow> ((\<lambda>n. of_nat n / x^n) \<longlongrightarrow> 0) sequentially"
-using powser_times_n_limit_0 [of "inverse x"]
-by (simp add: norm_divide divide_simps)
+ using powser_times_n_limit_0 [of "inverse x"]
+ by (simp add: norm_divide divide_simps)
lemma sum_split_even_odd:
fixes f :: "nat \<Rightarrow> real"
- shows
- "(\<Sum>i<2 * n. if even i then f i else g i) =
- (\<Sum>i<n. f (2 * i)) + (\<Sum>i<n. g (2 * i + 1))"
+ shows "(\<Sum>i<2 * n. if even i then f i else g i) = (\<Sum>i<n. f (2 * i)) + (\<Sum>i<n. g (2 * i + 1))"
proof (induct n)
case 0
then show ?case by simp
@@ -223,33 +213,35 @@
fix r :: real
assume "0 < r"
from \<open>g sums x\<close>[unfolded sums_def, THEN LIMSEQ_D, OF this]
- obtain no where no_eq: "\<And> n. n \<ge> no \<Longrightarrow> (norm (setsum g {..<n} - x) < r)" by blast
+ obtain no where no_eq: "\<And>n. n \<ge> no \<Longrightarrow> (norm (setsum g {..<n} - x) < r)"
+ by blast
let ?SUM = "\<lambda> m. \<Sum>i<m. if even i then 0 else g ((i - 1) div 2)"
- {
- fix m
- assume "m \<ge> 2 * no"
- hence "m div 2 \<ge> no" by auto
+ have "(norm (?SUM m - x) < r)" if "m \<ge> 2 * no" for m
+ proof -
+ from that have "m div 2 \<ge> no" by auto
have sum_eq: "?SUM (2 * (m div 2)) = setsum g {..< m div 2}"
using sum_split_even_odd by auto
- hence "(norm (?SUM (2 * (m div 2)) - x) < r)"
+ then have "(norm (?SUM (2 * (m div 2)) - x) < r)"
using no_eq unfolding sum_eq using \<open>m div 2 \<ge> no\<close> by auto
moreover
have "?SUM (2 * (m div 2)) = ?SUM m"
proof (cases "even m")
case True
- then show ?thesis by (auto simp add: even_two_times_div_two)
+ then show ?thesis
+ by (auto simp add: even_two_times_div_two)
next
case False
then have eq: "Suc (2 * (m div 2)) = m" by simp
- hence "even (2 * (m div 2))" using \<open>odd m\<close> by auto
+ then have "even (2 * (m div 2))" using \<open>odd m\<close> by auto
have "?SUM m = ?SUM (Suc (2 * (m div 2)))" unfolding eq ..
also have "\<dots> = ?SUM (2 * (m div 2))" using \<open>even (2 * (m div 2))\<close> by auto
finally show ?thesis by auto
qed
- ultimately have "(norm (?SUM m - x) < r)" by auto
- }
- thus "\<exists> no. \<forall> m \<ge> no. norm (?SUM m - x) < r" by blast
+ ultimately show ?thesis by auto
+ qed
+ then show "\<exists>no. \<forall> m \<ge> no. norm (?SUM m - x) < r"
+ by blast
qed
lemma sums_if:
@@ -258,70 +250,70 @@
shows "(\<lambda> n. if even n then f (n div 2) else g ((n - 1) div 2)) sums (x + y)"
proof -
let ?s = "\<lambda> n. if even n then 0 else f ((n - 1) div 2)"
- {
- fix B T E
- have "(if B then (0 :: real) else E) + (if B then T else 0) = (if B then T else E)"
- by (cases B) auto
- } note if_sum = this
+ have if_sum: "(if B then (0 :: real) else E) + (if B then T else 0) = (if B then T else E)"
+ for B T E
+ by (cases B) auto
have g_sums: "(\<lambda> n. if even n then 0 else g ((n - 1) div 2)) sums x"
using sums_if'[OF \<open>g sums x\<close>] .
- {
- have if_eq: "\<And>B T E. (if \<not> B then T else E) = (if B then E else T)" by auto
-
- have "?s sums y" using sums_if'[OF \<open>f sums y\<close>] .
- from this[unfolded sums_def, THEN LIMSEQ_Suc]
- have "(\<lambda> n. if even n then f (n div 2) else 0) sums y"
- by (simp add: lessThan_Suc_eq_insert_0 setsum_atLeast1_atMost_eq image_Suc_lessThan
+ have if_eq: "\<And>B T E. (if \<not> B then T else E) = (if B then E else T)"
+ by auto
+ have "?s sums y" using sums_if'[OF \<open>f sums y\<close>] .
+ from this[unfolded sums_def, THEN LIMSEQ_Suc]
+ have "(\<lambda>n. if even n then f (n div 2) else 0) sums y"
+ by (simp add: lessThan_Suc_eq_insert_0 setsum_atLeast1_atMost_eq image_Suc_lessThan
if_eq sums_def cong del: if_cong)
- }
- from sums_add[OF g_sums this] show ?thesis unfolding if_sum .
+ from sums_add[OF g_sums this] show ?thesis
+ by (simp only: if_sum)
qed
subsection \<open>Alternating series test / Leibniz formula\<close>
-text\<open>FIXME: generalise these results from the reals via type classes?\<close>
+(* FIXME: generalise these results from the reals via type classes? *)
lemma sums_alternating_upper_lower:
fixes a :: "nat \<Rightarrow> real"
- assumes mono: "\<And>n. a (Suc n) \<le> a n" and a_pos: "\<And>n. 0 \<le> a n" and "a \<longlonglongrightarrow> 0"
+ assumes mono: "\<And>n. a (Suc n) \<le> a n"
+ and a_pos: "\<And>n. 0 \<le> a n"
+ and "a \<longlonglongrightarrow> 0"
shows "\<exists>l. ((\<forall>n. (\<Sum>i<2*n. (- 1)^i*a i) \<le> l) \<and> (\<lambda> n. \<Sum>i<2*n. (- 1)^i*a i) \<longlonglongrightarrow> l) \<and>
((\<forall>n. l \<le> (\<Sum>i<2*n + 1. (- 1)^i*a i)) \<and> (\<lambda> n. \<Sum>i<2*n + 1. (- 1)^i*a i) \<longlonglongrightarrow> l)"
(is "\<exists>l. ((\<forall>n. ?f n \<le> l) \<and> _) \<and> ((\<forall>n. l \<le> ?g n) \<and> _)")
proof (rule nested_sequence_unique)
- have fg_diff: "\<And>n. ?f n - ?g n = - a (2 * n)" unfolding One_nat_def by auto
+ have fg_diff: "\<And>n. ?f n - ?g n = - a (2 * n)" by auto
show "\<forall>n. ?f n \<le> ?f (Suc n)"
proof
- fix n
- show "?f n \<le> ?f (Suc n)" using mono[of "2*n"] by auto
+ show "?f n \<le> ?f (Suc n)" for n
+ using mono[of "2*n"] by auto
qed
show "\<forall>n. ?g (Suc n) \<le> ?g n"
proof
- fix n
- show "?g (Suc n) \<le> ?g n" using mono[of "Suc (2*n)"]
- unfolding One_nat_def by auto
+ show "?g (Suc n) \<le> ?g n" for n
+ using mono[of "Suc (2*n)"] by auto
qed
show "\<forall>n. ?f n \<le> ?g n"
proof
- fix n
- show "?f n \<le> ?g n" using fg_diff a_pos
- unfolding One_nat_def by auto
+ show "?f n \<le> ?g n" for n
+ using fg_diff a_pos by auto
qed
- show "(\<lambda>n. ?f n - ?g n) \<longlonglongrightarrow> 0" unfolding fg_diff
+ show "(\<lambda>n. ?f n - ?g n) \<longlonglongrightarrow> 0"
+ unfolding fg_diff
proof (rule LIMSEQ_I)
fix r :: real
assume "0 < r"
with \<open>a \<longlonglongrightarrow> 0\<close>[THEN LIMSEQ_D] obtain N where "\<And> n. n \<ge> N \<Longrightarrow> norm (a n - 0) < r"
by auto
- hence "\<forall>n \<ge> N. norm (- a (2 * n) - 0) < r" by auto
- thus "\<exists>N. \<forall>n \<ge> N. norm (- a (2 * n) - 0) < r" by auto
+ then have "\<forall>n \<ge> N. norm (- a (2 * n) - 0) < r"
+ by auto
+ then show "\<exists>N. \<forall>n \<ge> N. norm (- a (2 * n) - 0) < r"
+ by auto
qed
qed
lemma summable_Leibniz':
fixes a :: "nat \<Rightarrow> real"
assumes a_zero: "a \<longlonglongrightarrow> 0"
- and a_pos: "\<And> n. 0 \<le> a n"
- and a_monotone: "\<And> n. a (Suc n) \<le> a n"
+ and a_pos: "\<And>n. 0 \<le> a n"
+ and a_monotone: "\<And>n. a (Suc n) \<le> a n"
shows summable: "summable (\<lambda> n. (-1)^n * a n)"
and "\<And>n. (\<Sum>i<2*n. (-1)^i*a i) \<le> (\<Sum>i. (-1)^i*a i)"
and "(\<lambda>n. \<Sum>i<2*n. (-1)^i*a i) \<longlonglongrightarrow> (\<Sum>i. (-1)^i*a i)"
@@ -345,44 +337,44 @@
fix r :: real
assume "0 < r"
with \<open>?f \<longlonglongrightarrow> l\<close>[THEN LIMSEQ_D]
- obtain f_no where f: "\<And> n. n \<ge> f_no \<Longrightarrow> norm (?f n - l) < r" by auto
-
+ obtain f_no where f: "\<And>n. n \<ge> f_no \<Longrightarrow> norm (?f n - l) < r"
+ by auto
from \<open>0 < r\<close> \<open>?g \<longlonglongrightarrow> l\<close>[THEN LIMSEQ_D]
- obtain g_no where g: "\<And> n. n \<ge> g_no \<Longrightarrow> norm (?g n - l) < r" by auto
-
- {
- fix n :: nat
- assume "n \<ge> (max (2 * f_no) (2 * g_no))"
- hence "n \<ge> 2 * f_no" and "n \<ge> 2 * g_no" by auto
- have "norm (?Sa n - l) < r"
+ obtain g_no where g: "\<And>n. n \<ge> g_no \<Longrightarrow> norm (?g n - l) < r"
+ by auto
+ have "norm (?Sa n - l) < r" if "n \<ge> (max (2 * f_no) (2 * g_no))" for n
+ proof -
+ from that have "n \<ge> 2 * f_no" and "n \<ge> 2 * g_no" by auto
+ show ?thesis
proof (cases "even n")
case True
- then have n_eq: "2 * (n div 2) = n" by (simp add: even_two_times_div_two)
+ then have n_eq: "2 * (n div 2) = n"
+ by (simp add: even_two_times_div_two)
with \<open>n \<ge> 2 * f_no\<close> have "n div 2 \<ge> f_no"
by auto
from f[OF this] show ?thesis
unfolding n_eq atLeastLessThanSuc_atLeastAtMost .
next
case False
- hence "even (n - 1)" by simp
+ then have "even (n - 1)" by simp
then have n_eq: "2 * ((n - 1) div 2) = n - 1"
by (simp add: even_two_times_div_two)
- hence range_eq: "n - 1 + 1 = n"
+ then have range_eq: "n - 1 + 1 = n"
using odd_pos[OF False] by auto
-
from n_eq \<open>n \<ge> 2 * g_no\<close> have "(n - 1) div 2 \<ge> g_no"
by auto
from g[OF this] show ?thesis
- unfolding n_eq range_eq .
+ by (simp only: n_eq range_eq)
qed
- }
- thus "\<exists>no. \<forall>n \<ge> no. norm (?Sa n - l) < r" by blast
+ qed
+ then show "\<exists>no. \<forall>n \<ge> no. norm (?Sa n - l) < r" by blast
qed
- hence sums_l: "(\<lambda>i. (-1)^i * a i) sums l"
- unfolding sums_def .
- thus "summable ?S" using summable_def by auto
-
- have "l = suminf ?S" using sums_unique[OF sums_l] .
+ then have sums_l: "(\<lambda>i. (-1)^i * a i) sums l"
+ by (simp only: sums_def)
+ then show "summable ?S"
+ by (auto simp: summable_def)
+
+ have "l = suminf ?S" by (rule sums_unique[OF sums_l])
fix n
show "suminf ?S \<le> ?g n"
@@ -397,7 +389,8 @@
theorem summable_Leibniz:
fixes a :: "nat \<Rightarrow> real"
- assumes a_zero: "a \<longlonglongrightarrow> 0" and "monoseq a"
+ assumes a_zero: "a \<longlonglongrightarrow> 0"
+ and "monoseq a"
shows "summable (\<lambda> n. (-1)^n * a n)" (is "?summable")
and "0 < a 0 \<longrightarrow>
(\<forall>n. (\<Sum>i. (- 1)^i*a i) \<in> { \<Sum>i<2*n. (- 1)^i * a i .. \<Sum>i<2*n+1. (- 1)^i * a i})" (is "?pos")
@@ -407,30 +400,25 @@
and "(\<lambda>n. \<Sum>i<2*n+1. (- 1)^i*a i) \<longlonglongrightarrow> (\<Sum>i. (- 1)^i*a i)" (is "?g")
proof -
have "?summable \<and> ?pos \<and> ?neg \<and> ?f \<and> ?g"
- proof (cases "(\<forall> n. 0 \<le> a n) \<and> (\<forall>m. \<forall>n\<ge>m. a n \<le> a m)")
+ proof (cases "(\<forall>n. 0 \<le> a n) \<and> (\<forall>m. \<forall>n\<ge>m. a n \<le> a m)")
case True
- hence ord: "\<And>n m. m \<le> n \<Longrightarrow> a n \<le> a m" and ge0: "\<And> n. 0 \<le> a n"
+ then have ord: "\<And>n m. m \<le> n \<Longrightarrow> a n \<le> a m"
+ and ge0: "\<And>n. 0 \<le> a n"
by auto
- {
- fix n
- have "a (Suc n) \<le> a n"
- using ord[where n="Suc n" and m=n] by auto
- } note mono = this
+ have mono: "a (Suc n) \<le> a n" for n
+ using ord[where n="Suc n" and m=n] by auto
note leibniz = summable_Leibniz'[OF \<open>a \<longlonglongrightarrow> 0\<close> ge0]
from leibniz[OF mono]
show ?thesis using \<open>0 \<le> a 0\<close> by auto
next
- let ?a = "\<lambda> n. - a n"
+ let ?a = "\<lambda>n. - a n"
case False
with monoseq_le[OF \<open>monoseq a\<close> \<open>a \<longlonglongrightarrow> 0\<close>]
have "(\<forall> n. a n \<le> 0) \<and> (\<forall>m. \<forall>n\<ge>m. a m \<le> a n)" by auto
- hence ord: "\<And>n m. m \<le> n \<Longrightarrow> ?a n \<le> ?a m" and ge0: "\<And> n. 0 \<le> ?a n"
+ then have ord: "\<And>n m. m \<le> n \<Longrightarrow> ?a n \<le> ?a m" and ge0: "\<And> n. 0 \<le> ?a n"
by auto
- {
- fix n
- have "?a (Suc n) \<le> ?a n" using ord[where n="Suc n" and m=n]
- by auto
- } note monotone = this
+ have monotone: "?a (Suc n) \<le> ?a n" for n
+ using ord[where n="Suc n" and m=n] by auto
note leibniz =
summable_Leibniz'[OF _ ge0, of "\<lambda>x. x",
OF tendsto_minus[OF \<open>a \<longlonglongrightarrow> 0\<close>, unfolded minus_zero] monotone]
@@ -440,9 +428,9 @@
unfolding summable_def by auto
from this[THEN sums_minus] have "(\<lambda> n. (-1)^n * a n) sums -l"
by auto
- hence ?summable unfolding summable_def by auto
+ then have ?summable by (auto simp: summable_def)
moreover
- have "\<And>a b :: real. \<bar>- a - - b\<bar> = \<bar>a - b\<bar>"
+ have "\<bar>- a - - b\<bar> = \<bar>a - b\<bar>" for a b :: real
unfolding minus_diff_minus by auto
from suminf_minus[OF leibniz(1), unfolded mult_minus_right minus_minus]
@@ -463,60 +451,60 @@
by safe
qed
+
subsection \<open>Term-by-Term Differentiability of Power Series\<close>
definition diffs :: "(nat \<Rightarrow> 'a::ring_1) \<Rightarrow> nat \<Rightarrow> 'a"
where "diffs c = (\<lambda>n. of_nat (Suc n) * c (Suc n))"
-text\<open>Lemma about distributing negation over it\<close>
+text \<open>Lemma about distributing negation over it.\<close>
lemma diffs_minus: "diffs (\<lambda>n. - c n) = (\<lambda>n. - diffs c n)"
by (simp add: diffs_def)
lemma diffs_equiv:
- fixes x :: "'a::{real_normed_vector, ring_1}"
+ fixes x :: "'a::{real_normed_vector,ring_1}"
shows "summable (\<lambda>n. diffs c n * x^n) \<Longrightarrow>
- (\<lambda>n. of_nat n * c n * x^(n - Suc 0)) sums (\<Sum>n. diffs c n * x^n)"
+ (\<lambda>n. of_nat n * c n * x^(n - Suc 0)) sums (\<Sum>n. diffs c n * x^n)"
unfolding diffs_def
by (simp add: summable_sums sums_Suc_imp)
lemma lemma_termdiff1:
- fixes z :: "'a :: {monoid_mult,comm_ring}" shows
- "(\<Sum>p<m. (((z + h) ^ (m - p)) * (z ^ p)) - (z ^ m)) =
- (\<Sum>p<m. (z ^ p) * (((z + h) ^ (m - p)) - (z ^ (m - p))))"
+ fixes z :: "'a :: {monoid_mult,comm_ring}"
+ shows "(\<Sum>p<m. (((z + h) ^ (m - p)) * (z ^ p)) - (z ^ m)) =
+ (\<Sum>p<m. (z ^ p) * (((z + h) ^ (m - p)) - (z ^ (m - p))))"
by (auto simp add: algebra_simps power_add [symmetric])
-lemma sumr_diff_mult_const2:
- "setsum f {..<n} - of_nat n * (r::'a::ring_1) = (\<Sum>i<n. f i - r)"
+lemma sumr_diff_mult_const2: "setsum f {..<n} - of_nat n * r = (\<Sum>i<n. f i - r)"
+ for r :: "'a::ring_1"
by (simp add: setsum_subtractf)
lemma lemma_realpow_rev_sumr:
- "(\<Sum>p<Suc n. (x ^ p) * (y ^ (n - p))) =
- (\<Sum>p<Suc n. (x ^ (n - p)) * (y ^ p))"
+ "(\<Sum>p<Suc n. (x ^ p) * (y ^ (n - p))) = (\<Sum>p<Suc n. (x ^ (n - p)) * (y ^ p))"
by (subst nat_diff_setsum_reindex[symmetric]) simp
lemma lemma_termdiff2:
- fixes h :: "'a :: {field}"
+ fixes h :: "'a::field"
assumes h: "h \<noteq> 0"
- shows
- "((z + h) ^ n - z ^ n) / h - of_nat n * z ^ (n - Suc 0) =
- h * (\<Sum>p< n - Suc 0. \<Sum>q< n - Suc 0 - p.
- (z + h) ^ q * z ^ (n - 2 - q))" (is "?lhs = ?rhs")
- apply (subgoal_tac "h * ?lhs = h * ?rhs", simp add: h)
+ shows "((z + h) ^ n - z ^ n) / h - of_nat n * z ^ (n - Suc 0) =
+ h * (\<Sum>p< n - Suc 0. \<Sum>q< n - Suc 0 - p. (z + h) ^ q * z ^ (n - 2 - q))"
+ (is "?lhs = ?rhs")
+ apply (subgoal_tac "h * ?lhs = h * ?rhs")
+ apply (simp add: h)
apply (simp add: right_diff_distrib diff_divide_distrib h)
apply (simp add: mult.assoc [symmetric])
- apply (cases "n", simp)
- apply (simp add: diff_power_eq_setsum h
- right_diff_distrib [symmetric] mult.assoc
- del: power_Suc setsum_lessThan_Suc of_nat_Suc)
+ apply (cases n)
+ apply simp
+ apply (simp add: diff_power_eq_setsum h right_diff_distrib [symmetric] mult.assoc
+ del: power_Suc setsum_lessThan_Suc of_nat_Suc)
apply (subst lemma_realpow_rev_sumr)
apply (subst sumr_diff_mult_const2)
apply simp
apply (simp only: lemma_termdiff1 setsum_right_distrib)
apply (rule setsum.cong [OF refl])
apply (simp add: less_iff_Suc_add)
- apply (clarify)
+ apply clarify
apply (simp add: setsum_right_distrib diff_power_eq_setsum ac_simps
- del: setsum_lessThan_Suc power_Suc)
+ del: setsum_lessThan_Suc power_Suc)
apply (subst mult.assoc [symmetric], subst power_add [symmetric])
apply (simp add: ac_simps)
done
@@ -527,21 +515,21 @@
and K: "0 \<le> K"
shows "setsum f {..<n-k} \<le> of_nat n * K"
apply (rule order_trans [OF setsum_mono])
- apply (rule f, simp)
+ apply (rule f)
+ apply simp
apply (simp add: mult_right_mono K)
done
lemma lemma_termdiff3:
- fixes h z :: "'a::{real_normed_field}"
+ fixes h z :: "'a::real_normed_field"
assumes 1: "h \<noteq> 0"
and 2: "norm z \<le> K"
and 3: "norm (z + h) \<le> K"
- shows "norm (((z + h) ^ n - z ^ n) / h - of_nat n * z ^ (n - Suc 0))
- \<le> of_nat n * of_nat (n - Suc 0) * K ^ (n - 2) * norm h"
+ shows "norm (((z + h) ^ n - z ^ n) / h - of_nat n * z ^ (n - Suc 0)) \<le>
+ of_nat n * of_nat (n - Suc 0) * K ^ (n - 2) * norm h"
proof -
have "norm (((z + h) ^ n - z ^ n) / h - of_nat n * z ^ (n - Suc 0)) =
- norm (\<Sum>p<n - Suc 0. \<Sum>q<n - Suc 0 - p.
- (z + h) ^ q * z ^ (n - 2 - q)) * norm h"
+ norm (\<Sum>p<n - Suc 0. \<Sum>q<n - Suc 0 - p. (z + h) ^ q * z ^ (n - 2 - q)) * norm h"
by (metis (lifting, no_types) lemma_termdiff2 [OF 1] mult.commute norm_mult)
also have "\<dots> \<le> of_nat n * (of_nat (n - Suc 0) * K ^ (n - 2)) * norm h"
proof (rule mult_right_mono [OF _ norm_ge_zero])
@@ -552,15 +540,16 @@
apply (simp only: norm_mult norm_power power_add)
apply (intro mult_mono power_mono 2 3 norm_ge_zero zero_le_power K)
done
- show "norm (\<Sum>p<n - Suc 0. \<Sum>q<n - Suc 0 - p. (z + h) ^ q * z ^ (n - 2 - q))
- \<le> of_nat n * (of_nat (n - Suc 0) * K ^ (n - 2))"
+ show "norm (\<Sum>p<n - Suc 0. \<Sum>q<n - Suc 0 - p. (z + h) ^ q * z ^ (n - 2 - q)) \<le>
+ of_nat n * (of_nat (n - Suc 0) * K ^ (n - 2))"
apply (intro
- order_trans [OF norm_setsum]
- real_setsum_nat_ivl_bounded2
- mult_nonneg_nonneg
- of_nat_0_le_iff
- zero_le_power K)
- apply (rule le_Kn, simp)
+ order_trans [OF norm_setsum]
+ real_setsum_nat_ivl_bounded2
+ mult_nonneg_nonneg
+ of_nat_0_le_iff
+ zero_le_power K)
+ apply (rule le_Kn)
+ apply simp
done
qed
also have "\<dots> = of_nat n * of_nat (n - Suc 0) * K ^ (n - 2) * norm h"
@@ -570,8 +559,9 @@
lemma lemma_termdiff4:
fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
- assumes k: "0 < (k::real)"
- and le: "\<And>h. \<lbrakk>h \<noteq> 0; norm h < k\<rbrakk> \<Longrightarrow> norm (f h) \<le> K * norm h"
+ and k :: real
+ assumes k: "0 < k"
+ and le: "\<And>h. h \<noteq> 0 \<Longrightarrow> norm h < k \<Longrightarrow> norm (f h) \<le> K * norm h"
shows "f \<midarrow>0\<rightarrow> 0"
proof (rule tendsto_norm_zero_cancel)
show "(\<lambda>h. norm (f h)) \<midarrow>0\<rightarrow> 0"
@@ -591,24 +581,25 @@
lemma lemma_termdiff5:
fixes g :: "'a::real_normed_vector \<Rightarrow> nat \<Rightarrow> 'b::banach"
- assumes k: "0 < (k::real)"
- assumes f: "summable f"
- assumes le: "\<And>h n. \<lbrakk>h \<noteq> 0; norm h < k\<rbrakk> \<Longrightarrow> norm (g h n) \<le> f n * norm h"
+ and k :: real
+ assumes k: "0 < k"
+ and f: "summable f"
+ and le: "\<And>h n. h \<noteq> 0 \<Longrightarrow> norm h < k \<Longrightarrow> norm (g h n) \<le> f n * norm h"
shows "(\<lambda>h. suminf (g h)) \<midarrow>0\<rightarrow> 0"
proof (rule lemma_termdiff4 [OF k])
- fix h::'a
+ fix h :: 'a
assume "h \<noteq> 0" and "norm h < k"
- hence A: "\<forall>n. norm (g h n) \<le> f n * norm h"
+ then have 1: "\<forall>n. norm (g h n) \<le> f n * norm h"
by (simp add: le)
- hence "\<exists>N. \<forall>n\<ge>N. norm (norm (g h n)) \<le> f n * norm h"
+ then have "\<exists>N. \<forall>n\<ge>N. norm (norm (g h n)) \<le> f n * norm h"
by simp
- moreover from f have B: "summable (\<lambda>n. f n * norm h)"
+ moreover from f have 2: "summable (\<lambda>n. f n * norm h)"
by (rule summable_mult2)
- ultimately have C: "summable (\<lambda>n. norm (g h n))"
+ ultimately have 3: "summable (\<lambda>n. norm (g h n))"
by (rule summable_comparison_test)
- hence "norm (suminf (g h)) \<le> (\<Sum>n. norm (g h n))"
+ then have "norm (suminf (g h)) \<le> (\<Sum>n. norm (g h n))"
by (rule summable_norm)
- also from A C B have "(\<Sum>n. norm (g h n)) \<le> (\<Sum>n. f n * norm h)"
+ also from 1 3 2 have "(\<Sum>n. norm (g h n)) \<le> (\<Sum>n. f n * norm h)"
by (rule suminf_le)
also from f have "(\<Sum>n. f n * norm h) = suminf f * norm h"
by (rule suminf_mult2 [symmetric])
@@ -616,62 +607,63 @@
qed
-text\<open>FIXME: Long proofs\<close>
+(* FIXME: Long proofs *)
lemma termdiffs_aux:
fixes x :: "'a::{real_normed_field,banach}"
assumes 1: "summable (\<lambda>n. diffs (diffs c) n * K ^ n)"
and 2: "norm x < norm K"
- shows "(\<lambda>h. \<Sum>n. c n * (((x + h) ^ n - x^n) / h
- - of_nat n * x ^ (n - Suc 0))) \<midarrow>0\<rightarrow> 0"
+ shows "(\<lambda>h. \<Sum>n. c n * (((x + h) ^ n - x^n) / h - of_nat n * x ^ (n - Suc 0))) \<midarrow>0\<rightarrow> 0"
proof -
- from dense [OF 2]
- obtain r where r1: "norm x < r" and r2: "r < norm K" by fast
+ from dense [OF 2] obtain r where r1: "norm x < r" and r2: "r < norm K"
+ by fast
from norm_ge_zero r1 have r: "0 < r"
by (rule order_le_less_trans)
- hence r_neq_0: "r \<noteq> 0" by simp
+ then have r_neq_0: "r \<noteq> 0" by simp
show ?thesis
proof (rule lemma_termdiff5)
- show "0 < r - norm x" using r1 by simp
+ show "0 < r - norm x"
+ using r1 by simp
from r r2 have "norm (of_real r::'a) < norm K"
by simp
with 1 have "summable (\<lambda>n. norm (diffs (diffs c) n * (of_real r ^ n)))"
by (rule powser_insidea)
- hence "summable (\<lambda>n. diffs (diffs (\<lambda>n. norm (c n))) n * r ^ n)"
- using r
- by (simp add: diffs_def norm_mult norm_power del: of_nat_Suc)
- hence "summable (\<lambda>n. of_nat n * diffs (\<lambda>n. norm (c n)) n * r ^ (n - Suc 0))"
+ then have "summable (\<lambda>n. diffs (diffs (\<lambda>n. norm (c n))) n * r ^ n)"
+ using r by (simp add: diffs_def norm_mult norm_power del: of_nat_Suc)
+ then have "summable (\<lambda>n. of_nat n * diffs (\<lambda>n. norm (c n)) n * r ^ (n - Suc 0))"
by (rule diffs_equiv [THEN sums_summable])
also have "(\<lambda>n. of_nat n * diffs (\<lambda>n. norm (c n)) n * r ^ (n - Suc 0)) =
(\<lambda>n. diffs (\<lambda>m. of_nat (m - Suc 0) * norm (c m) * inverse r) n * (r ^ n))"
apply (rule ext)
apply (simp add: diffs_def)
- apply (case_tac n, simp_all add: r_neq_0)
+ apply (case_tac n)
+ apply (simp_all add: r_neq_0)
done
finally have "summable
(\<lambda>n. of_nat n * (of_nat (n - Suc 0) * norm (c n) * inverse r) * r ^ (n - Suc 0))"
by (rule diffs_equiv [THEN sums_summable])
also have
- "(\<lambda>n. of_nat n * (of_nat (n - Suc 0) * norm (c n) * inverse r) *
- r ^ (n - Suc 0)) =
+ "(\<lambda>n. of_nat n * (of_nat (n - Suc 0) * norm (c n) * inverse r) * r ^ (n - Suc 0)) =
(\<lambda>n. norm (c n) * of_nat n * of_nat (n - Suc 0) * r ^ (n - 2))"
apply (rule ext)
- apply (case_tac "n", simp)
+ apply (case_tac n)
+ apply simp
apply (rename_tac nat)
- apply (case_tac "nat", simp)
+ apply (case_tac nat)
+ apply simp
apply (simp add: r_neq_0)
done
- finally
- show "summable (\<lambda>n. norm (c n) * of_nat n * of_nat (n - Suc 0) * r ^ (n - 2))" .
+ finally show "summable (\<lambda>n. norm (c n) * of_nat n * of_nat (n - Suc 0) * r ^ (n - 2))" .
next
- fix h::'a and n::nat
+ fix h :: 'a
+ fix n :: nat
assume h: "h \<noteq> 0"
assume "norm h < r - norm x"
- hence "norm x + norm h < r" by simp
+ then have "norm x + norm h < r" by simp
with norm_triangle_ineq have xh: "norm (x + h) < r"
by (rule order_le_less_trans)
- show "norm (c n * (((x + h) ^ n - x^n) / h - of_nat n * x ^ (n - Suc 0)))
- \<le> norm (c n) * of_nat n * of_nat (n - Suc 0) * r ^ (n - 2) * norm h"
+ show "norm (c n * (((x + h) ^ n - x^n) / h - of_nat n * x ^ (n - Suc 0))) \<le>
+ norm (c n) * of_nat n * of_nat (n - Suc 0) * r ^ (n - 2) * norm h"
apply (simp only: norm_mult mult.assoc)
apply (rule mult_left_mono [OF _ norm_ge_zero])
apply (simp add: mult.assoc [symmetric])
@@ -683,21 +675,22 @@
lemma termdiffs:
fixes K x :: "'a::{real_normed_field,banach}"
assumes 1: "summable (\<lambda>n. c n * K ^ n)"
- and 2: "summable (\<lambda>n. (diffs c) n * K ^ n)"
- and 3: "summable (\<lambda>n. (diffs (diffs c)) n * K ^ n)"
- and 4: "norm x < norm K"
+ and 2: "summable (\<lambda>n. (diffs c) n * K ^ n)"
+ and 3: "summable (\<lambda>n. (diffs (diffs c)) n * K ^ n)"
+ and 4: "norm x < norm K"
shows "DERIV (\<lambda>x. \<Sum>n. c n * x^n) x :> (\<Sum>n. (diffs c) n * x^n)"
unfolding DERIV_def
proof (rule LIM_zero_cancel)
show "(\<lambda>h. (suminf (\<lambda>n. c n * (x + h) ^ n) - suminf (\<lambda>n. c n * x^n)) / h
- suminf (\<lambda>n. diffs c n * x^n)) \<midarrow>0\<rightarrow> 0"
proof (rule LIM_equal2)
- show "0 < norm K - norm x" using 4 by (simp add: less_diff_eq)
+ show "0 < norm K - norm x"
+ using 4 by (simp add: less_diff_eq)
next
fix h :: 'a
assume "norm (h - 0) < norm K - norm x"
- hence "norm x + norm h < norm K" by simp
- hence 5: "norm (x + h) < norm K"
+ then have "norm x + norm h < norm K" by simp
+ then have 5: "norm (x + h) < norm K"
by (rule norm_triangle_ineq [THEN order_le_less_trans])
have "summable (\<lambda>n. c n * x^n)"
and "summable (\<lambda>n. c n * (x + h) ^ n)"
@@ -720,16 +713,17 @@
lemma termdiff_converges:
fixes x :: "'a::{real_normed_field,banach}"
assumes K: "norm x < K"
- and sm: "\<And>x. norm x < K \<Longrightarrow> summable(\<lambda>n. c n * x ^ n)"
- shows "summable (\<lambda>n. diffs c n * x ^ n)"
+ and sm: "\<And>x. norm x < K \<Longrightarrow> summable(\<lambda>n. c n * x ^ n)"
+ shows "summable (\<lambda>n. diffs c n * x ^ n)"
proof (cases "x = 0")
- case True then show ?thesis
- using powser_sums_zero sums_summable by auto
+ case True
+ then show ?thesis
+ using powser_sums_zero sums_summable by auto
next
case False
- then have "K>0"
+ then have "K > 0"
using K less_trans zero_less_norm_iff by blast
- then obtain r::real where r: "norm x < norm r" "norm r < K" "r>0"
+ then obtain r :: real where r: "norm x < norm r" "norm r < K" "r > 0"
using K False
by (auto simp: field_simps abs_less_iff add_pos_pos intro: that [of "(norm x + K) / 2"])
have "(\<lambda>n. of_nat n * (x / of_real r) ^ n) \<longlonglongrightarrow> 0"
@@ -741,10 +735,11 @@
done
have "summable (\<lambda>n. (of_nat n * c n) * x ^ n)"
apply (rule summable_comparison_test' [of "\<lambda>n. norm(c n * (of_real r) ^ n)" N])
- apply (rule powser_insidea [OF sm [of "of_real ((r+K)/2)"]])
- using N r norm_of_real [of "r+K", where 'a = 'a]
- apply (auto simp add: norm_divide norm_mult norm_power field_simps)
- using less_eq_real_def by fastforce
+ apply (rule powser_insidea [OF sm [of "of_real ((r+K)/2)"]])
+ using N r norm_of_real [of "r + K", where 'a = 'a]
+ apply (auto simp add: norm_divide norm_mult norm_power field_simps)
+ apply (fastforce simp: less_eq_real_def)
+ done
then have "summable (\<lambda>n. (of_nat (Suc n) * c(Suc n)) * x ^ Suc n)"
using summable_iff_shift [of "\<lambda>n. of_nat n * c n * x ^ n" 1]
by simp
@@ -758,23 +753,23 @@
lemma termdiff_converges_all:
fixes x :: "'a::{real_normed_field,banach}"
assumes "\<And>x. summable (\<lambda>n. c n * x^n)"
- shows "summable (\<lambda>n. diffs c n * x^n)"
+ shows "summable (\<lambda>n. diffs c n * x^n)"
apply (rule termdiff_converges [where K = "1 + norm x"])
using assms
- apply auto
+ apply auto
done
lemma termdiffs_strong:
fixes K x :: "'a::{real_normed_field,banach}"
assumes sm: "summable (\<lambda>n. c n * K ^ n)"
- and K: "norm x < norm K"
+ and K: "norm x < norm K"
shows "DERIV (\<lambda>x. \<Sum>n. c n * x^n) x :> (\<Sum>n. diffs c n * x^n)"
proof -
have K2: "norm ((of_real (norm K) + of_real (norm x)) / 2 :: 'a) < norm K"
using K
apply (auto simp: norm_divide field_simps)
apply (rule le_less_trans [of _ "of_real (norm K) + of_real (norm x)"])
- apply (auto simp: mult_2_right norm_triangle_mono)
+ apply (auto simp: mult_2_right norm_triangle_mono)
done
then have [simp]: "norm ((of_real (norm K) + of_real (norm x)) :: 'a) < norm K * 2"
by simp
@@ -786,16 +781,16 @@
by (blast intro: sm termdiff_converges powser_inside)
ultimately show ?thesis
apply (rule termdiffs [where K = "of_real (norm x + norm K) / 2"])
- apply (auto simp: field_simps)
+ apply (auto simp: field_simps)
using K
apply (simp_all add: of_real_add [symmetric] del: of_real_add)
done
qed
lemma termdiffs_strong_converges_everywhere:
- fixes K x :: "'a::{real_normed_field,banach}"
+ fixes K x :: "'a::{real_normed_field,banach}"
assumes "\<And>y. summable (\<lambda>n. c n * y ^ n)"
- shows "((\<lambda>x. \<Sum>n. c n * x^n) has_field_derivative (\<Sum>n. diffs c n * x^n)) (at x)"
+ shows "((\<lambda>x. \<Sum>n. c n * x^n) has_field_derivative (\<Sum>n. diffs c n * x^n)) (at x)"
using termdiffs_strong[OF assms[of "of_real (norm x + 1)"], of x]
by (force simp del: of_real_add)
@@ -803,7 +798,7 @@
fixes K x :: "'a::{real_normed_field,banach}"
assumes "summable (\<lambda>n. c n * K ^ n)"
assumes "norm x < norm K"
- shows "isCont (\<lambda>x. \<Sum>n. c n * x^n) x"
+ shows "isCont (\<lambda>x. \<Sum>n. c n * x^n) x"
using termdiffs_strong[OF assms] by (blast intro!: DERIV_isCont)
lemmas isCont_powser' = isCont_o2[OF _ isCont_powser]
@@ -811,15 +806,15 @@
lemma isCont_powser_converges_everywhere:
fixes K x :: "'a::{real_normed_field,banach}"
assumes "\<And>y. summable (\<lambda>n. c n * y ^ n)"
- shows "isCont (\<lambda>x. \<Sum>n. c n * x^n) x"
+ shows "isCont (\<lambda>x. \<Sum>n. c n * x^n) x"
using termdiffs_strong[OF assms[of "of_real (norm x + 1)"], of x]
by (force intro!: DERIV_isCont simp del: of_real_add)
lemma powser_limit_0:
fixes a :: "nat \<Rightarrow> 'a::{real_normed_field,banach}"
assumes s: "0 < s"
- and sm: "\<And>x. norm x < s \<Longrightarrow> (\<lambda>n. a n * x ^ n) sums (f x)"
- shows "(f \<longlongrightarrow> a 0) (at 0)"
+ and sm: "\<And>x. norm x < s \<Longrightarrow> (\<lambda>n. a n * x ^ n) sums (f x)"
+ shows "(f \<longlongrightarrow> a 0) (at 0)"
proof -
have "summable (\<lambda>n. a n * (of_real s / 2) ^ n)"
apply (rule sums_summable [where l = "f (of_real s / 2)", OF sm])
@@ -834,7 +829,7 @@
then have "isCont (\<lambda>x. \<Sum>n. a n * x ^ n) 0"
by (blast intro: DERIV_continuous)
then have "((\<lambda>x. \<Sum>n. a n * x ^ n) \<longlongrightarrow> a 0) (at 0)"
- by (simp add: continuous_within powser_zero)
+ by (simp add: continuous_within)
then show ?thesis
apply (rule Lim_transform)
apply (auto simp add: LIM_eq)
@@ -847,17 +842,17 @@
lemma powser_limit_0_strong:
fixes a :: "nat \<Rightarrow> 'a::{real_normed_field,banach}"
assumes s: "0 < s"
- and sm: "\<And>x. x \<noteq> 0 \<Longrightarrow> norm x < s \<Longrightarrow> (\<lambda>n. a n * x ^ n) sums (f x)"
- shows "(f \<longlongrightarrow> a 0) (at 0)"
+ and sm: "\<And>x. x \<noteq> 0 \<Longrightarrow> norm x < s \<Longrightarrow> (\<lambda>n. a n * x ^ n) sums (f x)"
+ shows "(f \<longlongrightarrow> a 0) (at 0)"
proof -
have *: "((\<lambda>x. if x = 0 then a 0 else f x) \<longlongrightarrow> a 0) (at 0)"
apply (rule powser_limit_0 [OF s])
- apply (case_tac "x=0")
- apply (auto simp add: powser_sums_zero sm)
+ apply (case_tac "x = 0")
+ apply (auto simp add: powser_sums_zero sm)
done
show ?thesis
apply (subst LIM_equal [where g = "(\<lambda>x. if x = 0 then a 0 else f x)"])
- apply (simp_all add: *)
+ apply (simp_all add: *)
done
qed
@@ -867,15 +862,16 @@
lemma DERIV_series':
fixes f :: "real \<Rightarrow> nat \<Rightarrow> real"
assumes DERIV_f: "\<And> n. DERIV (\<lambda> x. f x n) x0 :> (f' x0 n)"
- and allf_summable: "\<And> x. x \<in> {a <..< b} \<Longrightarrow> summable (f x)" and x0_in_I: "x0 \<in> {a <..< b}"
+ and allf_summable: "\<And> x. x \<in> {a <..< b} \<Longrightarrow> summable (f x)"
+ and x0_in_I: "x0 \<in> {a <..< b}"
and "summable (f' x0)"
and "summable L"
- and L_def: "\<And>n x y. \<lbrakk> x \<in> { a <..< b} ; y \<in> { a <..< b} \<rbrakk> \<Longrightarrow> \<bar>f x n - f y n\<bar> \<le> L n * \<bar>x - y\<bar>"
+ and L_def: "\<And>n x y. x \<in> {a <..< b} \<Longrightarrow> y \<in> {a <..< b} \<Longrightarrow> \<bar>f x n - f y n\<bar> \<le> L n * \<bar>x - y\<bar>"
shows "DERIV (\<lambda> x. suminf (f x)) x0 :> (suminf (f' x0))"
unfolding DERIV_def
proof (rule LIM_I)
fix r :: real
- assume "0 < r" hence "0 < r/3" by auto
+ assume "0 < r" then have "0 < r/3" by auto
obtain N_L where N_L: "\<And> n. N_L \<le> n \<Longrightarrow> \<bar> \<Sum> i. L (i + n) \<bar> < r/3"
using suminf_exist_split[OF \<open>0 < r/3\<close> \<open>summable L\<close>] by auto
@@ -884,8 +880,9 @@
using suminf_exist_split[OF \<open>0 < r/3\<close> \<open>summable (f' x0)\<close>] by auto
let ?N = "Suc (max N_L N_f')"
- have "\<bar> \<Sum> i. f' x0 (i + ?N) \<bar> < r/3" (is "?f'_part < r/3") and
- L_estimate: "\<bar> \<Sum> i. L (i + ?N) \<bar> < r/3" using N_L[of "?N"] and N_f' [of "?N"] by auto
+ have "\<bar> \<Sum> i. f' x0 (i + ?N) \<bar> < r/3" (is "?f'_part < r/3")
+ and L_estimate: "\<bar> \<Sum> i. L (i + ?N) \<bar> < r/3"
+ using N_L[of "?N"] and N_f' [of "?N"] by auto
let ?diff = "\<lambda>i x. (f (x0 + x) i - f x0 i) / x"
@@ -895,7 +892,8 @@
let ?s = "\<lambda>n. SOME s. 0 < s \<and> (\<forall> x. x \<noteq> 0 \<and> \<bar> x \<bar> < s \<longrightarrow> \<bar> ?diff n x - f' x0 n \<bar> < ?r)"
define S' where "S' = Min (?s ` {..< ?N })"
- have "0 < S'" unfolding S'_def
+ have "0 < S'"
+ unfolding S'_def
proof (rule iffD2[OF Min_gr_iff])
show "\<forall>x \<in> (?s ` {..< ?N }). 0 < x"
proof
@@ -906,20 +904,21 @@
from DERIV_D[OF DERIV_f[where n=n], THEN LIM_D, OF \<open>0 < ?r\<close>, unfolded real_norm_def]
obtain s where s_bound: "0 < s \<and> (\<forall>x. x \<noteq> 0 \<and> \<bar>x\<bar> < s \<longrightarrow> \<bar>?diff n x - f' x0 n\<bar> < ?r)"
by auto
- have "0 < ?s n" by (rule someI2[where a=s]) (auto simp add: s_bound simp del: of_nat_Suc)
- thus "0 < x" unfolding \<open>x = ?s n\<close> .
+ have "0 < ?s n"
+ by (rule someI2[where a=s]) (auto simp add: s_bound simp del: of_nat_Suc)
+ then show "0 < x" by (simp only: \<open>x = ?s n\<close>)
qed
qed auto
define S where "S = min (min (x0 - a) (b - x0)) S'"
- hence "0 < S" and S_a: "S \<le> x0 - a" and S_b: "S \<le> b - x0"
+ then have "0 < S" and S_a: "S \<le> x0 - a" and S_b: "S \<le> b - x0"
and "S \<le> S'" using x0_in_I and \<open>0 < S'\<close>
by auto
- {
- fix x
- assume "x \<noteq> 0" and "\<bar> x \<bar> < S"
- hence x_in_I: "x0 + x \<in> { a <..< b }"
+ have "\<bar>(suminf (f (x0 + x)) - suminf (f x0)) / x - suminf (f' x0)\<bar> < r"
+ if "x \<noteq> 0" and "\<bar>x\<bar> < S" for x
+ proof -
+ from that have x_in_I: "x0 + x \<in> {a <..< b}"
using S_a S_b by auto
note diff_smbl = summable_diff[OF allf_summable[OF x_in_I] allf_summable[OF x0_in_I]]
@@ -930,42 +929,49 @@
note div_shft_smbl = summable_divide[OF diff_shft_smbl]
note all_shft_smbl = summable_diff[OF div_smbl ign[OF \<open>summable (f' x0)\<close>]]
- { fix n
- have "\<bar> ?diff (n + ?N) x \<bar> \<le> L (n + ?N) * \<bar> (x0 + x) - x0 \<bar> / \<bar> x \<bar>"
+ have 1: "\<bar>(\<bar>?diff (n + ?N) x\<bar>)\<bar> \<le> L (n + ?N)" for n
+ proof -
+ have "\<bar>?diff (n + ?N) x\<bar> \<le> L (n + ?N) * \<bar>(x0 + x) - x0\<bar> / \<bar>x\<bar>"
using divide_right_mono[OF L_def[OF x_in_I x0_in_I] abs_ge_zero]
- unfolding abs_divide .
- hence "\<bar> (\<bar>?diff (n + ?N) x \<bar>) \<bar> \<le> L (n + ?N)"
- using \<open>x \<noteq> 0\<close> by auto }
- note 1 = this and 2 = summable_rabs_comparison_test[OF _ ign[OF \<open>summable L\<close>]]
- then have "\<bar> \<Sum> i. ?diff (i + ?N) x \<bar> \<le> (\<Sum> i. L (i + ?N))"
- by (metis (lifting) abs_idempotent order_trans[OF summable_rabs[OF 2] suminf_le[OF _ 2 ign[OF \<open>summable L\<close>]]])
- then have "\<bar> \<Sum> i. ?diff (i + ?N) x \<bar> \<le> r / 3" (is "?L_part \<le> r/3")
+ by (simp only: abs_divide)
+ with \<open>x \<noteq> 0\<close> show ?thesis by auto
+ qed
+ note 2 = summable_rabs_comparison_test[OF _ ign[OF \<open>summable L\<close>]]
+ from 1 have "\<bar> \<Sum> i. ?diff (i + ?N) x \<bar> \<le> (\<Sum> i. L (i + ?N))"
+ by (metis (lifting) abs_idempotent
+ order_trans[OF summable_rabs[OF 2] suminf_le[OF _ 2 ign[OF \<open>summable L\<close>]]])
+ then have "\<bar>\<Sum>i. ?diff (i + ?N) x\<bar> \<le> r / 3" (is "?L_part \<le> r/3")
using L_estimate by auto
- have "\<bar>\<Sum>n<?N. ?diff n x - f' x0 n \<bar> \<le> (\<Sum>n<?N. \<bar>?diff n x - f' x0 n \<bar>)" ..
+ have "\<bar>\<Sum>n<?N. ?diff n x - f' x0 n\<bar> \<le> (\<Sum>n<?N. \<bar>?diff n x - f' x0 n\<bar>)" ..
also have "\<dots> < (\<Sum>n<?N. ?r)"
proof (rule setsum_strict_mono)
fix n
assume "n \<in> {..< ?N}"
have "\<bar>x\<bar> < S" using \<open>\<bar>x\<bar> < S\<close> .
also have "S \<le> S'" using \<open>S \<le> S'\<close> .
- also have "S' \<le> ?s n" unfolding S'_def
+ also have "S' \<le> ?s n"
+ unfolding S'_def
proof (rule Min_le_iff[THEN iffD2])
have "?s n \<in> (?s ` {..<?N}) \<and> ?s n \<le> ?s n"
using \<open>n \<in> {..< ?N}\<close> by auto
- thus "\<exists> a \<in> (?s ` {..<?N}). a \<le> ?s n" by blast
+ then show "\<exists> a \<in> (?s ` {..<?N}). a \<le> ?s n"
+ by blast
qed auto
finally have "\<bar>x\<bar> < ?s n" .
- from DERIV_D[OF DERIV_f[where n=n], THEN LIM_D, OF \<open>0 < ?r\<close>, unfolded real_norm_def diff_0_right, unfolded some_eq_ex[symmetric], THEN conjunct2]
+ from DERIV_D[OF DERIV_f[where n=n], THEN LIM_D, OF \<open>0 < ?r\<close>,
+ unfolded real_norm_def diff_0_right, unfolded some_eq_ex[symmetric], THEN conjunct2]
have "\<forall>x. x \<noteq> 0 \<and> \<bar>x\<bar> < ?s n \<longrightarrow> \<bar>?diff n x - f' x0 n\<bar> < ?r" .
with \<open>x \<noteq> 0\<close> and \<open>\<bar>x\<bar> < ?s n\<close> show "\<bar>?diff n x - f' x0 n\<bar> < ?r"
by blast
qed auto
also have "\<dots> = of_nat (card {..<?N}) * ?r"
by (rule setsum_constant)
- also have "\<dots> = real ?N * ?r" by simp
- also have "\<dots> = r/3" by (auto simp del: of_nat_Suc)
+ also have "\<dots> = real ?N * ?r"
+ by simp
+ also have "\<dots> = r/3"
+ by (auto simp del: of_nat_Suc)
finally have "\<bar>\<Sum>n<?N. ?diff n x - f' x0 n \<bar> < r / 3" (is "?diff_part < r / 3") .
from suminf_diff[OF allf_summable[OF x_in_I] allf_summable[OF x0_in_I]]
@@ -973,148 +979,148 @@
\<bar>\<Sum>n. ?diff n x - f' x0 n\<bar>"
unfolding suminf_diff[OF div_smbl \<open>summable (f' x0)\<close>, symmetric]
using suminf_divide[OF diff_smbl, symmetric] by auto
- also have "\<dots> \<le> ?diff_part + \<bar> (\<Sum>n. ?diff (n + ?N) x) - (\<Sum> n. f' x0 (n + ?N)) \<bar>"
+ also have "\<dots> \<le> ?diff_part + \<bar>(\<Sum>n. ?diff (n + ?N) x) - (\<Sum> n. f' x0 (n + ?N))\<bar>"
unfolding suminf_split_initial_segment[OF all_smbl, where k="?N"]
unfolding suminf_diff[OF div_shft_smbl ign[OF \<open>summable (f' x0)\<close>]]
apply (subst (5) add.commute)
- by (rule abs_triangle_ineq)
+ apply (rule abs_triangle_ineq)
+ done
also have "\<dots> \<le> ?diff_part + ?L_part + ?f'_part"
using abs_triangle_ineq4 by auto
also have "\<dots> < r /3 + r/3 + r/3"
using \<open>?diff_part < r/3\<close> \<open>?L_part \<le> r/3\<close> and \<open>?f'_part < r/3\<close>
by (rule add_strict_mono [OF add_less_le_mono])
- finally have "\<bar>(suminf (f (x0 + x)) - suminf (f x0)) / x - suminf (f' x0)\<bar> < r"
+ finally show ?thesis
by auto
- }
- thus "\<exists> s > 0. \<forall> x. x \<noteq> 0 \<and> norm (x - 0) < s \<longrightarrow>
+ qed
+ then show "\<exists>s > 0. \<forall> x. x \<noteq> 0 \<and> norm (x - 0) < s \<longrightarrow>
norm (((\<Sum>n. f (x0 + x) n) - (\<Sum>n. f x0 n)) / x - (\<Sum>n. f' x0 n)) < r"
- using \<open>0 < S\<close> unfolding real_norm_def diff_0_right by blast
+ using \<open>0 < S\<close> by auto
qed
lemma DERIV_power_series':
fixes f :: "nat \<Rightarrow> real"
- assumes converges: "\<And> x. x \<in> {-R <..< R} \<Longrightarrow> summable (\<lambda> n. f n * real (Suc n) * x^n)"
- and x0_in_I: "x0 \<in> {-R <..< R}" and "0 < R"
- shows "DERIV (\<lambda> x. (\<Sum> n. f n * x^(Suc n))) x0 :> (\<Sum> n. f n * real (Suc n) * x0^n)"
- (is "DERIV (\<lambda> x. (suminf (?f x))) x0 :> (suminf (?f' x0))")
+ assumes converges: "\<And>x. x \<in> {-R <..< R} \<Longrightarrow> summable (\<lambda>n. f n * real (Suc n) * x^n)"
+ and x0_in_I: "x0 \<in> {-R <..< R}"
+ and "0 < R"
+ shows "DERIV (\<lambda>x. (\<Sum>n. f n * x^(Suc n))) x0 :> (\<Sum>n. f n * real (Suc n) * x0^n)"
+ (is "DERIV (\<lambda>x. suminf (?f x)) x0 :> suminf (?f' x0)")
proof -
- {
- fix R'
- assume "0 < R'" and "R' < R" and "-R' < x0" and "x0 < R'"
- hence "x0 \<in> {-R' <..< R'}" and "R' \<in> {-R <..< R}" and "x0 \<in> {-R <..< R}"
+ have for_subinterval: "DERIV (\<lambda>x. suminf (?f x)) x0 :> suminf (?f' x0)"
+ if "0 < R'" and "R' < R" and "-R' < x0" and "x0 < R'" for R'
+ proof -
+ from that have "x0 \<in> {-R' <..< R'}" and "R' \<in> {-R <..< R}" and "x0 \<in> {-R <..< R}"
by auto
- have "DERIV (\<lambda> x. (suminf (?f x))) x0 :> (suminf (?f' x0))"
+ show ?thesis
proof (rule DERIV_series')
show "summable (\<lambda> n. \<bar>f n * real (Suc n) * R'^n\<bar>)"
proof -
have "(R' + R) / 2 < R" and "0 < (R' + R) / 2"
using \<open>0 < R'\<close> \<open>0 < R\<close> \<open>R' < R\<close> by (auto simp: field_simps)
- hence in_Rball: "(R' + R) / 2 \<in> {-R <..< R}"
+ then have in_Rball: "(R' + R) / 2 \<in> {-R <..< R}"
using \<open>R' < R\<close> by auto
have "norm R' < norm ((R' + R) / 2)"
using \<open>0 < R'\<close> \<open>0 < R\<close> \<open>R' < R\<close> by (auto simp: field_simps)
from powser_insidea[OF converges[OF in_Rball] this] show ?thesis
by auto
qed
- {
- fix n x y
- assume "x \<in> {-R' <..< R'}" and "y \<in> {-R' <..< R'}"
- show "\<bar>?f x n - ?f y n\<bar> \<le> \<bar>f n * real (Suc n) * R'^n\<bar> * \<bar>x-y\<bar>"
- proof -
- have "\<bar>f n * x ^ (Suc n) - f n * y ^ (Suc n)\<bar> =
- (\<bar>f n\<bar> * \<bar>x-y\<bar>) * \<bar>\<Sum>p<Suc n. x ^ p * y ^ (n - p)\<bar>"
- unfolding right_diff_distrib[symmetric] diff_power_eq_setsum abs_mult
- by auto
- also have "\<dots> \<le> (\<bar>f n\<bar> * \<bar>x-y\<bar>) * (\<bar>real (Suc n)\<bar> * \<bar>R' ^ n\<bar>)"
- proof (rule mult_left_mono)
- have "\<bar>\<Sum>p<Suc n. x ^ p * y ^ (n - p)\<bar> \<le> (\<Sum>p<Suc n. \<bar>x ^ p * y ^ (n - p)\<bar>)"
- by (rule setsum_abs)
- also have "\<dots> \<le> (\<Sum>p<Suc n. R' ^ n)"
- proof (rule setsum_mono)
- fix p
- assume "p \<in> {..<Suc n}"
- hence "p \<le> n" by auto
- {
- fix n
- fix x :: real
- assume "x \<in> {-R'<..<R'}"
- hence "\<bar>x\<bar> \<le> R'" by auto
- hence "\<bar>x^n\<bar> \<le> R'^n"
- unfolding power_abs by (rule power_mono, auto)
- }
- from mult_mono[OF this[OF \<open>x \<in> {-R'<..<R'}\<close>, of p] this[OF \<open>y \<in> {-R'<..<R'}\<close>, of "n-p"]] \<open>0 < R'\<close>
- have "\<bar>x^p * y^(n-p)\<bar> \<le> R'^p * R'^(n-p)"
- unfolding abs_mult by auto
- thus "\<bar>x^p * y^(n-p)\<bar> \<le> R'^n"
- unfolding power_add[symmetric] using \<open>p \<le> n\<close> by auto
+ next
+ fix n x y
+ assume "x \<in> {-R' <..< R'}" and "y \<in> {-R' <..< R'}"
+ show "\<bar>?f x n - ?f y n\<bar> \<le> \<bar>f n * real (Suc n) * R'^n\<bar> * \<bar>x-y\<bar>"
+ proof -
+ have "\<bar>f n * x ^ (Suc n) - f n * y ^ (Suc n)\<bar> =
+ (\<bar>f n\<bar> * \<bar>x-y\<bar>) * \<bar>\<Sum>p<Suc n. x ^ p * y ^ (n - p)\<bar>"
+ unfolding right_diff_distrib[symmetric] diff_power_eq_setsum abs_mult
+ by auto
+ also have "\<dots> \<le> (\<bar>f n\<bar> * \<bar>x-y\<bar>) * (\<bar>real (Suc n)\<bar> * \<bar>R' ^ n\<bar>)"
+ proof (rule mult_left_mono)
+ have "\<bar>\<Sum>p<Suc n. x ^ p * y ^ (n - p)\<bar> \<le> (\<Sum>p<Suc n. \<bar>x ^ p * y ^ (n - p)\<bar>)"
+ by (rule setsum_abs)
+ also have "\<dots> \<le> (\<Sum>p<Suc n. R' ^ n)"
+ proof (rule setsum_mono)
+ fix p
+ assume "p \<in> {..<Suc n}"
+ then have "p \<le> n" by auto
+ have "\<bar>x^n\<bar> \<le> R'^n" if "x \<in> {-R'<..<R'}" for n and x :: real
+ proof -
+ from that have "\<bar>x\<bar> \<le> R'" by auto
+ then show ?thesis
+ unfolding power_abs by (rule power_mono) auto
qed
- also have "\<dots> = real (Suc n) * R' ^ n"
- unfolding setsum_constant card_atLeastLessThan by auto
- finally show "\<bar>\<Sum>p<Suc n. x ^ p * y ^ (n - p)\<bar> \<le> \<bar>real (Suc n)\<bar> * \<bar>R' ^ n\<bar>"
- unfolding abs_of_nonneg[OF zero_le_power[OF less_imp_le[OF \<open>0 < R'\<close>]]]
- by linarith
- show "0 \<le> \<bar>f n\<bar> * \<bar>x - y\<bar>"
- unfolding abs_mult[symmetric] by auto
+ from mult_mono[OF this[OF \<open>x \<in> {-R'<..<R'}\<close>, of p] this[OF \<open>y \<in> {-R'<..<R'}\<close>, of "n-p"]]
+ and \<open>0 < R'\<close>
+ have "\<bar>x^p * y^(n - p)\<bar> \<le> R'^p * R'^(n - p)"
+ unfolding abs_mult by auto
+ then show "\<bar>x^p * y^(n - p)\<bar> \<le> R'^n"
+ unfolding power_add[symmetric] using \<open>p \<le> n\<close> by auto
qed
- also have "\<dots> = \<bar>f n * real (Suc n) * R' ^ n\<bar> * \<bar>x - y\<bar>"
- unfolding abs_mult mult.assoc[symmetric] by algebra
- finally show ?thesis .
+ also have "\<dots> = real (Suc n) * R' ^ n"
+ unfolding setsum_constant card_atLeastLessThan by auto
+ finally show "\<bar>\<Sum>p<Suc n. x ^ p * y ^ (n - p)\<bar> \<le> \<bar>real (Suc n)\<bar> * \<bar>R' ^ n\<bar>"
+ unfolding abs_of_nonneg[OF zero_le_power[OF less_imp_le[OF \<open>0 < R'\<close>]]]
+ by linarith
+ show "0 \<le> \<bar>f n\<bar> * \<bar>x - y\<bar>"
+ unfolding abs_mult[symmetric] by auto
qed
- }
- {
+ also have "\<dots> = \<bar>f n * real (Suc n) * R' ^ n\<bar> * \<bar>x - y\<bar>"
+ unfolding abs_mult mult.assoc[symmetric] by algebra
+ finally show ?thesis .
+ qed
+ next
+ show "DERIV (\<lambda>x. ?f x n) x0 :> ?f' x0 n" for n
+ by (auto intro!: derivative_eq_intros simp del: power_Suc)
+ next
+ fix x
+ assume "x \<in> {-R' <..< R'}"
+ then have "R' \<in> {-R <..< R}" and "norm x < norm R'"
+ using assms \<open>R' < R\<close> by auto
+ have "summable (\<lambda>n. f n * x^n)"
+ proof (rule summable_comparison_test, intro exI allI impI)
fix n
- show "DERIV (\<lambda> x. ?f x n) x0 :> (?f' x0 n)"
- by (auto intro!: derivative_eq_intros simp del: power_Suc)
- }
- {
- fix x
- assume "x \<in> {-R' <..< R'}"
- hence "R' \<in> {-R <..< R}" and "norm x < norm R'"
- using assms \<open>R' < R\<close> by auto
- have "summable (\<lambda> n. f n * x^n)"
- proof (rule summable_comparison_test, intro exI allI impI)
- fix n
- have le: "\<bar>f n\<bar> * 1 \<le> \<bar>f n\<bar> * real (Suc n)"
- by (rule mult_left_mono) auto
- show "norm (f n * x^n) \<le> norm (f n * real (Suc n) * x^n)"
- unfolding real_norm_def abs_mult
- using le mult_right_mono by fastforce
- qed (rule powser_insidea[OF converges[OF \<open>R' \<in> {-R <..< R}\<close>] \<open>norm x < norm R'\<close>])
- from this[THEN summable_mult2[where c=x], simplified mult.assoc, simplified mult.commute]
- show "summable (?f x)" by auto
- }
+ have le: "\<bar>f n\<bar> * 1 \<le> \<bar>f n\<bar> * real (Suc n)"
+ by (rule mult_left_mono) auto
+ show "norm (f n * x^n) \<le> norm (f n * real (Suc n) * x^n)"
+ unfolding real_norm_def abs_mult
+ using le mult_right_mono by fastforce
+ qed (rule powser_insidea[OF converges[OF \<open>R' \<in> {-R <..< R}\<close>] \<open>norm x < norm R'\<close>])
+ from this[THEN summable_mult2[where c=x], simplified mult.assoc, simplified mult.commute]
+ show "summable (?f x)" by auto
+ next
show "summable (?f' x0)"
using converges[OF \<open>x0 \<in> {-R <..< R}\<close>] .
show "x0 \<in> {-R' <..< R'}"
using \<open>x0 \<in> {-R' <..< R'}\<close> .
qed
- } note for_subinterval = this
+ qed
let ?R = "(R + \<bar>x0\<bar>) / 2"
- have "\<bar>x0\<bar> < ?R" using assms by (auto simp: field_simps)
- hence "- ?R < x0"
+ have "\<bar>x0\<bar> < ?R"
+ using assms by (auto simp: field_simps)
+ then have "- ?R < x0"
proof (cases "x0 < 0")
case True
- hence "- x0 < ?R" using \<open>\<bar>x0\<bar> < ?R\<close> by auto
- thus ?thesis unfolding neg_less_iff_less[symmetric, of "- x0"] by auto
+ then have "- x0 < ?R"
+ using \<open>\<bar>x0\<bar> < ?R\<close> by auto
+ then show ?thesis
+ unfolding neg_less_iff_less[symmetric, of "- x0"] by auto
next
case False
have "- ?R < 0" using assms by auto
also have "\<dots> \<le> x0" using False by auto
finally show ?thesis .
qed
- hence "0 < ?R" "?R < R" "- ?R < x0" and "x0 < ?R"
+ then have "0 < ?R" "?R < R" "- ?R < x0" and "x0 < ?R"
using assms by (auto simp: field_simps)
- from for_subinterval[OF this]
- show ?thesis .
+ from for_subinterval[OF this] show ?thesis .
qed
-lemma isCont_pochhammer [continuous_intros]: "isCont (\<lambda>z::'a::real_normed_field. pochhammer z n) z"
- by (induction n) (auto intro!: continuous_intros simp: pochhammer_rec')
-
-lemma continuous_on_pochhammer [continuous_intros]:
- fixes A :: "'a :: real_normed_field set"
- shows "continuous_on A (\<lambda>z. pochhammer z n)"
+lemma isCont_pochhammer [continuous_intros]: "isCont (\<lambda>z. pochhammer z n) z"
+ for z :: "'a::real_normed_field"
+ by (induct n) (auto simp: pochhammer_rec')
+
+lemma continuous_on_pochhammer [continuous_intros]: "continuous_on A (\<lambda>z. pochhammer z n)"
+ for A :: "'a::real_normed_field set"
by (intro continuous_at_imp_continuous_on ballI isCont_pochhammer)
@@ -1144,29 +1150,26 @@
using r0 n by (simp add: mult_right_mono)
finally have "norm x * norm (S n) \<le> real (Suc n) * r * norm (S n)"
using norm_ge_zero by (rule mult_right_mono)
- hence "norm (x * S n) \<le> real (Suc n) * r * norm (S n)"
+ then have "norm (x * S n) \<le> real (Suc n) * r * norm (S n)"
by (rule order_trans [OF norm_mult_ineq])
- hence "norm (x * S n) / real (Suc n) \<le> r * norm (S n)"
+ then have "norm (x * S n) / real (Suc n) \<le> r * norm (S n)"
by (simp add: pos_divide_le_eq ac_simps)
- thus "norm (S (Suc n)) \<le> r * norm (S n)"
+ then show "norm (S (Suc n)) \<le> r * norm (S n)"
by (simp add: S_Suc inverse_eq_divide)
qed
qed
-lemma summable_norm_exp:
- fixes x :: "'a::{real_normed_algebra_1,banach}"
- shows "summable (\<lambda>n. norm (x^n /\<^sub>R fact n))"
+lemma summable_norm_exp: "summable (\<lambda>n. norm (x^n /\<^sub>R fact n))"
+ for x :: "'a::{real_normed_algebra_1,banach}"
proof (rule summable_norm_comparison_test [OF exI, rule_format])
show "summable (\<lambda>n. norm x^n /\<^sub>R fact n)"
by (rule summable_exp_generic)
- fix n
- show "norm (x^n /\<^sub>R fact n) \<le> norm x^n /\<^sub>R fact n"
+ show "norm (x^n /\<^sub>R fact n) \<le> norm x^n /\<^sub>R fact n" for n
by (simp add: norm_power_ineq)
qed
-lemma summable_exp:
- fixes x :: "'a::{real_normed_field,banach}"
- shows "summable (\<lambda>n. inverse (fact n) * x^n)"
+lemma summable_exp: "summable (\<lambda>n. inverse (fact n) * x^n)"
+ for x :: "'a::{real_normed_field,banach}"
using summable_exp_generic [where x=x]
by (simp add: scaleR_conv_of_real nonzero_of_real_inverse)
@@ -1176,22 +1179,22 @@
lemma exp_fdiffs:
"diffs (\<lambda>n. inverse (fact n)) = (\<lambda>n. inverse (fact n :: 'a::{real_normed_field,banach}))"
by (simp add: diffs_def mult_ac nonzero_inverse_mult_distrib nonzero_of_real_inverse
- del: mult_Suc of_nat_Suc)
+ del: mult_Suc of_nat_Suc)
lemma diffs_of_real: "diffs (\<lambda>n. of_real (f n)) = (\<lambda>n. of_real (diffs f n))"
by (simp add: diffs_def)
-lemma DERIV_exp [simp]: "DERIV exp x :> exp(x)"
+lemma DERIV_exp [simp]: "DERIV exp x :> exp x"
unfolding exp_def scaleR_conv_of_real
apply (rule DERIV_cong)
- apply (rule termdiffs [where K="of_real (1 + norm x)"])
- apply (simp_all only: diffs_of_real scaleR_conv_of_real exp_fdiffs)
- apply (rule exp_converges [THEN sums_summable, unfolded scaleR_conv_of_real])+
+ apply (rule termdiffs [where K="of_real (1 + norm x)"])
+ apply (simp_all only: diffs_of_real scaleR_conv_of_real exp_fdiffs)
+ apply (rule exp_converges [THEN sums_summable, unfolded scaleR_conv_of_real])+
apply (simp del: of_real_add)
done
declare DERIV_exp[THEN DERIV_chain2, derivative_intros]
- DERIV_exp[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros]
+ and DERIV_exp[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros]
lemma norm_exp: "norm (exp x) \<le> exp (norm x)"
proof -
@@ -1204,39 +1207,34 @@
finally show ?thesis .
qed
-lemma isCont_exp:
- fixes x::"'a::{real_normed_field,banach}"
- shows "isCont exp x"
+lemma isCont_exp: "isCont exp x"
+ for x :: "'a::{real_normed_field,banach}"
by (rule DERIV_exp [THEN DERIV_isCont])
-lemma isCont_exp' [simp]:
- fixes f:: "_ \<Rightarrow>'a::{real_normed_field,banach}"
- shows "isCont f a \<Longrightarrow> isCont (\<lambda>x. exp (f x)) a"
+lemma isCont_exp' [simp]: "isCont f a \<Longrightarrow> isCont (\<lambda>x. exp (f x)) a"
+ for f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
by (rule isCont_o2 [OF _ isCont_exp])
-lemma tendsto_exp [tendsto_intros]:
- fixes f:: "_ \<Rightarrow>'a::{real_normed_field,banach}"
- shows "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. exp (f x)) \<longlongrightarrow> exp a) F"
+lemma tendsto_exp [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. exp (f x)) \<longlongrightarrow> exp a) F"
+ for f:: "_ \<Rightarrow>'a::{real_normed_field,banach}"
by (rule isCont_tendsto_compose [OF isCont_exp])
-lemma continuous_exp [continuous_intros]:
- fixes f:: "_ \<Rightarrow>'a::{real_normed_field,banach}"
- shows "continuous F f \<Longrightarrow> continuous F (\<lambda>x. exp (f x))"
+lemma continuous_exp [continuous_intros]: "continuous F f \<Longrightarrow> continuous F (\<lambda>x. exp (f x))"
+ for f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
unfolding continuous_def by (rule tendsto_exp)
-lemma continuous_on_exp [continuous_intros]:
- fixes f:: "_ \<Rightarrow>'a::{real_normed_field,banach}"
- shows "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. exp (f x))"
+lemma continuous_on_exp [continuous_intros]: "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. exp (f x))"
+ for f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
unfolding continuous_on_def by (auto intro: tendsto_exp)
subsubsection \<open>Properties of the Exponential Function\<close>
lemma exp_zero [simp]: "exp 0 = 1"
- unfolding exp_def by (simp add: scaleR_conv_of_real powser_zero)
+ unfolding exp_def by (simp add: scaleR_conv_of_real)
lemma exp_series_add_commuting:
- fixes x y :: "'a::{real_normed_algebra_1, banach}"
+ fixes x y :: "'a::{real_normed_algebra_1,banach}"
defines S_def: "S \<equiv> \<lambda>x n. x^n /\<^sub>R fact n"
assumes comm: "x * y = y * x"
shows "S (x + y) n = (\<Sum>i\<le>n. S x i * S y (n - i))"
@@ -1248,55 +1246,49 @@
case (Suc n)
have S_Suc: "\<And>x n. S x (Suc n) = (x * S x n) /\<^sub>R real (Suc n)"
unfolding S_def by (simp del: mult_Suc)
- hence times_S: "\<And>x n. x * S x n = real (Suc n) *\<^sub>R S x (Suc n)"
+ then have times_S: "\<And>x n. x * S x n = real (Suc n) *\<^sub>R S x (Suc n)"
by simp
have S_comm: "\<And>n. S x n * y = y * S x n"
by (simp add: power_commuting_commutes comm S_def)
have "real (Suc n) *\<^sub>R S (x + y) (Suc n) = (x + y) * S (x + y) n"
by (simp only: times_S)
- also have "\<dots> = (x + y) * (\<Sum>i\<le>n. S x i * S y (n-i))"
+ also have "\<dots> = (x + y) * (\<Sum>i\<le>n. S x i * S y (n - i))"
by (simp only: Suc)
- also have "\<dots> = x * (\<Sum>i\<le>n. S x i * S y (n-i))
- + y * (\<Sum>i\<le>n. S x i * S y (n-i))"
+ also have "\<dots> = x * (\<Sum>i\<le>n. S x i * S y (n - i)) + y * (\<Sum>i\<le>n. S x i * S y (n - i))"
by (rule distrib_right)
- also have "\<dots> = (\<Sum>i\<le>n. x * S x i * S y (n-i))
- + (\<Sum>i\<le>n. S x i * y * S y (n-i))"
+ also have "\<dots> = (\<Sum>i\<le>n. x * S x i * S y (n - i)) + (\<Sum>i\<le>n. S x i * y * S y (n - i))"
by (simp add: setsum_right_distrib ac_simps S_comm)
- also have "\<dots> = (\<Sum>i\<le>n. x * S x i * S y (n-i))
- + (\<Sum>i\<le>n. S x i * (y * S y (n-i)))"
+ also have "\<dots> = (\<Sum>i\<le>n. x * S x i * S y (n - i)) + (\<Sum>i\<le>n. S x i * (y * S y (n - i)))"
by (simp add: ac_simps)
- also have "\<dots> = (\<Sum>i\<le>n. real (Suc i) *\<^sub>R (S x (Suc i) * S y (n-i)))
- + (\<Sum>i\<le>n. real (Suc n-i) *\<^sub>R (S x i * S y (Suc n-i)))"
+ also have "\<dots> = (\<Sum>i\<le>n. real (Suc i) *\<^sub>R (S x (Suc i) * S y (n - i))) +
+ (\<Sum>i\<le>n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i)))"
by (simp add: times_S Suc_diff_le)
- also have "(\<Sum>i\<le>n. real (Suc i) *\<^sub>R (S x (Suc i) * S y (n-i))) =
- (\<Sum>i\<le>Suc n. real i *\<^sub>R (S x i * S y (Suc n-i)))"
+ also have "(\<Sum>i\<le>n. real (Suc i) *\<^sub>R (S x (Suc i) * S y (n - i))) =
+ (\<Sum>i\<le>Suc n. real i *\<^sub>R (S x i * S y (Suc n - i)))"
by (subst setsum_atMost_Suc_shift) simp
- also have "(\<Sum>i\<le>n. real (Suc n-i) *\<^sub>R (S x i * S y (Suc n-i))) =
- (\<Sum>i\<le>Suc n. real (Suc n-i) *\<^sub>R (S x i * S y (Suc n-i)))"
+ also have "(\<Sum>i\<le>n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i))) =
+ (\<Sum>i\<le>Suc n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i)))"
by simp
- also have "(\<Sum>i\<le>Suc n. real i *\<^sub>R (S x i * S y (Suc n-i))) +
- (\<Sum>i\<le>Suc n. real (Suc n-i) *\<^sub>R (S x i * S y (Suc n-i))) =
- (\<Sum>i\<le>Suc n. real (Suc n) *\<^sub>R (S x i * S y (Suc n-i)))"
+ also have "(\<Sum>i\<le>Suc n. real i *\<^sub>R (S x i * S y (Suc n - i))) +
+ (\<Sum>i\<le>Suc n. real (Suc n - i) *\<^sub>R (S x i * S y (Suc n - i))) =
+ (\<Sum>i\<le>Suc n. real (Suc n) *\<^sub>R (S x i * S y (Suc n - i)))"
by (simp only: setsum.distrib [symmetric] scaleR_left_distrib [symmetric]
- of_nat_add [symmetric]) simp
- also have "\<dots> = real (Suc n) *\<^sub>R (\<Sum>i\<le>Suc n. S x i * S y (Suc n-i))"
+ of_nat_add [symmetric]) simp
+ also have "\<dots> = real (Suc n) *\<^sub>R (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))"
by (simp only: scaleR_right.setsum)
- finally show
- "S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))"
+ finally show "S (x + y) (Suc n) = (\<Sum>i\<le>Suc n. S x i * S y (Suc n - i))"
by (simp del: setsum_cl_ivl_Suc)
qed
lemma exp_add_commuting: "x * y = y * x \<Longrightarrow> exp (x + y) = exp x * exp y"
- unfolding exp_def
- by (simp only: Cauchy_product summable_norm_exp exp_series_add_commuting)
+ by (simp only: exp_def Cauchy_product summable_norm_exp exp_series_add_commuting)
lemma exp_times_arg_commute: "exp A * A = A * exp A"
by (simp add: exp_def suminf_mult[symmetric] summable_exp_generic power_commutes suminf_mult2)
-lemma exp_add:
- fixes x y::"'a::{real_normed_field,banach}"
- shows "exp (x + y) = exp x * exp y"
+lemma exp_add: "exp (x + y) = exp x * exp y"
+ for x y :: "'a::{real_normed_field,banach}"
by (rule exp_add_commuting) (simp add: ac_simps)
lemma exp_double: "exp(2 * z) = exp z ^ 2"
@@ -1307,7 +1299,7 @@
lemma exp_of_real: "exp (of_real x) = of_real (exp x)"
unfolding exp_def
apply (subst suminf_of_real)
- apply (rule summable_exp_generic)
+ apply (rule summable_exp_generic)
apply (simp add: scaleR_conv_of_real)
done
@@ -1316,47 +1308,47 @@
lemma exp_not_eq_zero [simp]: "exp x \<noteq> 0"
proof
- have "exp x * exp (- x) = 1" by (simp add: exp_add_commuting[symmetric])
+ have "exp x * exp (- x) = 1"
+ by (simp add: exp_add_commuting[symmetric])
also assume "exp x = 0"
- finally show "False" by simp
+ finally show False by simp
qed
-lemma exp_minus_inverse:
- shows "exp x * exp (- x) = 1"
+lemma exp_minus_inverse: "exp x * exp (- x) = 1"
by (simp add: exp_add_commuting[symmetric])
-lemma exp_minus:
- fixes x :: "'a::{real_normed_field, banach}"
- shows "exp (- x) = inverse (exp x)"
+lemma exp_minus: "exp (- x) = inverse (exp x)"
+ for x :: "'a::{real_normed_field,banach}"
by (intro inverse_unique [symmetric] exp_minus_inverse)
-lemma exp_diff:
- fixes x :: "'a::{real_normed_field, banach}"
- shows "exp (x - y) = exp x / exp y"
+lemma exp_diff: "exp (x - y) = exp x / exp y"
+ for x :: "'a::{real_normed_field,banach}"
using exp_add [of x "- y"] by (simp add: exp_minus divide_inverse)
-lemma exp_of_nat_mult:
- fixes x :: "'a::{real_normed_field,banach}"
- shows "exp(of_nat n * x) = exp(x) ^ n"
- by (induct n) (auto simp add: distrib_left exp_add mult.commute)
-
-corollary exp_real_of_nat_mult: "exp(real n * x) = exp(x) ^ n"
+lemma exp_of_nat_mult: "exp (of_nat n * x) = exp x ^ n"
+ for x :: "'a::{real_normed_field,banach}"
+ by (induct n) (auto simp add: distrib_left exp_add mult.commute)
+
+corollary exp_real_of_nat_mult: "exp (real n * x) = exp x ^ n"
by (simp add: exp_of_nat_mult)
-lemma exp_setsum: "finite I \<Longrightarrow> exp(setsum f I) = setprod (\<lambda>x. exp(f x)) I"
- by (induction I rule: finite_induct) (auto simp: exp_add_commuting mult.commute)
+lemma exp_setsum: "finite I \<Longrightarrow> exp (setsum f I) = setprod (\<lambda>x. exp (f x)) I"
+ by (induct I rule: finite_induct) (auto simp: exp_add_commuting mult.commute)
lemma exp_divide_power_eq:
- fixes x:: "'a::{real_normed_field,banach}"
- assumes "n>0" shows "exp (x / of_nat n) ^ n = exp x"
-using assms
+ fixes x :: "'a::{real_normed_field,banach}"
+ assumes "n > 0"
+ shows "exp (x / of_nat n) ^ n = exp x"
+ using assms
proof (induction n arbitrary: x)
- case 0 then show ?case by simp
+ case 0
+ then show ?case by simp
next
case (Suc n)
show ?case
- proof (cases "n=0")
- case True then show ?thesis by simp
+ proof (cases "n = 0")
+ case True
+ then show ?thesis by simp
next
case False
then have [simp]: "x * of_nat n / (1 + of_nat n) / of_nat n = x / (1 + of_nat n)"
@@ -1376,40 +1368,49 @@
text \<open>Comparisons of @{term "exp x"} with zero.\<close>
-text\<open>Proof: because every exponential can be seen as a square.\<close>
-lemma exp_ge_zero [simp]: "0 \<le> exp (x::real)"
+text \<open>Proof: because every exponential can be seen as a square.\<close>
+lemma exp_ge_zero [simp]: "0 \<le> exp x"
+ for x :: real
proof -
- have "0 \<le> exp (x/2) * exp (x/2)" by simp
- thus ?thesis by (simp add: exp_add [symmetric])
+ have "0 \<le> exp (x/2) * exp (x/2)"
+ by simp
+ then show ?thesis
+ by (simp add: exp_add [symmetric])
qed
-lemma exp_gt_zero [simp]: "0 < exp (x::real)"
+lemma exp_gt_zero [simp]: "0 < exp x"
+ for x :: real
by (simp add: order_less_le)
-lemma not_exp_less_zero [simp]: "\<not> exp (x::real) < 0"
+lemma not_exp_less_zero [simp]: "\<not> exp x < 0"
+ for x :: real
by (simp add: not_less)
-lemma not_exp_le_zero [simp]: "\<not> exp (x::real) \<le> 0"
+lemma not_exp_le_zero [simp]: "\<not> exp x \<le> 0"
+ for x :: real
by (simp add: not_le)
-lemma abs_exp_cancel [simp]: "\<bar>exp x::real\<bar> = exp x"
+lemma abs_exp_cancel [simp]: "\<bar>exp x\<bar> = exp x"
+ for x :: real
by simp
text \<open>Strict monotonicity of exponential.\<close>
lemma exp_ge_add_one_self_aux:
- assumes "0 \<le> (x::real)" shows "1+x \<le> exp(x)"
-using order_le_imp_less_or_eq [OF assms]
+ fixes x :: real
+ assumes "0 \<le> x"
+ shows "1 + x \<le> exp x"
+ using order_le_imp_less_or_eq [OF assms]
proof
assume "0 < x"
- have "1+x \<le> (\<Sum>n<2. inverse (fact n) * x^n)"
+ have "1 + x \<le> (\<Sum>n<2. inverse (fact n) * x^n)"
by (auto simp add: numeral_2_eq_2)
- also have "... \<le> (\<Sum>n. inverse (fact n) * x^n)"
+ also have "\<dots> \<le> (\<Sum>n. inverse (fact n) * x^n)"
apply (rule setsum_le_suminf [OF summable_exp])
using \<open>0 < x\<close>
apply (auto simp add: zero_le_mult_iff)
done
- finally show "1+x \<le> exp x"
+ finally show "1 + x \<le> exp x"
by (simp add: exp_def)
next
assume "0 = x"
@@ -1417,10 +1418,11 @@
by auto
qed
-lemma exp_gt_one: "0 < (x::real) \<Longrightarrow> 1 < exp x"
+lemma exp_gt_one: "0 < x \<Longrightarrow> 1 < exp x"
+ for x :: real
proof -
assume x: "0 < x"
- hence "1 < 1 + x" by simp
+ then have "1 < 1 + x" by simp
also from x have "1 + x \<le> exp x"
by (simp add: exp_ge_add_one_self_aux)
finally show ?thesis .
@@ -1432,59 +1434,75 @@
shows "exp x < exp y"
proof -
from \<open>x < y\<close> have "0 < y - x" by simp
- hence "1 < exp (y - x)" by (rule exp_gt_one)
- hence "1 < exp y / exp x" by (simp only: exp_diff)
- thus "exp x < exp y" by simp
+ then have "1 < exp (y - x)" by (rule exp_gt_one)
+ then have "1 < exp y / exp x" by (simp only: exp_diff)
+ then show "exp x < exp y" by simp
qed
-lemma exp_less_cancel: "exp (x::real) < exp y \<Longrightarrow> x < y"
+lemma exp_less_cancel: "exp x < exp y \<Longrightarrow> x < y"
+ for x y :: real
unfolding linorder_not_le [symmetric]
by (auto simp add: order_le_less exp_less_mono)
-lemma exp_less_cancel_iff [iff]: "exp (x::real) < exp y \<longleftrightarrow> x < y"
+lemma exp_less_cancel_iff [iff]: "exp x < exp y \<longleftrightarrow> x < y"
+ for x y :: real
by (auto intro: exp_less_mono exp_less_cancel)
-lemma exp_le_cancel_iff [iff]: "exp (x::real) \<le> exp y \<longleftrightarrow> x \<le> y"
+lemma exp_le_cancel_iff [iff]: "exp x \<le> exp y \<longleftrightarrow> x \<le> y"
+ for x y :: real
by (auto simp add: linorder_not_less [symmetric])
-lemma exp_inj_iff [iff]: "exp (x::real) = exp y \<longleftrightarrow> x = y"
+lemma exp_inj_iff [iff]: "exp x = exp y \<longleftrightarrow> x = y"
+ for x y :: real
by (simp add: order_eq_iff)
text \<open>Comparisons of @{term "exp x"} with one.\<close>
-lemma one_less_exp_iff [simp]: "1 < exp (x::real) \<longleftrightarrow> 0 < x"
- using exp_less_cancel_iff [where x=0 and y=x] by simp
-
-lemma exp_less_one_iff [simp]: "exp (x::real) < 1 \<longleftrightarrow> x < 0"
- using exp_less_cancel_iff [where x=x and y=0] by simp
-
-lemma one_le_exp_iff [simp]: "1 \<le> exp (x::real) \<longleftrightarrow> 0 \<le> x"
- using exp_le_cancel_iff [where x=0 and y=x] by simp
-
-lemma exp_le_one_iff [simp]: "exp (x::real) \<le> 1 \<longleftrightarrow> x \<le> 0"
- using exp_le_cancel_iff [where x=x and y=0] by simp
-
-lemma exp_eq_one_iff [simp]: "exp (x::real) = 1 \<longleftrightarrow> x = 0"
- using exp_inj_iff [where x=x and y=0] by simp
-
-lemma lemma_exp_total: "1 \<le> y \<Longrightarrow> \<exists>x. 0 \<le> x & x \<le> y - 1 & exp(x::real) = y"
+lemma one_less_exp_iff [simp]: "1 < exp x \<longleftrightarrow> 0 < x"
+ for x :: real
+ using exp_less_cancel_iff [where x = 0 and y = x] by simp
+
+lemma exp_less_one_iff [simp]: "exp x < 1 \<longleftrightarrow> x < 0"
+ for x :: real
+ using exp_less_cancel_iff [where x = x and y = 0] by simp
+
+lemma one_le_exp_iff [simp]: "1 \<le> exp x \<longleftrightarrow> 0 \<le> x"
+ for x :: real
+ using exp_le_cancel_iff [where x = 0 and y = x] by simp
+
+lemma exp_le_one_iff [simp]: "exp x \<le> 1 \<longleftrightarrow> x \<le> 0"
+ for x :: real
+ using exp_le_cancel_iff [where x = x and y = 0] by simp
+
+lemma exp_eq_one_iff [simp]: "exp x = 1 \<longleftrightarrow> x = 0"
+ for x :: real
+ using exp_inj_iff [where x = x and y = 0] by simp
+
+lemma lemma_exp_total: "1 \<le> y \<Longrightarrow> \<exists>x. 0 \<le> x \<and> x \<le> y - 1 \<and> exp x = y"
+ for y :: real
proof (rule IVT)
assume "1 \<le> y"
- hence "0 \<le> y - 1" by simp
- hence "1 + (y - 1) \<le> exp (y - 1)" by (rule exp_ge_add_one_self_aux)
- thus "y \<le> exp (y - 1)" by simp
+ then have "0 \<le> y - 1" by simp
+ then have "1 + (y - 1) \<le> exp (y - 1)"
+ by (rule exp_ge_add_one_self_aux)
+ then show "y \<le> exp (y - 1)" by simp
qed (simp_all add: le_diff_eq)
-lemma exp_total: "0 < (y::real) \<Longrightarrow> \<exists>x. exp x = y"
+lemma exp_total: "0 < y \<Longrightarrow> \<exists>x. exp x = y"
+ for y :: real
proof (rule linorder_le_cases [of 1 y])
assume "1 \<le> y"
- thus "\<exists>x. exp x = y" by (fast dest: lemma_exp_total)
+ then show "\<exists>x. exp x = y"
+ by (fast dest: lemma_exp_total)
next
assume "0 < y" and "y \<le> 1"
- hence "1 \<le> inverse y" by (simp add: one_le_inverse_iff)
- then obtain x where "exp x = inverse y" by (fast dest: lemma_exp_total)
- hence "exp (- x) = y" by (simp add: exp_minus)
- thus "\<exists>x. exp x = y" ..
+ then have "1 \<le> inverse y"
+ by (simp add: one_le_inverse_iff)
+ then obtain x where "exp x = inverse y"
+ by (fast dest: lemma_exp_total)
+ then have "exp (- x) = y"
+ by (simp add: exp_minus)
+ then show "\<exists>x. exp x = y" ..
qed
@@ -1494,9 +1512,9 @@
fixes ln :: "'a \<Rightarrow> 'a"
assumes ln_one [simp]: "ln 1 = 0"
-definition powr :: "['a,'a] => 'a::ln" (infixr "powr" 80)
+definition powr :: "'a \<Rightarrow> 'a \<Rightarrow> 'a::ln" (infixr "powr" 80)
\<comment> \<open>exponentation via ln and exp\<close>
- where [code del]: "x powr a \<equiv> if x = 0 then 0 else exp(a * ln x)"
+ where [code del]: "x powr a \<equiv> if x = 0 then 0 else exp (a * ln x)"
lemma powr_0 [simp]: "0 powr z = 0"
by (simp add: powr_def)
@@ -1509,118 +1527,116 @@
where "ln_real x = (THE u. exp u = x)"
instance
-by intro_classes (simp add: ln_real_def)
+ by intro_classes (simp add: ln_real_def)
end
lemma powr_eq_0_iff [simp]: "w powr z = 0 \<longleftrightarrow> w = 0"
by (simp add: powr_def)
-lemma ln_exp [simp]:
- fixes x::real shows "ln (exp x) = x"
+lemma ln_exp [simp]: "ln (exp x) = x"
+ for x :: real
by (simp add: ln_real_def)
-lemma exp_ln [simp]:
- fixes x::real shows "0 < x \<Longrightarrow> exp (ln x) = x"
+lemma exp_ln [simp]: "0 < x \<Longrightarrow> exp (ln x) = x"
+ for x :: real
by (auto dest: exp_total)
-lemma exp_ln_iff [simp]:
- fixes x::real shows "exp (ln x) = x \<longleftrightarrow> 0 < x"
+lemma exp_ln_iff [simp]: "exp (ln x) = x \<longleftrightarrow> 0 < x"
+ for x :: real
by (metis exp_gt_zero exp_ln)
-lemma ln_unique:
- fixes x::real shows "exp y = x \<Longrightarrow> ln x = y"
- by (erule subst, rule ln_exp)
-
-lemma ln_mult:
- fixes x::real shows "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln (x * y) = ln x + ln y"
+lemma ln_unique: "exp y = x \<Longrightarrow> ln x = y"
+ for x :: real
+ by (erule subst) (rule ln_exp)
+
+lemma ln_mult: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln (x * y) = ln x + ln y"
+ for x :: real
by (rule ln_unique) (simp add: exp_add)
-lemma ln_setprod:
- fixes f:: "'a => real"
- shows
- "\<lbrakk>finite I; \<And>i. i \<in> I \<Longrightarrow> f i > 0\<rbrakk> \<Longrightarrow> ln(setprod f I) = setsum (\<lambda>x. ln(f x)) I"
- by (induction I rule: finite_induct) (auto simp: ln_mult setprod_pos)
-
-lemma ln_inverse:
- fixes x::real shows "0 < x \<Longrightarrow> ln (inverse x) = - ln x"
+lemma ln_setprod: "finite I \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> f i > 0) \<Longrightarrow> ln (setprod f I) = setsum (\<lambda>x. ln(f x)) I"
+ for f :: "'a \<Rightarrow> real"
+ by (induct I rule: finite_induct) (auto simp: ln_mult setprod_pos)
+
+lemma ln_inverse: "0 < x \<Longrightarrow> ln (inverse x) = - ln x"
+ for x :: real
by (rule ln_unique) (simp add: exp_minus)
-lemma ln_div:
- fixes x::real shows "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln (x / y) = ln x - ln y"
+lemma ln_div: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln (x / y) = ln x - ln y"
+ for x :: real
by (rule ln_unique) (simp add: exp_diff)
lemma ln_realpow: "0 < x \<Longrightarrow> ln (x^n) = real n * ln x"
by (rule ln_unique) (simp add: exp_real_of_nat_mult)
-lemma ln_less_cancel_iff [simp]:
- fixes x::real shows "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln x < ln y \<longleftrightarrow> x < y"
+lemma ln_less_cancel_iff [simp]: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln x < ln y \<longleftrightarrow> x < y"
+ for x :: real
by (subst exp_less_cancel_iff [symmetric]) simp
-lemma ln_le_cancel_iff [simp]:
- fixes x::real shows "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln x \<le> ln y \<longleftrightarrow> x \<le> y"
+lemma ln_le_cancel_iff [simp]: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln x \<le> ln y \<longleftrightarrow> x \<le> y"
+ for x :: real
by (simp add: linorder_not_less [symmetric])
-lemma ln_inj_iff [simp]:
- fixes x::real shows "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln x = ln y \<longleftrightarrow> x = y"
+lemma ln_inj_iff [simp]: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln x = ln y \<longleftrightarrow> x = y"
+ for x :: real
by (simp add: order_eq_iff)
-lemma ln_add_one_self_le_self [simp]:
- fixes x::real shows "0 \<le> x \<Longrightarrow> ln (1 + x) \<le> x"
- apply (rule exp_le_cancel_iff [THEN iffD1])
- apply (simp add: exp_ge_add_one_self_aux)
- done
-
-lemma ln_less_self [simp]:
- fixes x::real shows "0 < x \<Longrightarrow> ln x < x"
- by (rule order_less_le_trans [where y="ln (1 + x)"]) simp_all
-
-lemma ln_ge_zero [simp]:
- fixes x::real shows "1 \<le> x \<Longrightarrow> 0 \<le> ln x"
+lemma ln_add_one_self_le_self [simp]: "0 \<le> x \<Longrightarrow> ln (1 + x) \<le> x"
+ for x :: real
+ by (rule exp_le_cancel_iff [THEN iffD1]) (simp add: exp_ge_add_one_self_aux)
+
+lemma ln_less_self [simp]: "0 < x \<Longrightarrow> ln x < x"
+ for x :: real
+ by (rule order_less_le_trans [where y = "ln (1 + x)"]) simp_all
+
+lemma ln_ge_zero [simp]: "1 \<le> x \<Longrightarrow> 0 \<le> ln x"
+ for x :: real
using ln_le_cancel_iff [of 1 x] by simp
-lemma ln_ge_zero_imp_ge_one:
- fixes x::real shows "0 \<le> ln x \<Longrightarrow> 0 < x \<Longrightarrow> 1 \<le> x"
+lemma ln_ge_zero_imp_ge_one: "0 \<le> ln x \<Longrightarrow> 0 < x \<Longrightarrow> 1 \<le> x"
+ for x :: real
using ln_le_cancel_iff [of 1 x] by simp
-lemma ln_ge_zero_iff [simp]:
- fixes x::real shows "0 < x \<Longrightarrow> 0 \<le> ln x \<longleftrightarrow> 1 \<le> x"
+lemma ln_ge_zero_iff [simp]: "0 < x \<Longrightarrow> 0 \<le> ln x \<longleftrightarrow> 1 \<le> x"
+ for x :: real
using ln_le_cancel_iff [of 1 x] by simp
-lemma ln_less_zero_iff [simp]:
- fixes x::real shows "0 < x \<Longrightarrow> ln x < 0 \<longleftrightarrow> x < 1"
+lemma ln_less_zero_iff [simp]: "0 < x \<Longrightarrow> ln x < 0 \<longleftrightarrow> x < 1"
+ for x :: real
using ln_less_cancel_iff [of x 1] by simp
-lemma ln_gt_zero:
- fixes x::real shows "1 < x \<Longrightarrow> 0 < ln x"
+lemma ln_gt_zero: "1 < x \<Longrightarrow> 0 < ln x"
+ for x :: real
using ln_less_cancel_iff [of 1 x] by simp
-lemma ln_gt_zero_imp_gt_one:
- fixes x::real shows "0 < ln x \<Longrightarrow> 0 < x \<Longrightarrow> 1 < x"
+lemma ln_gt_zero_imp_gt_one: "0 < ln x \<Longrightarrow> 0 < x \<Longrightarrow> 1 < x"
+ for x :: real
using ln_less_cancel_iff [of 1 x] by simp
-lemma ln_gt_zero_iff [simp]:
- fixes x::real shows "0 < x \<Longrightarrow> 0 < ln x \<longleftrightarrow> 1 < x"
+lemma ln_gt_zero_iff [simp]: "0 < x \<Longrightarrow> 0 < ln x \<longleftrightarrow> 1 < x"
+ for x :: real
using ln_less_cancel_iff [of 1 x] by simp
-lemma ln_eq_zero_iff [simp]:
- fixes x::real shows "0 < x \<Longrightarrow> ln x = 0 \<longleftrightarrow> x = 1"
+lemma ln_eq_zero_iff [simp]: "0 < x \<Longrightarrow> ln x = 0 \<longleftrightarrow> x = 1"
+ for x :: real
using ln_inj_iff [of x 1] by simp
-lemma ln_less_zero:
- fixes x::real shows "0 < x \<Longrightarrow> x < 1 \<Longrightarrow> ln x < 0"
+lemma ln_less_zero: "0 < x \<Longrightarrow> x < 1 \<Longrightarrow> ln x < 0"
+ for x :: real
by simp
-lemma ln_neg_is_const:
- fixes x::real shows "x \<le> 0 \<Longrightarrow> ln x = (THE x. False)"
- by (auto simp add: ln_real_def intro!: arg_cong[where f=The])
+lemma ln_neg_is_const: "x \<le> 0 \<Longrightarrow> ln x = (THE x. False)"
+ for x :: real
+ by (auto simp: ln_real_def intro!: arg_cong[where f = The])
lemma isCont_ln:
- fixes x::real assumes "x \<noteq> 0" shows "isCont ln x"
+ fixes x :: real
+ assumes "x \<noteq> 0"
+ shows "isCont ln x"
proof (cases "0 < x")
case True
then have "isCont ln (exp (ln x))"
- by (intro isCont_inv_fun[where d="\<bar>x\<bar>" and f=exp]) auto
+ by (intro isCont_inv_fun[where d = "\<bar>x\<bar>" and f = exp]) auto
with True show ?thesis
by simp
next
@@ -1629,12 +1645,11 @@
unfolding isCont_def
by (subst filterlim_cong[OF _ refl, of _ "nhds (ln 0)" _ "\<lambda>_. ln 0"])
(auto simp: ln_neg_is_const not_less eventually_at dist_real_def
- intro!: exI[of _ "\<bar>x\<bar>"])
+ intro!: exI[of _ "\<bar>x\<bar>"])
qed
-lemma tendsto_ln [tendsto_intros]:
- fixes a::real shows
- "(f \<longlongrightarrow> a) F \<Longrightarrow> a \<noteq> 0 \<Longrightarrow> ((\<lambda>x. ln (f x)) \<longlongrightarrow> ln a) F"
+lemma tendsto_ln [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> a \<noteq> 0 \<Longrightarrow> ((\<lambda>x. ln (f x)) \<longlongrightarrow> ln a) F"
+ for a :: real
by (rule isCont_tendsto_compose [OF isCont_ln])
lemma continuous_ln:
@@ -1653,32 +1668,30 @@
"continuous_on s f \<Longrightarrow> (\<forall>x\<in>s. f x \<noteq> 0) \<Longrightarrow> continuous_on s (\<lambda>x. ln (f x :: real))"
unfolding continuous_on_def by (auto intro: tendsto_ln)
-lemma DERIV_ln:
- fixes x::real shows "0 < x \<Longrightarrow> DERIV ln x :> inverse x"
- apply (rule DERIV_inverse_function [where f=exp and a=0 and b="x+1"])
- apply (auto intro: DERIV_cong [OF DERIV_exp exp_ln] isCont_ln)
- done
-
-lemma DERIV_ln_divide:
- fixes x::real shows "0 < x \<Longrightarrow> DERIV ln x :> 1 / x"
- by (rule DERIV_ln[THEN DERIV_cong], simp, simp add: divide_inverse)
+lemma DERIV_ln: "0 < x \<Longrightarrow> DERIV ln x :> inverse x"
+ for x :: real
+ by (rule DERIV_inverse_function [where f=exp and a=0 and b="x+1"])
+ (auto intro: DERIV_cong [OF DERIV_exp exp_ln] isCont_ln)
+
+lemma DERIV_ln_divide: "0 < x \<Longrightarrow> DERIV ln x :> 1 / x"
+ for x :: real
+ by (rule DERIV_ln[THEN DERIV_cong]) (simp_all add: divide_inverse)
declare DERIV_ln_divide[THEN DERIV_chain2, derivative_intros]
- DERIV_ln_divide[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros]
-
+ and DERIV_ln_divide[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros]
lemma ln_series:
assumes "0 < x" and "x < 2"
shows "ln x = (\<Sum> n. (-1)^n * (1 / real (n + 1)) * (x - 1)^(Suc n))"
- (is "ln x = suminf (?f (x - 1))")
+ (is "ln x = suminf (?f (x - 1))")
proof -
let ?f' = "\<lambda>x n. (-1)^n * (x - 1)^n"
have "ln x - suminf (?f (x - 1)) = ln 1 - suminf (?f (1 - 1))"
- proof (rule DERIV_isconst3[where x=x])
+ proof (rule DERIV_isconst3 [where x = x])
fix x :: real
assume "x \<in> {0 <..< 2}"
- hence "0 < x" and "x < 2" by auto
+ then have "0 < x" and "x < 2" by auto
have "norm (1 - x) < 1"
using \<open>0 < x\<close> and \<open>x < 2\<close> by auto
have "1 / x = 1 / (1 - (1 - x))" by auto
@@ -1696,87 +1709,88 @@
proof (rule DERIV_power_series')
show "x - 1 \<in> {- 1<..<1}" and "(0 :: real) < 1"
using \<open>0 < x\<close> \<open>x < 2\<close> by auto
+ next
fix x :: real
assume "x \<in> {- 1<..<1}"
- hence "norm (-x) < 1" by auto
+ then have "norm (-x) < 1" by auto
show "summable (\<lambda>n. (- 1) ^ n * (1 / real (n + 1)) * real (Suc n) * x^n)"
unfolding One_nat_def
by (auto simp add: power_mult_distrib[symmetric] summable_geometric[OF \<open>norm (-x) < 1\<close>])
qed
- hence "DERIV (\<lambda>x. suminf (?f x)) (x - 1) :> suminf (?f' x)"
+ then have "DERIV (\<lambda>x. suminf (?f x)) (x - 1) :> suminf (?f' x)"
unfolding One_nat_def by auto
- hence "DERIV (\<lambda>x. suminf (?f (x - 1))) x :> suminf (?f' x)"
+ then have "DERIV (\<lambda>x. suminf (?f (x - 1))) x :> suminf (?f' x)"
unfolding DERIV_def repos .
- ultimately have "DERIV (\<lambda>x. ln x - suminf (?f (x - 1))) x :> (suminf (?f' x) - suminf (?f' x))"
+ ultimately have "DERIV (\<lambda>x. ln x - suminf (?f (x - 1))) x :> suminf (?f' x) - suminf (?f' x)"
by (rule DERIV_diff)
- thus "DERIV (\<lambda>x. ln x - suminf (?f (x - 1))) x :> 0" by auto
+ then show "DERIV (\<lambda>x. ln x - suminf (?f (x - 1))) x :> 0" by auto
qed (auto simp add: assms)
- thus ?thesis by auto
+ then show ?thesis by auto
qed
lemma exp_first_terms:
fixes x :: "'a::{real_normed_algebra_1,banach}"
- shows "exp x = (\<Sum>n<k. inverse(fact n) *\<^sub>R (x ^ n)) + (\<Sum>n. inverse(fact (n+k)) *\<^sub>R (x ^ (n+k)))"
+ shows "exp x = (\<Sum>n<k. inverse(fact n) *\<^sub>R (x ^ n)) + (\<Sum>n. inverse(fact (n + k)) *\<^sub>R (x ^ (n + k)))"
proof -
have "exp x = suminf (\<lambda>n. inverse(fact n) *\<^sub>R (x^n))"
by (simp add: exp_def)
- also from summable_exp_generic have "... = (\<Sum> n. inverse(fact(n+k)) *\<^sub>R (x ^ (n+k))) +
+ also from summable_exp_generic have "\<dots> = (\<Sum> n. inverse(fact(n+k)) *\<^sub>R (x ^ (n + k))) +
(\<Sum> n::nat<k. inverse(fact n) *\<^sub>R (x^n))" (is "_ = _ + ?a")
by (rule suminf_split_initial_segment)
finally show ?thesis by simp
qed
-lemma exp_first_term:
- fixes x :: "'a::{real_normed_algebra_1,banach}"
- shows "exp x = 1 + (\<Sum> n. inverse(fact (Suc n)) *\<^sub>R (x ^ (Suc n)))"
+lemma exp_first_term: "exp x = 1 + (\<Sum>n. inverse (fact (Suc n)) *\<^sub>R (x ^ Suc n))"
+ for x :: "'a::{real_normed_algebra_1,banach}"
using exp_first_terms[of x 1] by simp
-lemma exp_first_two_terms:
- fixes x :: "'a::{real_normed_algebra_1,banach}"
- shows "exp x = 1 + x + (\<Sum> n. inverse(fact (n+2)) *\<^sub>R (x ^ (n+2)))"
- using exp_first_terms[of x 2]
- by (simp add: eval_nat_numeral)
-
-lemma exp_bound: "0 <= (x::real) \<Longrightarrow> x <= 1 \<Longrightarrow> exp x <= 1 + x + x\<^sup>2"
+lemma exp_first_two_terms: "exp x = 1 + x + (\<Sum>n. inverse (fact (n + 2)) *\<^sub>R (x ^ (n + 2)))"
+ for x :: "'a::{real_normed_algebra_1,banach}"
+ using exp_first_terms[of x 2] by (simp add: eval_nat_numeral)
+
+lemma exp_bound:
+ fixes x :: real
+ assumes a: "0 \<le> x"
+ and b: "x \<le> 1"
+ shows "exp x \<le> 1 + x + x\<^sup>2"
proof -
- assume a: "0 <= x"
- assume b: "x <= 1"
- {
- fix n :: nat
+ have aux1: "inverse (fact (n + 2)) * x ^ (n + 2) \<le> (x\<^sup>2/2) * ((1/2)^n)" for n :: nat
+ proof -
have "(2::nat) * 2 ^ n \<le> fact (n + 2)"
by (induct n) simp_all
- hence "real ((2::nat) * 2 ^ n) \<le> real_of_nat (fact (n + 2))"
+ then have "real ((2::nat) * 2 ^ n) \<le> real_of_nat (fact (n + 2))"
by (simp only: of_nat_le_iff)
- hence "((2::real) * 2 ^ n) \<le> fact (n + 2)"
- unfolding of_nat_fact
- by (simp add: of_nat_mult of_nat_power)
- hence "inverse (fact (n + 2)) \<le> inverse ((2::real) * 2 ^ n)"
+ then have "((2::real) * 2 ^ n) \<le> fact (n + 2)"
+ unfolding of_nat_fact by simp
+ then have "inverse (fact (n + 2)) \<le> inverse ((2::real) * 2 ^ n)"
by (rule le_imp_inverse_le) simp
- hence "inverse (fact (n + 2)) \<le> 1/(2::real) * (1/2)^n"
+ then have "inverse (fact (n + 2)) \<le> 1/(2::real) * (1/2)^n"
by (simp add: power_inverse [symmetric])
- hence "inverse (fact (n + 2)) * (x^n * x\<^sup>2) \<le> 1/2 * (1/2)^n * (1 * x\<^sup>2)"
- by (rule mult_mono)
- (rule mult_mono, simp_all add: power_le_one a b)
- hence "inverse (fact (n + 2)) * x ^ (n + 2) \<le> (x\<^sup>2/2) * ((1/2)^n)"
- unfolding power_add by (simp add: ac_simps del: fact_Suc) }
- note aux1 = this
+ then have "inverse (fact (n + 2)) * (x^n * x\<^sup>2) \<le> 1/2 * (1/2)^n * (1 * x\<^sup>2)"
+ by (rule mult_mono) (rule mult_mono, simp_all add: power_le_one a b)
+ then show ?thesis
+ unfolding power_add by (simp add: ac_simps del: fact_Suc)
+ qed
have "(\<lambda>n. x\<^sup>2 / 2 * (1 / 2) ^ n) sums (x\<^sup>2 / 2 * (1 / (1 - 1 / 2)))"
- by (intro sums_mult geometric_sums, simp)
- hence aux2: "(\<lambda>n. x\<^sup>2 / 2 * (1 / 2) ^ n) sums x\<^sup>2"
+ by (intro sums_mult geometric_sums) simp
+ then have aux2: "(\<lambda>n. x\<^sup>2 / 2 * (1 / 2) ^ n) sums x\<^sup>2"
by simp
- have "suminf (\<lambda>n. inverse(fact (n+2)) * (x ^ (n+2))) <= x\<^sup>2"
+ have "suminf (\<lambda>n. inverse(fact (n+2)) * (x ^ (n + 2))) \<le> x\<^sup>2"
proof -
- have "suminf (\<lambda>n. inverse(fact (n+2)) * (x ^ (n+2))) <=
- suminf (\<lambda>n. (x\<^sup>2/2) * ((1/2)^n))"
+ have "suminf (\<lambda>n. inverse(fact (n+2)) * (x ^ (n + 2))) \<le> suminf (\<lambda>n. (x\<^sup>2/2) * ((1/2)^n))"
apply (rule suminf_le)
- apply (rule allI, rule aux1)
- apply (rule summable_exp [THEN summable_ignore_initial_segment])
- by (rule sums_summable, rule aux2)
- also have "... = x\<^sup>2"
- by (rule sums_unique [THEN sym], rule aux2)
+ apply (rule allI)
+ apply (rule aux1)
+ apply (rule summable_exp [THEN summable_ignore_initial_segment])
+ apply (rule sums_summable)
+ apply (rule aux2)
+ done
+ also have "\<dots> = x\<^sup>2"
+ by (rule sums_unique [THEN sym]) (rule aux2)
finally show ?thesis .
qed
- thus ?thesis unfolding exp_first_two_terms by auto
+ then show ?thesis
+ unfolding exp_first_two_terms by auto
qed
corollary exp_half_le2: "exp(1/2) \<le> (2::real)"
@@ -1787,172 +1801,177 @@
using exp_bound [of 1]
by (simp add: field_simps)
-lemma exp_bound_half: "norm(z) \<le> 1/2 \<Longrightarrow> norm(exp z) \<le> 2"
+lemma exp_bound_half: "norm z \<le> 1/2 \<Longrightarrow> norm (exp z) \<le> 2"
by (blast intro: order_trans intro!: exp_half_le2 norm_exp)
lemma exp_bound_lemma:
- assumes "norm(z) \<le> 1/2" shows "norm(exp z) \<le> 1 + 2 * norm(z)"
+ assumes "norm z \<le> 1/2"
+ shows "norm (exp z) \<le> 1 + 2 * norm z"
proof -
- have n: "(norm z)\<^sup>2 \<le> norm z * 1"
+ have *: "(norm z)\<^sup>2 \<le> norm z * 1"
unfolding power2_eq_square
apply (rule mult_left_mono)
using assms
- apply auto
+ apply auto
done
show ?thesis
apply (rule order_trans [OF norm_exp])
apply (rule order_trans [OF exp_bound])
- using assms n
- apply auto
+ using assms *
+ apply auto
done
qed
-lemma real_exp_bound_lemma:
- fixes x :: real
- shows "0 \<le> x \<Longrightarrow> x \<le> 1/2 \<Longrightarrow> exp(x) \<le> 1 + 2 * x"
-using exp_bound_lemma [of x]
-by simp
+lemma real_exp_bound_lemma: "0 \<le> x \<Longrightarrow> x \<le> 1/2 \<Longrightarrow> exp x \<le> 1 + 2 * x"
+ for x :: real
+ using exp_bound_lemma [of x] by simp
lemma ln_one_minus_pos_upper_bound:
- fixes x::real shows "0 <= x \<Longrightarrow> x < 1 \<Longrightarrow> ln (1 - x) <= - x"
+ fixes x :: real
+ assumes a: "0 \<le> x" and b: "x < 1"
+ shows "ln (1 - x) \<le> - x"
proof -
- assume a: "0 <= (x::real)" and b: "x < 1"
- have "(1 - x) * (1 + x + x\<^sup>2) = (1 - x^3)"
+ have "(1 - x) * (1 + x + x\<^sup>2) = 1 - x^3"
by (simp add: algebra_simps power2_eq_square power3_eq_cube)
- also have "... <= 1"
+ also have "\<dots> \<le> 1"
by (auto simp add: a)
- finally have "(1 - x) * (1 + x + x\<^sup>2) <= 1" .
+ finally have "(1 - x) * (1 + x + x\<^sup>2) \<le> 1" .
moreover have c: "0 < 1 + x + x\<^sup>2"
by (simp add: add_pos_nonneg a)
- ultimately have "1 - x <= 1 / (1 + x + x\<^sup>2)"
+ ultimately have "1 - x \<le> 1 / (1 + x + x\<^sup>2)"
by (elim mult_imp_le_div_pos)
- also have "... <= 1 / exp x"
+ also have "\<dots> \<le> 1 / exp x"
by (metis a abs_one b exp_bound exp_gt_zero frac_le less_eq_real_def real_sqrt_abs
- real_sqrt_pow2_iff real_sqrt_power)
- also have "... = exp (-x)"
+ real_sqrt_pow2_iff real_sqrt_power)
+ also have "\<dots> = exp (- x)"
by (auto simp add: exp_minus divide_inverse)
- finally have "1 - x <= exp (- x)" .
+ finally have "1 - x \<le> exp (- x)" .
also have "1 - x = exp (ln (1 - x))"
by (metis b diff_0 exp_ln_iff less_iff_diff_less_0 minus_diff_eq)
- finally have "exp (ln (1 - x)) <= exp (- x)" .
- thus ?thesis by (auto simp only: exp_le_cancel_iff)
+ finally have "exp (ln (1 - x)) \<le> exp (- x)" .
+ then show ?thesis
+ by (auto simp only: exp_le_cancel_iff)
qed
-lemma exp_ge_add_one_self [simp]: "1 + (x::real) <= exp x"
- apply (case_tac "0 <= x")
- apply (erule exp_ge_add_one_self_aux)
- apply (case_tac "x <= -1")
- apply (subgoal_tac "1 + x <= 0")
- apply (erule order_trans)
- apply simp
- apply simp
- apply (subgoal_tac "1 + x = exp(ln (1 + x))")
- apply (erule ssubst)
- apply (subst exp_le_cancel_iff)
- apply (subgoal_tac "ln (1 - (- x)) <= - (- x)")
- apply simp
- apply (rule ln_one_minus_pos_upper_bound)
- apply auto
-done
+lemma exp_ge_add_one_self [simp]: "1 + x \<le> exp x"
+ for x :: real
+ apply (cases "0 \<le> x")
+ apply (erule exp_ge_add_one_self_aux)
+ apply (cases "x \<le> -1")
+ apply (subgoal_tac "1 + x \<le> 0")
+ apply (erule order_trans)
+ apply simp
+ apply simp
+ apply (subgoal_tac "1 + x = exp (ln (1 + x))")
+ apply (erule ssubst)
+ apply (subst exp_le_cancel_iff)
+ apply (subgoal_tac "ln (1 - (- x)) \<le> - (- x)")
+ apply simp
+ apply (rule ln_one_minus_pos_upper_bound)
+ apply auto
+ done
lemma ln_one_plus_pos_lower_bound:
- fixes x::real shows "0 <= x \<Longrightarrow> x <= 1 \<Longrightarrow> x - x\<^sup>2 <= ln (1 + x)"
+ fixes x :: real
+ assumes a: "0 \<le> x" and b: "x \<le> 1"
+ shows "x - x\<^sup>2 \<le> ln (1 + x)"
proof -
- assume a: "0 <= x" and b: "x <= 1"
have "exp (x - x\<^sup>2) = exp x / exp (x\<^sup>2)"
by (rule exp_diff)
- also have "... <= (1 + x + x\<^sup>2) / exp (x \<^sup>2)"
+ also have "\<dots> \<le> (1 + x + x\<^sup>2) / exp (x \<^sup>2)"
by (metis a b divide_right_mono exp_bound exp_ge_zero)
- also have "... <= (1 + x + x\<^sup>2) / (1 + x\<^sup>2)"
+ also have "\<dots> \<le> (1 + x + x\<^sup>2) / (1 + x\<^sup>2)"
by (simp add: a divide_left_mono add_pos_nonneg)
- also from a have "... <= 1 + x"
+ also from a have "\<dots> \<le> 1 + x"
by (simp add: field_simps add_strict_increasing zero_le_mult_iff)
- finally have "exp (x - x\<^sup>2) <= 1 + x" .
- also have "... = exp (ln (1 + x))"
+ finally have "exp (x - x\<^sup>2) \<le> 1 + x" .
+ also have "\<dots> = exp (ln (1 + x))"
proof -
from a have "0 < 1 + x" by auto
- thus ?thesis
+ then show ?thesis
by (auto simp only: exp_ln_iff [THEN sym])
qed
- finally have "exp (x - x\<^sup>2) <= exp (ln (1 + x))" .
- thus ?thesis
+ finally have "exp (x - x\<^sup>2) \<le> exp (ln (1 + x))" .
+ then show ?thesis
by (metis exp_le_cancel_iff)
qed
lemma ln_one_minus_pos_lower_bound:
- fixes x::real
- shows "0 <= x \<Longrightarrow> x <= (1 / 2) \<Longrightarrow> - x - 2 * x\<^sup>2 <= ln (1 - x)"
+ fixes x :: real
+ assumes a: "0 \<le> x" and b: "x \<le> 1 / 2"
+ shows "- x - 2 * x\<^sup>2 \<le> ln (1 - x)"
proof -
- assume a: "0 <= x" and b: "x <= (1 / 2)"
from b have c: "x < 1" by auto
then have "ln (1 - x) = - ln (1 + x / (1 - x))"
apply (subst ln_inverse [symmetric])
- apply (simp add: field_simps)
+ apply (simp add: field_simps)
apply (rule arg_cong [where f=ln])
apply (simp add: field_simps)
done
- also have "- (x / (1 - x)) <= ..."
+ also have "- (x / (1 - x)) \<le> \<dots>"
proof -
- have "ln (1 + x / (1 - x)) <= x / (1 - x)"
+ have "ln (1 + x / (1 - x)) \<le> x / (1 - x)"
using a c by (intro ln_add_one_self_le_self) auto
- thus ?thesis
+ then show ?thesis
by auto
qed
- also have "- (x / (1 - x)) = -x / (1 - x)"
+ also have "- (x / (1 - x)) = - x / (1 - x)"
by auto
- finally have d: "- x / (1 - x) <= ln (1 - x)" .
+ finally have d: "- x / (1 - x) \<le> ln (1 - x)" .
have "0 < 1 - x" using a b by simp
- hence e: "-x - 2 * x\<^sup>2 <= - x / (1 - x)"
- using mult_right_le_one_le[of "x*x" "2*x"] a b
+ then have e: "- x - 2 * x\<^sup>2 \<le> - x / (1 - x)"
+ using mult_right_le_one_le[of "x * x" "2 * x"] a b
by (simp add: field_simps power2_eq_square)
- from e d show "- x - 2 * x\<^sup>2 <= ln (1 - x)"
+ from e d show "- x - 2 * x\<^sup>2 \<le> ln (1 - x)"
by (rule order_trans)
qed
lemma ln_add_one_self_le_self2:
- fixes x::real shows "-1 < x \<Longrightarrow> ln(1 + x) <= x"
- apply (subgoal_tac "ln (1 + x) \<le> ln (exp x)", simp)
+ fixes x :: real
+ shows "-1 < x \<Longrightarrow> ln (1 + x) \<le> x"
+ apply (subgoal_tac "ln (1 + x) \<le> ln (exp x)")
+ apply simp
apply (subst ln_le_cancel_iff)
- apply auto
+ apply auto
done
lemma abs_ln_one_plus_x_minus_x_bound_nonneg:
- fixes x::real shows "0 <= x \<Longrightarrow> x <= 1 \<Longrightarrow> \<bar>ln (1 + x) - x\<bar> <= x\<^sup>2"
+ fixes x :: real
+ assumes x: "0 \<le> x" and x1: "x \<le> 1"
+ shows "\<bar>ln (1 + x) - x\<bar> \<le> x\<^sup>2"
proof -
- assume x: "0 <= x"
- assume x1: "x <= 1"
- from x have "ln (1 + x) <= x"
+ from x have "ln (1 + x) \<le> x"
by (rule ln_add_one_self_le_self)
- then have "ln (1 + x) - x <= 0"
+ then have "ln (1 + x) - x \<le> 0"
by simp
then have "\<bar>ln(1 + x) - x\<bar> = - (ln(1 + x) - x)"
by (rule abs_of_nonpos)
- also have "... = x - ln (1 + x)"
+ also have "\<dots> = x - ln (1 + x)"
by simp
- also have "... <= x\<^sup>2"
+ also have "\<dots> \<le> x\<^sup>2"
proof -
- from x x1 have "x - x\<^sup>2 <= ln (1 + x)"
+ from x x1 have "x - x\<^sup>2 \<le> ln (1 + x)"
by (intro ln_one_plus_pos_lower_bound)
- thus ?thesis
+ then show ?thesis
by simp
qed
finally show ?thesis .
qed
lemma abs_ln_one_plus_x_minus_x_bound_nonpos:
- fixes x::real shows "-(1 / 2) <= x \<Longrightarrow> x <= 0 \<Longrightarrow> \<bar>ln (1 + x) - x\<bar> <= 2 * x\<^sup>2"
+ fixes x :: real
+ assumes a: "-(1 / 2) \<le> x" and b: "x \<le> 0"
+ shows "\<bar>ln (1 + x) - x\<bar> \<le> 2 * x\<^sup>2"
proof -
- assume a: "-(1 / 2) <= x"
- assume b: "x <= 0"
- have "\<bar>ln (1 + x) - x\<bar> = x - ln(1 - (-x))"
+ have "\<bar>ln (1 + x) - x\<bar> = x - ln (1 - (- x))"
apply (subst abs_of_nonpos)
- apply simp
- apply (rule ln_add_one_self_le_self2)
+ apply simp
+ apply (rule ln_add_one_self_le_self2)
using a apply auto
done
- also have "... <= 2 * x\<^sup>2"
- apply (subgoal_tac "- (-x) - 2 * (-x)\<^sup>2 <= ln (1 - (-x))")
- apply (simp add: algebra_simps)
+ also have "\<dots> \<le> 2 * x\<^sup>2"
+ apply (subgoal_tac "- (-x) - 2 * (-x)\<^sup>2 \<le> ln (1 - (- x))")
+ apply (simp add: algebra_simps)
apply (rule ln_one_minus_pos_lower_bound)
using a b apply auto
done
@@ -1960,63 +1979,68 @@
qed
lemma abs_ln_one_plus_x_minus_x_bound:
- fixes x::real shows "\<bar>x\<bar> <= 1 / 2 \<Longrightarrow> \<bar>ln (1 + x) - x\<bar> <= 2 * x\<^sup>2"
- apply (case_tac "0 <= x")
- apply (rule order_trans)
- apply (rule abs_ln_one_plus_x_minus_x_bound_nonneg)
- apply auto
+ fixes x :: real
+ shows "\<bar>x\<bar> \<le> 1 / 2 \<Longrightarrow> \<bar>ln (1 + x) - x\<bar> \<le> 2 * x\<^sup>2"
+ apply (cases "0 \<le> x")
+ apply (rule order_trans)
+ apply (rule abs_ln_one_plus_x_minus_x_bound_nonneg)
+ apply auto
apply (rule abs_ln_one_plus_x_minus_x_bound_nonpos)
- apply auto
+ apply auto
done
lemma ln_x_over_x_mono:
- fixes x::real shows "exp 1 <= x \<Longrightarrow> x <= y \<Longrightarrow> (ln y / y) <= (ln x / x)"
+ fixes x :: real
+ assumes x: "exp 1 \<le> x" "x \<le> y"
+ shows "ln y / y \<le> ln x / x"
proof -
- assume x: "exp 1 <= x" "x <= y"
+ note x
moreover have "0 < exp (1::real)" by simp
ultimately have a: "0 < x" and b: "0 < y"
by (fast intro: less_le_trans order_trans)+
have "x * ln y - x * ln x = x * (ln y - ln x)"
by (simp add: algebra_simps)
- also have "... = x * ln(y / x)"
+ also have "\<dots> = x * ln (y / x)"
by (simp only: ln_div a b)
also have "y / x = (x + (y - x)) / x"
by simp
- also have "... = 1 + (y - x) / x"
+ also have "\<dots> = 1 + (y - x) / x"
using x a by (simp add: field_simps)
- also have "x * ln(1 + (y - x) / x) <= x * ((y - x) / x)"
+ also have "x * ln (1 + (y - x) / x) \<le> x * ((y - x) / x)"
using x a
by (intro mult_left_mono ln_add_one_self_le_self) simp_all
- also have "... = y - x" using a by simp
- also have "... = (y - x) * ln (exp 1)" by simp
- also have "... <= (y - x) * ln x"
+ also have "\<dots> = y - x"
+ using a by simp
+ also have "\<dots> = (y - x) * ln (exp 1)" by simp
+ also have "\<dots> \<le> (y - x) * ln x"
apply (rule mult_left_mono)
- apply (subst ln_le_cancel_iff)
- apply fact
- apply (rule a)
- apply (rule x)
+ apply (subst ln_le_cancel_iff)
+ apply fact
+ apply (rule a)
+ apply (rule x)
using x apply simp
done
- also have "... = y * ln x - x * ln x"
+ also have "\<dots> = y * ln x - x * ln x"
by (rule left_diff_distrib)
- finally have "x * ln y <= y * ln x"
+ finally have "x * ln y \<le> y * ln x"
by arith
- then have "ln y <= (y * ln x) / x" using a by (simp add: field_simps)
- also have "... = y * (ln x / x)" by simp
- finally show ?thesis using b by (simp add: field_simps)
+ then have "ln y \<le> (y * ln x) / x"
+ using a by (simp add: field_simps)
+ also have "\<dots> = y * (ln x / x)" by simp
+ finally show ?thesis
+ using b by (simp add: field_simps)
qed
-lemma ln_le_minus_one:
- fixes x::real shows "0 < x \<Longrightarrow> ln x \<le> x - 1"
+lemma ln_le_minus_one: "0 < x \<Longrightarrow> ln x \<le> x - 1"
+ for x :: real
using exp_ge_add_one_self[of "ln x"] by simp
-corollary ln_diff_le:
- fixes x::real
- shows "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln x - ln y \<le> (x - y) / y"
+corollary ln_diff_le: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> ln x - ln y \<le> (x - y) / y"
+ for x :: real
by (simp add: ln_div [symmetric] diff_divide_distrib ln_le_minus_one)
lemma ln_eq_minus_one:
- fixes x::real
+ fixes x :: real
assumes "0 < x" "ln x = x - 1"
shows "x = 1"
proof -
@@ -2060,19 +2084,18 @@
qed
qed
-lemma ln_x_over_x_tendsto_0:
- "((\<lambda>x::real. ln x / x) \<longlongrightarrow> 0) at_top"
+lemma ln_x_over_x_tendsto_0: "((\<lambda>x::real. ln x / x) \<longlongrightarrow> 0) at_top"
proof (rule lhospital_at_top_at_top[where f' = inverse and g' = "\<lambda>_. 1"])
from eventually_gt_at_top[of "0::real"]
- show "\<forall>\<^sub>F x in at_top. (ln has_real_derivative inverse x) (at x)"
- by eventually_elim (auto intro!: derivative_eq_intros simp: field_simps)
-qed (insert tendsto_inverse_0,
- auto simp: filterlim_ident dest!: tendsto_mono[OF at_top_le_at_infinity])
+ show "\<forall>\<^sub>F x in at_top. (ln has_real_derivative inverse x) (at x)"
+ by eventually_elim (auto intro!: derivative_eq_intros simp: field_simps)
+qed (use tendsto_inverse_0 in
+ \<open>auto simp: filterlim_ident dest!: tendsto_mono[OF at_top_le_at_infinity]\<close>)
lemma exp_ge_one_plus_x_over_n_power_n:
assumes "x \<ge> - real n" "n > 0"
- shows "(1 + x / of_nat n) ^ n \<le> exp x"
-proof (cases "x = -of_nat n")
+ shows "(1 + x / of_nat n) ^ n \<le> exp x"
+proof (cases "x = - of_nat n")
case False
from assms False have "(1 + x / of_nat n) ^ n = exp (of_nat n * ln (1 + x / of_nat n))"
by (subst exp_of_nat_mult, subst exp_ln) (simp_all add: field_simps)
@@ -2081,35 +2104,37 @@
with assms have "exp (of_nat n * ln (1 + x / of_nat n)) \<le> exp x"
by (simp add: field_simps)
finally show ?thesis .
-qed (simp_all add: zero_power)
+next
+ case True
+ then show ?thesis by (simp add: zero_power)
+qed
lemma exp_ge_one_minus_x_over_n_power_n:
assumes "x \<le> real n" "n > 0"
- shows "(1 - x / of_nat n) ^ n \<le> exp (-x)"
+ shows "(1 - x / of_nat n) ^ n \<le> exp (-x)"
using exp_ge_one_plus_x_over_n_power_n[of n "-x"] assms by simp
lemma exp_at_bot: "(exp \<longlongrightarrow> (0::real)) at_bot"
unfolding tendsto_Zfun_iff
proof (rule ZfunI, simp add: eventually_at_bot_dense)
- fix r :: real assume "0 < r"
- {
- fix x
- assume "x < ln r"
- then have "exp x < exp (ln r)"
+ fix r :: real
+ assume "0 < r"
+ have "exp x < r" if "x < ln r" for x
+ proof -
+ from that have "exp x < exp (ln r)"
by simp
- with \<open>0 < r\<close> have "exp x < r"
+ with \<open>0 < r\<close> show ?thesis
by simp
- }
+ qed
then show "\<exists>k. \<forall>n<k. exp n < r" by auto
qed
lemma exp_at_top: "LIM x at_top. exp x :: real :> at_top"
by (rule filterlim_at_top_at_top[where Q="\<lambda>x. True" and P="\<lambda>x. 0 < x" and g="ln"])
- (auto intro: eventually_gt_at_top)
-
-lemma lim_exp_minus_1:
- fixes x :: "'a::{real_normed_field,banach}"
- shows "((\<lambda>z::'a. (exp(z) - 1) / z) \<longlongrightarrow> 1) (at 0)"
+ (auto intro: eventually_gt_at_top)
+
+lemma lim_exp_minus_1: "((\<lambda>z::'a. (exp(z) - 1) / z) \<longlongrightarrow> 1) (at 0)"
+ for x :: "'a::{real_normed_field,banach}"
proof -
have "((\<lambda>z::'a. exp(z) - 1) has_field_derivative 1) (at 0)"
by (intro derivative_eq_intros | simp)+
@@ -2138,7 +2163,7 @@
show "((\<lambda>x. x ^ 0 / exp x) \<longlongrightarrow> (0::real)) at_top"
by (simp add: inverse_eq_divide[symmetric])
(metis filterlim_compose[OF tendsto_inverse_0] exp_at_top filterlim_mono
- at_top_le_at_infinity order_refl)
+ at_top_le_at_infinity order_refl)
next
case (Suc k)
show ?case
@@ -2155,14 +2180,13 @@
qed (rule exp_at_top)
qed
-
-definition log :: "[real,real] => real"
+definition log :: "real \<Rightarrow> real \<Rightarrow> real"
\<comment> \<open>logarithm of @{term x} to base @{term a}\<close>
where "log a x = ln x / ln a"
-
lemma tendsto_log [tendsto_intros]:
- "\<lbrakk>(f \<longlongrightarrow> a) F; (g \<longlongrightarrow> b) F; 0 < a; a \<noteq> 1; 0 < b\<rbrakk> \<Longrightarrow> ((\<lambda>x. log (f x) (g x)) \<longlongrightarrow> log a b) F"
+ "(f \<longlongrightarrow> a) F \<Longrightarrow> (g \<longlongrightarrow> b) F \<Longrightarrow> 0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> 0 < b \<Longrightarrow>
+ ((\<lambda>x. log (f x) (g x)) \<longlongrightarrow> log a b) F"
unfolding log_def by (intro tendsto_intros) auto
lemma continuous_log:
@@ -2197,77 +2221,77 @@
lemma powr_one_eq_one [simp]: "1 powr a = 1"
by (simp add: powr_def)
-lemma powr_zero_eq_one [simp]: "x powr 0 = (if x=0 then 0 else 1)"
+lemma powr_zero_eq_one [simp]: "x powr 0 = (if x = 0 then 0 else 1)"
by (simp add: powr_def)
-lemma powr_one_gt_zero_iff [simp]:
- fixes x::real shows "(x powr 1 = x) = (0 \<le> x)"
+lemma powr_one_gt_zero_iff [simp]: "x powr 1 = x \<longleftrightarrow> 0 \<le> x"
+ for x :: real
by (auto simp: powr_def)
declare powr_one_gt_zero_iff [THEN iffD2, simp]
-lemma powr_mult:
- fixes x::real shows "0 \<le> x \<Longrightarrow> 0 \<le> y \<Longrightarrow> (x * y) powr a = (x powr a) * (y powr a)"
+lemma powr_mult: "0 \<le> x \<Longrightarrow> 0 \<le> y \<Longrightarrow> (x * y) powr a = (x powr a) * (y powr a)"
+ for a x y :: real
by (simp add: powr_def exp_add [symmetric] ln_mult distrib_left)
-lemma powr_ge_pzero [simp]:
- fixes x::real shows "0 <= x powr y"
+lemma powr_ge_pzero [simp]: "0 \<le> x powr y"
+ for x y :: real
by (simp add: powr_def)
-lemma powr_divide:
- fixes x::real shows "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> (x / y) powr a = (x powr a) / (y powr a)"
+lemma powr_divide: "0 < x \<Longrightarrow> 0 < y \<Longrightarrow> (x / y) powr a = (x powr a) / (y powr a)"
+ for a b x :: real
apply (simp add: divide_inverse positive_imp_inverse_positive powr_mult)
apply (simp add: powr_def exp_minus [symmetric] exp_add [symmetric] ln_inverse)
done
-lemma powr_divide2:
- fixes x::real shows "x powr a / x powr b = x powr (a - b)"
+lemma powr_divide2: "x powr a / x powr b = x powr (a - b)"
+ for a b x :: real
apply (simp add: powr_def)
apply (subst exp_diff [THEN sym])
apply (simp add: left_diff_distrib)
done
-lemma powr_add:
- fixes x::real shows "x powr (a + b) = (x powr a) * (x powr b)"
+lemma powr_add: "x powr (a + b) = (x powr a) * (x powr b)"
+ for a b x :: real
by (simp add: powr_def exp_add [symmetric] distrib_right)
-lemma powr_mult_base:
- fixes x::real shows "0 < x \<Longrightarrow>x * x powr y = x powr (1 + y)"
+lemma powr_mult_base: "0 < x \<Longrightarrow>x * x powr y = x powr (1 + y)"
+ for x :: real
by (auto simp: powr_add)
-lemma powr_powr:
- fixes x::real shows "(x powr a) powr b = x powr (a * b)"
+lemma powr_powr: "(x powr a) powr b = x powr (a * b)"
+ for a b x :: real
by (simp add: powr_def)
-lemma powr_powr_swap:
- fixes x::real shows "(x powr a) powr b = (x powr b) powr a"
+lemma powr_powr_swap: "(x powr a) powr b = (x powr b) powr a"
+ for a b x :: real
by (simp add: powr_powr mult.commute)
-lemma powr_minus:
- fixes x::real shows "x powr (-a) = inverse (x powr a)"
+lemma powr_minus: "x powr (- a) = inverse (x powr a)"
+ for x a :: real
by (simp add: powr_def exp_minus [symmetric])
-lemma powr_minus_divide:
- fixes x::real shows "x powr (-a) = 1/(x powr a)"
+lemma powr_minus_divide: "x powr (- a) = 1/(x powr a)"
+ for x a :: real
by (simp add: divide_inverse powr_minus)
-lemma divide_powr_uminus:
- fixes a::real shows "a / b powr c = a * b powr (- c)"
+lemma divide_powr_uminus: "a / b powr c = a * b powr (- c)"
+ for a b c :: real
by (simp add: powr_minus_divide)
-lemma powr_less_mono:
- fixes x::real shows "a < b \<Longrightarrow> 1 < x \<Longrightarrow> x powr a < x powr b"
+lemma powr_less_mono: "a < b \<Longrightarrow> 1 < x \<Longrightarrow> x powr a < x powr b"
+ for a b x :: real
by (simp add: powr_def)
-lemma powr_less_cancel:
- fixes x::real shows "x powr a < x powr b \<Longrightarrow> 1 < x \<Longrightarrow> a < b"
+lemma powr_less_cancel: "x powr a < x powr b \<Longrightarrow> 1 < x \<Longrightarrow> a < b"
+ for a b x :: real
by (simp add: powr_def)
-lemma powr_less_cancel_iff [simp]:
- fixes x::real shows "1 < x \<Longrightarrow> (x powr a < x powr b) = (a < b)"
+lemma powr_less_cancel_iff [simp]: "1 < x \<Longrightarrow> x powr a < x powr b \<longleftrightarrow> a < b"
+ for a b x :: real
by (blast intro: powr_less_cancel powr_less_mono)
-lemma powr_le_cancel_iff [simp]:
- fixes x::real shows "1 < x \<Longrightarrow> (x powr a \<le> x powr b) = (a \<le> b)"
+lemma powr_le_cancel_iff [simp]: "1 < x \<Longrightarrow> x powr a \<le> x powr b \<longleftrightarrow> a \<le> b"
+ for a b x :: real
by (simp add: linorder_not_less [symmetric])
lemma log_ln: "ln x = log (exp(1)) x"
@@ -2285,7 +2309,7 @@
qed
lemmas DERIV_log[THEN DERIV_chain2, derivative_intros]
- DERIV_log[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros]
+ and DERIV_log[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros]
lemma powr_log_cancel [simp]: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> a powr (log a x) = x"
by (simp add: powr_def log_def)
@@ -2313,18 +2337,19 @@
lemma log_one [simp]: "log a 1 = 0"
by (simp add: log_def)
-lemma log_eq_one [simp]: "[| 0 < a; a \<noteq> 1 |] ==> log a a = 1"
+lemma log_eq_one [simp]: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> log a a = 1"
by (simp add: log_def)
lemma log_inverse: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> log a (inverse x) = - log a x"
- apply (rule_tac a1 = "log a x" in add_left_cancel [THEN iffD1])
+ apply (rule add_left_cancel [THEN iffD1, where a1 = "log a x"])
apply (simp add: log_mult [symmetric])
done
lemma log_divide: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> 0 < y \<Longrightarrow> log a (x/y) = log a x - log a y"
by (simp add: log_mult divide_inverse log_inverse)
-lemma powr_gt_zero [simp]: "0 < x powr a \<longleftrightarrow> (x::real) \<noteq> 0"
+lemma powr_gt_zero [simp]: "0 < x powr a \<longleftrightarrow> x \<noteq> 0"
+ for a x :: real
by (simp add: powr_def)
lemma log_add_eq_powr: "0 < b \<Longrightarrow> b \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> log b x + y = log b (x * b powr y)"
@@ -2333,11 +2358,11 @@
and minus_log_eq_powr: "0 < b \<Longrightarrow> b \<noteq> 1 \<Longrightarrow> 0 < x \<Longrightarrow> y - log b x = log b (b powr y / x)"
by (simp_all add: log_mult log_divide)
-lemma log_less_cancel_iff [simp]:
- "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 0 < y \<Longrightarrow> log a x < log a y \<longleftrightarrow> x < y"
+lemma log_less_cancel_iff [simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 0 < y \<Longrightarrow> log a x < log a y \<longleftrightarrow> x < y"
apply safe
- apply (rule_tac [2] powr_less_cancel)
- apply (drule_tac a = "log a x" in powr_less_mono, auto)
+ apply (rule_tac [2] powr_less_cancel)
+ apply (drule_tac a = "log a x" in powr_less_mono)
+ apply auto
done
lemma log_inj:
@@ -2351,18 +2376,19 @@
assume "x = y"
then show ?thesis by simp
next
- assume "x < y" hence "log b x < log b y"
+ assume "x < y"
+ then have "log b x < log b y"
using log_less_cancel_iff[OF \<open>1 < b\<close>] pos by simp
then show ?thesis using * by simp
next
- assume "y < x" hence "log b y < log b x"
+ assume "y < x"
+ then have "log b y < log b x"
using log_less_cancel_iff[OF \<open>1 < b\<close>] pos by simp
then show ?thesis using * by simp
qed
qed
-lemma log_le_cancel_iff [simp]:
- "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 0 < y \<Longrightarrow> (log a x \<le> log a y) = (x \<le> y)"
+lemma log_le_cancel_iff [simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 0 < y \<Longrightarrow> log a x \<le> log a y \<longleftrightarrow> x \<le> y"
by (simp add: linorder_not_less [symmetric])
lemma zero_less_log_cancel_iff[simp]: "1 < a \<Longrightarrow> 0 < x \<Longrightarrow> 0 < log a x \<longleftrightarrow> 1 < x"
@@ -2390,12 +2416,13 @@
using log_le_cancel_iff[of a x a] by simp
lemma le_log_iff:
+ fixes b x y :: real
assumes "1 < b" "x > 0"
- shows "y \<le> log b x \<longleftrightarrow> b powr y \<le> (x::real)"
+ shows "y \<le> log b x \<longleftrightarrow> b powr y \<le> x"
using assms
apply auto
- apply (metis (no_types, hide_lams) less_irrefl less_le_trans linear powr_le_cancel_iff
- powr_log_cancel zero_less_one)
+ apply (metis (no_types, hide_lams) less_irrefl less_le_trans linear powr_le_cancel_iff
+ powr_log_cancel zero_less_one)
apply (metis not_less order.trans order_refl powr_le_cancel_iff powr_log_cancel zero_le_one)
done
@@ -2417,27 +2444,28 @@
and less_powr_iff = log_less_iff[symmetric]
and le_powr_iff = log_le_iff[symmetric]
-lemma floor_log_eq_powr_iff:
- "x > 0 \<Longrightarrow> b > 1 \<Longrightarrow> \<lfloor>log b x\<rfloor> = k \<longleftrightarrow> b powr k \<le> x \<and> x < b powr (k + 1)"
+lemma floor_log_eq_powr_iff: "x > 0 \<Longrightarrow> b > 1 \<Longrightarrow> \<lfloor>log b x\<rfloor> = k \<longleftrightarrow> b powr k \<le> x \<and> x < b powr (k + 1)"
by (auto simp add: floor_eq_iff powr_le_iff less_powr_iff)
-lemma powr_realpow: "0 < x ==> x powr (real n) = x^n"
- by (induct n) (simp_all add: ac_simps powr_add of_nat_Suc)
+lemma powr_realpow: "0 < x \<Longrightarrow> x powr (real n) = x^n"
+ by (induct n) (simp_all add: ac_simps powr_add)
lemma powr_numeral: "0 < x \<Longrightarrow> x powr (numeral n :: real) = x ^ (numeral n)"
by (metis of_nat_numeral powr_realpow)
lemma powr_real_of_int:
- "x > 0 \<Longrightarrow> x powr real_of_int n = (if n \<ge> 0 then x ^ nat n else inverse (x ^ nat (-n)))"
+ "x > 0 \<Longrightarrow> x powr real_of_int n = (if n \<ge> 0 then x ^ nat n else inverse (x ^ nat (- n)))"
using powr_realpow[of x "nat n"] powr_realpow[of x "nat (-n)"]
by (auto simp: field_simps powr_minus)
lemma powr2_sqrt[simp]: "0 < x \<Longrightarrow> sqrt x powr 2 = x"
-by(simp add: powr_numeral)
-
-lemma powr_realpow2: "0 <= x ==> 0 < n ==> x^n = (if (x = 0) then 0 else x powr (real n))"
- apply (case_tac "x = 0", simp, simp)
- apply (rule powr_realpow [THEN sym], simp)
+ by (simp add: powr_numeral)
+
+lemma powr_realpow2: "0 \<le> x \<Longrightarrow> 0 < n \<Longrightarrow> x^n = (if (x = 0) then 0 else x powr (real n))"
+ apply (cases "x = 0")
+ apply simp_all
+ apply (rule powr_realpow [THEN sym])
+ apply simp
done
lemma powr_int:
@@ -2445,49 +2473,51 @@
shows "x powr i = (if i \<ge> 0 then x ^ nat i else 1 / x ^ nat (-i))"
proof (cases "i < 0")
case True
- have r: "x powr i = 1 / x powr (-i)" by (simp add: powr_minus field_simps)
- show ?thesis using \<open>i < 0\<close> \<open>x > 0\<close> by (simp add: r field_simps powr_realpow[symmetric])
+ have r: "x powr i = 1 / x powr (- i)"
+ by (simp add: powr_minus field_simps)
+ show ?thesis using \<open>i < 0\<close> \<open>x > 0\<close>
+ by (simp add: r field_simps powr_realpow[symmetric])
next
case False
- then show ?thesis by (simp add: assms powr_realpow[symmetric])
+ then show ?thesis
+ by (simp add: assms powr_realpow[symmetric])
qed
lemma compute_powr[code]:
- fixes i::real
+ fixes i :: real
shows "b powr i =
(if b \<le> 0 then Code.abort (STR ''op powr with nonpositive base'') (\<lambda>_. b powr i)
- else if \<lfloor>i\<rfloor> = i then (if 0 \<le> i then b ^ nat \<lfloor>i\<rfloor> else 1 / b ^ nat \<lfloor>- i\<rfloor>)
- else Code.abort (STR ''op powr with non-integer exponent'') (\<lambda>_. b powr i))"
+ else if \<lfloor>i\<rfloor> = i then (if 0 \<le> i then b ^ nat \<lfloor>i\<rfloor> else 1 / b ^ nat \<lfloor>- i\<rfloor>)
+ else Code.abort (STR ''op powr with non-integer exponent'') (\<lambda>_. b powr i))"
by (auto simp: powr_int)
-lemma powr_one:
- fixes x::real shows "0 \<le> x \<Longrightarrow> x powr 1 = x"
- using powr_realpow [of x 1]
- by simp
-
-lemma powr_neg_one:
- fixes x::real shows "0 < x \<Longrightarrow> x powr - 1 = 1 / x"
+lemma powr_one: "0 \<le> x \<Longrightarrow> x powr 1 = x"
+ for x :: real
+ using powr_realpow [of x 1] by simp
+
+lemma powr_neg_one: "0 < x \<Longrightarrow> x powr - 1 = 1 / x"
+ for x :: real
using powr_int [of x "- 1"] by simp
-lemma powr_neg_numeral:
- fixes x::real shows "0 < x \<Longrightarrow> x powr - numeral n = 1 / x ^ numeral n"
+lemma powr_neg_numeral: "0 < x \<Longrightarrow> x powr - numeral n = 1 / x ^ numeral n"
+ for x :: real
using powr_int [of x "- numeral n"] by simp
lemma root_powr_inverse: "0 < n \<Longrightarrow> 0 < x \<Longrightarrow> root n x = x powr (1/n)"
by (rule real_root_pos_unique) (auto simp: powr_realpow[symmetric] powr_powr)
-lemma ln_powr:
- fixes x::real shows "x \<noteq> 0 \<Longrightarrow> ln (x powr y) = y * ln x"
+lemma ln_powr: "x \<noteq> 0 \<Longrightarrow> ln (x powr y) = y * ln x"
+ for x :: real
by (simp add: powr_def)
-lemma ln_root: "\<lbrakk> n > 0; b > 0 \<rbrakk> \<Longrightarrow> ln (root n b) = ln b / n"
-by(simp add: root_powr_inverse ln_powr)
+lemma ln_root: "n > 0 \<Longrightarrow> b > 0 \<Longrightarrow> ln (root n b) = ln b / n"
+ by (simp add: root_powr_inverse ln_powr)
lemma ln_sqrt: "0 < x \<Longrightarrow> ln (sqrt x) = ln x / 2"
by (simp add: ln_powr powr_numeral ln_powr[symmetric] mult.commute)
-lemma log_root: "\<lbrakk> n > 0; a > 0 \<rbrakk> \<Longrightarrow> log b (root n a) = log b a / n"
-by(simp add: log_def ln_root)
+lemma log_root: "n > 0 \<Longrightarrow> a > 0 \<Longrightarrow> log b (root n a) = log b a / n"
+ by (simp add: log_def ln_root)
lemma log_powr: "x \<noteq> 0 \<Longrightarrow> log b (x powr y) = y * log b x"
by (simp add: log_def ln_powr)
@@ -2495,16 +2525,21 @@
lemma log_nat_power: "0 < x \<Longrightarrow> log b (x^n) = real n * log b x"
by (simp add: log_powr powr_realpow [symmetric])
-lemma le_log_of_power: assumes "1 < b" "b ^ n \<le> m" shows "n \<le> log b m"
+lemma le_log_of_power:
+ assumes "1 < b" "b ^ n \<le> m"
+ shows "n \<le> log b m"
proof -
from assms have "0 < m"
by (metis less_trans zero_less_power less_le_trans zero_less_one)
- have "n = log b (b ^ n)" using assms(1) by (simp add: log_nat_power)
- also have "\<dots> \<le> log b m" using assms \<open>0 < m\<close> by simp
+ have "n = log b (b ^ n)"
+ using assms(1) by (simp add: log_nat_power)
+ also have "\<dots> \<le> log b m"
+ using assms \<open>0 < m\<close> by simp
finally show ?thesis .
qed
-lemma le_log2_of_power: "2 ^ n \<le> (m::nat) \<Longrightarrow> n \<le> log 2 m"
+lemma le_log2_of_power: "2 ^ n \<le> m \<Longrightarrow> n \<le> log 2 m"
+ for m n :: nat
using le_log_of_power[of 2] by simp
lemma log_base_change: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> log b x = log a x / log a b"
@@ -2516,122 +2551,140 @@
lemma log_base_powr: "a \<noteq> 0 \<Longrightarrow> log (a powr b) x = log a x / b"
by (simp add: log_def ln_powr)
-lemma log_base_root: "\<lbrakk> n > 0; b > 0 \<rbrakk> \<Longrightarrow> log (root n b) x = n * (log b x)"
-by(simp add: log_def ln_root)
-
-lemma ln_bound:
- fixes x::real shows "1 <= x ==> ln x <= x"
- apply (subgoal_tac "ln(1 + (x - 1)) <= x - 1")
+lemma log_base_root: "n > 0 \<Longrightarrow> b > 0 \<Longrightarrow> log (root n b) x = n * (log b x)"
+ by (simp add: log_def ln_root)
+
+lemma ln_bound: "1 \<le> x \<Longrightarrow> ln x \<le> x"
+ for x :: real
+ apply (subgoal_tac "ln (1 + (x - 1)) \<le> x - 1")
+ apply simp
+ apply (rule ln_add_one_self_le_self)
apply simp
- apply (rule ln_add_one_self_le_self, simp)
- done
-
-lemma powr_mono:
- fixes x::real shows "a <= b ==> 1 <= x ==> x powr a <= x powr b"
- apply (cases "x = 1", simp)
- apply (cases "a = b", simp)
- apply (rule order_less_imp_le)
- apply (rule powr_less_mono, auto)
done
-lemma ge_one_powr_ge_zero:
- fixes x::real shows "1 <= x ==> 0 <= a ==> 1 <= x powr a"
-using powr_mono by fastforce
-
-lemma powr_less_mono2:
- fixes x::real shows "0 < a ==> 0 \<le> x ==> x < y ==> x powr a < y powr a"
+lemma powr_mono: "a \<le> b \<Longrightarrow> 1 \<le> x \<Longrightarrow> x powr a \<le> x powr b"
+ for x :: real
+ apply (cases "x = 1")
+ apply simp
+ apply (cases "a = b")
+ apply simp
+ apply (rule order_less_imp_le)
+ apply (rule powr_less_mono)
+ apply auto
+ done
+
+lemma ge_one_powr_ge_zero: "1 \<le> x \<Longrightarrow> 0 \<le> a \<Longrightarrow> 1 \<le> x powr a"
+ for x :: real
+ using powr_mono by fastforce
+
+lemma powr_less_mono2: "0 < a \<Longrightarrow> 0 \<le> x \<Longrightarrow> x < y \<Longrightarrow> x powr a < y powr a"
+ for x :: real
by (simp add: powr_def)
-lemma powr_less_mono2_neg:
- fixes x::real shows "a < 0 ==> 0 < x ==> x < y ==> y powr a < x powr a"
+lemma powr_less_mono2_neg: "a < 0 \<Longrightarrow> 0 < x \<Longrightarrow> x < y \<Longrightarrow> y powr a < x powr a"
+ for x :: real
by (simp add: powr_def)
-lemma powr_mono2:
- fixes x::real shows "0 <= a ==> 0 \<le> x ==> x <= y ==> x powr a <= y powr a"
- apply (case_tac "a = 0", simp)
- apply (case_tac "x = y", simp)
+lemma powr_mono2: "0 \<le> a \<Longrightarrow> 0 \<le> x \<Longrightarrow> x \<le> y \<Longrightarrow> x powr a \<le> y powr a"
+ for x :: real
+ apply (case_tac "a = 0")
+ apply simp
+ apply (case_tac "x = y")
+ apply simp
apply (metis dual_order.strict_iff_order powr_less_mono2)
done
lemma powr_mono2':
- assumes "a \<le> 0" "x > 0" "x \<le> (y::real)"
- shows "x powr a \<ge> y powr a"
+ fixes a x y :: real
+ assumes "a \<le> 0" "x > 0" "x \<le> y"
+ shows "x powr a \<ge> y powr a"
proof -
- from assms have "x powr -a \<le> y powr -a" by (intro powr_mono2) simp_all
- with assms show ?thesis by (auto simp add: powr_minus field_simps)
+ from assms have "x powr - a \<le> y powr - a"
+ by (intro powr_mono2) simp_all
+ with assms show ?thesis
+ by (auto simp add: powr_minus field_simps)
qed
-lemma powr_inj:
- fixes x::real shows "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> a powr x = a powr y \<longleftrightarrow> x = y"
+lemma powr_inj: "0 < a \<Longrightarrow> a \<noteq> 1 \<Longrightarrow> a powr x = a powr y \<longleftrightarrow> x = y"
+ for x :: real
unfolding powr_def exp_inj_iff by simp
lemma powr_half_sqrt: "0 \<le> x \<Longrightarrow> x powr (1/2) = sqrt x"
by (simp add: powr_def root_powr_inverse sqrt_def)
-lemma ln_powr_bound:
- fixes x::real shows "1 \<le> x \<Longrightarrow> 0 < a \<Longrightarrow> ln x \<le> (x powr a) / a"
+lemma ln_powr_bound: "1 \<le> x \<Longrightarrow> 0 < a \<Longrightarrow> ln x \<le> (x powr a) / a"
+ for x :: real
by (metis exp_gt_zero linear ln_eq_zero_iff ln_exp ln_less_self ln_powr mult.commute
- mult_imp_le_div_pos not_less powr_gt_zero)
+ mult_imp_le_div_pos not_less powr_gt_zero)
lemma ln_powr_bound2:
- fixes x::real
+ fixes x :: real
assumes "1 < x" and "0 < a"
- shows "(ln x) powr a <= (a powr a) * x"
+ shows "(ln x) powr a \<le> (a powr a) * x"
proof -
- from assms have "ln x <= (x powr (1 / a)) / (1 / a)"
+ from assms have "ln x \<le> (x powr (1 / a)) / (1 / a)"
by (metis less_eq_real_def ln_powr_bound zero_less_divide_1_iff)
- also have "... = a * (x powr (1 / a))"
+ also have "\<dots> = a * (x powr (1 / a))"
by simp
- finally have "(ln x) powr a <= (a * (x powr (1 / a))) powr a"
+ finally have "(ln x) powr a \<le> (a * (x powr (1 / a))) powr a"
by (metis assms less_imp_le ln_gt_zero powr_mono2)
- also have "... = (a powr a) * ((x powr (1 / a)) powr a)"
+ also have "\<dots> = (a powr a) * ((x powr (1 / a)) powr a)"
using assms powr_mult by auto
also have "(x powr (1 / a)) powr a = x powr ((1 / a) * a)"
by (rule powr_powr)
- also have "... = x" using assms
+ also have "\<dots> = x" using assms
by auto
finally show ?thesis .
qed
lemma tendsto_powr:
- fixes a::real
- assumes f: "(f \<longlongrightarrow> a) F" and g: "(g \<longlongrightarrow> b) F" and a: "a \<noteq> 0"
+ fixes a b :: real
+ assumes f: "(f \<longlongrightarrow> a) F"
+ and g: "(g \<longlongrightarrow> b) F"
+ and a: "a \<noteq> 0"
shows "((\<lambda>x. f x powr g x) \<longlongrightarrow> a powr b) F"
unfolding powr_def
proof (rule filterlim_If)
from f show "((\<lambda>x. 0) \<longlongrightarrow> (if a = 0 then 0 else exp (b * ln a))) (inf F (principal {x. f x = 0}))"
by simp (auto simp: filterlim_iff eventually_inf_principal elim: eventually_mono dest: t1_space_nhds)
-qed (insert f g a, auto intro!: tendsto_intros intro: tendsto_mono inf_le1)
+ from f g a show "((\<lambda>x. exp (g x * ln (f x))) \<longlongrightarrow> (if a = 0 then 0 else exp (b * ln a)))
+ (inf F (principal {x. f x \<noteq> 0}))"
+ by (auto intro!: tendsto_intros intro: tendsto_mono inf_le1)
+qed
lemma tendsto_powr'[tendsto_intros]:
- fixes a::real
- assumes f: "(f \<longlongrightarrow> a) F" and g: "(g \<longlongrightarrow> b) F"
- and a: "a \<noteq> 0 \<or> (b > 0 \<and> eventually (\<lambda>x. f x \<ge> 0) F)"
+ fixes a :: real
+ assumes f: "(f \<longlongrightarrow> a) F"
+ and g: "(g \<longlongrightarrow> b) F"
+ and a: "a \<noteq> 0 \<or> (b > 0 \<and> eventually (\<lambda>x. f x \<ge> 0) F)"
shows "((\<lambda>x. f x powr g x) \<longlongrightarrow> a powr b) F"
proof -
- from a consider "a \<noteq> 0" | "a = 0" "b > 0" "eventually (\<lambda>x. f x \<ge> 0) F" by auto
- thus ?thesis
+ from a consider "a \<noteq> 0" | "a = 0" "b > 0" "eventually (\<lambda>x. f x \<ge> 0) F"
+ by auto
+ then show ?thesis
proof cases
- assume "a \<noteq> 0"
- from f g this show ?thesis by (rule tendsto_powr)
+ case 1
+ with f g show ?thesis by (rule tendsto_powr)
next
- assume a: "a = 0" and b: "b > 0" and f_nonneg: "eventually (\<lambda>x. f x \<ge> 0) F"
- hence "((\<lambda>x. if f x = 0 then 0 else exp (g x * ln (f x))) \<longlongrightarrow> 0) F"
+ case 2
+ have "((\<lambda>x. if f x = 0 then 0 else exp (g x * ln (f x))) \<longlongrightarrow> 0) F"
proof (intro filterlim_If)
have "filterlim f (principal {0<..}) (inf F (principal {z. f z \<noteq> 0}))"
- using f_nonneg by (auto simp add: filterlim_iff eventually_inf_principal
- eventually_principal elim: eventually_mono)
+ using \<open>eventually (\<lambda>x. f x \<ge> 0) F\<close>
+ by (auto simp add: filterlim_iff eventually_inf_principal
+ eventually_principal elim: eventually_mono)
moreover have "filterlim f (nhds a) (inf F (principal {z. f z \<noteq> 0}))"
by (rule tendsto_mono[OF _ f]) simp_all
ultimately have f: "filterlim f (at_right 0) (inf F (principal {x. f x \<noteq> 0}))"
- by (simp add: at_within_def filterlim_inf a)
+ by (simp add: at_within_def filterlim_inf \<open>a = 0\<close>)
have g: "(g \<longlongrightarrow> b) (inf F (principal {z. f z \<noteq> 0}))"
by (rule tendsto_mono[OF _ g]) simp_all
show "((\<lambda>x. exp (g x * ln (f x))) \<longlongrightarrow> 0) (inf F (principal {x. f x \<noteq> 0}))"
by (rule filterlim_compose[OF exp_at_bot] filterlim_tendsto_pos_mult_at_bot
- filterlim_compose[OF ln_at_0] f g b)+
+ filterlim_compose[OF ln_at_0] f g \<open>b > 0\<close>)+
qed simp_all
- with a show ?thesis by (simp add: powr_def)
+ with \<open>a = 0\<close> show ?thesis
+ by (simp add: powr_def)
qed
qed
@@ -2643,32 +2696,40 @@
using assms unfolding continuous_def by (rule tendsto_powr)
lemma continuous_at_within_powr[continuous_intros]:
+ fixes f g :: "_ \<Rightarrow> real"
assumes "continuous (at a within s) f"
and "continuous (at a within s) g"
and "f a \<noteq> 0"
- shows "continuous (at a within s) (\<lambda>x. (f x) powr (g x :: real))"
+ shows "continuous (at a within s) (\<lambda>x. (f x) powr (g x))"
using assms unfolding continuous_within by (rule tendsto_powr)
lemma isCont_powr[continuous_intros, simp]:
- assumes "isCont f a" "isCont g a" "f a \<noteq> (0::real)"
+ fixes f g :: "_ \<Rightarrow> real"
+ assumes "isCont f a" "isCont g a" "f a \<noteq> 0"
shows "isCont (\<lambda>x. (f x) powr g x) a"
using assms unfolding continuous_at by (rule tendsto_powr)
lemma continuous_on_powr[continuous_intros]:
- assumes "continuous_on s f" "continuous_on s g" and "\<forall>x\<in>s. f x \<noteq> (0::real)"
+ fixes f g :: "_ \<Rightarrow> real"
+ assumes "continuous_on s f" "continuous_on s g" and "\<forall>x\<in>s. f x \<noteq> 0"
shows "continuous_on s (\<lambda>x. (f x) powr (g x))"
using assms unfolding continuous_on_def by (fast intro: tendsto_powr)
-
+
lemma tendsto_powr2:
- fixes a::real
- assumes f: "(f \<longlongrightarrow> a) F" and g: "(g \<longlongrightarrow> b) F" and f_nonneg: "\<forall>\<^sub>F x in F. 0 \<le> f x" and b: "0 < b"
+ fixes a :: real
+ assumes f: "(f \<longlongrightarrow> a) F"
+ and g: "(g \<longlongrightarrow> b) F"
+ and "\<forall>\<^sub>F x in F. 0 \<le> f x"
+ and b: "0 < b"
shows "((\<lambda>x. f x powr g x) \<longlongrightarrow> a powr b) F"
using tendsto_powr'[of f a F g b] assms by auto
lemma DERIV_powr:
- fixes r::real
- assumes g: "DERIV g x :> m" and pos: "g x > 0" and f: "DERIV f x :> r"
- shows "DERIV (\<lambda>x. g x powr f x) x :> (g x powr f x) * (r * ln (g x) + m * f x / g x)"
+ fixes r :: real
+ assumes g: "DERIV g x :> m"
+ and pos: "g x > 0"
+ and f: "DERIV f x :> r"
+ shows "DERIV (\<lambda>x. g x powr f x) x :> (g x powr f x) * (r * ln (g x) + m * f x / g x)"
proof -
have "DERIV (\<lambda>x. exp (f x * ln (g x))) x :> (g x powr f x) * (r * ln (g x) + m * f x / g x)"
using pos
@@ -2683,9 +2744,10 @@
qed
lemma DERIV_fun_powr:
- fixes r::real
- assumes g: "DERIV g x :> m" and pos: "g x > 0"
- shows "DERIV (\<lambda>x. (g x) powr r) x :> r * (g x) powr (r - of_nat 1) * m"
+ fixes r :: real
+ assumes g: "DERIV g x :> m"
+ and pos: "g x > 0"
+ shows "DERIV (\<lambda>x. (g x) powr r) x :> r * (g x) powr (r - of_nat 1) * m"
using DERIV_powr[OF g pos DERIV_const, of r] pos
by (simp add: powr_divide2[symmetric] field_simps)
@@ -2693,8 +2755,9 @@
assumes "z > 0"
shows "((\<lambda>z. z powr r) has_real_derivative r * z powr (r - 1)) (at z)"
proof (subst DERIV_cong_ev[OF refl _ refl])
- from assms have "eventually (\<lambda>z. z \<noteq> 0) (nhds z)" by (intro t1_space_nhds) auto
- thus "eventually (\<lambda>z. z powr r = exp (r * ln z)) (nhds z)"
+ from assms have "eventually (\<lambda>z. z \<noteq> 0) (nhds z)"
+ by (intro t1_space_nhds) auto
+ then show "eventually (\<lambda>z. z powr r = exp (r * ln z)) (nhds z)"
unfolding powr_def by eventually_elim simp
from assms show "((\<lambda>z. exp (r * ln z)) has_real_derivative r * z powr (r - 1)) (at z)"
by (auto intro!: derivative_eq_intros simp: powr_def field_simps exp_diff)
@@ -2708,12 +2771,14 @@
using tendsto_powr2[OF assms] by simp
lemma continuous_on_powr':
- assumes "continuous_on s f" "continuous_on s g" and
- "\<forall>x\<in>s. f x \<ge> (0::real) \<and> (f x = 0 \<longrightarrow> g x > 0)"
+ fixes f g :: "_ \<Rightarrow> real"
+ assumes "continuous_on s f" "continuous_on s g"
+ and "\<forall>x\<in>s. f x \<ge> 0 \<and> (f x = 0 \<longrightarrow> g x > 0)"
shows "continuous_on s (\<lambda>x. (f x) powr (g x))"
unfolding continuous_on_def
proof
- fix x assume x: "x \<in> s"
+ fix x
+ assume x: "x \<in> s"
from assms x show "((\<lambda>x. f x powr g x) \<longlongrightarrow> f x powr g x) (at x within s)"
proof (cases "f x = 0")
case True
@@ -2735,18 +2800,20 @@
proof -
have "((\<lambda>x. exp (s * ln (f x))) \<longlongrightarrow> (0::real)) F" (is "?X")
by (auto intro!: filterlim_compose[OF exp_at_bot] filterlim_compose[OF ln_at_top]
- filterlim_tendsto_neg_mult_at_bot assms)
+ filterlim_tendsto_neg_mult_at_bot assms)
also have "?X \<longleftrightarrow> ((\<lambda>x. f x powr s) \<longlongrightarrow> (0::real)) F"
using f filterlim_at_top_dense[of f F]
by (intro filterlim_cong[OF refl refl]) (auto simp: neq_iff powr_def elim: eventually_mono)
finally show ?thesis .
qed
-lemma tendsto_exp_limit_at_right:
- fixes x :: real
- shows "((\<lambda>y. (1 + x * y) powr (1 / y)) \<longlongrightarrow> exp x) (at_right 0)"
-proof cases
- assume "x \<noteq> 0"
+lemma tendsto_exp_limit_at_right: "((\<lambda>y. (1 + x * y) powr (1 / y)) \<longlongrightarrow> exp x) (at_right 0)"
+ for x :: real
+proof (cases "x = 0")
+ case True
+ then show ?thesis by simp
+next
+ case False
have "((\<lambda>y. ln (1 + x * y)::real) has_real_derivative 1 * x) (at 0)"
by (auto intro!: derivative_eq_intros)
then have "((\<lambda>y. ln (1 + x * y) / y) \<longlongrightarrow> x) (at 0)"
@@ -2757,32 +2824,32 @@
proof (rule filterlim_mono_eventually)
show "eventually (\<lambda>xa. exp (ln (1 + x * xa) / xa) = (1 + x * xa) powr (1 / xa)) (at_right 0)"
unfolding eventually_at_right[OF zero_less_one]
- using \<open>x \<noteq> 0\<close>
- apply (intro exI[of _ "1 / \<bar>x\<bar>"])
+ using False
+ apply (intro exI[of _ "1 / \<bar>x\<bar>"])
apply (auto simp: field_simps powr_def abs_if)
- by (metis add_less_same_cancel1 mult_less_0_iff not_less_iff_gr_or_eq zero_less_one)
+ apply (metis add_less_same_cancel1 mult_less_0_iff not_less_iff_gr_or_eq zero_less_one)
+ done
qed (simp_all add: at_eq_sup_left_right)
-qed simp
-
-lemma tendsto_exp_limit_at_top:
- fixes x :: real
- shows "((\<lambda>y. (1 + x / y) powr y) \<longlongrightarrow> exp x) at_top"
+qed
+
+lemma tendsto_exp_limit_at_top: "((\<lambda>y. (1 + x / y) powr y) \<longlongrightarrow> exp x) at_top"
+ for x :: real
apply (subst filterlim_at_top_to_right)
apply (simp add: inverse_eq_divide)
apply (rule tendsto_exp_limit_at_right)
done
-lemma tendsto_exp_limit_sequentially:
- fixes x :: real
- shows "(\<lambda>n. (1 + x / n) ^ n) \<longlonglongrightarrow> exp x"
+lemma tendsto_exp_limit_sequentially: "(\<lambda>n. (1 + x / n) ^ n) \<longlonglongrightarrow> exp x"
+ for x :: real
proof (rule filterlim_mono_eventually)
from reals_Archimedean2 [of "\<bar>x\<bar>"] obtain n :: nat where *: "real n > \<bar>x\<bar>" ..
- hence "eventually (\<lambda>n :: nat. 0 < 1 + x / real n) at_top"
+ then have "eventually (\<lambda>n :: nat. 0 < 1 + x / real n) at_top"
apply (intro eventually_sequentiallyI [of n])
- apply (case_tac "x \<ge> 0")
- apply (rule add_pos_nonneg, auto intro: divide_nonneg_nonneg)
- apply (subgoal_tac "x / real xa > -1")
- apply (auto simp add: field_simps)
+ apply (cases "x \<ge> 0")
+ apply (rule add_pos_nonneg)
+ apply (auto intro: divide_nonneg_nonneg)
+ apply (subgoal_tac "x / real xa > - 1")
+ apply (auto simp add: field_simps)
done
then show "eventually (\<lambda>n. (1 + x / n) powr n = (1 + x / n) ^ n) at_top"
by (rule eventually_mono) (erule powr_realpow)
@@ -2790,13 +2857,14 @@
by (rule filterlim_compose [OF tendsto_exp_limit_at_top filterlim_real_sequentially])
qed auto
+
subsection \<open>Sine and Cosine\<close>
-definition sin_coeff :: "nat \<Rightarrow> real" where
- "sin_coeff = (\<lambda>n. if even n then 0 else (- 1) ^ ((n - Suc 0) div 2) / (fact n))"
-
-definition cos_coeff :: "nat \<Rightarrow> real" where
- "cos_coeff = (\<lambda>n. if even n then ((- 1) ^ (n div 2)) / (fact n) else 0)"
+definition sin_coeff :: "nat \<Rightarrow> real"
+ where "sin_coeff = (\<lambda>n. if even n then 0 else (- 1) ^ ((n - Suc 0) div 2) / (fact n))"
+
+definition cos_coeff :: "nat \<Rightarrow> real"
+ where "cos_coeff = (\<lambda>n. if even n then ((- 1) ^ (n div 2)) / (fact n) else 0)"
definition sin :: "'a \<Rightarrow> 'a::{real_normed_algebra_1,banach}"
where "sin = (\<lambda>x. \<Sum>n. sin_coeff n *\<^sub>R x^n)"
@@ -2818,41 +2886,37 @@
unfolding cos_coeff_def sin_coeff_def
by (simp del: mult_Suc) (auto elim: oddE)
-lemma summable_norm_sin:
- fixes x :: "'a::{real_normed_algebra_1,banach}"
- shows "summable (\<lambda>n. norm (sin_coeff n *\<^sub>R x^n))"
+lemma summable_norm_sin: "summable (\<lambda>n. norm (sin_coeff n *\<^sub>R x^n))"
+ for x :: "'a::{real_normed_algebra_1,banach}"
unfolding sin_coeff_def
apply (rule summable_comparison_test [OF _ summable_norm_exp [where x=x]])
apply (auto simp: divide_inverse abs_mult power_abs [symmetric] zero_le_mult_iff)
done
-lemma summable_norm_cos:
- fixes x :: "'a::{real_normed_algebra_1,banach}"
- shows "summable (\<lambda>n. norm (cos_coeff n *\<^sub>R x^n))"
+lemma summable_norm_cos: "summable (\<lambda>n. norm (cos_coeff n *\<^sub>R x^n))"
+ for x :: "'a::{real_normed_algebra_1,banach}"
unfolding cos_coeff_def
apply (rule summable_comparison_test [OF _ summable_norm_exp [where x=x]])
apply (auto simp: divide_inverse abs_mult power_abs [symmetric] zero_le_mult_iff)
done
-lemma sin_converges: "(\<lambda>n. sin_coeff n *\<^sub>R x^n) sums sin(x)"
-unfolding sin_def
+lemma sin_converges: "(\<lambda>n. sin_coeff n *\<^sub>R x^n) sums sin x"
+ unfolding sin_def
by (metis (full_types) summable_norm_cancel summable_norm_sin summable_sums)
-lemma cos_converges: "(\<lambda>n. cos_coeff n *\<^sub>R x^n) sums cos(x)"
-unfolding cos_def
+lemma cos_converges: "(\<lambda>n. cos_coeff n *\<^sub>R x^n) sums cos x"
+ unfolding cos_def
by (metis (full_types) summable_norm_cancel summable_norm_cos summable_sums)
-lemma sin_of_real:
- fixes x::real
- shows "sin (of_real x) = of_real (sin x)"
+lemma sin_of_real: "sin (of_real x) = of_real (sin x)"
+ for x :: real
proof -
have "(\<lambda>n. of_real (sin_coeff n *\<^sub>R x^n)) = (\<lambda>n. sin_coeff n *\<^sub>R (of_real x)^n)"
proof
- fix n
- show "of_real (sin_coeff n *\<^sub>R x^n) = sin_coeff n *\<^sub>R of_real x^n"
+ show "of_real (sin_coeff n *\<^sub>R x^n) = sin_coeff n *\<^sub>R of_real x^n" for n
by (simp add: scaleR_conv_of_real)
qed
- also have "... sums (sin (of_real x))"
+ also have "\<dots> sums (sin (of_real x))"
by (rule sin_converges)
finally have "(\<lambda>n. of_real (sin_coeff n *\<^sub>R x^n)) sums (sin (of_real x))" .
then show ?thesis
@@ -2863,17 +2927,15 @@
corollary sin_in_Reals [simp]: "z \<in> \<real> \<Longrightarrow> sin z \<in> \<real>"
by (metis Reals_cases Reals_of_real sin_of_real)
-lemma cos_of_real:
- fixes x::real
- shows "cos (of_real x) = of_real (cos x)"
+lemma cos_of_real: "cos (of_real x) = of_real (cos x)"
+ for x :: real
proof -
have "(\<lambda>n. of_real (cos_coeff n *\<^sub>R x^n)) = (\<lambda>n. cos_coeff n *\<^sub>R (of_real x)^n)"
proof
- fix n
- show "of_real (cos_coeff n *\<^sub>R x^n) = cos_coeff n *\<^sub>R of_real x^n"
+ show "of_real (cos_coeff n *\<^sub>R x^n) = cos_coeff n *\<^sub>R of_real x^n" for n
by (simp add: scaleR_conv_of_real)
qed
- also have "... sums (cos (of_real x))"
+ also have "\<dots> sums (cos (of_real x))"
by (rule cos_converges)
finally have "(\<lambda>n. of_real (cos_coeff n *\<^sub>R x^n)) sums (cos (of_real x))" .
then show ?thesis
@@ -2890,30 +2952,28 @@
lemma diffs_cos_coeff: "diffs cos_coeff = (\<lambda>n. - sin_coeff n)"
by (simp add: diffs_def cos_coeff_Suc del: of_nat_Suc)
-text\<open>Now at last we can get the derivatives of exp, sin and cos\<close>
-
-lemma DERIV_sin [simp]:
- fixes x :: "'a::{real_normed_field,banach}"
- shows "DERIV sin x :> cos(x)"
+text \<open>Now at last we can get the derivatives of exp, sin and cos.\<close>
+
+lemma DERIV_sin [simp]: "DERIV sin x :> cos x"
+ for x :: "'a::{real_normed_field,banach}"
unfolding sin_def cos_def scaleR_conv_of_real
apply (rule DERIV_cong)
- apply (rule termdiffs [where K="of_real (norm x) + 1 :: 'a"])
- apply (simp_all add: norm_less_p1 diffs_of_real diffs_sin_coeff diffs_cos_coeff
+ apply (rule termdiffs [where K="of_real (norm x) + 1 :: 'a"])
+ apply (simp_all add: norm_less_p1 diffs_of_real diffs_sin_coeff diffs_cos_coeff
summable_minus_iff scaleR_conv_of_real [symmetric]
summable_norm_sin [THEN summable_norm_cancel]
summable_norm_cos [THEN summable_norm_cancel])
done
declare DERIV_sin[THEN DERIV_chain2, derivative_intros]
- DERIV_sin[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros]
-
-lemma DERIV_cos [simp]:
- fixes x :: "'a::{real_normed_field,banach}"
- shows "DERIV cos x :> -sin(x)"
+ and DERIV_sin[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros]
+
+lemma DERIV_cos [simp]: "DERIV cos x :> - sin x"
+ for x :: "'a::{real_normed_field,banach}"
unfolding sin_def cos_def scaleR_conv_of_real
apply (rule DERIV_cong)
- apply (rule termdiffs [where K="of_real (norm x) + 1 :: 'a"])
- apply (simp_all add: norm_less_p1 diffs_of_real diffs_minus suminf_minus
+ apply (rule termdiffs [where K="of_real (norm x) + 1 :: 'a"])
+ apply (simp_all add: norm_less_p1 diffs_of_real diffs_minus suminf_minus
diffs_sin_coeff diffs_cos_coeff
summable_minus_iff scaleR_conv_of_real [symmetric]
summable_norm_sin [THEN summable_norm_cancel]
@@ -2921,151 +2981,147 @@
done
declare DERIV_cos[THEN DERIV_chain2, derivative_intros]
- DERIV_cos[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros]
-
-lemma isCont_sin:
- fixes x :: "'a::{real_normed_field,banach}"
- shows "isCont sin x"
+ and DERIV_cos[THEN DERIV_chain2, unfolded has_field_derivative_def, derivative_intros]
+
+lemma isCont_sin: "isCont sin x"
+ for x :: "'a::{real_normed_field,banach}"
by (rule DERIV_sin [THEN DERIV_isCont])
-lemma isCont_cos:
- fixes x :: "'a::{real_normed_field,banach}"
- shows "isCont cos x"
+lemma isCont_cos: "isCont cos x"
+ for x :: "'a::{real_normed_field,banach}"
by (rule DERIV_cos [THEN DERIV_isCont])
-lemma isCont_sin' [simp]:
- fixes f:: "_ \<Rightarrow> 'a::{real_normed_field,banach}"
- shows "isCont f a \<Longrightarrow> isCont (\<lambda>x. sin (f x)) a"
+lemma isCont_sin' [simp]: "isCont f a \<Longrightarrow> isCont (\<lambda>x. sin (f x)) a"
+ for f :: "_ \<Rightarrow> 'a::{real_normed_field,banach}"
by (rule isCont_o2 [OF _ isCont_sin])
-(*FIXME A CONTEXT FOR F WOULD BE BETTER*)
-
-lemma isCont_cos' [simp]:
- fixes f:: "_ \<Rightarrow> 'a::{real_normed_field,banach}"
- shows "isCont f a \<Longrightarrow> isCont (\<lambda>x. cos (f x)) a"
+(* FIXME a context for f would be better *)
+
+lemma isCont_cos' [simp]: "isCont f a \<Longrightarrow> isCont (\<lambda>x. cos (f x)) a"
+ for f :: "_ \<Rightarrow> 'a::{real_normed_field,banach}"
by (rule isCont_o2 [OF _ isCont_cos])
-lemma tendsto_sin [tendsto_intros]:
- fixes f:: "_ \<Rightarrow> 'a::{real_normed_field,banach}"
- shows "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. sin (f x)) \<longlongrightarrow> sin a) F"
+lemma tendsto_sin [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. sin (f x)) \<longlongrightarrow> sin a) F"
+ for f :: "_ \<Rightarrow> 'a::{real_normed_field,banach}"
by (rule isCont_tendsto_compose [OF isCont_sin])
-lemma tendsto_cos [tendsto_intros]:
- fixes f:: "_ \<Rightarrow> 'a::{real_normed_field,banach}"
- shows "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. cos (f x)) \<longlongrightarrow> cos a) F"
+lemma tendsto_cos [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> ((\<lambda>x. cos (f x)) \<longlongrightarrow> cos a) F"
+ for f :: "_ \<Rightarrow> 'a::{real_normed_field,banach}"
by (rule isCont_tendsto_compose [OF isCont_cos])
-lemma continuous_sin [continuous_intros]:
- fixes f:: "_ \<Rightarrow> 'a::{real_normed_field,banach}"
- shows "continuous F f \<Longrightarrow> continuous F (\<lambda>x. sin (f x))"
+lemma continuous_sin [continuous_intros]: "continuous F f \<Longrightarrow> continuous F (\<lambda>x. sin (f x))"
+ for f :: "_ \<Rightarrow> 'a::{real_normed_field,banach}"
unfolding continuous_def by (rule tendsto_sin)
-lemma continuous_on_sin [continuous_intros]:
- fixes f:: "_ \<Rightarrow> 'a::{real_normed_field,banach}"
- shows "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. sin (f x))"
+lemma continuous_on_sin [continuous_intros]: "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. sin (f x))"
+ for f :: "_ \<Rightarrow> 'a::{real_normed_field,banach}"
unfolding continuous_on_def by (auto intro: tendsto_sin)
-lemma continuous_within_sin:
- fixes z :: "'a::{real_normed_field,banach}"
- shows "continuous (at z within s) sin"
+lemma continuous_within_sin: "continuous (at z within s) sin"
+ for z :: "'a::{real_normed_field,banach}"
by (simp add: continuous_within tendsto_sin)
-lemma continuous_cos [continuous_intros]:
- fixes f:: "_ \<Rightarrow> 'a::{real_normed_field,banach}"
- shows "continuous F f \<Longrightarrow> continuous F (\<lambda>x. cos (f x))"
+lemma continuous_cos [continuous_intros]: "continuous F f \<Longrightarrow> continuous F (\<lambda>x. cos (f x))"
+ for f :: "_ \<Rightarrow> 'a::{real_normed_field,banach}"
unfolding continuous_def by (rule tendsto_cos)
-lemma continuous_on_cos [continuous_intros]:
- fixes f:: "_ \<Rightarrow> 'a::{real_normed_field,banach}"
- shows "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. cos (f x))"
+lemma continuous_on_cos [continuous_intros]: "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. cos (f x))"
+ for f :: "_ \<Rightarrow> 'a::{real_normed_field,banach}"
unfolding continuous_on_def by (auto intro: tendsto_cos)
-lemma continuous_within_cos:
- fixes z :: "'a::{real_normed_field,banach}"
- shows "continuous (at z within s) cos"
+lemma continuous_within_cos: "continuous (at z within s) cos"
+ for z :: "'a::{real_normed_field,banach}"
by (simp add: continuous_within tendsto_cos)
+
subsection \<open>Properties of Sine and Cosine\<close>
lemma sin_zero [simp]: "sin 0 = 0"
- unfolding sin_def sin_coeff_def by (simp add: scaleR_conv_of_real powser_zero)
+ by (simp add: sin_def sin_coeff_def scaleR_conv_of_real)
lemma cos_zero [simp]: "cos 0 = 1"
- unfolding cos_def cos_coeff_def by (simp add: scaleR_conv_of_real powser_zero)
-
-lemma DERIV_fun_sin:
- "DERIV g x :> m \<Longrightarrow> DERIV (\<lambda>x. sin(g x)) x :> cos(g x) * m"
+ by (simp add: cos_def cos_coeff_def scaleR_conv_of_real)
+
+lemma DERIV_fun_sin: "DERIV g x :> m \<Longrightarrow> DERIV (\<lambda>x. sin (g x)) x :> cos (g x) * m"
by (auto intro!: derivative_intros)
-lemma DERIV_fun_cos:
- "DERIV g x :> m \<Longrightarrow> DERIV (\<lambda>x. cos(g x)) x :> -sin(g x) * m"
+lemma DERIV_fun_cos: "DERIV g x :> m \<Longrightarrow> DERIV (\<lambda>x. cos(g x)) x :> - sin (g x) * m"
by (auto intro!: derivative_eq_intros)
+
subsection \<open>Deriving the Addition Formulas\<close>
-text\<open>The the product of two cosine series\<close>
+text \<open>The product of two cosine series.\<close>
lemma cos_x_cos_y:
fixes x :: "'a::{real_normed_field,banach}"
- shows "(\<lambda>p. \<Sum>n\<le>p.
- if even p \<and> even n
- then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0)
- sums (cos x * cos y)"
+ shows
+ "(\<lambda>p. \<Sum>n\<le>p.
+ if even p \<and> even n
+ then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0)
+ sums (cos x * cos y)"
proof -
- { fix n p::nat
- assume "n\<le>p"
- then have *: "even n \<Longrightarrow> even p \<Longrightarrow> (-1) ^ (n div 2) * (-1) ^ ((p - n) div 2) = (-1 :: real) ^ (p div 2)"
+ have "(cos_coeff n * cos_coeff (p - n)) *\<^sub>R (x^n * y^(p - n)) =
+ (if even p \<and> even n then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p - n)
+ else 0)"
+ if "n \<le> p" for n p :: nat
+ proof -
+ from that have *: "even n \<Longrightarrow> even p \<Longrightarrow>
+ (-1) ^ (n div 2) * (-1) ^ ((p - n) div 2) = (-1 :: real) ^ (p div 2)"
by (metis div_add power_add le_add_diff_inverse odd_add)
- have "(cos_coeff n * cos_coeff (p - n)) *\<^sub>R (x^n * y^(p-n)) =
- (if even p \<and> even n then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0)"
- using \<open>n\<le>p\<close>
- by (auto simp: * algebra_simps cos_coeff_def binomial_fact)
- }
+ with that show ?thesis
+ by (auto simp: algebra_simps cos_coeff_def binomial_fact)
+ qed
then have "(\<lambda>p. \<Sum>n\<le>p. if even p \<and> even n
then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0) =
(\<lambda>p. \<Sum>n\<le>p. (cos_coeff n * cos_coeff (p - n)) *\<^sub>R (x^n * y^(p-n)))"
by simp
- also have "... = (\<lambda>p. \<Sum>n\<le>p. (cos_coeff n *\<^sub>R x^n) * (cos_coeff (p - n) *\<^sub>R y^(p-n)))"
+ also have "\<dots> = (\<lambda>p. \<Sum>n\<le>p. (cos_coeff n *\<^sub>R x^n) * (cos_coeff (p - n) *\<^sub>R y^(p-n)))"
by (simp add: algebra_simps)
- also have "... sums (cos x * cos y)"
+ also have "\<dots> sums (cos x * cos y)"
using summable_norm_cos
by (auto simp: cos_def scaleR_conv_of_real intro!: Cauchy_product_sums)
finally show ?thesis .
qed
-text\<open>The product of two sine series\<close>
+text \<open>The product of two sine series.\<close>
lemma sin_x_sin_y:
fixes x :: "'a::{real_normed_field,banach}"
- shows "(\<lambda>p. \<Sum>n\<le>p.
- if even p \<and> odd n
- then - ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0)
- sums (sin x * sin y)"
+ shows
+ "(\<lambda>p. \<Sum>n\<le>p.
+ if even p \<and> odd n
+ then - ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n)
+ else 0)
+ sums (sin x * sin y)"
proof -
- { fix n p::nat
- assume "n\<le>p"
- { assume np: "odd n" "even p"
- with \<open>n\<le>p\<close> have "n - Suc 0 + (p - Suc n) = p - Suc (Suc 0)" "Suc (Suc 0) \<le> p"
+ have "(sin_coeff n * sin_coeff (p - n)) *\<^sub>R (x^n * y^(p-n)) =
+ (if even p \<and> odd n
+ then -((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n)
+ else 0)"
+ if "n \<le> p" for n p :: nat
+ proof -
+ have "(-1) ^ ((n - Suc 0) div 2) * (-1) ^ ((p - Suc n) div 2) = - ((-1 :: real) ^ (p div 2))"
+ if np: "odd n" "even p"
+ proof -
+ from \<open>n \<le> p\<close> np have *: "n - Suc 0 + (p - Suc n) = p - Suc (Suc 0)" "Suc (Suc 0) \<le> p"
by arith+
- moreover have "(p - Suc (Suc 0)) div 2 = p div 2 - Suc 0"
+ have "(p - Suc (Suc 0)) div 2 = p div 2 - Suc 0"
by simp
- ultimately have *: "(-1) ^ ((n - Suc 0) div 2) * (-1) ^ ((p - Suc n) div 2) = - ((-1 :: real) ^ (p div 2))"
- using np \<open>n\<le>p\<close>
+ with \<open>n \<le> p\<close> np * show ?thesis
apply (simp add: power_add [symmetric] div_add [symmetric] del: div_add)
- apply (metis (no_types) One_nat_def Suc_1 le_div_geq minus_minus mult.left_neutral mult_minus_left power.simps(2) zero_less_Suc)
+ apply (metis (no_types) One_nat_def Suc_1 le_div_geq minus_minus
+ mult.left_neutral mult_minus_left power.simps(2) zero_less_Suc)
done
- } then
- have "(sin_coeff n * sin_coeff (p - n)) *\<^sub>R (x^n * y^(p-n)) =
- (if even p \<and> odd n
- then -((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0)"
- using \<open>n\<le>p\<close>
- by (auto simp: algebra_simps sin_coeff_def binomial_fact)
- }
+ qed
+ then show ?thesis
+ using \<open>n\<le>p\<close> by (auto simp: algebra_simps sin_coeff_def binomial_fact)
+ qed
then have "(\<lambda>p. \<Sum>n\<le>p. if even p \<and> odd n
then - ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0) =
(\<lambda>p. \<Sum>n\<le>p. (sin_coeff n * sin_coeff (p - n)) *\<^sub>R (x^n * y^(p-n)))"
by simp
- also have "... = (\<lambda>p. \<Sum>n\<le>p. (sin_coeff n *\<^sub>R x^n) * (sin_coeff (p - n) *\<^sub>R y^(p-n)))"
+ also have "\<dots> = (\<lambda>p. \<Sum>n\<le>p. (sin_coeff n *\<^sub>R x^n) * (sin_coeff (p - n) *\<^sub>R y^(p-n)))"
by (simp add: algebra_simps)
- also have "... sums (sin x * sin y)"
+ also have "\<dots> sums (sin x * sin y)"
using summable_norm_sin
by (auto simp: sin_def scaleR_conv_of_real intro!: Cauchy_product_sums)
finally show ?thesis .
@@ -3074,36 +3130,38 @@
lemma sums_cos_x_plus_y:
fixes x :: "'a::{real_normed_field,banach}"
shows
- "(\<lambda>p. \<Sum>n\<le>p. if even p
- then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n)
- else 0)
- sums cos (x + y)"
+ "(\<lambda>p. \<Sum>n\<le>p.
+ if even p
+ then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n)
+ else 0)
+ sums cos (x + y)"
proof -
- { fix p::nat
- have "(\<Sum>n\<le>p. if even p
- then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n)
- else 0) =
- (if even p
- then \<Sum>n\<le>p. ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n)
- else 0)"
+ have
+ "(\<Sum>n\<le>p.
+ if even p then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n)
+ else 0) = cos_coeff p *\<^sub>R ((x + y) ^ p)"
+ for p :: nat
+ proof -
+ have
+ "(\<Sum>n\<le>p. if even p then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0) =
+ (if even p then \<Sum>n\<le>p. ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0)"
by simp
- also have "... = (if even p
- then of_real ((-1) ^ (p div 2) / (fact p)) * (\<Sum>n\<le>p. (p choose n) *\<^sub>R (x^n) * y^(p-n))
- else 0)"
+ also have "\<dots> =
+ (if even p
+ then of_real ((-1) ^ (p div 2) / (fact p)) * (\<Sum>n\<le>p. (p choose n) *\<^sub>R (x^n) * y^(p-n))
+ else 0)"
by (auto simp: setsum_right_distrib field_simps scaleR_conv_of_real nonzero_of_real_divide)
- also have "... = cos_coeff p *\<^sub>R ((x + y) ^ p)"
+ also have "\<dots> = cos_coeff p *\<^sub>R ((x + y) ^ p)"
by (simp add: cos_coeff_def binomial_ring [of x y] scaleR_conv_of_real atLeast0AtMost)
- finally have "(\<Sum>n\<le>p. if even p
- then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n)
- else 0) = cos_coeff p *\<^sub>R ((x + y) ^ p)" .
- }
- then have "(\<lambda>p. \<Sum>n\<le>p.
- if even p
- then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n)
- else 0)
- = (\<lambda>p. cos_coeff p *\<^sub>R ((x+y)^p))"
- by simp
- also have "... sums cos (x + y)"
+ finally show ?thesis .
+ qed
+ then have
+ "(\<lambda>p. \<Sum>n\<le>p.
+ if even p
+ then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n)
+ else 0) = (\<lambda>p. cos_coeff p *\<^sub>R ((x+y)^p))"
+ by simp
+ also have "\<dots> sums cos (x + y)"
by (rule cos_converges)
finally show ?thesis .
qed
@@ -3112,26 +3170,24 @@
fixes x :: "'a::{real_normed_field,banach}"
shows "cos (x + y) = cos x * cos y - sin x * sin y"
proof -
- { fix n p::nat
- assume "n\<le>p"
- then have "(if even p \<and> even n
- then ((- 1) ^ (p div 2) * int (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0) -
- (if even p \<and> odd n
- then - ((- 1) ^ (p div 2) * int (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0)
- = (if even p
- then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0)"
- by simp
- }
- then have "(\<lambda>p. \<Sum>n\<le>p. (if even p
- then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0))
- sums (cos x * cos y - sin x * sin y)"
+ have
+ "(if even p \<and> even n
+ then ((- 1) ^ (p div 2) * int (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0) -
+ (if even p \<and> odd n
+ then - ((- 1) ^ (p div 2) * int (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0) =
+ (if even p then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0)"
+ if "n \<le> p" for n p :: nat
+ by simp
+ then have
+ "(\<lambda>p. \<Sum>n\<le>p. (if even p then ((-1) ^ (p div 2) * (p choose n) / (fact p)) *\<^sub>R (x^n) * y^(p-n) else 0))
+ sums (cos x * cos y - sin x * sin y)"
using sums_diff [OF cos_x_cos_y [of x y] sin_x_sin_y [of x y]]
by (simp add: setsum_subtractf [symmetric])
then show ?thesis
by (blast intro: sums_cos_x_plus_y sums_unique2)
qed
-lemma sin_minus_converges: "(\<lambda>n. - (sin_coeff n *\<^sub>R (-x)^n)) sums sin(x)"
+lemma sin_minus_converges: "(\<lambda>n. - (sin_coeff n *\<^sub>R (-x)^n)) sums sin x"
proof -
have [simp]: "\<And>n. - (sin_coeff n *\<^sub>R (-x)^n) = (sin_coeff n *\<^sub>R x^n)"
by (auto simp: sin_coeff_def elim!: oddE)
@@ -3139,13 +3195,13 @@
by (simp add: sin_def summable_norm_sin [THEN summable_norm_cancel, THEN summable_sums])
qed
-lemma sin_minus [simp]:
- fixes x :: "'a::{real_normed_algebra_1,banach}"
- shows "sin (-x) = -sin(x)"
-using sin_minus_converges [of x]
-by (auto simp: sin_def summable_norm_sin [THEN summable_norm_cancel] suminf_minus sums_iff equation_minus_iff)
-
-lemma cos_minus_converges: "(\<lambda>n. (cos_coeff n *\<^sub>R (-x)^n)) sums cos(x)"
+lemma sin_minus [simp]: "sin (- x) = - sin x"
+ for x :: "'a::{real_normed_algebra_1,banach}"
+ using sin_minus_converges [of x]
+ by (auto simp: sin_def summable_norm_sin [THEN summable_norm_cancel]
+ suminf_minus sums_iff equation_minus_iff)
+
+lemma cos_minus_converges: "(\<lambda>n. (cos_coeff n *\<^sub>R (-x)^n)) sums cos x"
proof -
have [simp]: "\<And>n. (cos_coeff n *\<^sub>R (-x)^n) = (cos_coeff n *\<^sub>R x^n)"
by (auto simp: Transcendental.cos_coeff_def elim!: evenE)
@@ -3153,110 +3209,91 @@
by (simp add: cos_def summable_norm_cos [THEN summable_norm_cancel, THEN summable_sums])
qed
-lemma cos_minus [simp]:
- fixes x :: "'a::{real_normed_algebra_1,banach}"
- shows "cos (-x) = cos(x)"
-using cos_minus_converges [of x]
-by (simp add: cos_def summable_norm_cos [THEN summable_norm_cancel]
- suminf_minus sums_iff equation_minus_iff)
-
-lemma sin_cos_squared_add [simp]:
- fixes x :: "'a::{real_normed_field,banach}"
- shows "(sin x)\<^sup>2 + (cos x)\<^sup>2 = 1"
-using cos_add [of x "-x"]
-by (simp add: power2_eq_square algebra_simps)
-
-lemma sin_cos_squared_add2 [simp]:
- fixes x :: "'a::{real_normed_field,banach}"
- shows "(cos x)\<^sup>2 + (sin x)\<^sup>2 = 1"
+lemma cos_minus [simp]: "cos (-x) = cos x"
+ for x :: "'a::{real_normed_algebra_1,banach}"
+ using cos_minus_converges [of x]
+ by (simp add: cos_def summable_norm_cos [THEN summable_norm_cancel]
+ suminf_minus sums_iff equation_minus_iff)
+
+lemma sin_cos_squared_add [simp]: "(sin x)\<^sup>2 + (cos x)\<^sup>2 = 1"
+ for x :: "'a::{real_normed_field,banach}"
+ using cos_add [of x "-x"]
+ by (simp add: power2_eq_square algebra_simps)
+
+lemma sin_cos_squared_add2 [simp]: "(cos x)\<^sup>2 + (sin x)\<^sup>2 = 1"
+ for x :: "'a::{real_normed_field,banach}"
by (subst add.commute, rule sin_cos_squared_add)
-lemma sin_cos_squared_add3 [simp]:
- fixes x :: "'a::{real_normed_field,banach}"
- shows "cos x * cos x + sin x * sin x = 1"
+lemma sin_cos_squared_add3 [simp]: "cos x * cos x + sin x * sin x = 1"
+ for x :: "'a::{real_normed_field,banach}"
using sin_cos_squared_add2 [unfolded power2_eq_square] .
-lemma sin_squared_eq:
- fixes x :: "'a::{real_normed_field,banach}"
- shows "(sin x)\<^sup>2 = 1 - (cos x)\<^sup>2"
+lemma sin_squared_eq: "(sin x)\<^sup>2 = 1 - (cos x)\<^sup>2"
+ for x :: "'a::{real_normed_field,banach}"
unfolding eq_diff_eq by (rule sin_cos_squared_add)
-lemma cos_squared_eq:
- fixes x :: "'a::{real_normed_field,banach}"
- shows "(cos x)\<^sup>2 = 1 - (sin x)\<^sup>2"
+lemma cos_squared_eq: "(cos x)\<^sup>2 = 1 - (sin x)\<^sup>2"
+ for x :: "'a::{real_normed_field,banach}"
unfolding eq_diff_eq by (rule sin_cos_squared_add2)
-lemma abs_sin_le_one [simp]:
- fixes x :: real
- shows "\<bar>sin x\<bar> \<le> 1"
- by (rule power2_le_imp_le, simp_all add: sin_squared_eq)
-
-lemma sin_ge_minus_one [simp]:
- fixes x :: real
- shows "-1 \<le> sin x"
- using abs_sin_le_one [of x] unfolding abs_le_iff by simp
-
-lemma sin_le_one [simp]:
- fixes x :: real
- shows "sin x \<le> 1"
- using abs_sin_le_one [of x] unfolding abs_le_iff by simp
-
-lemma abs_cos_le_one [simp]:
- fixes x :: real
- shows "\<bar>cos x\<bar> \<le> 1"
- by (rule power2_le_imp_le, simp_all add: cos_squared_eq)
-
-lemma cos_ge_minus_one [simp]:
- fixes x :: real
- shows "-1 \<le> cos x"
- using abs_cos_le_one [of x] unfolding abs_le_iff by simp
-
-lemma cos_le_one [simp]:
- fixes x :: real
- shows "cos x \<le> 1"
- using abs_cos_le_one [of x] unfolding abs_le_iff by simp
-
-lemma cos_diff:
- fixes x :: "'a::{real_normed_field,banach}"
- shows "cos (x - y) = cos x * cos y + sin x * sin y"
+lemma abs_sin_le_one [simp]: "\<bar>sin x\<bar> \<le> 1"
+ for x :: real
+ by (rule power2_le_imp_le) (simp_all add: sin_squared_eq)
+
+lemma sin_ge_minus_one [simp]: "- 1 \<le> sin x"
+ for x :: real
+ using abs_sin_le_one [of x] by (simp add: abs_le_iff)
+
+lemma sin_le_one [simp]: "sin x \<le> 1"
+ for x :: real
+ using abs_sin_le_one [of x] by (simp add: abs_le_iff)
+
+lemma abs_cos_le_one [simp]: "\<bar>cos x\<bar> \<le> 1"
+ for x :: real
+ by (rule power2_le_imp_le) (simp_all add: cos_squared_eq)
+
+lemma cos_ge_minus_one [simp]: "- 1 \<le> cos x"
+ for x :: real
+ using abs_cos_le_one [of x] by (simp add: abs_le_iff)
+
+lemma cos_le_one [simp]: "cos x \<le> 1"
+ for x :: real
+ using abs_cos_le_one [of x] by (simp add: abs_le_iff)
+
+lemma cos_diff: "cos (x - y) = cos x * cos y + sin x * sin y"
+ for x :: "'a::{real_normed_field,banach}"
using cos_add [of x "- y"] by simp
-lemma cos_double:
- fixes x :: "'a::{real_normed_field,banach}"
- shows "cos(2*x) = (cos x)\<^sup>2 - (sin x)\<^sup>2"
- using cos_add [where x=x and y=x]
- by (simp add: power2_eq_square)
-
-lemma sin_cos_le1:
- fixes x::real shows "\<bar>sin x * sin y + cos x * cos y\<bar> \<le> 1"
- using cos_diff [of x y]
- by (metis abs_cos_le_one add.commute)
-
-lemma DERIV_fun_pow: "DERIV g x :> m ==>
- DERIV (\<lambda>x. (g x) ^ n) x :> real n * (g x) ^ (n - 1) * m"
+lemma cos_double: "cos(2*x) = (cos x)\<^sup>2 - (sin x)\<^sup>2"
+ for x :: "'a::{real_normed_field,banach}"
+ using cos_add [where x=x and y=x] by (simp add: power2_eq_square)
+
+lemma sin_cos_le1: "\<bar>sin x * sin y + cos x * cos y\<bar> \<le> 1"
+ for x :: real
+ using cos_diff [of x y] by (metis abs_cos_le_one add.commute)
+
+lemma DERIV_fun_pow: "DERIV g x :> m \<Longrightarrow> DERIV (\<lambda>x. (g x) ^ n) x :> real n * (g x) ^ (n - 1) * m"
by (auto intro!: derivative_eq_intros simp:)
-lemma DERIV_fun_exp:
- "DERIV g x :> m ==> DERIV (\<lambda>x. exp(g x)) x :> exp(g x) * m"
+lemma DERIV_fun_exp: "DERIV g x :> m \<Longrightarrow> DERIV (\<lambda>x. exp (g x)) x :> exp (g x) * m"
by (auto intro!: derivative_intros)
+
subsection \<open>The Constant Pi\<close>
definition pi :: real
- where "pi = 2 * (THE x. 0 \<le> (x::real) & x \<le> 2 & cos x = 0)"
-
-text\<open>Show that there's a least positive @{term x} with @{term "cos(x) = 0"};
+ where "pi = 2 * (THE x. 0 \<le> x \<and> x \<le> 2 \<and> cos x = 0)"
+
+text \<open>Show that there's a least positive @{term x} with @{term "cos x = 0"};
hence define pi.\<close>
-lemma sin_paired:
- fixes x :: real
- shows "(\<lambda>n. (- 1) ^ n / (fact (2 * n + 1)) * x ^ (2 * n + 1)) sums sin x"
+lemma sin_paired: "(\<lambda>n. (- 1) ^ n / (fact (2 * n + 1)) * x ^ (2 * n + 1)) sums sin x"
+ for x :: real
proof -
have "(\<lambda>n. \<Sum>k = n*2..<n * 2 + 2. sin_coeff k * x ^ k) sums sin x"
- apply (rule sums_group)
- using sin_converges [of x, unfolded scaleR_conv_of_real]
- by auto
- thus ?thesis unfolding One_nat_def sin_coeff_def by (simp add: ac_simps)
+ by (rule sums_group) (use sin_converges [of x, unfolded scaleR_conv_of_real] in auto)
+ then show ?thesis
+ by (simp add: sin_coeff_def ac_simps)
qed
lemma sin_gt_zero_02:
@@ -3272,52 +3309,51 @@
let ?k3 = "real (Suc (Suc (Suc (4 * n))))"
have "x * x < ?k2 * ?k3"
using assms by (intro mult_strict_mono', simp_all)
- hence "x * x * x * x ^ (n * 4) < ?k2 * ?k3 * x * x ^ (n * 4)"
+ then have "x * x * x * x ^ (n * 4) < ?k2 * ?k3 * x * x ^ (n * 4)"
by (intro mult_strict_right_mono zero_less_power \<open>0 < x\<close>)
- thus "0 < ?f n"
+ then show "0 < ?f n"
by (simp add: divide_simps mult_ac del: mult_Suc)
qed
have sums: "?f sums sin x"
- by (rule sin_paired [THEN sums_group], simp)
+ by (rule sin_paired [THEN sums_group]) simp
show "0 < sin x"
unfolding sums_unique [OF sums]
using sums_summable [OF sums] pos
by (rule suminf_pos)
qed
-lemma cos_double_less_one:
- fixes x :: real
- shows "0 < x \<Longrightarrow> x < 2 \<Longrightarrow> cos (2 * x) < 1"
+lemma cos_double_less_one: "0 < x \<Longrightarrow> x < 2 \<Longrightarrow> cos (2 * x) < 1"
+ for x :: real
using sin_gt_zero_02 [where x = x] by (auto simp: cos_squared_eq cos_double)
-lemma cos_paired:
- fixes x :: real
- shows "(\<lambda>n. (- 1) ^ n / (fact (2 * n)) * x ^ (2 * n)) sums cos x"
+lemma cos_paired: "(\<lambda>n. (- 1) ^ n / (fact (2 * n)) * x ^ (2 * n)) sums cos x"
+ for x :: real
proof -
have "(\<lambda>n. \<Sum>k = n * 2..<n * 2 + 2. cos_coeff k * x ^ k) sums cos x"
- apply (rule sums_group)
- using cos_converges [of x, unfolded scaleR_conv_of_real]
- by auto
- thus ?thesis unfolding cos_coeff_def by (simp add: ac_simps)
+ by (rule sums_group) (use cos_converges [of x, unfolded scaleR_conv_of_real] in auto)
+ then show ?thesis
+ by (simp add: cos_coeff_def ac_simps)
qed
lemmas realpow_num_eq_if = power_eq_if
lemma sumr_pos_lt_pair:
fixes f :: "nat \<Rightarrow> real"
- shows "\<lbrakk>summable f;
- \<And>d. 0 < f (k + (Suc(Suc 0) * d)) + f (k + ((Suc(Suc 0) * d) + 1))\<rbrakk>
- \<Longrightarrow> setsum f {..<k} < suminf f"
-apply (simp only: One_nat_def)
-apply (subst suminf_split_initial_segment [where k=k], assumption, simp)
-apply (drule_tac k=k in summable_ignore_initial_segment)
-apply (drule_tac k="Suc (Suc 0)" in sums_group [OF summable_sums], simp)
-apply simp
-apply (metis (no_types, lifting) add.commute suminf_pos summable_def sums_unique)
-done
-
-lemma cos_two_less_zero [simp]:
- "cos 2 < (0::real)"
+ shows "summable f \<Longrightarrow>
+ (\<And>d. 0 < f (k + (Suc(Suc 0) * d)) + f (k + ((Suc (Suc 0) * d) + 1))) \<Longrightarrow>
+ setsum f {..<k} < suminf f"
+ apply (simp only: One_nat_def)
+ apply (subst suminf_split_initial_segment [where k=k])
+ apply assumption
+ apply simp
+ apply (drule_tac k=k in summable_ignore_initial_segment)
+ apply (drule_tac k="Suc (Suc 0)" in sums_group [OF summable_sums])
+ apply simp
+ apply simp
+ apply (metis (no_types, lifting) add.commute suminf_pos summable_def sums_unique)
+ done
+
+lemma cos_two_less_zero [simp]: "cos 2 < (0::real)"
proof -
note fact_Suc [simp del]
from sums_minus [OF cos_paired]
@@ -3327,13 +3363,14 @@
by (rule sums_summable)
have "0 < (\<Sum>n<Suc (Suc (Suc 0)). - ((- 1::real) ^ n * 2 ^ (2 * n) / (fact (2 * n))))"
by (simp add: fact_num_eq_if realpow_num_eq_if)
- moreover have "(\<Sum>n<Suc (Suc (Suc 0)). - ((- 1::real) ^ n * 2 ^ (2 * n) / (fact (2 * n))))
- < (\<Sum>n. - ((- 1) ^ n * 2 ^ (2 * n) / (fact (2 * n))))"
+ moreover have "(\<Sum>n<Suc (Suc (Suc 0)). - ((- 1::real) ^ n * 2 ^ (2 * n) / (fact (2 * n)))) <
+ (\<Sum>n. - ((- 1) ^ n * 2 ^ (2 * n) / (fact (2 * n))))"
proof -
- { fix d
+ {
+ fix d
let ?six4d = "Suc (Suc (Suc (Suc (Suc (Suc (4 * d))))))"
have "(4::real) * (fact (?six4d)) < (Suc (Suc (?six4d)) * fact (Suc (?six4d)))"
- unfolding of_nat_mult by (rule mult_strict_mono) (simp_all add: fact_less_mono)
+ unfolding of_nat_mult by (rule mult_strict_mono) (simp_all add: fact_less_mono)
then have "(4::real) * (fact (?six4d)) < (fact (Suc (Suc (?six4d))))"
by (simp only: fact_Suc [of "Suc (?six4d)"] of_nat_mult of_nat_fact)
then have "(4::real) * inverse (fact (Suc (Suc (?six4d)))) < inverse (fact (?six4d))"
@@ -3353,40 +3390,40 @@
lemmas cos_two_neq_zero [simp] = cos_two_less_zero [THEN less_imp_neq]
lemmas cos_two_le_zero [simp] = cos_two_less_zero [THEN order_less_imp_le]
-lemma cos_is_zero: "EX! x::real. 0 \<le> x & x \<le> 2 \<and> cos x = 0"
+lemma cos_is_zero: "\<exists>!x::real. 0 \<le> x \<and> x \<le> 2 \<and> cos x = 0"
proof (rule ex_ex1I)
- show "\<exists>x::real. 0 \<le> x & x \<le> 2 & cos x = 0"
- by (rule IVT2, simp_all)
+ show "\<exists>x::real. 0 \<le> x \<and> x \<le> 2 \<and> cos x = 0"
+ by (rule IVT2) simp_all
next
- fix x::real and y::real
+ fix x y :: real
assume x: "0 \<le> x \<and> x \<le> 2 \<and> cos x = 0"
assume y: "0 \<le> y \<and> y \<le> 2 \<and> cos y = 0"
have [simp]: "\<forall>x::real. cos differentiable (at x)"
unfolding real_differentiable_def by (auto intro: DERIV_cos)
- from x y show "x = y"
- apply (cut_tac less_linear [of x y], auto)
- apply (drule_tac f = cos in Rolle)
- apply (drule_tac [5] f = cos in Rolle)
- apply (auto dest!: DERIV_cos [THEN DERIV_unique])
- apply (metis order_less_le_trans less_le sin_gt_zero_02)
+ from x y less_linear [of x y] show "x = y"
+ apply auto
+ apply (drule_tac f = cos in Rolle)
+ apply (drule_tac [5] f = cos in Rolle)
+ apply (auto dest!: DERIV_cos [THEN DERIV_unique])
+ apply (metis order_less_le_trans less_le sin_gt_zero_02)
apply (metis order_less_le_trans less_le sin_gt_zero_02)
done
qed
-lemma pi_half: "pi/2 = (THE x. 0 \<le> x & x \<le> 2 & cos x = 0)"
+lemma pi_half: "pi/2 = (THE x. 0 \<le> x \<and> x \<le> 2 \<and> cos x = 0)"
by (simp add: pi_def)
lemma cos_pi_half [simp]: "cos (pi / 2) = 0"
by (simp add: pi_half cos_is_zero [THEN theI'])
-lemma cos_of_real_pi_half [simp]:
- fixes x :: "'a :: {real_field,banach,real_normed_algebra_1}"
- shows "cos ((of_real pi / 2) :: 'a) = 0"
-by (metis cos_pi_half cos_of_real eq_numeral_simps(4) nonzero_of_real_divide of_real_0 of_real_numeral)
+lemma cos_of_real_pi_half [simp]: "cos ((of_real pi / 2) :: 'a) = 0"
+ if "SORT_CONSTRAINT('a::{real_field,banach,real_normed_algebra_1})"
+ by (metis cos_pi_half cos_of_real eq_numeral_simps(4)
+ nonzero_of_real_divide of_real_0 of_real_numeral)
lemma pi_half_gt_zero [simp]: "0 < pi / 2"
apply (rule order_le_neq_trans)
- apply (simp add: pi_half cos_is_zero [THEN theI'])
+ apply (simp add: pi_half cos_is_zero [THEN theI'])
apply (metis cos_pi_half cos_zero zero_neq_one)
done
@@ -3395,7 +3432,7 @@
lemma pi_half_less_two [simp]: "pi / 2 < 2"
apply (rule order_le_neq_trans)
- apply (simp add: pi_half cos_is_zero [THEN theI'])
+ apply (simp add: pi_half cos_is_zero [THEN theI'])
apply (metis cos_pi_half cos_two_neq_zero)
done
@@ -3425,45 +3462,36 @@
using sin_gt_zero_02 [OF pi_half_gt_zero pi_half_less_two]
by (simp add: power2_eq_1_iff)
-lemma sin_of_real_pi_half [simp]:
- fixes x :: "'a :: {real_field,banach,real_normed_algebra_1}"
- shows "sin ((of_real pi / 2) :: 'a) = 1"
+lemma sin_of_real_pi_half [simp]: "sin ((of_real pi / 2) :: 'a) = 1"
+ if "SORT_CONSTRAINT('a::{real_field,banach,real_normed_algebra_1})"
using sin_pi_half
-by (metis sin_pi_half eq_numeral_simps(4) nonzero_of_real_divide of_real_1 of_real_numeral sin_of_real)
-
-lemma sin_cos_eq:
- fixes x :: "'a::{real_normed_field,banach}"
- shows "sin x = cos (of_real pi / 2 - x)"
+ by (metis sin_pi_half eq_numeral_simps(4) nonzero_of_real_divide of_real_1 of_real_numeral sin_of_real)
+
+lemma sin_cos_eq: "sin x = cos (of_real pi / 2 - x)"
+ for x :: "'a::{real_normed_field,banach}"
by (simp add: cos_diff)
-lemma minus_sin_cos_eq:
- fixes x :: "'a::{real_normed_field,banach}"
- shows "-sin x = cos (x + of_real pi / 2)"
+lemma minus_sin_cos_eq: "- sin x = cos (x + of_real pi / 2)"
+ for x :: "'a::{real_normed_field,banach}"
by (simp add: cos_add nonzero_of_real_divide)
-lemma cos_sin_eq:
- fixes x :: "'a::{real_normed_field,banach}"
- shows "cos x = sin (of_real pi / 2 - x)"
- using sin_cos_eq [of "of_real pi / 2 - x"]
- by simp
-
-lemma sin_add:
- fixes x :: "'a::{real_normed_field,banach}"
- shows "sin (x + y) = sin x * cos y + cos x * sin y"
+lemma cos_sin_eq: "cos x = sin (of_real pi / 2 - x)"
+ for x :: "'a::{real_normed_field,banach}"
+ using sin_cos_eq [of "of_real pi / 2 - x"] by simp
+
+lemma sin_add: "sin (x + y) = sin x * cos y + cos x * sin y"
+ for x :: "'a::{real_normed_field,banach}"
using cos_add [of "of_real pi / 2 - x" "-y"]
by (simp add: cos_sin_eq) (simp add: sin_cos_eq)
-lemma sin_diff:
- fixes x :: "'a::{real_normed_field,banach}"
- shows "sin (x - y) = sin x * cos y - cos x * sin y"
+lemma sin_diff: "sin (x - y) = sin x * cos y - cos x * sin y"
+ for x :: "'a::{real_normed_field,banach}"
using sin_add [of x "- y"] by simp
-lemma sin_double:
- fixes x :: "'a::{real_normed_field,banach}"
- shows "sin(2 * x) = 2 * sin x * cos x"
+lemma sin_double: "sin(2 * x) = 2 * sin x * cos x"
+ for x :: "'a::{real_normed_field,banach}"
using sin_add [where x=x and y=x] by simp
-
lemma cos_of_real_pi [simp]: "cos (of_real pi) = -1"
using cos_add [where x = "pi/2" and y = "pi/2"]
by (simp add: cos_of_real)
@@ -3490,10 +3518,10 @@
lemma cos_periodic_pi2 [simp]: "cos (pi + x) = - cos x"
by (simp add: cos_add)
-lemma sin_periodic [simp]: "sin (x + 2*pi) = sin x"
+lemma sin_periodic [simp]: "sin (x + 2 * pi) = sin x"
by (simp add: sin_add sin_double cos_double)
-lemma cos_periodic [simp]: "cos (x + 2*pi) = cos x"
+lemma cos_periodic [simp]: "cos (x + 2 * pi) = cos x"
by (simp add: cos_add sin_double cos_double)
lemma cos_npi [simp]: "cos (real n * pi) = (- 1) ^ n"
@@ -3502,204 +3530,197 @@
lemma cos_npi2 [simp]: "cos (pi * real n) = (- 1) ^ n"
by (metis cos_npi mult.commute)
-lemma sin_npi [simp]: "sin (real (n::nat) * pi) = 0"
- by (induct n) (auto simp: of_nat_Suc distrib_right)
-
-lemma sin_npi2 [simp]: "sin (pi * real (n::nat)) = 0"
+lemma sin_npi [simp]: "sin (real n * pi) = 0"
+ for n :: nat
+ by (induct n) (auto simp: distrib_right)
+
+lemma sin_npi2 [simp]: "sin (pi * real n) = 0"
+ for n :: nat
by (simp add: mult.commute [of pi])
-lemma cos_two_pi [simp]: "cos (2*pi) = 1"
+lemma cos_two_pi [simp]: "cos (2 * pi) = 1"
by (simp add: cos_double)
-lemma sin_two_pi [simp]: "sin (2*pi) = 0"
+lemma sin_two_pi [simp]: "sin (2 * pi) = 0"
by (simp add: sin_double)
-
-lemma sin_times_sin:
- fixes w :: "'a::{real_normed_field,banach}"
- shows "sin(w) * sin(z) = (cos(w - z) - cos(w + z)) / 2"
+lemma sin_times_sin: "sin w * sin z = (cos (w - z) - cos (w + z)) / 2"
+ for w :: "'a::{real_normed_field,banach}"
by (simp add: cos_diff cos_add)
-lemma sin_times_cos:
- fixes w :: "'a::{real_normed_field,banach}"
- shows "sin(w) * cos(z) = (sin(w + z) + sin(w - z)) / 2"
+lemma sin_times_cos: "sin w * cos z = (sin (w + z) + sin (w - z)) / 2"
+ for w :: "'a::{real_normed_field,banach}"
by (simp add: sin_diff sin_add)
-lemma cos_times_sin:
- fixes w :: "'a::{real_normed_field,banach}"
- shows "cos(w) * sin(z) = (sin(w + z) - sin(w - z)) / 2"
+lemma cos_times_sin: "cos w * sin z = (sin (w + z) - sin (w - z)) / 2"
+ for w :: "'a::{real_normed_field,banach}"
by (simp add: sin_diff sin_add)
-lemma cos_times_cos:
- fixes w :: "'a::{real_normed_field,banach}"
- shows "cos(w) * cos(z) = (cos(w - z) + cos(w + z)) / 2"
+lemma cos_times_cos: "cos w * cos z = (cos (w - z) + cos (w + z)) / 2"
+ for w :: "'a::{real_normed_field,banach}"
by (simp add: cos_diff cos_add)
-lemma sin_plus_sin: (*FIXME field should not be necessary*)
- fixes w :: "'a::{real_normed_field,banach,field}"
- shows "sin(w) + sin(z) = 2 * sin((w + z) / 2) * cos((w - z) / 2)"
+lemma sin_plus_sin: "sin w + sin z = 2 * sin ((w + z) / 2) * cos ((w - z) / 2)"
+ for w :: "'a::{real_normed_field,banach,field}" (* FIXME field should not be necessary *)
apply (simp add: mult.assoc sin_times_cos)
apply (simp add: field_simps)
done
-lemma sin_diff_sin:
- fixes w :: "'a::{real_normed_field,banach,field}"
- shows "sin(w) - sin(z) = 2 * sin((w - z) / 2) * cos((w + z) / 2)"
+lemma sin_diff_sin: "sin w - sin z = 2 * sin ((w - z) / 2) * cos ((w + z) / 2)"
+ for w :: "'a::{real_normed_field,banach,field}"
apply (simp add: mult.assoc sin_times_cos)
apply (simp add: field_simps)
done
-lemma cos_plus_cos:
- fixes w :: "'a::{real_normed_field,banach,field}"
- shows "cos(w) + cos(z) = 2 * cos((w + z) / 2) * cos((w - z) / 2)"
+lemma cos_plus_cos: "cos w + cos z = 2 * cos ((w + z) / 2) * cos ((w - z) / 2)"
+ for w :: "'a::{real_normed_field,banach,field}"
apply (simp add: mult.assoc cos_times_cos)
apply (simp add: field_simps)
done
-lemma cos_diff_cos:
- fixes w :: "'a::{real_normed_field,banach,field}"
- shows "cos(w) - cos(z) = 2 * sin((w + z) / 2) * sin((z - w) / 2)"
+lemma cos_diff_cos: "cos w - cos z = 2 * sin ((w + z) / 2) * sin ((z - w) / 2)"
+ for w :: "'a::{real_normed_field,banach,field}"
apply (simp add: mult.assoc sin_times_sin)
apply (simp add: field_simps)
done
-lemma cos_double_cos:
- fixes z :: "'a::{real_normed_field,banach}"
- shows "cos(2 * z) = 2 * cos z ^ 2 - 1"
-by (simp add: cos_double sin_squared_eq)
-
-lemma cos_double_sin:
- fixes z :: "'a::{real_normed_field,banach}"
- shows "cos(2 * z) = 1 - 2 * sin z ^ 2"
-by (simp add: cos_double sin_squared_eq)
+lemma cos_double_cos: "cos (2 * z) = 2 * cos z ^ 2 - 1"
+ for z :: "'a::{real_normed_field,banach}"
+ by (simp add: cos_double sin_squared_eq)
+
+lemma cos_double_sin: "cos (2 * z) = 1 - 2 * sin z ^ 2"
+ for z :: "'a::{real_normed_field,banach}"
+ by (simp add: cos_double sin_squared_eq)
lemma sin_pi_minus [simp]: "sin (pi - x) = sin x"
by (metis sin_minus sin_periodic_pi minus_minus uminus_add_conv_diff)
-lemma cos_pi_minus [simp]: "cos (pi - x) = -(cos x)"
+lemma cos_pi_minus [simp]: "cos (pi - x) = - (cos x)"
by (metis cos_minus cos_periodic_pi uminus_add_conv_diff)
lemma sin_minus_pi [simp]: "sin (x - pi) = - (sin x)"
by (simp add: sin_diff)
-lemma cos_minus_pi [simp]: "cos (x - pi) = -(cos x)"
+lemma cos_minus_pi [simp]: "cos (x - pi) = - (cos x)"
by (simp add: cos_diff)
-lemma sin_2pi_minus [simp]: "sin (2*pi - x) = -(sin x)"
+lemma sin_2pi_minus [simp]: "sin (2 * pi - x) = - (sin x)"
by (metis sin_periodic_pi2 add_diff_eq mult_2 sin_pi_minus)
-lemma cos_2pi_minus [simp]: "cos (2*pi - x) = cos x"
+lemma cos_2pi_minus [simp]: "cos (2 * pi - x) = cos x"
by (metis (no_types, hide_lams) cos_add cos_minus cos_two_pi sin_minus sin_two_pi
- diff_0_right minus_diff_eq mult_1 mult_zero_left uminus_add_conv_diff)
-
-lemma sin_gt_zero2: "\<lbrakk>0 < x; x < pi/2\<rbrakk> \<Longrightarrow> 0 < sin x"
+ diff_0_right minus_diff_eq mult_1 mult_zero_left uminus_add_conv_diff)
+
+lemma sin_gt_zero2: "0 < x \<Longrightarrow> x < pi/2 \<Longrightarrow> 0 < sin x"
by (metis sin_gt_zero_02 order_less_trans pi_half_less_two)
lemma sin_less_zero:
assumes "- pi/2 < x" and "x < 0"
shows "sin x < 0"
proof -
- have "0 < sin (- x)" using assms by (simp only: sin_gt_zero2)
- thus ?thesis by simp
+ have "0 < sin (- x)"
+ using assms by (simp only: sin_gt_zero2)
+ then show ?thesis by simp
qed
lemma pi_less_4: "pi < 4"
using pi_half_less_two by auto
-lemma cos_gt_zero: "\<lbrakk>0 < x; x < pi/2\<rbrakk> \<Longrightarrow> 0 < cos x"
+lemma cos_gt_zero: "0 < x \<Longrightarrow> x < pi/2 \<Longrightarrow> 0 < cos x"
by (simp add: cos_sin_eq sin_gt_zero2)
-lemma cos_gt_zero_pi: "\<lbrakk>-(pi/2) < x; x < pi/2\<rbrakk> \<Longrightarrow> 0 < cos x"
+lemma cos_gt_zero_pi: "-(pi/2) < x \<Longrightarrow> x < pi/2 \<Longrightarrow> 0 < cos x"
using cos_gt_zero [of x] cos_gt_zero [of "-x"]
by (cases rule: linorder_cases [of x 0]) auto
-lemma cos_ge_zero: "\<lbrakk>-(pi/2) \<le> x; x \<le> pi/2\<rbrakk> \<Longrightarrow> 0 \<le> cos x"
- apply (auto simp: order_le_less cos_gt_zero_pi)
- by (metis cos_pi_half eq_divide_eq eq_numeral_simps(4))
-
-lemma sin_gt_zero: "\<lbrakk>0 < x; x < pi \<rbrakk> \<Longrightarrow> 0 < sin x"
+lemma cos_ge_zero: "-(pi/2) \<le> x \<Longrightarrow> x \<le> pi/2 \<Longrightarrow> 0 \<le> cos x"
+ by (auto simp: order_le_less cos_gt_zero_pi)
+ (metis cos_pi_half eq_divide_eq eq_numeral_simps(4))
+
+lemma sin_gt_zero: "0 < x \<Longrightarrow> x < pi \<Longrightarrow> 0 < sin x"
by (simp add: sin_cos_eq cos_gt_zero_pi)
-lemma sin_lt_zero: "pi < x \<Longrightarrow> x < 2*pi \<Longrightarrow> sin x < 0"
- using sin_gt_zero [of "x-pi"]
+lemma sin_lt_zero: "pi < x \<Longrightarrow> x < 2 * pi \<Longrightarrow> sin x < 0"
+ using sin_gt_zero [of "x - pi"]
by (simp add: sin_diff)
lemma pi_ge_two: "2 \<le> pi"
proof (rule ccontr)
- assume "\<not> 2 \<le> pi" hence "pi < 2" by auto
- have "\<exists>y > pi. y < 2 \<and> y < 2*pi"
- proof (cases "2 < 2*pi")
- case True with dense[OF \<open>pi < 2\<close>] show ?thesis by auto
+ assume "\<not> ?thesis"
+ then have "pi < 2" by auto
+ have "\<exists>y > pi. y < 2 \<and> y < 2 * pi"
+ proof (cases "2 < 2 * pi")
+ case True
+ with dense[OF \<open>pi < 2\<close>] show ?thesis by auto
next
- case False have "pi < 2*pi" by auto
+ case False
+ have "pi < 2 * pi" by auto
from dense[OF this] and False show ?thesis by auto
qed
- then obtain y where "pi < y" and "y < 2" and "y < 2*pi" by blast
- hence "0 < sin y" using sin_gt_zero_02 by auto
- moreover
- have "sin y < 0" using sin_gt_zero[of "y - pi"] \<open>pi < y\<close> and \<open>y < 2*pi\<close> sin_periodic_pi[of "y - pi"] by auto
+ then obtain y where "pi < y" and "y < 2" and "y < 2 * pi"
+ by blast
+ then have "0 < sin y"
+ using sin_gt_zero_02 by auto
+ moreover have "sin y < 0"
+ using sin_gt_zero[of "y - pi"] \<open>pi < y\<close> and \<open>y < 2 * pi\<close> sin_periodic_pi[of "y - pi"]
+ by auto
ultimately show False by auto
qed
-lemma sin_ge_zero: "\<lbrakk>0 \<le> x; x \<le> pi\<rbrakk> \<Longrightarrow> 0 \<le> sin x"
+lemma sin_ge_zero: "0 \<le> x \<Longrightarrow> x \<le> pi \<Longrightarrow> 0 \<le> sin x"
by (auto simp: order_le_less sin_gt_zero)
-lemma sin_le_zero: "pi \<le> x \<Longrightarrow> x < 2*pi \<Longrightarrow> sin x \<le> 0"
- using sin_ge_zero [of "x-pi"]
- by (simp add: sin_diff)
+lemma sin_le_zero: "pi \<le> x \<Longrightarrow> x < 2 * pi \<Longrightarrow> sin x \<le> 0"
+ using sin_ge_zero [of "x - pi"] by (simp add: sin_diff)
lemma sin_pi_divide_n_ge_0 [simp]:
- assumes "n \<noteq> 0" shows "0 \<le> sin (pi / real n)"
-apply (rule sin_ge_zero)
-using assms
-apply (simp_all add: divide_simps)
-done
+ assumes "n \<noteq> 0"
+ shows "0 \<le> sin (pi / real n)"
+ by (rule sin_ge_zero) (use assms in \<open>simp_all add: divide_simps\<close>)
lemma sin_pi_divide_n_gt_0:
- assumes "2 \<le> n" shows "0 < sin (pi / real n)"
-apply (rule sin_gt_zero)
-using assms
-apply (simp_all add: divide_simps)
-done
-
-text \<open>FIXME: This proof is almost identical to lemma \<open>cos_is_zero\<close>.
- It should be possible to factor out some of the common parts.\<close>
-
-lemma cos_total: "\<lbrakk>-1 \<le> y; y \<le> 1\<rbrakk> \<Longrightarrow> EX! x. 0 \<le> x & x \<le> pi & (cos x = y)"
+ assumes "2 \<le> n"
+ shows "0 < sin (pi / real n)"
+ by (rule sin_gt_zero) (use assms in \<open>simp_all add: divide_simps\<close>)
+
+(* FIXME: This proof is almost identical to lemma \<open>cos_is_zero\<close>.
+ It should be possible to factor out some of the common parts. *)
+lemma cos_total:
+ assumes y: "- 1 \<le> y" "y \<le> 1"
+ shows "\<exists>!x. 0 \<le> x \<and> x \<le> pi \<and> cos x = y"
proof (rule ex_ex1I)
- assume y: "-1 \<le> y" "y \<le> 1"
- show "\<exists>x. 0 \<le> x & x \<le> pi & cos x = y"
- by (rule IVT2, simp_all add: y)
+ show "\<exists>x. 0 \<le> x \<and> x \<le> pi \<and> cos x = y"
+ by (rule IVT2) (simp_all add: y)
next
fix a b
assume a: "0 \<le> a \<and> a \<le> pi \<and> cos a = y"
assume b: "0 \<le> b \<and> b \<le> pi \<and> cos b = y"
have [simp]: "\<forall>x::real. cos differentiable (at x)"
unfolding real_differentiable_def by (auto intro: DERIV_cos)
- from a b show "a = b"
- apply (cut_tac less_linear [of a b], auto)
- apply (drule_tac f = cos in Rolle)
- apply (drule_tac [5] f = cos in Rolle)
- apply (auto dest!: DERIV_cos [THEN DERIV_unique])
- apply (metis order_less_le_trans less_le sin_gt_zero)
+ from a b less_linear [of a b] show "a = b"
+ apply auto
+ apply (drule_tac f = cos in Rolle)
+ apply (drule_tac [5] f = cos in Rolle)
+ apply (auto dest!: DERIV_cos [THEN DERIV_unique])
+ apply (metis order_less_le_trans less_le sin_gt_zero)
apply (metis order_less_le_trans less_le sin_gt_zero)
done
qed
lemma sin_total:
assumes y: "-1 \<le> y" "y \<le> 1"
- shows "\<exists>! x. -(pi/2) \<le> x & x \<le> pi/2 & (sin x = y)"
+ shows "\<exists>!x. - (pi/2) \<le> x \<and> x \<le> pi/2 \<and> sin x = y"
proof -
from cos_total [OF y]
obtain x where x: "0 \<le> x" "x \<le> pi" "cos x = y"
- and uniq: "\<And>x'. 0 \<le> x' \<Longrightarrow> x' \<le> pi \<Longrightarrow> cos x' = y \<Longrightarrow> x' = x "
+ and uniq: "\<And>x'. 0 \<le> x' \<Longrightarrow> x' \<le> pi \<Longrightarrow> cos x' = y \<Longrightarrow> x' = x "
by blast
show ?thesis
apply (simp add: sin_cos_eq)
apply (rule ex1I [where a="pi/2 - x"])
- apply (cut_tac [2] x'="pi/2 - xa" in uniq)
+ apply (cut_tac [2] x'="pi/2 - xa" in uniq)
using x
- apply auto
+ apply auto
done
qed
@@ -3713,7 +3734,7 @@
obtain n where "real n * pi \<le> x" "x < real (Suc n) * pi"
apply (rule that [of "nat \<lfloor>x/pi\<rfloor>"])
using assms
- apply (simp_all add: xle)
+ apply (simp_all add: xle)
apply (metis floor_less_iff less_irrefl mult_imp_div_pos_less not_le pi_gt_zero)
done
then have x: "0 \<le> x - n * pi" "(x - n * pi) \<le> pi" "cos (x - n * pi) = 0"
@@ -3721,7 +3742,7 @@
then have "\<exists>!x. 0 \<le> x \<and> x \<le> pi \<and> cos x = 0"
by (auto simp: intro!: cos_total)
then obtain \<theta> where \<theta>: "0 \<le> \<theta>" "\<theta> \<le> pi" "cos \<theta> = 0"
- and uniq: "\<And>\<phi>. \<lbrakk>0 \<le> \<phi>; \<phi> \<le> pi; cos \<phi> = 0\<rbrakk> \<Longrightarrow> \<phi> = \<theta>"
+ and uniq: "\<And>\<phi>. 0 \<le> \<phi> \<Longrightarrow> \<phi> \<le> pi \<Longrightarrow> cos \<phi> = 0 \<Longrightarrow> \<phi> = \<theta>"
by blast
then have "x - real n * pi = \<theta>"
using x by blast
@@ -3731,8 +3752,7 @@
by (rule_tac x = "Suc (2 * n)" in exI) (simp add: algebra_simps)
qed
-lemma sin_zero_lemma:
- "\<lbrakk>0 \<le> x; sin x = 0\<rbrakk> \<Longrightarrow> \<exists>n::nat. even n & x = real n * (pi/2)"
+lemma sin_zero_lemma: "0 \<le> x \<Longrightarrow> sin x = 0 \<Longrightarrow> \<exists>n::nat. even n \<and> x = real n * (pi/2)"
using cos_zero_lemma [of "x + pi/2"]
apply (clarsimp simp add: cos_add)
apply (rule_tac x = "n - 1" in exI)
@@ -3740,79 +3760,78 @@
done
lemma cos_zero_iff:
- "(cos x = 0) \<longleftrightarrow>
- ((\<exists>n. odd n & (x = real n * (pi/2))) \<or> (\<exists>n. odd n & (x = -(real n * (pi/2)))))"
- (is "?lhs = ?rhs")
+ "cos x = 0 \<longleftrightarrow> ((\<exists>n. odd n \<and> x = real n * (pi/2)) \<or> (\<exists>n. odd n \<and> x = - (real n * (pi/2))))"
+ (is "?lhs = ?rhs")
proof -
- { fix n :: nat
- assume "odd n"
- then obtain m where "n = 2 * m + 1" ..
- then have "cos (real n * pi / 2) = 0"
+ have *: "cos (real n * pi / 2) = 0" if "odd n" for n :: nat
+ proof -
+ from that obtain m where "n = 2 * m + 1" ..
+ then show ?thesis
by (simp add: field_simps) (simp add: cos_add add_divide_distrib)
- } note * = this
+ qed
show ?thesis
proof
- assume "cos x = 0" then show ?rhs
- using cos_zero_lemma [of x] cos_zero_lemma [of "-x"] by force
- next
- assume ?rhs then show "cos x = 0"
- by (auto dest: * simp del: eq_divide_eq_numeral1)
+ show ?rhs if ?lhs
+ using that cos_zero_lemma [of x] cos_zero_lemma [of "-x"] by force
+ show ?lhs if ?rhs
+ using that by (auto dest: * simp del: eq_divide_eq_numeral1)
qed
qed
lemma sin_zero_iff:
- "(sin x = 0) \<longleftrightarrow>
- ((\<exists>n. even n & (x = real n * (pi/2))) \<or> (\<exists>n. even n & (x = -(real n * (pi/2)))))"
- (is "?lhs = ?rhs")
+ "sin x = 0 \<longleftrightarrow> ((\<exists>n. even n \<and> x = real n * (pi/2)) \<or> (\<exists>n. even n \<and> x = - (real n * (pi/2))))"
+ (is "?lhs = ?rhs")
proof
- assume "sin x = 0" then show ?rhs
- using sin_zero_lemma [of x] sin_zero_lemma [of "-x"] by force
-next
- assume ?rhs then show "sin x = 0"
- by (auto elim: evenE)
+ show ?rhs if ?lhs
+ using that sin_zero_lemma [of x] sin_zero_lemma [of "-x"] by force
+ show ?lhs if ?rhs
+ using that by (auto elim: evenE)
qed
-lemma cos_zero_iff_int:
- "cos x = 0 \<longleftrightarrow> (\<exists>n. odd n \<and> x = of_int n * (pi/2))"
+lemma cos_zero_iff_int: "cos x = 0 \<longleftrightarrow> (\<exists>n. odd n \<and> x = of_int n * (pi/2))"
proof safe
assume "cos x = 0"
- then show "\<exists>n. odd n & x = of_int n * (pi/2)"
- apply (simp add: cos_zero_iff, safe)
- apply (metis even_int_iff of_int_of_nat_eq)
- apply (rule_tac x="- (int n)" in exI, simp)
+ then show "\<exists>n. odd n \<and> x = of_int n * (pi/2)"
+ apply (simp add: cos_zero_iff)
+ apply safe
+ apply (metis even_int_iff of_int_of_nat_eq)
+ apply (rule_tac x="- (int n)" in exI)
+ apply simp
done
next
- fix n::int
+ fix n :: int
assume "odd n"
then show "cos (of_int n * (pi / 2)) = 0"
apply (simp add: cos_zero_iff)
- apply (case_tac n rule: int_cases2, simp_all)
+ apply (cases n rule: int_cases2)
+ apply simp_all
done
qed
-lemma sin_zero_iff_int:
- "sin x = 0 \<longleftrightarrow> (\<exists>n. even n & (x = of_int n * (pi/2)))"
+lemma sin_zero_iff_int: "sin x = 0 \<longleftrightarrow> (\<exists>n. even n \<and> x = of_int n * (pi/2))"
proof safe
assume "sin x = 0"
then show "\<exists>n. even n \<and> x = of_int n * (pi / 2)"
- apply (simp add: sin_zero_iff, safe)
- apply (metis even_int_iff of_int_of_nat_eq)
- apply (rule_tac x="- (int n)" in exI, simp)
+ apply (simp add: sin_zero_iff)
+ apply safe
+ apply (metis even_int_iff of_int_of_nat_eq)
+ apply (rule_tac x="- (int n)" in exI)
+ apply simp
done
next
- fix n::int
+ fix n :: int
assume "even n"
then show "sin (of_int n * (pi / 2)) = 0"
apply (simp add: sin_zero_iff)
- apply (case_tac n rule: int_cases2, simp_all)
+ apply (cases n rule: int_cases2)
+ apply simp_all
done
qed
-lemma sin_zero_iff_int2:
- "sin x = 0 \<longleftrightarrow> (\<exists>n::int. x = of_int n * pi)"
+lemma sin_zero_iff_int2: "sin x = 0 \<longleftrightarrow> (\<exists>n::int. x = of_int n * pi)"
apply (simp only: sin_zero_iff_int)
apply (safe elim!: evenE)
- apply (simp_all add: field_simps)
+ apply (simp_all add: field_simps)
using dvd_triv_left apply fastforce
done
@@ -3824,12 +3843,14 @@
from MVT2[OF \<open>y < x\<close> DERIV_cos[THEN impI, THEN allI]]
obtain z where "y < z" and "z < x" and cos_diff: "cos x - cos y = (x - y) * - sin z"
by auto
- hence "0 < z" and "z < pi" using assms by auto
- hence "0 < sin z" using sin_gt_zero by auto
- hence "cos x - cos y < 0"
+ then have "0 < z" and "z < pi"
+ using assms by auto
+ then have "0 < sin z"
+ using sin_gt_zero by auto
+ then have "cos x - cos y < 0"
unfolding cos_diff minus_mult_commute[symmetric]
using \<open>- (x - y) < 0\<close> by (rule mult_pos_neg2)
- thus ?thesis by auto
+ then show ?thesis by auto
qed
lemma cos_monotone_0_pi_le:
@@ -3841,22 +3862,22 @@
using cos_monotone_0_pi[OF \<open>0 \<le> y\<close> True \<open>x \<le> pi\<close>] by auto
next
case False
- hence "y = x" using \<open>y \<le> x\<close> by auto
- thus ?thesis by auto
+ then have "y = x" using \<open>y \<le> x\<close> by auto
+ then show ?thesis by auto
qed
lemma cos_monotone_minus_pi_0:
- assumes "-pi \<le> y" and "y < x" and "x \<le> 0"
+ assumes "- pi \<le> y" and "y < x" and "x \<le> 0"
shows "cos y < cos x"
proof -
- have "0 \<le> -x" and "-x < -y" and "-y \<le> pi"
+ have "0 \<le> - x" and "- x < - y" and "- y \<le> pi"
using assms by auto
from cos_monotone_0_pi[OF this] show ?thesis
unfolding cos_minus .
qed
lemma cos_monotone_minus_pi_0':
- assumes "-pi \<le> y" and "y \<le> x" and "x \<le> 0"
+ assumes "- pi \<le> y" and "y \<le> x" and "x \<le> 0"
shows "cos y \<le> cos x"
proof (cases "y < x")
case True
@@ -3864,18 +3885,18 @@
by auto
next
case False
- hence "y = x" using \<open>y \<le> x\<close> by auto
- thus ?thesis by auto
+ then have "y = x" using \<open>y \<le> x\<close> by auto
+ then show ?thesis by auto
qed
lemma sin_monotone_2pi:
assumes "- (pi/2) \<le> y" and "y < x" and "x \<le> pi/2"
shows "sin y < sin x"
- apply (simp add: sin_cos_eq)
- apply (rule cos_monotone_0_pi)
- using assms
+ apply (simp add: sin_cos_eq)
+ apply (rule cos_monotone_0_pi)
+ using assms
apply auto
- done
+ done
lemma sin_monotone_2pi_le:
assumes "- (pi / 2) \<le> y" and "y \<le> x" and "x \<le> pi / 2"
@@ -3883,7 +3904,9 @@
by (metis assms le_less sin_monotone_2pi)
lemma sin_x_le_x:
- fixes x::real assumes x: "x \<ge> 0" shows "sin x \<le> x"
+ fixes x :: real
+ assumes x: "x \<ge> 0"
+ shows "sin x \<le> x"
proof -
let ?f = "\<lambda>x. x - sin x"
from x have "?f x \<ge> ?f 0"
@@ -3891,11 +3914,13 @@
apply (intro allI impI exI[of _ "1 - cos x" for x])
apply (auto intro!: derivative_eq_intros simp: field_simps)
done
- thus "sin x \<le> x" by simp
+ then show "sin x \<le> x" by simp
qed
lemma sin_x_ge_neg_x:
- fixes x::real assumes x: "x \<ge> 0" shows "sin x \<ge> - x"
+ fixes x :: real
+ assumes x: "x \<ge> 0"
+ shows "sin x \<ge> - x"
proof -
let ?f = "\<lambda>x. x + sin x"
from x have "?f x \<ge> ?f 0"
@@ -3903,11 +3928,11 @@
apply (intro allI impI exI[of _ "1 + cos x" for x])
apply (auto intro!: derivative_eq_intros simp: field_simps real_0_le_add_iff)
done
- thus "sin x \<ge> -x" by simp
+ then show "sin x \<ge> -x" by simp
qed
-lemma abs_sin_x_le_abs_x:
- fixes x::real shows "\<bar>sin x\<bar> \<le> \<bar>x\<bar>"
+lemma abs_sin_x_le_abs_x: "\<bar>sin x\<bar> \<le> \<bar>x\<bar>"
+ for x :: real
using sin_x_ge_neg_x [of x] sin_x_le_x [of x] sin_x_ge_neg_x [of "-x"] sin_x_le_x [of "-x"]
by (auto simp: abs_real_def)
@@ -3918,35 +3943,42 @@
proof -
have "sin ((real n + 1/2) * pi) = cos (real n * pi)"
by (auto simp: algebra_simps sin_add)
- thus ?thesis
+ then show ?thesis
by (simp add: distrib_right add_divide_distrib add.commute mult.commute [of pi])
qed
-lemma cos_2npi [simp]: "cos (2 * real (n::nat) * pi) = 1"
+lemma cos_2npi [simp]: "cos (2 * real n * pi) = 1"
+ for n :: nat
by (cases "even n") (simp_all add: cos_double mult.assoc)
lemma cos_3over2_pi [simp]: "cos (3/2*pi) = 0"
- apply (subgoal_tac "cos (pi + pi/2) = 0", simp)
- apply (subst cos_add, simp)
+ apply (subgoal_tac "cos (pi + pi/2) = 0")
+ apply simp
+ apply (subst cos_add)
+ apply simp
done
-lemma sin_2npi [simp]: "sin (2 * real (n::nat) * pi) = 0"
+lemma sin_2npi [simp]: "sin (2 * real n * pi) = 0"
+ for n :: nat
by (auto simp: mult.assoc sin_double)
lemma sin_3over2_pi [simp]: "sin (3/2*pi) = - 1"
- apply (subgoal_tac "sin (pi + pi/2) = - 1", simp)
- apply (subst sin_add, simp)
+ apply (subgoal_tac "sin (pi + pi/2) = - 1")
+ apply simp
+ apply (subst sin_add)
+ apply simp
done
lemma cos_pi_eq_zero [simp]: "cos (pi * real (Suc (2 * m)) / 2) = 0"
-by (simp only: cos_add sin_add of_nat_Suc distrib_right distrib_left add_divide_distrib, auto)
+ by (simp only: cos_add sin_add of_nat_Suc distrib_right distrib_left add_divide_distrib, auto)
lemma DERIV_cos_add [simp]: "DERIV (\<lambda>x. cos (x + k)) xa :> - sin (xa + k)"
by (auto intro!: derivative_eq_intros)
lemma sin_zero_norm_cos_one:
fixes x :: "'a::{real_normed_field,banach}"
- assumes "sin x = 0" shows "norm (cos x) = 1"
+ assumes "sin x = 0"
+ shows "norm (cos x) = 1"
using sin_cos_squared_add [of x, unfolded assms]
by (simp add: square_norm_one)
@@ -3955,23 +3987,23 @@
lemma cos_one_sin_zero:
fixes x :: "'a::{real_normed_field,banach}"
- assumes "cos x = 1" shows "sin x = 0"
+ assumes "cos x = 1"
+ shows "sin x = 0"
using sin_cos_squared_add [of x, unfolded assms]
by simp
-lemma sin_times_pi_eq_0: "sin(x * pi) = 0 \<longleftrightarrow> x \<in> \<int>"
+lemma sin_times_pi_eq_0: "sin (x * pi) = 0 \<longleftrightarrow> x \<in> \<int>"
by (simp add: sin_zero_iff_int2) (metis Ints_cases Ints_of_int)
-lemma cos_one_2pi:
- "cos(x) = 1 \<longleftrightarrow> (\<exists>n::nat. x = n * 2*pi) | (\<exists>n::nat. x = -(n * 2*pi))"
- (is "?lhs = ?rhs")
+lemma cos_one_2pi: "cos x = 1 \<longleftrightarrow> (\<exists>n::nat. x = n * 2 * pi) | (\<exists>n::nat. x = - (n * 2 * pi))"
+ (is "?lhs = ?rhs")
proof
- assume "cos(x) = 1"
+ assume ?lhs
then have "sin x = 0"
by (simp add: cos_one_sin_zero)
then show ?rhs
proof (simp only: sin_zero_iff, elim exE disjE conjE)
- fix n::nat
+ fix n :: nat
assume n: "even n" "x = real n * (pi/2)"
then obtain m where m: "n = 2 * m"
using dvdE by blast
@@ -3981,7 +4013,7 @@
using m me n
by (auto simp: field_simps elim!: evenE)
next
- fix n::nat
+ fix n :: nat
assume n: "even n" "x = - (real n * (pi/2))"
then obtain m where m: "n = 2 * m"
using dvdE by blast
@@ -3992,33 +4024,33 @@
by (auto simp: field_simps elim!: evenE)
qed
next
- assume "?rhs"
+ assume ?rhs
then show "cos x = 1"
by (metis cos_2npi cos_minus mult.assoc mult.left_commute)
qed
-lemma cos_one_2pi_int: "cos(x) = 1 \<longleftrightarrow> (\<exists>n::int. x = n * 2*pi)"
- apply auto \<comment>\<open>FIXME simproc bug\<close>
- apply (auto simp: cos_one_2pi)
- apply (metis of_int_of_nat_eq)
- apply (metis mult_minus_right of_int_minus of_int_of_nat_eq)
- by (metis mult_minus_right of_int_of_nat )
-
-lemma sin_cos_sqrt: "0 \<le> sin(x) \<Longrightarrow> (sin(x) = sqrt(1 - (cos(x) ^ 2)))"
+lemma cos_one_2pi_int: "cos x = 1 \<longleftrightarrow> (\<exists>n::int. x = n * 2 * pi)"
+ apply auto (* FIXME simproc bug? *)
+ apply (auto simp: cos_one_2pi)
+ apply (metis of_int_of_nat_eq)
+ apply (metis mult_minus_right of_int_minus of_int_of_nat_eq)
+ apply (metis mult_minus_right of_int_of_nat)
+ done
+
+lemma sin_cos_sqrt: "0 \<le> sin x \<Longrightarrow> sin x = sqrt (1 - (cos(x) ^ 2))"
using sin_squared_eq real_sqrt_unique by fastforce
-lemma sin_eq_0_pi: "-pi < x \<Longrightarrow> x < pi \<Longrightarrow> sin(x) = 0 \<Longrightarrow> x = 0"
+lemma sin_eq_0_pi: "- pi < x \<Longrightarrow> x < pi \<Longrightarrow> sin x = 0 \<Longrightarrow> x = 0"
by (metis sin_gt_zero sin_minus minus_less_iff neg_0_less_iff_less not_less_iff_gr_or_eq)
-lemma cos_treble_cos:
- fixes x :: "'a::{real_normed_field,banach}"
- shows "cos(3 * x) = 4 * cos(x) ^ 3 - 3 * cos x"
+lemma cos_treble_cos: "cos (3 * x) = 4 * cos x ^ 3 - 3 * cos x"
+ for x :: "'a::{real_normed_field,banach}"
proof -
have *: "(sin x * (sin x * 3)) = 3 - (cos x * (cos x * 3))"
by (simp add: mult.assoc [symmetric] sin_squared_eq [unfolded power2_eq_square])
have "cos(3 * x) = cos(2*x + x)"
by simp
- also have "... = 4 * cos(x) ^ 3 - 3 * cos x"
+ also have "\<dots> = 4 * cos x ^ 3 - 3 * cos x"
apply (simp only: cos_add cos_double sin_double)
apply (simp add: * field_simps power2_eq_square power3_eq_cube)
done
@@ -4027,7 +4059,8 @@
lemma cos_45: "cos (pi / 4) = sqrt 2 / 2"
proof -
- let ?c = "cos (pi / 4)" and ?s = "sin (pi / 4)"
+ let ?c = "cos (pi / 4)"
+ let ?s = "sin (pi / 4)"
have nonneg: "0 \<le> ?c"
by (simp add: cos_ge_zero)
have "0 = cos (pi / 4 + pi / 4)"
@@ -4038,15 +4071,16 @@
by (simp add: sin_squared_eq)
finally have "?c\<^sup>2 = (sqrt 2 / 2)\<^sup>2"
by (simp add: power_divide)
- thus ?thesis
+ then show ?thesis
using nonneg by (rule power2_eq_imp_eq) simp
qed
lemma cos_30: "cos (pi / 6) = sqrt 3/2"
proof -
- let ?c = "cos (pi / 6)" and ?s = "sin (pi / 6)"
+ let ?c = "cos (pi / 6)"
+ let ?s = "sin (pi / 6)"
have pos_c: "0 < ?c"
- by (rule cos_gt_zero, simp, simp)
+ by (rule cos_gt_zero) simp_all
have "0 = cos (pi / 6 + pi / 6 + pi / 6)"
by simp
also have "\<dots> = (?c * ?c - ?s * ?s) * ?c - (?s * ?c + ?c * ?s) * ?s"
@@ -4055,7 +4089,7 @@
by (simp add: algebra_simps power2_eq_square)
finally have "?c\<^sup>2 = (sqrt 3/2)\<^sup>2"
using pos_c by (simp add: sin_squared_eq power_divide)
- thus ?thesis
+ then show ?thesis
using pos_c [THEN order_less_imp_le]
by (rule power2_eq_imp_eq) simp
qed
@@ -4068,31 +4102,35 @@
lemma cos_60: "cos (pi / 3) = 1 / 2"
apply (rule power2_eq_imp_eq)
- apply (simp add: cos_squared_eq sin_60 power_divide)
- apply (rule cos_ge_zero, rule order_trans [where y=0], simp_all)
+ apply (simp add: cos_squared_eq sin_60 power_divide)
+ apply (rule cos_ge_zero)
+ apply (rule order_trans [where y=0])
+ apply simp_all
done
lemma sin_30: "sin (pi / 6) = 1 / 2"
by (simp add: sin_cos_eq cos_60)
-lemma cos_integer_2pi: "n \<in> \<int> \<Longrightarrow> cos(2*pi * n) = 1"
+lemma cos_integer_2pi: "n \<in> \<int> \<Longrightarrow> cos(2 * pi * n) = 1"
by (metis Ints_cases cos_one_2pi_int mult.assoc mult.commute)
-lemma sin_integer_2pi: "n \<in> \<int> \<Longrightarrow> sin(2*pi * n) = 0"
+lemma sin_integer_2pi: "n \<in> \<int> \<Longrightarrow> sin(2 * pi * n) = 0"
by (metis sin_two_pi Ints_mult mult.assoc mult.commute sin_times_pi_eq_0)
-lemma cos_int_2npi [simp]: "cos (2 * of_int (n::int) * pi) = 1"
+lemma cos_int_2npi [simp]: "cos (2 * of_int n * pi) = 1"
+ for n :: int
by (simp add: cos_one_2pi_int)
-lemma sin_int_2npi [simp]: "sin (2 * of_int (n::int) * pi) = 0"
+lemma sin_int_2npi [simp]: "sin (2 * of_int n * pi) = 0"
+ for n :: int
by (metis Ints_of_int mult.assoc mult.commute sin_integer_2pi)
-lemma sincos_principal_value: "\<exists>y. (-pi < y \<and> y \<le> pi) \<and> (sin(y) = sin(x) \<and> cos(y) = cos(x))"
- apply (rule exI [where x="pi - (2*pi) * frac((pi - x) / (2*pi))"])
+lemma sincos_principal_value: "\<exists>y. (- pi < y \<and> y \<le> pi) \<and> (sin y = sin x \<and> cos y = cos x)"
+ apply (rule exI [where x="pi - (2 * pi) * frac ((pi - x) / (2 * pi))"])
apply (auto simp: field_simps frac_lt_1)
- apply (simp_all add: frac_def divide_simps)
- apply (simp_all add: add_divide_distrib diff_divide_distrib)
- apply (simp_all add: sin_diff cos_diff mult.assoc [symmetric] cos_integer_2pi sin_integer_2pi)
+ apply (simp_all add: frac_def divide_simps)
+ apply (simp_all add: add_divide_distrib diff_divide_distrib)
+ apply (simp_all add: sin_diff cos_diff mult.assoc [symmetric] cos_integer_2pi sin_integer_2pi)
done
@@ -4101,13 +4139,11 @@
definition tan :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
where "tan = (\<lambda>x. sin x / cos x)"
-lemma tan_of_real:
- "of_real (tan x) = (tan (of_real x) :: 'a::{real_normed_field,banach})"
+lemma tan_of_real: "of_real (tan x) = (tan (of_real x) :: 'a::{real_normed_field,banach})"
by (simp add: tan_def sin_of_real cos_of_real)
-lemma tan_in_Reals [simp]:
- fixes z :: "'a::{real_normed_field,banach}"
- shows "z \<in> \<real> \<Longrightarrow> tan z \<in> \<real>"
+lemma tan_in_Reals [simp]: "z \<in> \<real> \<Longrightarrow> tan z \<in> \<real>"
+ for z :: "'a::{real_normed_field,banach}"
by (simp add: tan_def)
lemma tan_zero [simp]: "tan 0 = 0"
@@ -4116,52 +4152,46 @@
lemma tan_pi [simp]: "tan pi = 0"
by (simp add: tan_def)
-lemma tan_npi [simp]: "tan (real (n::nat) * pi) = 0"
+lemma tan_npi [simp]: "tan (real n * pi) = 0"
+ for n :: nat
by (simp add: tan_def)
-lemma tan_minus [simp]: "tan (-x) = - tan x"
- by (simp add: tan_def)
-
-lemma tan_periodic [simp]: "tan (x + 2*pi) = tan x"
+lemma tan_minus [simp]: "tan (- x) = - tan x"
by (simp add: tan_def)
-lemma lemma_tan_add1:
- "\<lbrakk>cos x \<noteq> 0; cos y \<noteq> 0\<rbrakk> \<Longrightarrow> 1 - tan x * tan y = cos (x + y)/(cos x * cos y)"
+lemma tan_periodic [simp]: "tan (x + 2 * pi) = tan x"
+ by (simp add: tan_def)
+
+lemma lemma_tan_add1: "cos x \<noteq> 0 \<Longrightarrow> cos y \<noteq> 0 \<Longrightarrow> 1 - tan x * tan y = cos (x + y)/(cos x * cos y)"
by (simp add: tan_def cos_add field_simps)
-lemma add_tan_eq:
- fixes x :: "'a::{real_normed_field,banach}"
- shows "\<lbrakk>cos x \<noteq> 0; cos y \<noteq> 0\<rbrakk> \<Longrightarrow> tan x + tan y = sin(x + y)/(cos x * cos y)"
+lemma add_tan_eq: "cos x \<noteq> 0 \<Longrightarrow> cos y \<noteq> 0 \<Longrightarrow> tan x + tan y = sin(x + y)/(cos x * cos y)"
+ for x :: "'a::{real_normed_field,banach}"
by (simp add: tan_def sin_add field_simps)
lemma tan_add:
- fixes x :: "'a::{real_normed_field,banach}"
- shows
- "\<lbrakk>cos x \<noteq> 0; cos y \<noteq> 0; cos (x + y) \<noteq> 0\<rbrakk>
- \<Longrightarrow> tan(x + y) = (tan(x) + tan(y))/(1 - tan(x) * tan(y))"
- by (simp add: add_tan_eq lemma_tan_add1 field_simps) (simp add: tan_def)
-
-lemma tan_double:
- fixes x :: "'a::{real_normed_field,banach}"
- shows
- "\<lbrakk>cos x \<noteq> 0; cos (2 * x) \<noteq> 0\<rbrakk>
- \<Longrightarrow> tan (2 * x) = (2 * tan x) / (1 - (tan x)\<^sup>2)"
+ "cos x \<noteq> 0 \<Longrightarrow> cos y \<noteq> 0 \<Longrightarrow> cos (x + y) \<noteq> 0 \<Longrightarrow> tan (x + y) = (tan x + tan y)/(1 - tan x * tan y)"
+ for x :: "'a::{real_normed_field,banach}"
+ by (simp add: add_tan_eq lemma_tan_add1 field_simps) (simp add: tan_def)
+
+lemma tan_double: "cos x \<noteq> 0 \<Longrightarrow> cos (2 * x) \<noteq> 0 \<Longrightarrow> tan (2 * x) = (2 * tan x) / (1 - (tan x)\<^sup>2)"
+ for x :: "'a::{real_normed_field,banach}"
using tan_add [of x x] by (simp add: power2_eq_square)
-lemma tan_gt_zero: "\<lbrakk>0 < x; x < pi/2\<rbrakk> \<Longrightarrow> 0 < tan x"
+lemma tan_gt_zero: "0 < x \<Longrightarrow> x < pi/2 \<Longrightarrow> 0 < tan x"
by (simp add: tan_def zero_less_divide_iff sin_gt_zero2 cos_gt_zero_pi)
lemma tan_less_zero:
- assumes lb: "- pi/2 < x" and "x < 0"
+ assumes "- pi/2 < x" and "x < 0"
shows "tan x < 0"
proof -
- have "0 < tan (- x)" using assms by (simp only: tan_gt_zero)
- thus ?thesis by simp
+ have "0 < tan (- x)"
+ using assms by (simp only: tan_gt_zero)
+ then show ?thesis by simp
qed
-lemma tan_half:
- fixes x :: "'a::{real_normed_field,banach,field}"
- shows "tan x = sin (2 * x) / (cos (2 * x) + 1)"
+lemma tan_half: "tan x = sin (2 * x) / (cos (2 * x) + 1)"
+ for x :: "'a::{real_normed_field,banach,field}"
unfolding tan_def sin_double cos_double sin_squared_eq
by (simp add: power2_eq_square)
@@ -4174,25 +4204,23 @@
lemma tan_60: "tan (pi / 3) = sqrt 3"
unfolding tan_def by (simp add: sin_60 cos_60)
-lemma DERIV_tan [simp]:
- fixes x :: "'a::{real_normed_field,banach}"
- shows "cos x \<noteq> 0 \<Longrightarrow> DERIV tan x :> inverse ((cos x)\<^sup>2)"
+lemma DERIV_tan [simp]: "cos x \<noteq> 0 \<Longrightarrow> DERIV tan x :> inverse ((cos x)\<^sup>2)"
+ for x :: "'a::{real_normed_field,banach}"
unfolding tan_def
by (auto intro!: derivative_eq_intros, simp add: divide_inverse power2_eq_square)
-lemma isCont_tan:
- fixes x :: "'a::{real_normed_field,banach}"
- shows "cos x \<noteq> 0 \<Longrightarrow> isCont tan x"
+lemma isCont_tan: "cos x \<noteq> 0 \<Longrightarrow> isCont tan x"
+ for x :: "'a::{real_normed_field,banach}"
by (rule DERIV_tan [THEN DERIV_isCont])
lemma isCont_tan' [simp,continuous_intros]:
fixes a :: "'a::{real_normed_field,banach}" and f :: "'a \<Rightarrow> 'a"
- shows "\<lbrakk>isCont f a; cos (f a) \<noteq> 0\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. tan (f x)) a"
+ shows "isCont f a \<Longrightarrow> cos (f a) \<noteq> 0 \<Longrightarrow> isCont (\<lambda>x. tan (f x)) a"
by (rule isCont_o2 [OF _ isCont_tan])
lemma tendsto_tan [tendsto_intros]:
fixes f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
- shows "\<lbrakk>(f \<longlongrightarrow> a) F; cos a \<noteq> 0\<rbrakk> \<Longrightarrow> ((\<lambda>x. tan (f x)) \<longlongrightarrow> tan a) F"
+ shows "(f \<longlongrightarrow> a) F \<Longrightarrow> cos a \<noteq> 0 \<Longrightarrow> ((\<lambda>x. tan (f x)) \<longlongrightarrow> tan a) F"
by (rule isCont_tendsto_compose [OF isCont_tan])
lemma continuous_tan:
@@ -4207,61 +4235,69 @@
lemma continuous_within_tan [continuous_intros]:
fixes f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
- shows
- "continuous (at x within s) f \<Longrightarrow> cos (f x) \<noteq> 0 \<Longrightarrow> continuous (at x within s) (\<lambda>x. tan (f x))"
+ shows "continuous (at x within s) f \<Longrightarrow>
+ cos (f x) \<noteq> 0 \<Longrightarrow> continuous (at x within s) (\<lambda>x. tan (f x))"
unfolding continuous_within by (rule tendsto_tan)
lemma LIM_cos_div_sin: "(\<lambda>x. cos(x)/sin(x)) \<midarrow>pi/2\<rightarrow> 0"
by (rule LIM_cong_limit, (rule tendsto_intros)+, simp_all)
-lemma lemma_tan_total: "0 < y ==> \<exists>x. 0 < x & x < pi/2 & y < tan x"
- apply (cut_tac LIM_cos_div_sin)
+lemma lemma_tan_total: "0 < y \<Longrightarrow> \<exists>x. 0 < x \<and> x < pi/2 \<and> y < tan x"
+ apply (insert LIM_cos_div_sin)
apply (simp only: LIM_eq)
- apply (drule_tac x = "inverse y" in spec, safe, force)
- apply (drule_tac ?d1.0 = s in pi_half_gt_zero [THEN [2] real_lbound_gt_zero], safe)
+ apply (drule_tac x = "inverse y" in spec)
+ apply safe
+ apply force
+ apply (drule_tac ?d1.0 = s in pi_half_gt_zero [THEN [2] real_lbound_gt_zero])
+ apply safe
apply (rule_tac x = "(pi/2) - e" in exI)
apply (simp (no_asm_simp))
apply (drule_tac x = "(pi/2) - e" in spec)
apply (auto simp add: tan_def sin_diff cos_diff)
apply (rule inverse_less_iff_less [THEN iffD1])
- apply (auto simp add: divide_inverse)
- apply (rule mult_pos_pos)
- apply (subgoal_tac [3] "0 < sin e & 0 < cos e")
- apply (auto intro: cos_gt_zero sin_gt_zero2 simp add: mult.commute)
+ apply (auto simp add: divide_inverse)
+ apply (rule mult_pos_pos)
+ apply (subgoal_tac [3] "0 < sin e \<and> 0 < cos e")
+ apply (auto intro: cos_gt_zero sin_gt_zero2 simp: mult.commute)
done
-lemma tan_total_pos: "0 \<le> y ==> \<exists>x. 0 \<le> x & x < pi/2 & tan x = y"
- apply (frule order_le_imp_less_or_eq, safe)
+lemma tan_total_pos: "0 \<le> y \<Longrightarrow> \<exists>x. 0 \<le> x \<and> x < pi/2 \<and> tan x = y"
+ apply (frule order_le_imp_less_or_eq)
+ apply safe
prefer 2 apply force
- apply (drule lemma_tan_total, safe)
+ apply (drule lemma_tan_total)
+ apply safe
apply (cut_tac f = tan and a = 0 and b = x and y = y in IVT_objl)
apply (auto intro!: DERIV_tan [THEN DERIV_isCont])
apply (drule_tac y = xa in order_le_imp_less_or_eq)
apply (auto dest: cos_gt_zero)
done
-lemma lemma_tan_total1: "\<exists>x. -(pi/2) < x & x < (pi/2) & tan x = y"
- apply (cut_tac linorder_linear [of 0 y], safe)
- apply (drule tan_total_pos)
- apply (cut_tac [2] y="-y" in tan_total_pos, safe)
- apply (rule_tac [3] x = "-x" in exI)
- apply (auto del: exI intro!: exI)
+lemma lemma_tan_total1: "\<exists>x. -(pi/2) < x \<and> x < (pi/2) \<and> tan x = y"
+ apply (insert linorder_linear [of 0 y])
+ apply safe
+ apply (drule tan_total_pos)
+ apply (cut_tac [2] y="-y" in tan_total_pos)
+ apply safe
+ apply (rule_tac [3] x = "-x" in exI)
+ apply (auto del: exI intro!: exI)
done
-lemma tan_total: "EX! x. -(pi/2) < x & x < (pi/2) & tan x = y"
- apply (cut_tac y = y in lemma_tan_total1, auto)
+lemma tan_total: "\<exists>! x. -(pi/2) < x \<and> x < (pi/2) \<and> tan x = y"
+ apply (insert lemma_tan_total1 [where y = y])
+ apply auto
apply hypsubst_thin
- apply (cut_tac x = xa and y = y in linorder_less_linear, auto)
- apply (subgoal_tac [2] "\<exists>z. y < z & z < xa & DERIV tan z :> 0")
- apply (subgoal_tac "\<exists>z. xa < z & z < y & DERIV tan z :> 0")
- apply (rule_tac [4] Rolle)
- apply (rule_tac [2] Rolle)
- apply (auto del: exI intro!: DERIV_tan DERIV_isCont exI
- simp add: real_differentiable_def)
- txt\<open>Now, simulate TRYALL\<close>
- apply (rule_tac [!] DERIV_tan asm_rl)
- apply (auto dest!: DERIV_unique [OF _ DERIV_tan]
- simp add: cos_gt_zero_pi [THEN less_imp_neq, THEN not_sym])
+ apply (cut_tac x = xa and y = y in linorder_less_linear)
+ apply auto
+ apply (subgoal_tac [2] "\<exists>z. y < z \<and> z < xa \<and> DERIV tan z :> 0")
+ apply (subgoal_tac "\<exists>z. xa < z \<and> z < y \<and> DERIV tan z :> 0")
+ apply (rule_tac [4] Rolle)
+ apply (rule_tac [2] Rolle)
+ apply (auto del: exI intro!: DERIV_tan DERIV_isCont exI
+ simp add: real_differentiable_def)
+ apply (rule_tac [!] DERIV_tan asm_rl)
+ apply (auto dest!: DERIV_unique [OF _ DERIV_tan]
+ simp add: cos_gt_zero_pi [THEN less_imp_neq, THEN not_sym])
done
lemma tan_monotone:
@@ -4272,20 +4308,26 @@
proof (rule allI, rule impI)
fix x' :: real
assume "y \<le> x' \<and> x' \<le> x"
- hence "-(pi/2) < x'" and "x' < pi/2" using assms by auto
+ then have "-(pi/2) < x'" and "x' < pi/2"
+ using assms by auto
from cos_gt_zero_pi[OF this]
have "cos x' \<noteq> 0" by auto
- thus "DERIV tan x' :> inverse ((cos x')\<^sup>2)" by (rule DERIV_tan)
+ then show "DERIV tan x' :> inverse ((cos x')\<^sup>2)"
+ by (rule DERIV_tan)
qed
from MVT2[OF \<open>y < x\<close> this]
obtain z where "y < z" and "z < x"
and tan_diff: "tan x - tan y = (x - y) * inverse ((cos z)\<^sup>2)" by auto
- hence "- (pi / 2) < z" and "z < pi / 2" using assms by auto
- hence "0 < cos z" using cos_gt_zero_pi by auto
- hence inv_pos: "0 < inverse ((cos z)\<^sup>2)" by auto
+ then have "- (pi / 2) < z" and "z < pi / 2"
+ using assms by auto
+ then have "0 < cos z"
+ using cos_gt_zero_pi by auto
+ then have inv_pos: "0 < inverse ((cos z)\<^sup>2)"
+ by auto
have "0 < x - y" using \<open>y < x\<close> by auto
- with inv_pos have "0 < tan x - tan y" unfolding tan_diff by auto
- thus ?thesis by auto
+ with inv_pos have "0 < tan x - tan y"
+ unfolding tan_diff by auto
+ then show ?thesis by auto
qed
lemma tan_monotone':
@@ -4293,24 +4335,29 @@
and "y < pi / 2"
and "- (pi / 2) < x"
and "x < pi / 2"
- shows "(y < x) = (tan y < tan x)"
+ shows "y < x \<longleftrightarrow> tan y < tan x"
proof
assume "y < x"
- thus "tan y < tan x"
+ then show "tan y < tan x"
using tan_monotone and \<open>- (pi / 2) < y\<close> and \<open>x < pi / 2\<close> by auto
next
assume "tan y < tan x"
show "y < x"
proof (rule ccontr)
- assume "\<not> y < x" hence "x \<le> y" by auto
- hence "tan x \<le> tan y"
+ assume "\<not> ?thesis"
+ then have "x \<le> y" by auto
+ then have "tan x \<le> tan y"
proof (cases "x = y")
- case True thus ?thesis by auto
+ case True
+ then show ?thesis by auto
next
- case False hence "x < y" using \<open>x \<le> y\<close> by auto
- from tan_monotone[OF \<open>- (pi/2) < x\<close> this \<open>y < pi / 2\<close>] show ?thesis by auto
+ case False
+ then have "x < y" using \<open>x \<le> y\<close> by auto
+ from tan_monotone[OF \<open>- (pi/2) < x\<close> this \<open>y < pi / 2\<close>] show ?thesis
+ by auto
qed
- thus False using \<open>tan y < tan x\<close> by auto
+ then show False
+ using \<open>tan y < tan x\<close> by auto
qed
qed
@@ -4320,9 +4367,8 @@
lemma tan_periodic_pi[simp]: "tan (x + pi) = tan x"
by (simp add: tan_def)
-lemma tan_periodic_nat[simp]:
- fixes n :: nat
- shows "tan (x + real n * pi) = tan x"
+lemma tan_periodic_nat[simp]: "tan (x + real n * pi) = tan x"
+ for n :: nat
proof (induct n arbitrary: x)
case 0
then show ?case by simp
@@ -4330,18 +4376,19 @@
case (Suc n)
have split_pi_off: "x + real (Suc n) * pi = (x + real n * pi) + pi"
unfolding Suc_eq_plus1 of_nat_add distrib_right by auto
- show ?case unfolding split_pi_off using Suc by auto
+ show ?case
+ unfolding split_pi_off using Suc by auto
qed
-lemma tan_periodic_int[simp]: fixes i :: int shows "tan (x + of_int i * pi) = tan x"
+lemma tan_periodic_int[simp]: "tan (x + of_int i * pi) = tan x"
proof (cases "0 \<le> i")
case True
- hence i_nat: "of_int i = of_int (nat i)" by auto
+ then have i_nat: "of_int i = of_int (nat i)" by auto
show ?thesis unfolding i_nat
by (metis of_int_of_nat_eq tan_periodic_nat)
next
case False
- hence i_nat: "of_int i = - of_int (nat (-i))" by auto
+ then have i_nat: "of_int i = - of_int (nat (- i))" by auto
have "tan x = tan (x + of_int i * pi - of_int i * pi)"
by auto
also have "\<dots> = tan (x + of_int i * pi)"
@@ -4357,34 +4404,30 @@
unfolding tan_def by (simp add: sin_45 cos_45)
lemma tan_diff:
- fixes x :: "'a::{real_normed_field,banach}"
- shows
- "\<lbrakk>cos x \<noteq> 0; cos y \<noteq> 0; cos (x - y) \<noteq> 0\<rbrakk>
- \<Longrightarrow> tan(x - y) = (tan(x) - tan(y))/(1 + tan(x) * tan(y))"
- using tan_add [of x "-y"]
- by simp
-
-
-lemma tan_pos_pi2_le: "0 \<le> x ==> x < pi/2 \<Longrightarrow> 0 \<le> tan x"
+ "cos x \<noteq> 0 \<Longrightarrow> cos y \<noteq> 0 \<Longrightarrow> cos (x - y) \<noteq> 0 \<Longrightarrow> tan (x - y) = (tan x - tan y)/(1 + tan x * tan y)"
+ for x :: "'a::{real_normed_field,banach}"
+ using tan_add [of x "-y"] by simp
+
+lemma tan_pos_pi2_le: "0 \<le> x \<Longrightarrow> x < pi/2 \<Longrightarrow> 0 \<le> tan x"
using less_eq_real_def tan_gt_zero by auto
-lemma cos_tan: "\<bar>x\<bar> < pi/2 \<Longrightarrow> cos(x) = 1 / sqrt(1 + tan(x) ^ 2)"
+lemma cos_tan: "\<bar>x\<bar> < pi/2 \<Longrightarrow> cos x = 1 / sqrt (1 + tan x ^ 2)"
using cos_gt_zero_pi [of x]
by (simp add: divide_simps tan_def real_sqrt_divide abs_if split: if_split_asm)
-lemma sin_tan: "\<bar>x\<bar> < pi/2 \<Longrightarrow> sin(x) = tan(x) / sqrt(1 + tan(x) ^ 2)"
+lemma sin_tan: "\<bar>x\<bar> < pi/2 \<Longrightarrow> sin x = tan x / sqrt (1 + tan x ^ 2)"
using cos_gt_zero [of "x"] cos_gt_zero [of "-x"]
by (force simp add: divide_simps tan_def real_sqrt_divide abs_if split: if_split_asm)
-lemma tan_mono_le: "-(pi/2) < x ==> x \<le> y ==> y < pi/2 \<Longrightarrow> tan(x) \<le> tan(y)"
+lemma tan_mono_le: "-(pi/2) < x \<Longrightarrow> x \<le> y \<Longrightarrow> y < pi/2 \<Longrightarrow> tan x \<le> tan y"
using less_eq_real_def tan_monotone by auto
-lemma tan_mono_lt_eq: "-(pi/2) < x ==> x < pi/2 ==> -(pi/2) < y ==> y < pi/2
- \<Longrightarrow> (tan(x) < tan(y) \<longleftrightarrow> x < y)"
+lemma tan_mono_lt_eq:
+ "-(pi/2) < x \<Longrightarrow> x < pi/2 \<Longrightarrow> -(pi/2) < y \<Longrightarrow> y < pi/2 \<Longrightarrow> tan x < tan y \<longleftrightarrow> x < y"
using tan_monotone' by blast
-lemma tan_mono_le_eq: "-(pi/2) < x ==> x < pi/2 ==> -(pi/2) < y ==> y < pi/2
- \<Longrightarrow> (tan(x) \<le> tan(y) \<longleftrightarrow> x \<le> y)"
+lemma tan_mono_le_eq:
+ "-(pi/2) < x \<Longrightarrow> x < pi/2 \<Longrightarrow> -(pi/2) < y \<Longrightarrow> y < pi/2 \<Longrightarrow> tan x \<le> tan y \<longleftrightarrow> x \<le> y"
by (meson tan_mono_le not_le tan_monotone)
lemma tan_bound_pi2: "\<bar>x\<bar> < pi/4 \<Longrightarrow> \<bar>tan x\<bar> < 1"
@@ -4394,18 +4437,17 @@
lemma tan_cot: "tan(pi/2 - x) = inverse(tan x)"
by (simp add: tan_def sin_diff cos_diff)
+
subsection \<open>Cotangent\<close>
definition cot :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
where "cot = (\<lambda>x. cos x / sin x)"
-lemma cot_of_real:
- "of_real (cot x) = (cot (of_real x) :: 'a::{real_normed_field,banach})"
+lemma cot_of_real: "of_real (cot x) = (cot (of_real x) :: 'a::{real_normed_field,banach})"
by (simp add: cot_def sin_of_real cos_of_real)
-lemma cot_in_Reals [simp]:
- fixes z :: "'a::{real_normed_field,banach}"
- shows "z \<in> \<real> \<Longrightarrow> cot z \<in> \<real>"
+lemma cot_in_Reals [simp]: "z \<in> \<real> \<Longrightarrow> cot z \<in> \<real>"
+ for z :: "'a::{real_normed_field,banach}"
by (simp add: cot_def)
lemma cot_zero [simp]: "cot 0 = 0"
@@ -4414,13 +4456,14 @@
lemma cot_pi [simp]: "cot pi = 0"
by (simp add: cot_def)
-lemma cot_npi [simp]: "cot (real (n::nat) * pi) = 0"
+lemma cot_npi [simp]: "cot (real n * pi) = 0"
+ for n :: nat
by (simp add: cot_def)
-lemma cot_minus [simp]: "cot (-x) = - cot x"
+lemma cot_minus [simp]: "cot (- x) = - cot x"
by (simp add: cot_def)
-lemma cot_periodic [simp]: "cot (x + 2*pi) = cot x"
+lemma cot_periodic [simp]: "cot (x + 2 * pi) = cot x"
by (simp add: cot_def)
lemma cot_altdef: "cot x = inverse (tan x)"
@@ -4429,44 +4472,42 @@
lemma tan_altdef: "tan x = inverse (cot x)"
by (simp add: cot_def tan_def)
-lemma tan_cot': "tan(pi/2 - x) = cot x"
+lemma tan_cot': "tan (pi/2 - x) = cot x"
by (simp add: tan_cot cot_altdef)
-lemma cot_gt_zero: "\<lbrakk>0 < x; x < pi/2\<rbrakk> \<Longrightarrow> 0 < cot x"
+lemma cot_gt_zero: "0 < x \<Longrightarrow> x < pi/2 \<Longrightarrow> 0 < cot x"
by (simp add: cot_def zero_less_divide_iff sin_gt_zero2 cos_gt_zero_pi)
lemma cot_less_zero:
assumes lb: "- pi/2 < x" and "x < 0"
shows "cot x < 0"
proof -
- have "0 < cot (- x)" using assms by (simp only: cot_gt_zero)
- thus ?thesis by simp
+ have "0 < cot (- x)"
+ using assms by (simp only: cot_gt_zero)
+ then show ?thesis by simp
qed
-lemma DERIV_cot [simp]:
- fixes x :: "'a::{real_normed_field,banach}"
- shows "sin x \<noteq> 0 \<Longrightarrow> DERIV cot x :> -inverse ((sin x)\<^sup>2)"
+lemma DERIV_cot [simp]: "sin x \<noteq> 0 \<Longrightarrow> DERIV cot x :> -inverse ((sin x)\<^sup>2)"
+ for x :: "'a::{real_normed_field,banach}"
unfolding cot_def using cos_squared_eq[of x]
- by (auto intro!: derivative_eq_intros, simp add: divide_inverse power2_eq_square)
-
-lemma isCont_cot:
- fixes x :: "'a::{real_normed_field,banach}"
- shows "sin x \<noteq> 0 \<Longrightarrow> isCont cot x"
+ by (auto intro!: derivative_eq_intros) (simp add: divide_inverse power2_eq_square)
+
+lemma isCont_cot: "sin x \<noteq> 0 \<Longrightarrow> isCont cot x"
+ for x :: "'a::{real_normed_field,banach}"
by (rule DERIV_cot [THEN DERIV_isCont])
lemma isCont_cot' [simp,continuous_intros]:
- fixes a :: "'a::{real_normed_field,banach}" and f :: "'a \<Rightarrow> 'a"
- shows "\<lbrakk>isCont f a; sin (f a) \<noteq> 0\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. cot (f x)) a"
+ "isCont f a \<Longrightarrow> sin (f a) \<noteq> 0 \<Longrightarrow> isCont (\<lambda>x. cot (f x)) a"
+ for a :: "'a::{real_normed_field,banach}" and f :: "'a \<Rightarrow> 'a"
by (rule isCont_o2 [OF _ isCont_cot])
-lemma tendsto_cot [tendsto_intros]:
- fixes f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
- shows "\<lbrakk>(f \<longlongrightarrow> a) F; sin a \<noteq> 0\<rbrakk> \<Longrightarrow> ((\<lambda>x. cot (f x)) \<longlongrightarrow> cot a) F"
+lemma tendsto_cot [tendsto_intros]: "(f \<longlongrightarrow> a) F \<Longrightarrow> sin a \<noteq> 0 \<Longrightarrow> ((\<lambda>x. cot (f x)) \<longlongrightarrow> cot a) F"
+ for f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
by (rule isCont_tendsto_compose [OF isCont_cot])
lemma continuous_cot:
- fixes f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
- shows "continuous F f \<Longrightarrow> sin (f (Lim F (\<lambda>x. x))) \<noteq> 0 \<Longrightarrow> continuous F (\<lambda>x. cot (f x))"
+ "continuous F f \<Longrightarrow> sin (f (Lim F (\<lambda>x. x))) \<noteq> 0 \<Longrightarrow> continuous F (\<lambda>x. cot (f x))"
+ for f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
unfolding continuous_def by (rule tendsto_cot)
lemma continuous_on_cot [continuous_intros]:
@@ -4476,167 +4517,164 @@
lemma continuous_within_cot [continuous_intros]:
fixes f :: "'a \<Rightarrow> 'a::{real_normed_field,banach}"
- shows
- "continuous (at x within s) f \<Longrightarrow> sin (f x) \<noteq> 0 \<Longrightarrow> continuous (at x within s) (\<lambda>x. cot (f x))"
+ shows "continuous (at x within s) f \<Longrightarrow> sin (f x) \<noteq> 0 \<Longrightarrow> continuous (at x within s) (\<lambda>x. cot (f x))"
unfolding continuous_within by (rule tendsto_cot)
subsection \<open>Inverse Trigonometric Functions\<close>
-definition arcsin :: "real => real"
- where "arcsin y = (THE x. -(pi/2) \<le> x & x \<le> pi/2 & sin x = y)"
-
-definition arccos :: "real => real"
- where "arccos y = (THE x. 0 \<le> x & x \<le> pi & cos x = y)"
-
-definition arctan :: "real => real"
- where "arctan y = (THE x. -(pi/2) < x & x < pi/2 & tan x = y)"
-
-lemma arcsin:
- "-1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow>
- -(pi/2) \<le> arcsin y & arcsin y \<le> pi/2 & sin(arcsin y) = y"
+definition arcsin :: "real \<Rightarrow> real"
+ where "arcsin y = (THE x. -(pi/2) \<le> x \<and> x \<le> pi/2 \<and> sin x = y)"
+
+definition arccos :: "real \<Rightarrow> real"
+ where "arccos y = (THE x. 0 \<le> x \<and> x \<le> pi \<and> cos x = y)"
+
+definition arctan :: "real \<Rightarrow> real"
+ where "arctan y = (THE x. -(pi/2) < x \<and> x < pi/2 \<and> tan x = y)"
+
+lemma arcsin: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> - (pi/2) \<le> arcsin y \<and> arcsin y \<le> pi/2 \<and> sin (arcsin y) = y"
unfolding arcsin_def by (rule theI' [OF sin_total])
-lemma arcsin_pi:
- "-1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> -(pi/2) \<le> arcsin y & arcsin y \<le> pi & sin(arcsin y) = y"
- apply (drule (1) arcsin)
- apply (force intro: order_trans)
- done
-
-lemma sin_arcsin [simp]: "-1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> sin(arcsin y) = y"
+lemma arcsin_pi: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> - (pi/2) \<le> arcsin y \<and> arcsin y \<le> pi \<and> sin (arcsin y) = y"
+ by (drule (1) arcsin) (force intro: order_trans)
+
+lemma sin_arcsin [simp]: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> sin (arcsin y) = y"
+ by (blast dest: arcsin)
+
+lemma arcsin_bounded: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> - (pi/2) \<le> arcsin y \<and> arcsin y \<le> pi/2"
by (blast dest: arcsin)
-lemma arcsin_bounded: "-1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> -(pi/2) \<le> arcsin y & arcsin y \<le> pi/2"
- by (blast dest: arcsin)
-
-lemma arcsin_lbound: "-1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> -(pi/2) \<le> arcsin y"
+lemma arcsin_lbound: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> - (pi/2) \<le> arcsin y"
by (blast dest: arcsin)
-lemma arcsin_ubound: "-1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arcsin y \<le> pi/2"
+lemma arcsin_ubound: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arcsin y \<le> pi/2"
by (blast dest: arcsin)
-lemma arcsin_lt_bounded:
- "\<lbrakk>-1 < y; y < 1\<rbrakk> \<Longrightarrow> -(pi/2) < arcsin y & arcsin y < pi/2"
+lemma arcsin_lt_bounded: "- 1 < y \<Longrightarrow> y < 1 \<Longrightarrow> - (pi/2) < arcsin y \<and> arcsin y < pi/2"
apply (frule order_less_imp_le)
apply (frule_tac y = y in order_less_imp_le)
apply (frule arcsin_bounded)
- apply (safe, simp)
- apply (drule_tac y = "arcsin y" in order_le_imp_less_or_eq)
- apply (drule_tac [2] y = "pi/2" in order_le_imp_less_or_eq, safe)
- apply (drule_tac [!] f = sin in arg_cong, auto)
+ apply safe
+ apply simp
+ apply (drule_tac y = "arcsin y" in order_le_imp_less_or_eq)
+ apply (drule_tac [2] y = "pi/2" in order_le_imp_less_or_eq)
+ apply safe
+ apply (drule_tac [!] f = sin in arg_cong)
+ apply auto
done
-lemma arcsin_sin: "\<lbrakk>-(pi/2) \<le> x; x \<le> pi/2\<rbrakk> \<Longrightarrow> arcsin(sin x) = x"
+lemma arcsin_sin: "- (pi/2) \<le> x \<Longrightarrow> x \<le> pi/2 \<Longrightarrow> arcsin (sin x) = x"
apply (unfold arcsin_def)
apply (rule the1_equality)
- apply (rule sin_total, auto)
+ apply (rule sin_total)
+ apply auto
done
lemma arcsin_0 [simp]: "arcsin 0 = 0"
- using arcsin_sin [of 0]
- by simp
+ using arcsin_sin [of 0] by simp
lemma arcsin_1 [simp]: "arcsin 1 = pi/2"
- using arcsin_sin [of "pi/2"]
- by simp
-
-lemma arcsin_minus_1 [simp]: "arcsin (-1) = - (pi/2)"
- using arcsin_sin [of "-pi/2"]
- by simp
-
-lemma arcsin_minus: "-1 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> arcsin(-x) = -arcsin x"
+ using arcsin_sin [of "pi/2"] by simp
+
+lemma arcsin_minus_1 [simp]: "arcsin (- 1) = - (pi/2)"
+ using arcsin_sin [of "- pi/2"] by simp
+
+lemma arcsin_minus: "- 1 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> arcsin (- x) = - arcsin x"
by (metis (no_types, hide_lams) arcsin arcsin_sin minus_minus neg_le_iff_le sin_minus)
-lemma arcsin_eq_iff: "\<bar>x\<bar> \<le> 1 \<Longrightarrow> \<bar>y\<bar> \<le> 1 \<Longrightarrow> (arcsin x = arcsin y \<longleftrightarrow> x = y)"
+lemma arcsin_eq_iff: "\<bar>x\<bar> \<le> 1 \<Longrightarrow> \<bar>y\<bar> \<le> 1 \<Longrightarrow> arcsin x = arcsin y \<longleftrightarrow> x = y"
by (metis abs_le_iff arcsin minus_le_iff)
-lemma cos_arcsin_nonzero: "-1 < x \<Longrightarrow> x < 1 \<Longrightarrow> cos(arcsin x) \<noteq> 0"
+lemma cos_arcsin_nonzero: "- 1 < x \<Longrightarrow> x < 1 \<Longrightarrow> cos (arcsin x) \<noteq> 0"
using arcsin_lt_bounded cos_gt_zero_pi by force
-lemma arccos:
- "\<lbrakk>-1 \<le> y; y \<le> 1\<rbrakk>
- \<Longrightarrow> 0 \<le> arccos y & arccos y \<le> pi & cos(arccos y) = y"
+lemma arccos: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> 0 \<le> arccos y \<and> arccos y \<le> pi \<and> cos (arccos y) = y"
unfolding arccos_def by (rule theI' [OF cos_total])
-lemma cos_arccos [simp]: "\<lbrakk>-1 \<le> y; y \<le> 1\<rbrakk> \<Longrightarrow> cos(arccos y) = y"
+lemma cos_arccos [simp]: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> cos (arccos y) = y"
by (blast dest: arccos)
-lemma arccos_bounded: "\<lbrakk>-1 \<le> y; y \<le> 1\<rbrakk> \<Longrightarrow> 0 \<le> arccos y & arccos y \<le> pi"
+lemma arccos_bounded: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> 0 \<le> arccos y \<and> arccos y \<le> pi"
by (blast dest: arccos)
-lemma arccos_lbound: "\<lbrakk>-1 \<le> y; y \<le> 1\<rbrakk> \<Longrightarrow> 0 \<le> arccos y"
+lemma arccos_lbound: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> 0 \<le> arccos y"
by (blast dest: arccos)
-lemma arccos_ubound: "\<lbrakk>-1 \<le> y; y \<le> 1\<rbrakk> \<Longrightarrow> arccos y \<le> pi"
+lemma arccos_ubound: "- 1 \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arccos y \<le> pi"
by (blast dest: arccos)
-lemma arccos_lt_bounded:
- "\<lbrakk>-1 < y; y < 1\<rbrakk> \<Longrightarrow> 0 < arccos y & arccos y < pi"
+lemma arccos_lt_bounded: "- 1 < y \<Longrightarrow> y < 1 \<Longrightarrow> 0 < arccos y \<and> arccos y < pi"
apply (frule order_less_imp_le)
apply (frule_tac y = y in order_less_imp_le)
- apply (frule arccos_bounded, auto)
- apply (drule_tac y = "arccos y" in order_le_imp_less_or_eq)
- apply (drule_tac [2] y = pi in order_le_imp_less_or_eq, auto)
- apply (drule_tac [!] f = cos in arg_cong, auto)
+ apply (frule arccos_bounded)
+ apply auto
+ apply (drule_tac y = "arccos y" in order_le_imp_less_or_eq)
+ apply (drule_tac [2] y = pi in order_le_imp_less_or_eq)
+ apply auto
+ apply (drule_tac [!] f = cos in arg_cong)
+ apply auto
done
-lemma arccos_cos: "\<lbrakk>0 \<le> x; x \<le> pi\<rbrakk> \<Longrightarrow> arccos(cos x) = x"
- apply (simp add: arccos_def)
- apply (auto intro!: the1_equality cos_total)
- done
-
-lemma arccos_cos2: "\<lbrakk>x \<le> 0; -pi \<le> x\<rbrakk> \<Longrightarrow> arccos(cos x) = -x"
- apply (simp add: arccos_def)
- apply (auto intro!: the1_equality cos_total)
- done
-
-lemma cos_arcsin: "\<lbrakk>-1 \<le> x; x \<le> 1\<rbrakk> \<Longrightarrow> cos (arcsin x) = sqrt (1 - x\<^sup>2)"
+lemma arccos_cos: "0 \<le> x \<Longrightarrow> x \<le> pi \<Longrightarrow> arccos (cos x) = x"
+ by (auto simp: arccos_def intro!: the1_equality cos_total)
+
+lemma arccos_cos2: "x \<le> 0 \<Longrightarrow> - pi \<le> x \<Longrightarrow> arccos (cos x) = -x"
+ by (auto simp: arccos_def intro!: the1_equality cos_total)
+
+lemma cos_arcsin: "- 1 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> cos (arcsin x) = sqrt (1 - x\<^sup>2)"
apply (subgoal_tac "x\<^sup>2 \<le> 1")
- apply (rule power2_eq_imp_eq)
- apply (simp add: cos_squared_eq)
- apply (rule cos_ge_zero)
- apply (erule (1) arcsin_lbound)
- apply (erule (1) arcsin_ubound)
+ apply (rule power2_eq_imp_eq)
+ apply (simp add: cos_squared_eq)
+ apply (rule cos_ge_zero)
+ apply (erule (1) arcsin_lbound)
+ apply (erule (1) arcsin_ubound)
+ apply simp
+ apply (subgoal_tac "\<bar>x\<bar>\<^sup>2 \<le> 1\<^sup>2")
+ apply simp
+ apply (rule power_mono)
+ apply simp
apply simp
- apply (subgoal_tac "\<bar>x\<bar>\<^sup>2 \<le> 1\<^sup>2", simp)
- apply (rule power_mono, simp, simp)
done
-lemma sin_arccos: "\<lbrakk>-1 \<le> x; x \<le> 1\<rbrakk> \<Longrightarrow> sin (arccos x) = sqrt (1 - x\<^sup>2)"
+lemma sin_arccos: "- 1 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> sin (arccos x) = sqrt (1 - x\<^sup>2)"
apply (subgoal_tac "x\<^sup>2 \<le> 1")
- apply (rule power2_eq_imp_eq)
- apply (simp add: sin_squared_eq)
- apply (rule sin_ge_zero)
- apply (erule (1) arccos_lbound)
- apply (erule (1) arccos_ubound)
+ apply (rule power2_eq_imp_eq)
+ apply (simp add: sin_squared_eq)
+ apply (rule sin_ge_zero)
+ apply (erule (1) arccos_lbound)
+ apply (erule (1) arccos_ubound)
+ apply simp
+ apply (subgoal_tac "\<bar>x\<bar>\<^sup>2 \<le> 1\<^sup>2")
+ apply simp
+ apply (rule power_mono)
+ apply simp
apply simp
- apply (subgoal_tac "\<bar>x\<bar>\<^sup>2 \<le> 1\<^sup>2", simp)
- apply (rule power_mono, simp, simp)
done
lemma arccos_0 [simp]: "arccos 0 = pi/2"
-by (metis arccos_cos cos_gt_zero cos_pi cos_pi_half pi_gt_zero pi_half_ge_zero not_le not_zero_less_neg_numeral numeral_One)
+ by (metis arccos_cos cos_gt_zero cos_pi cos_pi_half pi_gt_zero
+ pi_half_ge_zero not_le not_zero_less_neg_numeral numeral_One)
lemma arccos_1 [simp]: "arccos 1 = 0"
using arccos_cos by force
-lemma arccos_minus_1 [simp]: "arccos(-1) = pi"
+lemma arccos_minus_1 [simp]: "arccos (- 1) = pi"
by (metis arccos_cos cos_pi order_refl pi_ge_zero)
-lemma arccos_minus: "-1 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> arccos(-x) = pi - arccos x"
+lemma arccos_minus: "-1 \<le> x \<Longrightarrow> x \<le> 1 \<Longrightarrow> arccos (- x) = pi - arccos x"
by (metis arccos_cos arccos_cos2 cos_minus_pi cos_total diff_le_0_iff_le le_add_same_cancel1
- minus_diff_eq uminus_add_conv_diff)
-
-lemma sin_arccos_nonzero: "-1 < x \<Longrightarrow> x < 1 \<Longrightarrow> ~(sin(arccos x) = 0)"
+ minus_diff_eq uminus_add_conv_diff)
+
+lemma sin_arccos_nonzero: "- 1 < x \<Longrightarrow> x < 1 \<Longrightarrow> \<not> sin (arccos x) = 0"
using arccos_lt_bounded sin_gt_zero by force
-lemma arctan: "- (pi/2) < arctan y & arctan y < pi/2 & tan (arctan y) = y"
+lemma arctan: "- (pi/2) < arctan y \<and> arctan y < pi/2 \<and> tan (arctan y) = y"
unfolding arctan_def by (rule theI' [OF tan_total])
lemma tan_arctan: "tan (arctan y) = y"
by (simp add: arctan)
-lemma arctan_bounded: "- (pi/2) < arctan y & arctan y < pi/2"
+lemma arctan_bounded: "- (pi/2) < arctan y \<and> arctan y < pi/2"
by (auto simp only: arctan)
lemma arctan_lbound: "- (pi/2) < arctan y"
@@ -4660,13 +4698,13 @@
lemma arctan_minus: "arctan (- x) = - arctan x"
apply (rule arctan_unique)
- apply (simp only: neg_less_iff_less arctan_ubound)
- apply (metis minus_less_iff arctan_lbound, simp add: arctan)
+ apply (simp only: neg_less_iff_less arctan_ubound)
+ apply (metis minus_less_iff arctan_lbound)
+ apply (simp add: arctan)
done
lemma cos_arctan_not_zero [simp]: "cos (arctan x) \<noteq> 0"
- by (intro less_imp_neq [symmetric] cos_gt_zero_pi
- arctan_lbound arctan_ubound)
+ by (intro less_imp_neq [symmetric] cos_gt_zero_pi arctan_lbound arctan_ubound)
lemma cos_arctan: "cos (arctan x) = 1 / sqrt (1 + x\<^sup>2)"
proof (rule power2_eq_imp_eq)
@@ -4676,7 +4714,7 @@
by (intro less_imp_le cos_gt_zero_pi arctan_lbound arctan_ubound)
have "(cos (arctan x))\<^sup>2 * (1 + (tan (arctan x))\<^sup>2) = 1"
unfolding tan_def by (simp add: distrib_left power_divide)
- thus "(cos (arctan x))\<^sup>2 = (1 / sqrt (1 + x\<^sup>2))\<^sup>2"
+ then show "(cos (arctan x))\<^sup>2 = (1 / sqrt (1 + x\<^sup>2))\<^sup>2"
using \<open>0 < 1 + x\<^sup>2\<close> by (simp add: arctan power_divide eq_divide_eq)
qed
@@ -4685,12 +4723,11 @@
using tan_arctan [of x] unfolding tan_def cos_arctan
by (simp add: eq_divide_eq)
-lemma tan_sec:
- fixes x :: "'a::{real_normed_field,banach,field}"
- shows "cos x \<noteq> 0 \<Longrightarrow> 1 + (tan x)\<^sup>2 = (inverse (cos x))\<^sup>2"
+lemma tan_sec: "cos x \<noteq> 0 \<Longrightarrow> 1 + (tan x)\<^sup>2 = (inverse (cos x))\<^sup>2"
+ for x :: "'a::{real_normed_field,banach,field}"
apply (rule power_inverse [THEN subst])
apply (rule_tac c1 = "(cos x)\<^sup>2" in mult_right_cancel [THEN iffD1])
- apply (auto simp add: tan_def field_simps)
+ apply (auto simp add: tan_def field_simps)
done
lemma arctan_less_iff: "arctan x < arctan y \<longleftrightarrow> x < y"
@@ -4766,11 +4803,14 @@
by (auto simp: continuous_on_eq_continuous_at subset_eq)
lemma isCont_arctan: "isCont arctan x"
- apply (rule arctan_lbound [of x, THEN dense, THEN exE], clarify)
- apply (rule arctan_ubound [of x, THEN dense, THEN exE], clarify)
- apply (subgoal_tac "isCont arctan (tan (arctan x))", simp add: arctan)
+ apply (rule arctan_lbound [of x, THEN dense, THEN exE])
+ apply clarify
+ apply (rule arctan_ubound [of x, THEN dense, THEN exE])
+ apply clarify
+ apply (subgoal_tac "isCont arctan (tan (arctan x))")
+ apply (simp add: arctan)
apply (erule (1) isCont_inverse_function2 [where f=tan])
- apply (metis arctan_tan order_le_less_trans order_less_le_trans)
+ apply (metis arctan_tan order_le_less_trans order_less_le_trans)
apply (metis cos_gt_zero_pi isCont_tan order_less_le_trans less_le)
done
@@ -4780,38 +4820,50 @@
lemma continuous_arctan [continuous_intros]: "continuous F f \<Longrightarrow> continuous F (\<lambda>x. arctan (f x))"
unfolding continuous_def by (rule tendsto_arctan)
-lemma continuous_on_arctan [continuous_intros]: "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. arctan (f x))"
+lemma continuous_on_arctan [continuous_intros]:
+ "continuous_on s f \<Longrightarrow> continuous_on s (\<lambda>x. arctan (f x))"
unfolding continuous_on_def by (auto intro: tendsto_arctan)
-lemma DERIV_arcsin:
- "\<lbrakk>-1 < x; x < 1\<rbrakk> \<Longrightarrow> DERIV arcsin x :> inverse (sqrt (1 - x\<^sup>2))"
+lemma DERIV_arcsin: "- 1 < x \<Longrightarrow> x < 1 \<Longrightarrow> DERIV arcsin x :> inverse (sqrt (1 - x\<^sup>2))"
apply (rule DERIV_inverse_function [where f=sin and a="-1" and b=1])
- apply (rule DERIV_cong [OF DERIV_sin])
- apply (simp add: cos_arcsin)
- apply (subgoal_tac "\<bar>x\<bar>\<^sup>2 < 1\<^sup>2", simp)
- apply (rule power_strict_mono, simp, simp, simp, assumption, assumption)
- apply simp
+ apply (rule DERIV_cong [OF DERIV_sin])
+ apply (simp add: cos_arcsin)
+ apply (subgoal_tac "\<bar>x\<bar>\<^sup>2 < 1\<^sup>2")
+ apply simp
+ apply (rule power_strict_mono)
+ apply simp
+ apply simp
+ apply simp
+ apply assumption
+ apply assumption
+ apply simp
apply (erule (1) isCont_arcsin)
done
-lemma DERIV_arccos:
- "\<lbrakk>-1 < x; x < 1\<rbrakk> \<Longrightarrow> DERIV arccos x :> inverse (- sqrt (1 - x\<^sup>2))"
+lemma DERIV_arccos: "- 1 < x \<Longrightarrow> x < 1 \<Longrightarrow> DERIV arccos x :> inverse (- sqrt (1 - x\<^sup>2))"
apply (rule DERIV_inverse_function [where f=cos and a="-1" and b=1])
- apply (rule DERIV_cong [OF DERIV_cos])
- apply (simp add: sin_arccos)
- apply (subgoal_tac "\<bar>x\<bar>\<^sup>2 < 1\<^sup>2", simp)
- apply (rule power_strict_mono, simp, simp, simp, assumption, assumption)
- apply simp
+ apply (rule DERIV_cong [OF DERIV_cos])
+ apply (simp add: sin_arccos)
+ apply (subgoal_tac "\<bar>x\<bar>\<^sup>2 < 1\<^sup>2")
+ apply simp
+ apply (rule power_strict_mono)
+ apply simp
+ apply simp
+ apply simp
+ apply assumption
+ apply assumption
+ apply simp
apply (erule (1) isCont_arccos)
done
lemma DERIV_arctan: "DERIV arctan x :> inverse (1 + x\<^sup>2)"
apply (rule DERIV_inverse_function [where f=tan and a="x - 1" and b="x + 1"])
- apply (rule DERIV_cong [OF DERIV_tan])
- apply (rule cos_arctan_not_zero)
- apply (simp_all add: add_pos_nonneg arctan isCont_arctan)
- apply (simp add: arctan power_inverse [symmetric] tan_sec [symmetric])
- apply (subgoal_tac "0 < 1 + x\<^sup>2", simp)
+ apply (rule DERIV_cong [OF DERIV_tan])
+ apply (rule cos_arctan_not_zero)
+ apply (simp_all add: add_pos_nonneg arctan isCont_arctan)
+ apply (simp add: arctan power_inverse [symmetric] tan_sec [symmetric])
+ apply (subgoal_tac "0 < 1 + x\<^sup>2")
+ apply simp
apply (simp_all add: add_pos_nonneg arctan isCont_arctan)
done
@@ -4840,7 +4892,6 @@
define y where "y = pi/2 - min (pi/2) e"
then have y: "0 \<le> y" "y < pi/2" "pi/2 \<le> e + y"
using \<open>0 < e\<close> by auto
-
show "eventually (\<lambda>x. dist (arctan x) (pi / 2) < e) at_top"
proof (intro eventually_at_top_dense[THEN iffD2] exI allI impI)
fix x
@@ -4860,7 +4911,7 @@
by (intro tendsto_minus tendsto_arctan_at_top)
-subsection\<open>Prove Totality of the Trigonometric Functions\<close>
+subsection \<open>Prove Totality of the Trigonometric Functions\<close>
lemma cos_arccos_abs: "\<bar>y\<bar> \<le> 1 \<Longrightarrow> cos (arccos y) = y"
by (simp add: abs_le_iff)
@@ -4868,29 +4919,26 @@
lemma sin_arccos_abs: "\<bar>y\<bar> \<le> 1 \<Longrightarrow> sin (arccos y) = sqrt (1 - y\<^sup>2)"
by (simp add: sin_arccos abs_le_iff)
-lemma sin_mono_less_eq: "\<lbrakk>-(pi/2) \<le> x; x \<le> pi/2; -(pi/2) \<le> y; y \<le> pi/2\<rbrakk>
- \<Longrightarrow> (sin(x) < sin(y) \<longleftrightarrow> x < y)"
-by (metis not_less_iff_gr_or_eq sin_monotone_2pi)
-
-lemma sin_mono_le_eq: "\<lbrakk>-(pi/2) \<le> x; x \<le> pi/2; -(pi/2) \<le> y; y \<le> pi/2\<rbrakk>
- \<Longrightarrow> (sin(x) \<le> sin(y) \<longleftrightarrow> x \<le> y)"
-by (meson leD le_less_linear sin_monotone_2pi sin_monotone_2pi_le)
+lemma sin_mono_less_eq:
+ "- (pi/2) \<le> x \<Longrightarrow> x \<le> pi/2 \<Longrightarrow> - (pi/2) \<le> y \<Longrightarrow> y \<le> pi/2 \<Longrightarrow> sin x < sin y \<longleftrightarrow> x < y"
+ by (metis not_less_iff_gr_or_eq sin_monotone_2pi)
+
+lemma sin_mono_le_eq:
+ "- (pi/2) \<le> x \<Longrightarrow> x \<le> pi/2 \<Longrightarrow> - (pi/2) \<le> y \<Longrightarrow> y \<le> pi/2 \<Longrightarrow> sin x \<le> sin y \<longleftrightarrow> x \<le> y"
+ by (meson leD le_less_linear sin_monotone_2pi sin_monotone_2pi_le)
lemma sin_inj_pi:
- "\<lbrakk>-(pi/2) \<le> x; x \<le> pi/2;-(pi/2) \<le> y; y \<le> pi/2; sin(x) = sin(y)\<rbrakk> \<Longrightarrow> x = y"
-by (metis arcsin_sin)
-
-lemma cos_mono_less_eq:
- "0 \<le> x ==> x \<le> pi ==> 0 \<le> y ==> y \<le> pi \<Longrightarrow> (cos(x) < cos(y) \<longleftrightarrow> y < x)"
-by (meson cos_monotone_0_pi cos_monotone_0_pi_le leD le_less_linear)
-
-lemma cos_mono_le_eq: "0 \<le> x ==> x \<le> pi ==> 0 \<le> y ==> y \<le> pi
- \<Longrightarrow> (cos(x) \<le> cos(y) \<longleftrightarrow> y \<le> x)"
+ "- (pi/2) \<le> x \<Longrightarrow> x \<le> pi/2 \<Longrightarrow> - (pi/2) \<le> y \<Longrightarrow> y \<le> pi/2 \<Longrightarrow> sin x = sin y \<Longrightarrow> x = y"
+ by (metis arcsin_sin)
+
+lemma cos_mono_less_eq: "0 \<le> x \<Longrightarrow> x \<le> pi \<Longrightarrow> 0 \<le> y \<Longrightarrow> y \<le> pi \<Longrightarrow> cos x < cos y \<longleftrightarrow> y < x"
+ by (meson cos_monotone_0_pi cos_monotone_0_pi_le leD le_less_linear)
+
+lemma cos_mono_le_eq: "0 \<le> x \<Longrightarrow> x \<le> pi \<Longrightarrow> 0 \<le> y \<Longrightarrow> y \<le> pi \<Longrightarrow> cos x \<le> cos y \<longleftrightarrow> y \<le> x"
by (metis arccos_cos cos_monotone_0_pi_le eq_iff linear)
-lemma cos_inj_pi: "0 \<le> x ==> x \<le> pi ==> 0 \<le> y ==> y \<le> pi ==> cos(x) = cos(y)
- \<Longrightarrow> x = y"
-by (metis arccos_cos)
+lemma cos_inj_pi: "0 \<le> x \<Longrightarrow> x \<le> pi \<Longrightarrow> 0 \<le> y \<Longrightarrow> y \<le> pi \<Longrightarrow> cos x = cos y \<Longrightarrow> x = y"
+ by (metis arccos_cos)
lemma arccos_le_pi2: "\<lbrakk>0 \<le> y; y \<le> 1\<rbrakk> \<Longrightarrow> arccos y \<le> pi/2"
by (metis (mono_tags) arccos_0 arccos cos_le_one cos_monotone_0_pi_le
@@ -4898,109 +4946,97 @@
lemma sincos_total_pi_half:
assumes "0 \<le> x" "0 \<le> y" "x\<^sup>2 + y\<^sup>2 = 1"
- shows "\<exists>t. 0 \<le> t \<and> t \<le> pi/2 \<and> x = cos t \<and> y = sin t"
+ shows "\<exists>t. 0 \<le> t \<and> t \<le> pi/2 \<and> x = cos t \<and> y = sin t"
proof -
have x1: "x \<le> 1"
- using assms
- by (metis le_add_same_cancel1 power2_le_imp_le power_one zero_le_power2)
- with assms have ax: "0 \<le> arccos x" "cos (arccos x) = x"
+ using assms by (metis le_add_same_cancel1 power2_le_imp_le power_one zero_le_power2)
+ with assms have *: "0 \<le> arccos x" "cos (arccos x) = x"
by (auto simp: arccos)
from assms have "y = sqrt (1 - x\<^sup>2)"
by (metis abs_of_nonneg add.commute add_diff_cancel real_sqrt_abs)
- with x1 ax assms arccos_le_pi2 [of x] show ?thesis
+ with x1 * assms arccos_le_pi2 [of x] show ?thesis
by (rule_tac x="arccos x" in exI) (auto simp: sin_arccos)
qed
lemma sincos_total_pi:
- assumes "0 \<le> y" and "x\<^sup>2 + y\<^sup>2 = 1"
- shows "\<exists>t. 0 \<le> t \<and> t \<le> pi \<and> x = cos t \<and> y = sin t"
+ assumes "0 \<le> y" "x\<^sup>2 + y\<^sup>2 = 1"
+ shows "\<exists>t. 0 \<le> t \<and> t \<le> pi \<and> x = cos t \<and> y = sin t"
proof (cases rule: le_cases [of 0 x])
- case le from sincos_total_pi_half [OF le]
- show ?thesis
+ case le
+ from sincos_total_pi_half [OF le] show ?thesis
by (metis pi_ge_two pi_half_le_two add.commute add_le_cancel_left add_mono assms)
next
case ge
then have "0 \<le> -x"
by simp
- then obtain t where "t\<ge>0" "t \<le> pi/2" "-x = cos t" "y = sin t"
+ then obtain t where t: "t\<ge>0" "t \<le> pi/2" "-x = cos t" "y = sin t"
using sincos_total_pi_half assms
- apply auto
- by (metis \<open>0 \<le> - x\<close> power2_minus)
- then show ?thesis
- by (rule_tac x="pi-t" in exI, auto)
+ by auto (metis \<open>0 \<le> - x\<close> power2_minus)
+ show ?thesis
+ by (rule exI [where x = "pi -t"]) (use t in auto)
qed
lemma sincos_total_2pi_le:
assumes "x\<^sup>2 + y\<^sup>2 = 1"
- shows "\<exists>t. 0 \<le> t \<and> t \<le> 2*pi \<and> x = cos t \<and> y = sin t"
+ shows "\<exists>t. 0 \<le> t \<and> t \<le> 2 * pi \<and> x = cos t \<and> y = sin t"
proof (cases rule: le_cases [of 0 y])
- case le from sincos_total_pi [OF le]
- show ?thesis
+ case le
+ from sincos_total_pi [OF le] show ?thesis
by (metis assms le_add_same_cancel1 mult.commute mult_2_right order.trans)
next
case ge
then have "0 \<le> -y"
by simp
- then obtain t where "t\<ge>0" "t \<le> pi" "x = cos t" "-y = sin t"
+ then obtain t where t: "t\<ge>0" "t \<le> pi" "x = cos t" "-y = sin t"
using sincos_total_pi assms
- apply auto
- by (metis \<open>0 \<le> - y\<close> power2_minus)
- then show ?thesis
- by (rule_tac x="2*pi-t" in exI, auto)
+ by auto (metis \<open>0 \<le> - y\<close> power2_minus)
+ show ?thesis
+ by (rule exI [where x = "2 * pi - t"]) (use t in auto)
qed
lemma sincos_total_2pi:
assumes "x\<^sup>2 + y\<^sup>2 = 1"
- obtains t where "0 \<le> t" "t < 2*pi" "x = cos t" "y = sin t"
+ obtains t where "0 \<le> t" "t < 2*pi" "x = cos t" "y = sin t"
proof -
from sincos_total_2pi_le [OF assms]
obtain t where t: "0 \<le> t" "t \<le> 2*pi" "x = cos t" "y = sin t"
by blast
show ?thesis
- apply (cases "t = 2*pi")
- using t that
- apply force+
- done
+ by (cases "t = 2 * pi") (use t that in \<open>force+\<close>)
qed
lemma arcsin_less_mono: "\<bar>x\<bar> \<le> 1 \<Longrightarrow> \<bar>y\<bar> \<le> 1 \<Longrightarrow> arcsin x < arcsin y \<longleftrightarrow> x < y"
- apply (rule trans [OF sin_mono_less_eq [symmetric]])
- using arcsin_ubound arcsin_lbound
- apply auto
- done
+ by (rule trans [OF sin_mono_less_eq [symmetric]]) (use arcsin_ubound arcsin_lbound in auto)
lemma arcsin_le_mono: "\<bar>x\<bar> \<le> 1 \<Longrightarrow> \<bar>y\<bar> \<le> 1 \<Longrightarrow> arcsin x \<le> arcsin y \<longleftrightarrow> x \<le> y"
using arcsin_less_mono not_le by blast
-lemma arcsin_less_arcsin: "-1 \<le> x \<Longrightarrow> x < y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arcsin x < arcsin y"
+lemma arcsin_less_arcsin: "- 1 \<le> x \<Longrightarrow> x < y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arcsin x < arcsin y"
using arcsin_less_mono by auto
-lemma arcsin_le_arcsin: "-1 \<le> x \<Longrightarrow> x \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arcsin x \<le> arcsin y"
+lemma arcsin_le_arcsin: "- 1 \<le> x \<Longrightarrow> x \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arcsin x \<le> arcsin y"
using arcsin_le_mono by auto
-lemma arccos_less_mono: "\<bar>x\<bar> \<le> 1 \<Longrightarrow> \<bar>y\<bar> \<le> 1 \<Longrightarrow> (arccos x < arccos y \<longleftrightarrow> y < x)"
- apply (rule trans [OF cos_mono_less_eq [symmetric]])
- using arccos_ubound arccos_lbound
- apply auto
- done
+lemma arccos_less_mono: "\<bar>x\<bar> \<le> 1 \<Longrightarrow> \<bar>y\<bar> \<le> 1 \<Longrightarrow> arccos x < arccos y \<longleftrightarrow> y < x"
+ by (rule trans [OF cos_mono_less_eq [symmetric]]) (use arccos_ubound arccos_lbound in auto)
lemma arccos_le_mono: "\<bar>x\<bar> \<le> 1 \<Longrightarrow> \<bar>y\<bar> \<le> 1 \<Longrightarrow> arccos x \<le> arccos y \<longleftrightarrow> y \<le> x"
- using arccos_less_mono [of y x]
- by (simp add: not_le [symmetric])
-
-lemma arccos_less_arccos: "-1 \<le> x \<Longrightarrow> x < y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arccos y < arccos x"
+ using arccos_less_mono [of y x] by (simp add: not_le [symmetric])
+
+lemma arccos_less_arccos: "- 1 \<le> x \<Longrightarrow> x < y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arccos y < arccos x"
using arccos_less_mono by auto
-lemma arccos_le_arccos: "-1 \<le> x \<Longrightarrow> x \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arccos y \<le> arccos x"
+lemma arccos_le_arccos: "- 1 \<le> x \<Longrightarrow> x \<le> y \<Longrightarrow> y \<le> 1 \<Longrightarrow> arccos y \<le> arccos x"
using arccos_le_mono by auto
-lemma arccos_eq_iff: "\<bar>x\<bar> \<le> 1 & \<bar>y\<bar> \<le> 1 \<Longrightarrow> (arccos x = arccos y \<longleftrightarrow> x = y)"
+lemma arccos_eq_iff: "\<bar>x\<bar> \<le> 1 \<and> \<bar>y\<bar> \<le> 1 \<Longrightarrow> arccos x = arccos y \<longleftrightarrow> x = y"
using cos_arccos_abs by fastforce
-subsection \<open>Machins formula\<close>
+
+subsection \<open>Machin's formula\<close>
lemma arctan_one: "arctan 1 = pi / 4"
- by (rule arctan_unique, simp_all add: tan_45 m2pi_less_pi)
+ by (rule arctan_unique) (simp_all add: tan_45 m2pi_less_pi)
lemma tan_total_pi4:
assumes "\<bar>x\<bar> < 1"
@@ -5008,70 +5044,78 @@
proof
show "- (pi / 4) < arctan x \<and> arctan x < pi / 4 \<and> tan (arctan x) = x"
unfolding arctan_one [symmetric] arctan_minus [symmetric]
- unfolding arctan_less_iff using assms by (auto simp add: arctan)
-
+ unfolding arctan_less_iff
+ using assms by (auto simp add: arctan)
qed
lemma arctan_add:
- assumes "\<bar>x\<bar> \<le> 1" and "\<bar>y\<bar> < 1"
+ assumes "\<bar>x\<bar> \<le> 1" "\<bar>y\<bar> < 1"
shows "arctan x + arctan y = arctan ((x + y) / (1 - x * y))"
proof (rule arctan_unique [symmetric])
- have "- (pi / 4) \<le> arctan x" and "- (pi / 4) < arctan y"
+ have "- (pi / 4) \<le> arctan x" "- (pi / 4) < arctan y"
unfolding arctan_one [symmetric] arctan_minus [symmetric]
- unfolding arctan_le_iff arctan_less_iff using assms by auto
- from add_le_less_mono [OF this]
- show 1: "- (pi / 2) < arctan x + arctan y" by simp
- have "arctan x \<le> pi / 4" and "arctan y < pi / 4"
+ unfolding arctan_le_iff arctan_less_iff
+ using assms by auto
+ from add_le_less_mono [OF this] show 1: "- (pi / 2) < arctan x + arctan y"
+ by simp
+ have "arctan x \<le> pi / 4" "arctan y < pi / 4"
unfolding arctan_one [symmetric]
- unfolding arctan_le_iff arctan_less_iff using assms by auto
- from add_le_less_mono [OF this]
- show 2: "arctan x + arctan y < pi / 2" by simp
+ unfolding arctan_le_iff arctan_less_iff
+ using assms by auto
+ from add_le_less_mono [OF this] show 2: "arctan x + arctan y < pi / 2"
+ by simp
show "tan (arctan x + arctan y) = (x + y) / (1 - x * y)"
using cos_gt_zero_pi [OF 1 2] by (simp add: arctan tan_add)
qed
-lemma arctan_double:
- assumes "\<bar>x\<bar> < 1"
- shows "2 * arctan x = arctan ((2*x) / (1 - x\<^sup>2))"
- by (metis assms arctan_add linear mult_2 not_less power2_eq_square)
-
-theorem machin: "pi / 4 = 4 * arctan (1/5) - arctan (1 / 239)"
+lemma arctan_double: "\<bar>x\<bar> < 1 \<Longrightarrow> 2 * arctan x = arctan ((2 * x) / (1 - x\<^sup>2))"
+ by (metis arctan_add linear mult_2 not_less power2_eq_square)
+
+theorem machin: "pi / 4 = 4 * arctan (1 / 5) - arctan (1 / 239)"
proof -
- have "\<bar>1 / 5\<bar> < (1 :: real)" by auto
- from arctan_add[OF less_imp_le[OF this] this]
- have "2 * arctan (1 / 5) = arctan (5 / 12)" by auto
+ have "\<bar>1 / 5\<bar> < (1 :: real)"
+ by auto
+ from arctan_add[OF less_imp_le[OF this] this] have "2 * arctan (1 / 5) = arctan (5 / 12)"
+ by auto
moreover
- have "\<bar>5 / 12\<bar> < (1 :: real)" by auto
- from arctan_add[OF less_imp_le[OF this] this]
- have "2 * arctan (5 / 12) = arctan (120 / 119)" by auto
+ have "\<bar>5 / 12\<bar> < (1 :: real)"
+ by auto
+ from arctan_add[OF less_imp_le[OF this] this] have "2 * arctan (5 / 12) = arctan (120 / 119)"
+ by auto
moreover
- have "\<bar>1\<bar> \<le> (1::real)" and "\<bar>1 / 239\<bar> < (1::real)" by auto
- from arctan_add[OF this]
- have "arctan 1 + arctan (1 / 239) = arctan (120 / 119)" by auto
- ultimately have "arctan 1 + arctan (1 / 239) = 4 * arctan (1 / 5)" by auto
- thus ?thesis unfolding arctan_one by algebra
+ have "\<bar>1\<bar> \<le> (1::real)" and "\<bar>1 / 239\<bar> < (1::real)"
+ by auto
+ from arctan_add[OF this] have "arctan 1 + arctan (1 / 239) = arctan (120 / 119)"
+ by auto
+ ultimately have "arctan 1 + arctan (1 / 239) = 4 * arctan (1 / 5)"
+ by auto
+ then show ?thesis
+ unfolding arctan_one by algebra
qed
-lemma machin_Euler: "5 * arctan(1/7) + 2 * arctan(3/79) = pi/4"
+lemma machin_Euler: "5 * arctan (1 / 7) + 2 * arctan (3 / 79) = pi / 4"
proof -
- have 17: "\<bar>1/7\<bar> < (1 :: real)" by auto
- with arctan_double have "2 * arctan (1/7) = arctan (7/24)"
+ have 17: "\<bar>1 / 7\<bar> < (1 :: real)" by auto
+ with arctan_double have "2 * arctan (1 / 7) = arctan (7 / 24)"
by simp (simp add: field_simps)
- moreover have "\<bar>7/24\<bar> < (1 :: real)" by auto
- with arctan_double have "2 * arctan (7/24) = arctan (336/527)" by simp (simp add: field_simps)
- moreover have "\<bar>336/527\<bar> < (1 :: real)" by auto
+ moreover
+ have "\<bar>7 / 24\<bar> < (1 :: real)" by auto
+ with arctan_double have "2 * arctan (7 / 24) = arctan (336 / 527)"
+ by simp (simp add: field_simps)
+ moreover
+ have "\<bar>336 / 527\<bar> < (1 :: real)" by auto
from arctan_add[OF less_imp_le[OF 17] this]
- have "arctan(1/7) + arctan (336/527) = arctan (2879/3353)" by auto
- ultimately have I: "5 * arctan(1/7) = arctan (2879/3353)" by auto
- have 379: "\<bar>3/79\<bar> < (1 :: real)" by auto
- with arctan_double have II: "2 * arctan (3/79) = arctan (237/3116)" by simp (simp add: field_simps)
- have *: "\<bar>2879/3353\<bar> < (1 :: real)" by auto
- have "\<bar>237/3116\<bar> < (1 :: real)" by auto
- from arctan_add[OF less_imp_le[OF *] this]
- have "arctan (2879/3353) + arctan (237/3116) = pi/4"
+ have "arctan(1/7) + arctan (336 / 527) = arctan (2879 / 3353)"
+ by auto
+ ultimately have I: "5 * arctan (1 / 7) = arctan (2879 / 3353)" by auto
+ have 379: "\<bar>3 / 79\<bar> < (1 :: real)" by auto
+ with arctan_double have II: "2 * arctan (3 / 79) = arctan (237 / 3116)"
+ by simp (simp add: field_simps)
+ have *: "\<bar>2879 / 3353\<bar> < (1 :: real)" by auto
+ have "\<bar>237 / 3116\<bar> < (1 :: real)" by auto
+ from arctan_add[OF less_imp_le[OF *] this] have "arctan (2879/3353) + arctan (237/3116) = pi/4"
by (simp add: arctan_one)
- then show ?thesis using I II
- by auto
+ with I II show ?thesis by auto
qed
(*But could also prove MACHIN_GAUSS:
@@ -5083,45 +5127,46 @@
lemma monoseq_arctan_series:
fixes x :: real
assumes "\<bar>x\<bar> \<le> 1"
- shows "monoseq (\<lambda> n. 1 / real (n*2+1) * x^(n*2+1))" (is "monoseq ?a")
+ shows "monoseq (\<lambda>n. 1 / real (n * 2 + 1) * x^(n * 2 + 1))"
+ (is "monoseq ?a")
proof (cases "x = 0")
case True
- thus ?thesis unfolding monoseq_def One_nat_def by auto
+ then show ?thesis by (auto simp: monoseq_def)
next
case False
- have "norm x \<le> 1" and "x \<le> 1" and "-1 \<le> x" using assms by auto
+ have "norm x \<le> 1" and "x \<le> 1" and "-1 \<le> x"
+ using assms by auto
show "monoseq ?a"
proof -
- {
- fix n
- fix x :: real
- assume "0 \<le> x" and "x \<le> 1"
- have "1 / real (Suc (Suc n * 2)) * x ^ Suc (Suc n * 2) \<le>
+ have mono: "1 / real (Suc (Suc n * 2)) * x ^ Suc (Suc n * 2) \<le>
1 / real (Suc (n * 2)) * x ^ Suc (n * 2)"
- proof (rule mult_mono)
- show "1 / real (Suc (Suc n * 2)) \<le> 1 / real (Suc (n * 2))"
- by (rule frac_le) simp_all
- show "0 \<le> 1 / real (Suc (n * 2))"
- by auto
- show "x ^ Suc (Suc n * 2) \<le> x ^ Suc (n * 2)"
- by (rule power_decreasing) (simp_all add: \<open>0 \<le> x\<close> \<open>x \<le> 1\<close>)
- show "0 \<le> x ^ Suc (Suc n * 2)"
- by (rule zero_le_power) (simp add: \<open>0 \<le> x\<close>)
- qed
- } note mono = this
-
+ if "0 \<le> x" and "x \<le> 1" for n and x :: real
+ proof (rule mult_mono)
+ show "1 / real (Suc (Suc n * 2)) \<le> 1 / real (Suc (n * 2))"
+ by (rule frac_le) simp_all
+ show "0 \<le> 1 / real (Suc (n * 2))"
+ by auto
+ show "x ^ Suc (Suc n * 2) \<le> x ^ Suc (n * 2)"
+ by (rule power_decreasing) (simp_all add: \<open>0 \<le> x\<close> \<open>x \<le> 1\<close>)
+ show "0 \<le> x ^ Suc (Suc n * 2)"
+ by (rule zero_le_power) (simp add: \<open>0 \<le> x\<close>)
+ qed
show ?thesis
proof (cases "0 \<le> x")
- case True from mono[OF this \<open>x \<le> 1\<close>, THEN allI]
- show ?thesis unfolding Suc_eq_plus1[symmetric]
- by (rule mono_SucI2)
+ case True
+ from mono[OF this \<open>x \<le> 1\<close>, THEN allI]
+ show ?thesis
+ unfolding Suc_eq_plus1[symmetric] by (rule mono_SucI2)
next
case False
- hence "0 \<le> -x" and "-x \<le> 1" using \<open>-1 \<le> x\<close> by auto
+ then have "0 \<le> - x" and "- x \<le> 1"
+ using \<open>-1 \<le> x\<close> by auto
from mono[OF this]
- have "\<And>n. 1 / real (Suc (Suc n * 2)) * x ^ Suc (Suc n * 2) \<ge>
- 1 / real (Suc (n * 2)) * x ^ Suc (n * 2)" using \<open>0 \<le> -x\<close> by auto
- thus ?thesis unfolding Suc_eq_plus1[symmetric] by (rule mono_SucI1[OF allI])
+ have "1 / real (Suc (Suc n * 2)) * x ^ Suc (Suc n * 2) \<ge>
+ 1 / real (Suc (n * 2)) * x ^ Suc (n * 2)" for n
+ using \<open>0 \<le> -x\<close> by auto
+ then show ?thesis
+ unfolding Suc_eq_plus1[symmetric] by (rule mono_SucI1[OF allI])
qed
qed
qed
@@ -5129,29 +5174,33 @@
lemma zeroseq_arctan_series:
fixes x :: real
assumes "\<bar>x\<bar> \<le> 1"
- shows "(\<lambda> n. 1 / real (n*2+1) * x^(n*2+1)) \<longlonglongrightarrow> 0" (is "?a \<longlonglongrightarrow> 0")
+ shows "(\<lambda>n. 1 / real (n * 2 + 1) * x^(n * 2 + 1)) \<longlonglongrightarrow> 0"
+ (is "?a \<longlonglongrightarrow> 0")
proof (cases "x = 0")
case True
- thus ?thesis
- unfolding One_nat_def by auto
+ then show ?thesis by simp
next
case False
- have "norm x \<le> 1" and "x \<le> 1" and "-1 \<le> x" using assms by auto
+ have "norm x \<le> 1" and "x \<le> 1" and "-1 \<le> x"
+ using assms by auto
show "?a \<longlonglongrightarrow> 0"
proof (cases "\<bar>x\<bar> < 1")
case True
- hence "norm x < 1" by auto
+ then have "norm x < 1" by auto
from tendsto_mult[OF LIMSEQ_inverse_real_of_nat LIMSEQ_power_zero[OF \<open>norm x < 1\<close>, THEN LIMSEQ_Suc]]
have "(\<lambda>n. 1 / real (n + 1) * x ^ (n + 1)) \<longlonglongrightarrow> 0"
unfolding inverse_eq_divide Suc_eq_plus1 by simp
- then show ?thesis using pos2 by (rule LIMSEQ_linear)
+ then show ?thesis
+ using pos2 by (rule LIMSEQ_linear)
next
case False
- hence "x = -1 \<or> x = 1" using \<open>\<bar>x\<bar> \<le> 1\<close> by auto
- hence n_eq: "\<And> n. x ^ (n * 2 + 1) = x"
+ then have "x = -1 \<or> x = 1"
+ using \<open>\<bar>x\<bar> \<le> 1\<close> by auto
+ then have n_eq: "\<And> n. x ^ (n * 2 + 1) = x"
unfolding One_nat_def by auto
from tendsto_mult[OF LIMSEQ_inverse_real_of_nat[THEN LIMSEQ_linear, OF pos2, unfolded inverse_eq_divide] tendsto_const[of x]]
- show ?thesis unfolding n_eq Suc_eq_plus1 by auto
+ show ?thesis
+ unfolding n_eq Suc_eq_plus1 by auto
qed
qed
@@ -5159,100 +5208,109 @@
fixes n :: nat
assumes "\<bar>x\<bar> \<le> 1"
shows "summable (\<lambda> k. (-1)^k * (1 / real (k*2+1) * x ^ (k*2+1)))"
- (is "summable (?c x)")
- by (rule summable_Leibniz(1), rule zeroseq_arctan_series[OF assms], rule monoseq_arctan_series[OF assms])
+ (is "summable (?c x)")
+ by (rule summable_Leibniz(1),
+ rule zeroseq_arctan_series[OF assms],
+ rule monoseq_arctan_series[OF assms])
lemma DERIV_arctan_series:
- assumes "\<bar> x \<bar> < 1"
- shows "DERIV (\<lambda> x'. \<Sum> k. (-1)^k * (1 / real (k*2+1) * x' ^ (k*2+1))) x :> (\<Sum> k. (-1)^k * x^(k*2))"
- (is "DERIV ?arctan _ :> ?Int")
+ assumes "\<bar>x\<bar> < 1"
+ shows "DERIV (\<lambda>x'. \<Sum>k. (-1)^k * (1 / real (k * 2 + 1) * x' ^ (k * 2 + 1))) x :>
+ (\<Sum>k. (-1)^k * x^(k * 2))"
+ (is "DERIV ?arctan _ :> ?Int")
proof -
let ?f = "\<lambda>n. if even n then (-1)^(n div 2) * 1 / real (Suc n) else 0"
- have n_even: "\<And>n :: nat. even n \<Longrightarrow> 2 * (n div 2) = n"
+ have n_even: "even n \<Longrightarrow> 2 * (n div 2) = n" for n :: nat
by presburger
- then have if_eq: "\<And>n x'. ?f n * real (Suc n) * x'^n =
- (if even n then (-1)^(n div 2) * x'^(2 * (n div 2)) else 0)"
+ then have if_eq: "?f n * real (Suc n) * x'^n =
+ (if even n then (-1)^(n div 2) * x'^(2 * (n div 2)) else 0)"
+ for n x'
by auto
- {
- fix x :: real
- assume "\<bar>x\<bar> < 1"
- hence "x\<^sup>2 < 1" by (simp add: abs_square_less_1)
+ have summable_Integral: "summable (\<lambda> n. (- 1) ^ n * x^(2 * n))" if "\<bar>x\<bar> < 1" for x :: real
+ proof -
+ from that have "x\<^sup>2 < 1"
+ by (simp add: abs_square_less_1)
have "summable (\<lambda> n. (- 1) ^ n * (x\<^sup>2) ^n)"
- by (rule summable_Leibniz(1), auto intro!: LIMSEQ_realpow_zero monoseq_realpow \<open>x\<^sup>2 < 1\<close> order_less_imp_le[OF \<open>x\<^sup>2 < 1\<close>])
- hence "summable (\<lambda> n. (- 1) ^ n * x^(2*n))" unfolding power_mult .
- } note summable_Integral = this
-
- {
- fix f :: "nat \<Rightarrow> real"
- have "\<And>x. f sums x = (\<lambda> n. if even n then f (n div 2) else 0) sums x"
+ by (rule summable_Leibniz(1))
+ (auto intro!: LIMSEQ_realpow_zero monoseq_realpow \<open>x\<^sup>2 < 1\<close> order_less_imp_le[OF \<open>x\<^sup>2 < 1\<close>])
+ then show ?thesis
+ by (simp only: power_mult)
+ qed
+
+ have sums_even: "op sums f = op sums (\<lambda> n. if even n then f (n div 2) else 0)"
+ for f :: "nat \<Rightarrow> real"
+ proof -
+ have "f sums x = (\<lambda> n. if even n then f (n div 2) else 0) sums x" for x :: real
proof
- fix x :: real
assume "f sums x"
- from sums_if[OF sums_zero this]
- show "(\<lambda>n. if even n then f (n div 2) else 0) sums x"
+ from sums_if[OF sums_zero this] show "(\<lambda>n. if even n then f (n div 2) else 0) sums x"
by auto
next
- fix x :: real
assume "(\<lambda> n. if even n then f (n div 2) else 0) sums x"
from LIMSEQ_linear[OF this[simplified sums_def] pos2, simplified sum_split_even_odd[simplified mult.commute]]
- show "f sums x" unfolding sums_def by auto
+ show "f sums x"
+ unfolding sums_def by auto
qed
- hence "op sums f = op sums (\<lambda> n. if even n then f (n div 2) else 0)" ..
- } note sums_even = this
+ then show ?thesis ..
+ qed
have Int_eq: "(\<Sum>n. ?f n * real (Suc n) * x^n) = ?Int"
- unfolding if_eq mult.commute[of _ 2] suminf_def sums_even[of "\<lambda> n. (- 1) ^ n * x ^ (2 * n)", symmetric]
+ unfolding if_eq mult.commute[of _ 2]
+ suminf_def sums_even[of "\<lambda> n. (- 1) ^ n * x ^ (2 * n)", symmetric]
by auto
- {
- fix x :: real
+ have arctan_eq: "(\<Sum>n. ?f n * x^(Suc n)) = ?arctan x" for x
+ proof -
have if_eq': "\<And>n. (if even n then (- 1) ^ (n div 2) * 1 / real (Suc n) else 0) * x ^ Suc n =
(if even n then (- 1) ^ (n div 2) * (1 / real (Suc (2 * (n div 2))) * x ^ Suc (2 * (n div 2))) else 0)"
using n_even by auto
- have idx_eq: "\<And>n. n * 2 + 1 = Suc (2 * n)" by auto
- have "(\<Sum>n. ?f n * x^(Suc n)) = ?arctan x"
- unfolding if_eq' idx_eq suminf_def sums_even[of "\<lambda> n. (- 1) ^ n * (1 / real (Suc (2 * n)) * x ^ Suc (2 * n))", symmetric]
+ have idx_eq: "\<And>n. n * 2 + 1 = Suc (2 * n)"
by auto
- } note arctan_eq = this
-
- have "DERIV (\<lambda> x. \<Sum> n. ?f n * x^(Suc n)) x :> (\<Sum> n. ?f n * real (Suc n) * x^n)"
+ then show ?thesis
+ unfolding if_eq' idx_eq suminf_def
+ sums_even[of "\<lambda> n. (- 1) ^ n * (1 / real (Suc (2 * n)) * x ^ Suc (2 * n))", symmetric]
+ by auto
+ qed
+
+ have "DERIV (\<lambda> x. \<Sum> n. ?f n * x^(Suc n)) x :> (\<Sum>n. ?f n * real (Suc n) * x^n)"
proof (rule DERIV_power_series')
- show "x \<in> {- 1 <..< 1}" using \<open>\<bar> x \<bar> < 1\<close> by auto
- {
- fix x' :: real
- assume x'_bounds: "x' \<in> {- 1 <..< 1}"
- then have "\<bar>x'\<bar> < 1" by auto
- then
- have *: "summable (\<lambda>n. (- 1) ^ n * x' ^ (2 * n))"
+ show "x \<in> {- 1 <..< 1}"
+ using \<open>\<bar> x \<bar> < 1\<close> by auto
+ show "summable (\<lambda> n. ?f n * real (Suc n) * x'^n)"
+ if x'_bounds: "x' \<in> {- 1 <..< 1}" for x' :: real
+ proof -
+ from that have "\<bar>x'\<bar> < 1" by auto
+ then have *: "summable (\<lambda>n. (- 1) ^ n * x' ^ (2 * n))"
by (rule summable_Integral)
- let ?S = "\<Sum> n. (-1)^n * x'^(2 * n)"
- show "summable (\<lambda> n. ?f n * real (Suc n) * x'^n)" unfolding if_eq
- apply (rule sums_summable [where l="0 + ?S"])
+ show ?thesis
+ unfolding if_eq
+ apply (rule sums_summable [where l="0 + (\<Sum>n. (-1)^n * x'^(2 * n))"])
apply (rule sums_if)
- apply (rule sums_zero)
+ apply (rule sums_zero)
apply (rule summable_sums)
apply (rule *)
done
- }
+ qed
qed auto
- thus ?thesis unfolding Int_eq arctan_eq .
+ then show ?thesis
+ by (simp only: Int_eq arctan_eq)
qed
lemma arctan_series:
- assumes "\<bar> x \<bar> \<le> 1"
- shows "arctan x = (\<Sum>k. (-1)^k * (1 / real (k*2+1) * x ^ (k*2+1)))"
- (is "_ = suminf (\<lambda> n. ?c x n)")
+ assumes "\<bar>x\<bar> \<le> 1"
+ shows "arctan x = (\<Sum>k. (-1)^k * (1 / real (k * 2 + 1) * x ^ (k * 2 + 1)))"
+ (is "_ = suminf (\<lambda> n. ?c x n)")
proof -
let ?c' = "\<lambda>x n. (-1)^n * x^(n*2)"
- {
- fix r x :: real
- assume "0 < r" and "r < 1" and "\<bar> x \<bar> < r"
- have "\<bar>x\<bar> < 1" using \<open>r < 1\<close> and \<open>\<bar>x\<bar> < r\<close> by auto
- from DERIV_arctan_series[OF this] have "DERIV (\<lambda> x. suminf (?c x)) x :> (suminf (?c' x))" .
- } note DERIV_arctan_suminf = this
+ have DERIV_arctan_suminf: "DERIV (\<lambda> x. suminf (?c x)) x :> (suminf (?c' x))"
+ if "0 < r" and "r < 1" and "\<bar>x\<bar> < r" for r x :: real
+ proof (rule DERIV_arctan_series)
+ from that show "\<bar>x\<bar> < 1"
+ using \<open>r < 1\<close> and \<open>\<bar>x\<bar> < r\<close> by auto
+ qed
{
fix x :: real
@@ -5260,141 +5318,133 @@
note summable_Leibniz[OF zeroseq_arctan_series[OF this] monoseq_arctan_series[OF this]]
} note arctan_series_borders = this
- {
- fix x :: real
- assume "\<bar>x\<bar> < 1"
- have "arctan x = (\<Sum>k. ?c x k)"
+ have when_less_one: "arctan x = (\<Sum>k. ?c x k)" if "\<bar>x\<bar> < 1" for x :: real
+ proof -
+ obtain r where "\<bar>x\<bar> < r" and "r < 1"
+ using dense[OF \<open>\<bar>x\<bar> < 1\<close>] by blast
+ then have "0 < r" and "- r < x" and "x < r" by auto
+
+ have suminf_eq_arctan_bounded: "suminf (?c x) - arctan x = suminf (?c a) - arctan a"
+ if "-r < a" and "b < r" and "a < b" and "a \<le> x" and "x \<le> b" for x a b
proof -
- obtain r where "\<bar>x\<bar> < r" and "r < 1"
- using dense[OF \<open>\<bar>x\<bar> < 1\<close>] by blast
- hence "0 < r" and "-r < x" and "x < r" by auto
-
- have suminf_eq_arctan_bounded: "\<And>x a b. \<lbrakk> -r < a ; b < r ; a < b ; a \<le> x ; x \<le> b \<rbrakk> \<Longrightarrow>
- suminf (?c x) - arctan x = suminf (?c a) - arctan a"
- proof -
- fix x a b
- assume "-r < a" and "b < r" and "a < b" and "a \<le> x" and "x \<le> b"
- hence "\<bar>x\<bar> < r" by auto
- show "suminf (?c x) - arctan x = suminf (?c a) - arctan a"
- proof (rule DERIV_isconst2[of "a" "b"])
- show "a < b" and "a \<le> x" and "x \<le> b"
- using \<open>a < b\<close> \<open>a \<le> x\<close> \<open>x \<le> b\<close> by auto
- have "\<forall>x. -r < x \<and> x < r \<longrightarrow> DERIV (\<lambda> x. suminf (?c x) - arctan x) x :> 0"
- proof (rule allI, rule impI)
- fix x
- assume "-r < x \<and> x < r"
- hence "\<bar>x\<bar> < r" by auto
- hence "\<bar>x\<bar> < 1" using \<open>r < 1\<close> by auto
- have "\<bar> - (x\<^sup>2) \<bar> < 1"
- using abs_square_less_1 \<open>\<bar>x\<bar> < 1\<close> by auto
- hence "(\<lambda> n. (- (x\<^sup>2)) ^ n) sums (1 / (1 - (- (x\<^sup>2))))"
- unfolding real_norm_def[symmetric] by (rule geometric_sums)
- hence "(?c' x) sums (1 / (1 - (- (x\<^sup>2))))"
- unfolding power_mult_distrib[symmetric] power_mult mult.commute[of _ 2] by auto
- hence suminf_c'_eq_geom: "inverse (1 + x\<^sup>2) = suminf (?c' x)"
- using sums_unique unfolding inverse_eq_divide by auto
- have "DERIV (\<lambda> x. suminf (?c x)) x :> (inverse (1 + x\<^sup>2))"
- unfolding suminf_c'_eq_geom
- by (rule DERIV_arctan_suminf[OF \<open>0 < r\<close> \<open>r < 1\<close> \<open>\<bar>x\<bar> < r\<close>])
- from DERIV_diff [OF this DERIV_arctan]
- show "DERIV (\<lambda> x. suminf (?c x) - arctan x) x :> 0"
- by auto
- qed
- hence DERIV_in_rball: "\<forall> y. a \<le> y \<and> y \<le> b \<longrightarrow> DERIV (\<lambda> x. suminf (?c x) - arctan x) y :> 0"
- using \<open>-r < a\<close> \<open>b < r\<close> by auto
- thus "\<forall> y. a < y \<and> y < b \<longrightarrow> DERIV (\<lambda> x. suminf (?c x) - arctan x) y :> 0"
- using \<open>\<bar>x\<bar> < r\<close> by auto
- show "\<forall> y. a \<le> y \<and> y \<le> b \<longrightarrow> isCont (\<lambda> x. suminf (?c x) - arctan x) y"
- using DERIV_in_rball DERIV_isCont by auto
+ from that have "\<bar>x\<bar> < r" by auto
+ show "suminf (?c x) - arctan x = suminf (?c a) - arctan a"
+ proof (rule DERIV_isconst2[of "a" "b"])
+ show "a < b" and "a \<le> x" and "x \<le> b"
+ using \<open>a < b\<close> \<open>a \<le> x\<close> \<open>x \<le> b\<close> by auto
+ have "\<forall>x. - r < x \<and> x < r \<longrightarrow> DERIV (\<lambda> x. suminf (?c x) - arctan x) x :> 0"
+ proof (rule allI, rule impI)
+ fix x
+ assume "-r < x \<and> x < r"
+ then have "\<bar>x\<bar> < r" by auto
+ with \<open>r < 1\<close> have "\<bar>x\<bar> < 1" by auto
+ have "\<bar>- (x\<^sup>2)\<bar> < 1" using abs_square_less_1 \<open>\<bar>x\<bar> < 1\<close> by auto
+ then have "(\<lambda>n. (- (x\<^sup>2)) ^ n) sums (1 / (1 - (- (x\<^sup>2))))"
+ unfolding real_norm_def[symmetric] by (rule geometric_sums)
+ then have "(?c' x) sums (1 / (1 - (- (x\<^sup>2))))"
+ unfolding power_mult_distrib[symmetric] power_mult mult.commute[of _ 2] by auto
+ then have suminf_c'_eq_geom: "inverse (1 + x\<^sup>2) = suminf (?c' x)"
+ using sums_unique unfolding inverse_eq_divide by auto
+ have "DERIV (\<lambda> x. suminf (?c x)) x :> (inverse (1 + x\<^sup>2))"
+ unfolding suminf_c'_eq_geom
+ by (rule DERIV_arctan_suminf[OF \<open>0 < r\<close> \<open>r < 1\<close> \<open>\<bar>x\<bar> < r\<close>])
+ from DERIV_diff [OF this DERIV_arctan] show "DERIV (\<lambda>x. suminf (?c x) - arctan x) x :> 0"
+ by auto
qed
+ then have DERIV_in_rball: "\<forall>y. a \<le> y \<and> y \<le> b \<longrightarrow> DERIV (\<lambda>x. suminf (?c x) - arctan x) y :> 0"
+ using \<open>-r < a\<close> \<open>b < r\<close> by auto
+ then show "\<forall>y. a < y \<and> y < b \<longrightarrow> DERIV (\<lambda>x. suminf (?c x) - arctan x) y :> 0"
+ using \<open>\<bar>x\<bar> < r\<close> by auto
+ show "\<forall>y. a \<le> y \<and> y \<le> b \<longrightarrow> isCont (\<lambda>x. suminf (?c x) - arctan x) y"
+ using DERIV_in_rball DERIV_isCont by auto
qed
-
- have suminf_arctan_zero: "suminf (?c 0) - arctan 0 = 0"
- unfolding Suc_eq_plus1[symmetric] power_Suc2 mult_zero_right arctan_zero_zero suminf_zero
+ qed
+
+ have suminf_arctan_zero: "suminf (?c 0) - arctan 0 = 0"
+ unfolding Suc_eq_plus1[symmetric] power_Suc2 mult_zero_right arctan_zero_zero suminf_zero
+ by auto
+
+ have "suminf (?c x) - arctan x = 0"
+ proof (cases "x = 0")
+ case True
+ then show ?thesis
+ using suminf_arctan_zero by auto
+ next
+ case False
+ then have "0 < \<bar>x\<bar>" and "- \<bar>x\<bar> < \<bar>x\<bar>"
by auto
-
- have "suminf (?c x) - arctan x = 0"
- proof (cases "x = 0")
- case True
- thus ?thesis using suminf_arctan_zero by auto
- next
- case False
- hence "0 < \<bar>x\<bar>" and "- \<bar>x\<bar> < \<bar>x\<bar>" by auto
- have "suminf (?c (-\<bar>x\<bar>)) - arctan (-\<bar>x\<bar>) = suminf (?c 0) - arctan 0"
- by (rule suminf_eq_arctan_bounded[where x1="0" and a1="-\<bar>x\<bar>" and b1="\<bar>x\<bar>", symmetric])
- (simp_all only: \<open>\<bar>x\<bar> < r\<close> \<open>-\<bar>x\<bar> < \<bar>x\<bar>\<close> neg_less_iff_less)
- moreover
- have "suminf (?c x) - arctan x = suminf (?c (-\<bar>x\<bar>)) - arctan (-\<bar>x\<bar>)"
- by (rule suminf_eq_arctan_bounded[where x1="x" and a1="-\<bar>x\<bar>" and b1="\<bar>x\<bar>"])
- (simp_all only: \<open>\<bar>x\<bar> < r\<close> \<open>-\<bar>x\<bar> < \<bar>x\<bar>\<close> neg_less_iff_less)
- ultimately
- show ?thesis using suminf_arctan_zero by auto
- qed
- thus ?thesis by auto
+ have "suminf (?c (- \<bar>x\<bar>)) - arctan (- \<bar>x\<bar>) = suminf (?c 0) - arctan 0"
+ by (rule suminf_eq_arctan_bounded[where x1="0" and a1="-\<bar>x\<bar>" and b1="\<bar>x\<bar>", symmetric])
+ (simp_all only: \<open>\<bar>x\<bar> < r\<close> \<open>-\<bar>x\<bar> < \<bar>x\<bar>\<close> neg_less_iff_less)
+ moreover
+ have "suminf (?c x) - arctan x = suminf (?c (- \<bar>x\<bar>)) - arctan (- \<bar>x\<bar>)"
+ by (rule suminf_eq_arctan_bounded[where x1="x" and a1="- \<bar>x\<bar>" and b1="\<bar>x\<bar>"])
+ (simp_all only: \<open>\<bar>x\<bar> < r\<close> \<open>- \<bar>x\<bar> < \<bar>x\<bar>\<close> neg_less_iff_less)
+ ultimately show ?thesis
+ using suminf_arctan_zero by auto
qed
- } note when_less_one = this
-
- show "arctan x = suminf (\<lambda> n. ?c x n)"
+ then show ?thesis by auto
+ qed
+
+ show "arctan x = suminf (\<lambda>n. ?c x n)"
proof (cases "\<bar>x\<bar> < 1")
case True
- thus ?thesis by (rule when_less_one)
+ then show ?thesis by (rule when_less_one)
next
case False
- hence "\<bar>x\<bar> = 1" using \<open>\<bar>x\<bar> \<le> 1\<close> by auto
- let ?a = "\<lambda>x n. \<bar>1 / real (n*2+1) * x^(n*2+1)\<bar>"
- let ?diff = "\<lambda> x n. \<bar> arctan x - (\<Sum> i<n. ?c x i)\<bar>"
- {
- fix n :: nat
+ then have "\<bar>x\<bar> = 1" using \<open>\<bar>x\<bar> \<le> 1\<close> by auto
+ let ?a = "\<lambda>x n. \<bar>1 / real (n * 2 + 1) * x^(n * 2 + 1)\<bar>"
+ let ?diff = "\<lambda>x n. \<bar>arctan x - (\<Sum>i<n. ?c x i)\<bar>"
+ have "?diff 1 n \<le> ?a 1 n" for n :: nat
+ proof -
have "0 < (1 :: real)" by auto
moreover
- {
- fix x :: real
- assume "0 < x" and "x < 1"
- hence "\<bar>x\<bar> \<le> 1" and "\<bar>x\<bar> < 1" by auto
+ have "?diff x n \<le> ?a x n" if "0 < x" and "x < 1" for x :: real
+ proof -
+ from that have "\<bar>x\<bar> \<le> 1" and "\<bar>x\<bar> < 1"
+ by auto
from \<open>0 < x\<close> have "0 < 1 / real (0 * 2 + (1::nat)) * x ^ (0 * 2 + 1)"
by auto
note bounds = mp[OF arctan_series_borders(2)[OF \<open>\<bar>x\<bar> \<le> 1\<close>] this, unfolded when_less_one[OF \<open>\<bar>x\<bar> < 1\<close>, symmetric], THEN spec]
have "0 < 1 / real (n*2+1) * x^(n*2+1)"
- by (rule mult_pos_pos, auto simp only: zero_less_power[OF \<open>0 < x\<close>], auto)
- hence a_pos: "?a x n = 1 / real (n*2+1) * x^(n*2+1)"
+ by (rule mult_pos_pos) (simp_all only: zero_less_power[OF \<open>0 < x\<close>], auto)
+ then have a_pos: "?a x n = 1 / real (n*2+1) * x^(n*2+1)"
by (rule abs_of_pos)
- have "?diff x n \<le> ?a x n"
+ show ?thesis
proof (cases "even n")
case True
- hence sgn_pos: "(-1)^n = (1::real)" by auto
+ then have sgn_pos: "(-1)^n = (1::real)" by auto
from \<open>even n\<close> obtain m where "n = 2 * m" ..
then have "2 * m = n" ..
from bounds[of m, unfolded this atLeastAtMost_iff]
have "\<bar>arctan x - (\<Sum>i<n. (?c x i))\<bar> \<le> (\<Sum>i<n + 1. (?c x i)) - (\<Sum>i<n. (?c x i))"
by auto
- also have "\<dots> = ?c x n" unfolding One_nat_def by auto
+ also have "\<dots> = ?c x n" by auto
also have "\<dots> = ?a x n" unfolding sgn_pos a_pos by auto
finally show ?thesis .
next
case False
- hence sgn_neg: "(-1)^n = (-1::real)" by auto
+ then have sgn_neg: "(-1)^n = (-1::real)" by auto
from \<open>odd n\<close> obtain m where "n = 2 * m + 1" ..
then have m_def: "2 * m + 1 = n" ..
- hence m_plus: "2 * (m + 1) = n + 1" by auto
+ then have m_plus: "2 * (m + 1) = n + 1" by auto
from bounds[of "m + 1", unfolded this atLeastAtMost_iff, THEN conjunct1] bounds[of m, unfolded m_def atLeastAtMost_iff, THEN conjunct2]
- have "\<bar>arctan x - (\<Sum>i<n. (?c x i))\<bar> \<le> (\<Sum>i<n. (?c x i)) - (\<Sum>i<n+1. (?c x i))"
- by auto
- also have "\<dots> = - ?c x n" unfolding One_nat_def by auto
+ have "\<bar>arctan x - (\<Sum>i<n. (?c x i))\<bar> \<le> (\<Sum>i<n. (?c x i)) - (\<Sum>i<n+1. (?c x i))" by auto
+ also have "\<dots> = - ?c x n" by auto
also have "\<dots> = ?a x n" unfolding sgn_neg a_pos by auto
finally show ?thesis .
qed
- hence "0 \<le> ?a x n - ?diff x n" by auto
- }
- hence "\<forall> x \<in> { 0 <..< 1 }. 0 \<le> ?a x n - ?diff x n" by auto
- moreover have "\<And>x. isCont (\<lambda> x. ?a x n - ?diff x n) x"
+ qed
+ hence "\<forall>x \<in> { 0 <..< 1 }. 0 \<le> ?a x n - ?diff x n" by auto
+ moreover have "isCont (\<lambda> x. ?a x n - ?diff x n) x" for x
unfolding diff_conv_add_uminus divide_inverse
by (auto intro!: isCont_add isCont_rabs continuous_ident isCont_minus isCont_arctan
isCont_inverse isCont_mult isCont_power continuous_const isCont_setsum
simp del: add_uminus_conv_diff)
ultimately have "0 \<le> ?a 1 n - ?diff 1 n"
by (rule LIM_less_bound)
- hence "?diff 1 n \<le> ?a 1 n" by auto
- }
+ then show ?thesis by auto
+ qed
have "?a 1 \<longlonglongrightarrow> 0"
unfolding tendsto_rabs_zero_iff power_one divide_inverse One_nat_def
by (auto intro!: tendsto_mult LIMSEQ_linear LIMSEQ_inverse_real_of_nat simp del: of_nat_Suc)
@@ -5402,18 +5452,15 @@
proof (rule LIMSEQ_I)
fix r :: real
assume "0 < r"
- obtain N :: nat where N_I: "\<And>n. N \<le> n \<Longrightarrow> ?a 1 n < r"
+ obtain N :: nat where N_I: "N \<le> n \<Longrightarrow> ?a 1 n < r" for n
using LIMSEQ_D[OF \<open>?a 1 \<longlonglongrightarrow> 0\<close> \<open>0 < r\<close>] by auto
- {
- fix n
- assume "N \<le> n" from \<open>?diff 1 n \<le> ?a 1 n\<close> N_I[OF this]
- have "norm (?diff 1 n - 0) < r" by auto
- }
- thus "\<exists> N. \<forall> n \<ge> N. norm (?diff 1 n - 0) < r" by blast
+ have "norm (?diff 1 n - 0) < r" if "N \<le> n" for n
+ using \<open>?diff 1 n \<le> ?a 1 n\<close> N_I[OF that] by auto
+ then show "\<exists>N. \<forall> n \<ge> N. norm (?diff 1 n - 0) < r" by blast
qed
from this [unfolded tendsto_rabs_zero_iff, THEN tendsto_add [OF _ tendsto_const], of "- arctan 1", THEN tendsto_minus]
have "(?c 1) sums (arctan 1)" unfolding sums_def by auto
- hence "arctan 1 = (\<Sum> i. ?c 1 i)" by (rule sums_unique)
+ then have "arctan 1 = (\<Sum>i. ?c 1 i)" by (rule sums_unique)
show ?thesis
proof (cases "x = 1")
@@ -5421,20 +5468,20 @@
then show ?thesis by (simp add: \<open>arctan 1 = (\<Sum> i. ?c 1 i)\<close>)
next
case False
- hence "x = -1" using \<open>\<bar>x\<bar> = 1\<close> by auto
+ then have "x = -1" using \<open>\<bar>x\<bar> = 1\<close> by auto
have "- (pi / 2) < 0" using pi_gt_zero by auto
have "- (2 * pi) < 0" using pi_gt_zero by auto
- have c_minus_minus: "\<And>i. ?c (- 1) i = - ?c 1 i"
- unfolding One_nat_def by auto
+ have c_minus_minus: "?c (- 1) i = - ?c 1 i" for i by auto
have "arctan (- 1) = arctan (tan (-(pi / 4)))"
unfolding tan_45 tan_minus ..
also have "\<dots> = - (pi / 4)"
- by (rule arctan_tan, auto simp add: order_less_trans[OF \<open>- (pi / 2) < 0\<close> pi_gt_zero])
+ by (rule arctan_tan) (auto simp: order_less_trans[OF \<open>- (pi / 2) < 0\<close> pi_gt_zero])
also have "\<dots> = - (arctan (tan (pi / 4)))"
- unfolding neg_equal_iff_equal by (rule arctan_tan[symmetric], auto simp add: order_less_trans[OF \<open>- (2 * pi) < 0\<close> pi_gt_zero])
+ unfolding neg_equal_iff_equal
+ by (rule arctan_tan[symmetric]) (auto simp: order_less_trans[OF \<open>- (2 * pi) < 0\<close> pi_gt_zero])
also have "\<dots> = - (arctan 1)"
unfolding tan_45 ..
also have "\<dots> = - (\<Sum> i. ?c 1 i)"
@@ -5447,17 +5494,16 @@
qed
qed
-lemma arctan_half:
- fixes x :: real
- shows "arctan x = 2 * arctan (x / (1 + sqrt(1 + x\<^sup>2)))"
+lemma arctan_half: "arctan x = 2 * arctan (x / (1 + sqrt(1 + x\<^sup>2)))"
+ for x :: real
proof -
obtain y where low: "- (pi / 2) < y" and high: "y < pi / 2" and y_eq: "tan y = x"
using tan_total by blast
- hence low2: "- (pi / 2) < y / 2" and high2: "y / 2 < pi / 2"
+ then have low2: "- (pi / 2) < y / 2" and high2: "y / 2 < pi / 2"
by auto
- have "0 < cos y" using cos_gt_zero_pi[OF low high] .
- hence "cos y \<noteq> 0" and cos_sqrt: "sqrt ((cos y)\<^sup>2) = cos y"
+ have "0 < cos y" by (rule cos_gt_zero_pi[OF low high])
+ then have "cos y \<noteq> 0" and cos_sqrt: "sqrt ((cos y)\<^sup>2) = cos y"
by auto
have "1 + (tan y)\<^sup>2 = 1 + (sin y)\<^sup>2 / (cos y)\<^sup>2"
@@ -5516,10 +5562,13 @@
by (simp add: tan_def cos_arctan sin_arctan sin_diff cos_diff)
qed
-theorem pi_series: "pi / 4 = (\<Sum> k. (-1)^k * 1 / real (k*2+1))" (is "_ = ?SUM")
+theorem pi_series: "pi / 4 = (\<Sum>k. (-1)^k * 1 / real (k * 2 + 1))"
+ (is "_ = ?SUM")
proof -
- have "pi / 4 = arctan 1" using arctan_one by auto
- also have "\<dots> = ?SUM" using arctan_series[of 1] by auto
+ have "pi / 4 = arctan 1"
+ using arctan_one by auto
+ also have "\<dots> = ?SUM"
+ using arctan_series[of 1] by auto
finally show ?thesis by auto
qed
@@ -5527,133 +5576,133 @@
subsection \<open>Existence of Polar Coordinates\<close>
lemma cos_x_y_le_one: "\<bar>x / sqrt (x\<^sup>2 + y\<^sup>2)\<bar> \<le> 1"
- apply (rule power2_le_imp_le [OF _ zero_le_one])
- apply (simp add: power_divide divide_le_eq not_sum_power2_lt_zero)
- done
+ by (rule power2_le_imp_le [OF _ zero_le_one])
+ (simp add: power_divide divide_le_eq not_sum_power2_lt_zero)
lemmas cos_arccos_lemma1 = cos_arccos_abs [OF cos_x_y_le_one]
lemmas sin_arccos_lemma1 = sin_arccos_abs [OF cos_x_y_le_one]
-lemma polar_Ex: "\<exists>r::real. \<exists>a. x = r * cos a & y = r * sin a"
+lemma polar_Ex: "\<exists>r::real. \<exists>a. x = r * cos a \<and> y = r * sin a"
proof -
- have polar_ex1: "\<And>y. 0 < y \<Longrightarrow> \<exists>r a. x = r * cos a & y = r * sin a"
- apply (rule_tac x = "sqrt (x\<^sup>2 + y\<^sup>2)" in exI)
- apply (rule_tac x = "arccos (x / sqrt (x\<^sup>2 + y\<^sup>2))" in exI)
+ have polar_ex1: "0 < y \<Longrightarrow> \<exists>r a. x = r * cos a \<and> y = r * sin a" for y
+ apply (rule exI [where x = "sqrt (x\<^sup>2 + y\<^sup>2)"])
+ apply (rule exI [where x = "arccos (x / sqrt (x\<^sup>2 + y\<^sup>2))"])
apply (simp add: cos_arccos_lemma1 sin_arccos_lemma1 power_divide
- real_sqrt_mult [symmetric] right_diff_distrib)
+ real_sqrt_mult [symmetric] right_diff_distrib)
done
show ?thesis
proof (cases "0::real" y rule: linorder_cases)
case less
- then show ?thesis by (rule polar_ex1)
+ then show ?thesis
+ by (rule polar_ex1)
next
case equal
- then show ?thesis
- by (force simp add: intro!: cos_zero sin_zero)
+ then show ?thesis
+ by (force simp add: intro!: cos_zero sin_zero)
next
case greater
- then show ?thesis
- using polar_ex1 [where y="-y"]
- by auto (metis cos_minus minus_minus minus_mult_right sin_minus)
+ with polar_ex1 [where y="-y"] show ?thesis
+ by auto (metis cos_minus minus_minus minus_mult_right sin_minus)
qed
qed
-subsection\<open>Basics about polynomial functions: products, extremal behaviour and root counts\<close>
-
-lemma pairs_le_eq_Sigma:
- fixes m::nat
- shows "{(i,j). i+j \<le> m} = Sigma (atMost m) (\<lambda>r. atMost (m-r))"
-by auto
-
-lemma setsum_up_index_split:
- "(\<Sum>k\<le>m + n. f k) = (\<Sum>k\<le>m. f k) + (\<Sum>k = Suc m..m + n. f k)"
+subsection \<open>Basics about polynomial functions: products, extremal behaviour and root counts\<close>
+
+lemma pairs_le_eq_Sigma: "{(i, j). i + j \<le> m} = Sigma (atMost m) (\<lambda>r. atMost (m - r))"
+ for m :: nat
+ by auto
+
+lemma setsum_up_index_split: "(\<Sum>k\<le>m + n. f k) = (\<Sum>k\<le>m. f k) + (\<Sum>k = Suc m..m + n. f k)"
by (metis atLeast0AtMost Suc_eq_plus1 le0 setsum_ub_add_nat)
-lemma Sigma_interval_disjoint:
- fixes w :: "'a::order"
- shows "(SIGMA i:A. {..v i}) \<inter> (SIGMA i:A.{v i<..w}) = {}"
- by auto
-
-lemma product_atMost_eq_Un:
- fixes m :: nat
- shows "A \<times> {..m} = (SIGMA i:A.{..m - i}) \<union> (SIGMA i:A.{m - i<..m})"
- by auto
+lemma Sigma_interval_disjoint: "(SIGMA i:A. {..v i}) \<inter> (SIGMA i:A.{v i<..w}) = {}"
+ for w :: "'a::order"
+ by auto
+
+lemma product_atMost_eq_Un: "A \<times> {..m} = (SIGMA i:A.{..m - i}) \<union> (SIGMA i:A.{m - i<..m})"
+ for m :: nat
+ by auto
lemma polynomial_product: (*with thanks to Chaitanya Mangla*)
- fixes x:: "'a :: idom"
- assumes m: "\<And>i. i>m \<Longrightarrow> (a i) = 0" and n: "\<And>j. j>n \<Longrightarrow> (b j) = 0"
+ fixes x :: "'a::idom"
+ assumes m: "\<And>i. i > m \<Longrightarrow> a i = 0"
+ and n: "\<And>j. j > n \<Longrightarrow> b j = 0"
shows "(\<Sum>i\<le>m. (a i) * x ^ i) * (\<Sum>j\<le>n. (b j) * x ^ j) =
- (\<Sum>r\<le>m + n. (\<Sum>k\<le>r. (a k) * (b (r - k))) * x ^ r)"
+ (\<Sum>r\<le>m + n. (\<Sum>k\<le>r. (a k) * (b (r - k))) * x ^ r)"
proof -
have "(\<Sum>i\<le>m. (a i) * x ^ i) * (\<Sum>j\<le>n. (b j) * x ^ j) = (\<Sum>i\<le>m. \<Sum>j\<le>n. (a i * x ^ i) * (b j * x ^ j))"
by (rule setsum_product)
- also have "... = (\<Sum>i\<le>m + n. \<Sum>j\<le>n + m. a i * x ^ i * (b j * x ^ j))"
+ also have "\<dots> = (\<Sum>i\<le>m + n. \<Sum>j\<le>n + m. a i * x ^ i * (b j * x ^ j))"
using assms by (auto simp: setsum_up_index_split)
- also have "... = (\<Sum>r\<le>m + n. \<Sum>j\<le>m + n - r. a r * x ^ r * (b j * x ^ j))"
+ also have "\<dots> = (\<Sum>r\<le>m + n. \<Sum>j\<le>m + n - r. a r * x ^ r * (b j * x ^ j))"
apply (simp add: add_ac setsum.Sigma product_atMost_eq_Un)
apply (clarsimp simp add: setsum_Un Sigma_interval_disjoint intro!: setsum.neutral)
- by (metis add_diff_assoc2 add.commute add_lessD1 leD m n nat_le_linear neqE)
- also have "... = (\<Sum>(i,j)\<in>{(i,j). i+j \<le> m+n}. (a i * x ^ i) * (b j * x ^ j))"
+ apply (metis add_diff_assoc2 add.commute add_lessD1 leD m n nat_le_linear neqE)
+ done
+ also have "\<dots> = (\<Sum>(i,j)\<in>{(i,j). i+j \<le> m+n}. (a i * x ^ i) * (b j * x ^ j))"
by (auto simp: pairs_le_eq_Sigma setsum.Sigma)
- also have "... = (\<Sum>r\<le>m + n. (\<Sum>k\<le>r. (a k) * (b (r - k))) * x ^ r)"
+ also have "\<dots> = (\<Sum>r\<le>m + n. (\<Sum>k\<le>r. (a k) * (b (r - k))) * x ^ r)"
apply (subst setsum_triangle_reindex_eq)
apply (auto simp: algebra_simps setsum_right_distrib intro!: setsum.cong)
- by (metis le_add_diff_inverse power_add)
+ apply (metis le_add_diff_inverse power_add)
+ done
finally show ?thesis .
qed
lemma polynomial_product_nat:
- fixes x:: nat
- assumes m: "\<And>i. i>m \<Longrightarrow> (a i) = 0" and n: "\<And>j. j>n \<Longrightarrow> (b j) = 0"
+ fixes x :: nat
+ assumes m: "\<And>i. i > m \<Longrightarrow> a i = 0"
+ and n: "\<And>j. j > n \<Longrightarrow> b j = 0"
shows "(\<Sum>i\<le>m. (a i) * x ^ i) * (\<Sum>j\<le>n. (b j) * x ^ j) =
- (\<Sum>r\<le>m + n. (\<Sum>k\<le>r. (a k) * (b (r - k))) * x ^ r)"
+ (\<Sum>r\<le>m + n. (\<Sum>k\<le>r. (a k) * (b (r - k))) * x ^ r)"
using polynomial_product [of m a n b x] assms
- by (simp only: of_nat_mult [symmetric] of_nat_power [symmetric] of_nat_eq_iff Int.int_setsum [symmetric])
+ by (simp only: of_nat_mult [symmetric] of_nat_power [symmetric]
+ of_nat_eq_iff Int.int_setsum [symmetric])
lemma polyfun_diff: (*COMPLEX_SUB_POLYFUN in HOL Light*)
- fixes x :: "'a::idom"
+ fixes x :: "'a::idom"
assumes "1 \<le> n"
- shows "(\<Sum>i\<le>n. a i * x^i) - (\<Sum>i\<le>n. a i * y^i) =
- (x - y) * (\<Sum>j<n. (\<Sum>i=Suc j..n. a i * y^(i - j - 1)) * x^j)"
+ shows "(\<Sum>i\<le>n. a i * x^i) - (\<Sum>i\<le>n. a i * y^i) =
+ (x - y) * (\<Sum>j<n. (\<Sum>i=Suc j..n. a i * y^(i - j - 1)) * x^j)"
proof -
have h: "bij_betw (\<lambda>(i,j). (j,i)) ((SIGMA i : atMost n. lessThan i)) (SIGMA j : lessThan n. {Suc j..n})"
by (auto simp: bij_betw_def inj_on_def)
- have "(\<Sum>i\<le>n. a i * x^i) - (\<Sum>i\<le>n. a i * y^i) =
- (\<Sum>i\<le>n. a i * (x^i - y^i))"
+ have "(\<Sum>i\<le>n. a i * x^i) - (\<Sum>i\<le>n. a i * y^i) = (\<Sum>i\<le>n. a i * (x^i - y^i))"
by (simp add: right_diff_distrib setsum_subtractf)
- also have "... = (\<Sum>i\<le>n. a i * (x - y) * (\<Sum>j<i. y^(i - Suc j) * x^j))"
+ also have "\<dots> = (\<Sum>i\<le>n. a i * (x - y) * (\<Sum>j<i. y^(i - Suc j) * x^j))"
by (simp add: power_diff_sumr2 mult.assoc)
- also have "... = (\<Sum>i\<le>n. \<Sum>j<i. a i * (x - y) * (y^(i - Suc j) * x^j))"
+ also have "\<dots> = (\<Sum>i\<le>n. \<Sum>j<i. a i * (x - y) * (y^(i - Suc j) * x^j))"
by (simp add: setsum_right_distrib)
- also have "... = (\<Sum>(i,j) \<in> (SIGMA i : atMost n. lessThan i). a i * (x - y) * (y^(i - Suc j) * x^j))"
+ also have "\<dots> = (\<Sum>(i,j) \<in> (SIGMA i : atMost n. lessThan i). a i * (x - y) * (y^(i - Suc j) * x^j))"
by (simp add: setsum.Sigma)
- also have "... = (\<Sum>(j,i) \<in> (SIGMA j : lessThan n. {Suc j..n}). a i * (x - y) * (y^(i - Suc j) * x^j))"
+ also have "\<dots> = (\<Sum>(j,i) \<in> (SIGMA j : lessThan n. {Suc j..n}). a i * (x - y) * (y^(i - Suc j) * x^j))"
by (auto simp add: setsum.reindex_bij_betw [OF h, symmetric] intro: setsum.strong_cong)
- also have "... = (\<Sum>j<n. \<Sum>i=Suc j..n. a i * (x - y) * (y^(i - Suc j) * x^j))"
+ also have "\<dots> = (\<Sum>j<n. \<Sum>i=Suc j..n. a i * (x - y) * (y^(i - Suc j) * x^j))"
by (simp add: setsum.Sigma)
- also have "... = (x - y) * (\<Sum>j<n. (\<Sum>i=Suc j..n. a i * y^(i - j - 1)) * x^j)"
+ also have "\<dots> = (x - y) * (\<Sum>j<n. (\<Sum>i=Suc j..n. a i * y^(i - j - 1)) * x^j)"
by (simp add: setsum_right_distrib mult_ac)
finally show ?thesis .
qed
lemma polyfun_diff_alt: (*COMPLEX_SUB_POLYFUN_ALT in HOL Light*)
- fixes x :: "'a::idom"
+ fixes x :: "'a::idom"
assumes "1 \<le> n"
- shows "(\<Sum>i\<le>n. a i * x^i) - (\<Sum>i\<le>n. a i * y^i) =
- (x - y) * ((\<Sum>j<n. \<Sum>k<n-j. a(j+k+1) * y^k * x^j))"
+ shows "(\<Sum>i\<le>n. a i * x^i) - (\<Sum>i\<le>n. a i * y^i) =
+ (x - y) * ((\<Sum>j<n. \<Sum>k<n-j. a(j + k + 1) * y^k * x^j))"
proof -
- { fix j::nat
- assume "j<n"
+ have "(\<Sum>i=Suc j..n. a i * y^(i - j - 1)) = (\<Sum>k<n-j. a(j+k+1) * y^k)"
+ if "j < n" for j :: nat
+ proof -
have h: "bij_betw (\<lambda>i. i - (j + 1)) {Suc j..n} (lessThan (n-j))"
apply (auto simp: bij_betw_def inj_on_def)
apply (rule_tac x="x + Suc j" in image_eqI)
- apply (auto simp: )
+ apply (auto simp: )
done
- have "(\<Sum>i=Suc j..n. a i * y^(i - j - 1)) = (\<Sum>k<n-j. a(j+k+1) * y^k)"
+ then show ?thesis
by (auto simp add: setsum.reindex_bij_betw [OF h, symmetric] intro: setsum.strong_cong)
- }
+ qed
then show ?thesis
by (simp add: polyfun_diff [OF assms] setsum_left_distrib)
qed
@@ -5661,18 +5710,19 @@
lemma polyfun_linear_factor: (*COMPLEX_POLYFUN_LINEAR_FACTOR in HOL Light*)
fixes a :: "'a::idom"
shows "\<exists>b. \<forall>z. (\<Sum>i\<le>n. c(i) * z^i) = (z - a) * (\<Sum>i<n. b(i) * z^i) + (\<Sum>i\<le>n. c(i) * a^i)"
-proof (cases "n=0")
+proof (cases "n = 0")
case True then show ?thesis
by simp
next
case False
- have "(\<exists>b. \<forall>z. (\<Sum>i\<le>n. c(i) * z^i) = (z - a) * (\<Sum>i<n. b(i) * z^i) + (\<Sum>i\<le>n. c(i) * a^i)) =
- (\<exists>b. \<forall>z. (\<Sum>i\<le>n. c(i) * z^i) - (\<Sum>i\<le>n. c(i) * a^i) = (z - a) * (\<Sum>i<n. b(i) * z^i))"
+ have "(\<exists>b. \<forall>z. (\<Sum>i\<le>n. c i * z^i) = (z - a) * (\<Sum>i<n. b i * z^i) + (\<Sum>i\<le>n. c i * a^i)) \<longleftrightarrow>
+ (\<exists>b. \<forall>z. (\<Sum>i\<le>n. c i * z^i) - (\<Sum>i\<le>n. c i * a^i) = (z - a) * (\<Sum>i<n. b i * z^i))"
by (simp add: algebra_simps)
- also have "... = (\<exists>b. \<forall>z. (z - a) * (\<Sum>j<n. (\<Sum>i = Suc j..n. c i * a^(i - Suc j)) * z^j) = (z - a) * (\<Sum>i<n. b(i) * z^i))"
+ also have "\<dots> \<longleftrightarrow>
+ (\<exists>b. \<forall>z. (z - a) * (\<Sum>j<n. (\<Sum>i = Suc j..n. c i * a^(i - Suc j)) * z^j) =
+ (z - a) * (\<Sum>i<n. b i * z^i))"
using False by (simp add: polyfun_diff)
- also have "... = True"
- by auto
+ also have "\<dots> = True" by auto
finally show ?thesis
by simp
qed
@@ -5680,23 +5730,21 @@
lemma polyfun_linear_factor_root: (*COMPLEX_POLYFUN_LINEAR_FACTOR_ROOT in HOL Light*)
fixes a :: "'a::idom"
assumes "(\<Sum>i\<le>n. c(i) * a^i) = 0"
- obtains b where "\<And>z. (\<Sum>i\<le>n. c(i) * z^i) = (z - a) * (\<Sum>i<n. b(i) * z^i)"
- using polyfun_linear_factor [of c n a] assms
- by auto
+ obtains b where "\<And>z. (\<Sum>i\<le>n. c i * z^i) = (z - a) * (\<Sum>i<n. b i * z^i)"
+ using polyfun_linear_factor [of c n a] assms by auto
(*The material of this section, up until this point, could go into a new theory of polynomials
based on Main alone. The remaining material involves limits, continuity, series, etc.*)
-lemma isCont_polynom:
- fixes c :: "nat \<Rightarrow> 'a::real_normed_div_algebra"
- shows "isCont (\<lambda>w. \<Sum>i\<le>n. c i * w^i) a"
+lemma isCont_polynom: "isCont (\<lambda>w. \<Sum>i\<le>n. c i * w^i) a"
+ for c :: "nat \<Rightarrow> 'a::real_normed_div_algebra"
by simp
lemma zero_polynom_imp_zero_coeffs:
- fixes c :: "nat \<Rightarrow> 'a::{ab_semigroup_mult,real_normed_div_algebra}"
+ fixes c :: "nat \<Rightarrow> 'a::{ab_semigroup_mult,real_normed_div_algebra}"
assumes "\<And>w. (\<Sum>i\<le>n. c i * w^i) = 0" "k \<le> n"
- shows "c k = 0"
-using assms
+ shows "c k = 0"
+ using assms
proof (induction n arbitrary: c k)
case 0
then show ?case
@@ -5705,36 +5753,35 @@
case (Suc n c k)
have [simp]: "c 0 = 0" using Suc.prems(1) [of 0]
by simp
- { fix w
+ have "(\<Sum>i\<le>Suc n. c i * w^i) = w * (\<Sum>i\<le>n. c (Suc i) * w^i)" for w
+ proof -
have "(\<Sum>i\<le>Suc n. c i * w^i) = (\<Sum>i\<le>n. c (Suc i) * w ^ Suc i)"
unfolding Set_Interval.setsum_atMost_Suc_shift
by simp
- also have "... = w * (\<Sum>i\<le>n. c (Suc i) * w^i)"
+ also have "\<dots> = w * (\<Sum>i\<le>n. c (Suc i) * w^i)"
by (simp add: setsum_right_distrib ac_simps)
- finally have "(\<Sum>i\<le>Suc n. c i * w^i) = w * (\<Sum>i\<le>n. c (Suc i) * w^i)" .
- }
- then have wnz: "\<And>w. w \<noteq> 0 \<Longrightarrow> (\<Sum>i\<le>n. c (Suc i) * w^i) = 0"
+ finally show ?thesis .
+ qed
+ then have w: "\<And>w. w \<noteq> 0 \<Longrightarrow> (\<Sum>i\<le>n. c (Suc i) * w^i) = 0"
using Suc by auto
then have "(\<lambda>h. \<Sum>i\<le>n. c (Suc i) * h^i) \<midarrow>0\<rightarrow> 0"
- by (simp cong: LIM_cong) \<comment>\<open>the case @{term"w=0"} by continuity\<close>
+ by (simp cong: LIM_cong) \<comment> \<open>the case \<open>w = 0\<close> by continuity\<close>
then have "(\<Sum>i\<le>n. c (Suc i) * 0^i) = 0"
using isCont_polynom [of 0 "\<lambda>i. c (Suc i)" n] LIM_unique
by (force simp add: Limits.isCont_iff)
- then have "\<And>w. (\<Sum>i\<le>n. c (Suc i) * w^i) = 0" using wnz
- by metis
- then have "\<And>i. i\<le>n \<Longrightarrow> c (Suc i) = 0"
- using Suc.IH [of "\<lambda>i. c (Suc i)"]
- by blast
+ then have "\<And>w. (\<Sum>i\<le>n. c (Suc i) * w^i) = 0"
+ using w by metis
+ then have "\<And>i. i \<le> n \<Longrightarrow> c (Suc i) = 0"
+ using Suc.IH [of "\<lambda>i. c (Suc i)"] by blast
then show ?case using \<open>k \<le> Suc n\<close>
by (cases k) auto
qed
lemma polyfun_rootbound: (*COMPLEX_POLYFUN_ROOTBOUND in HOL Light*)
- fixes c :: "nat \<Rightarrow> 'a::{idom,real_normed_div_algebra}"
+ fixes c :: "nat \<Rightarrow> 'a::{idom,real_normed_div_algebra}"
assumes "c k \<noteq> 0" "k\<le>n"
- shows "finite {z. (\<Sum>i\<le>n. c(i) * z^i) = 0} \<and>
- card {z. (\<Sum>i\<le>n. c(i) * z^i) = 0} \<le> n"
-using assms
+ shows "finite {z. (\<Sum>i\<le>n. c(i) * z^i) = 0} \<and> card {z. (\<Sum>i\<le>n. c(i) * z^i) = 0} \<le> n"
+ using assms
proof (induction n arbitrary: c k)
case 0
then show ?case
@@ -5754,9 +5801,9 @@
then obtain b where b: "\<And>w. (\<Sum>i\<le>Suc m. c i * w^i) = (w - z0) * (\<Sum>i\<le>m. b i * w^i)"
using polyfun_linear_factor_root [OF z0, unfolded lessThan_Suc_atMost]
by blast
- then have eq: "{z. (\<Sum>i\<le>Suc m. c(i) * z^i) = 0} = insert z0 {z. (\<Sum>i\<le>m. b(i) * z^i) = 0}"
+ then have eq: "{z. (\<Sum>i\<le>Suc m. c i * z^i) = 0} = insert z0 {z. (\<Sum>i\<le>m. b i * z^i) = 0}"
by auto
- have "~(\<forall>k\<le>m. b k = 0)"
+ have "\<not> (\<forall>k\<le>m. b k = 0)"
proof
assume [simp]: "\<forall>k\<le>m. b k = 0"
then have "\<And>w. (\<Sum>i\<le>m. b i * w^i) = 0"
@@ -5764,10 +5811,8 @@
then have "\<And>w. (\<Sum>i\<le>Suc m. c i * w^i) = 0"
using b by simp
then have "\<And>k. k \<le> Suc m \<Longrightarrow> c k = 0"
- using zero_polynom_imp_zero_coeffs
- by blast
- then show False using Suc.prems
- by blast
+ using zero_polynom_imp_zero_coeffs by blast
+ then show False using Suc.prems by blast
qed
then obtain k' where bk': "b k' \<noteq> 0" "k' \<le> m"
by blast
@@ -5778,48 +5823,43 @@
qed
lemma
- fixes c :: "nat \<Rightarrow> 'a::{idom,real_normed_div_algebra}"
+ fixes c :: "nat \<Rightarrow> 'a::{idom,real_normed_div_algebra}"
assumes "c k \<noteq> 0" "k\<le>n"
- shows polyfun_roots_finite: "finite {z. (\<Sum>i\<le>n. c(i) * z^i) = 0}"
- and polyfun_roots_card: "card {z. (\<Sum>i\<le>n. c(i) * z^i) = 0} \<le> n"
-using polyfun_rootbound assms
- by auto
+ shows polyfun_roots_finite: "finite {z. (\<Sum>i\<le>n. c(i) * z^i) = 0}"
+ and polyfun_roots_card: "card {z. (\<Sum>i\<le>n. c(i) * z^i) = 0} \<le> n"
+ using polyfun_rootbound assms by auto
lemma polyfun_finite_roots: (*COMPLEX_POLYFUN_FINITE_ROOTS in HOL Light*)
fixes c :: "nat \<Rightarrow> 'a::{idom,real_normed_div_algebra}"
shows "finite {x. (\<Sum>i\<le>n. c i * x^i) = 0} \<longleftrightarrow> (\<exists>i\<le>n. c i \<noteq> 0)"
- (is "?lhs = ?rhs")
+ (is "?lhs = ?rhs")
proof
assume ?lhs
- moreover
- { assume "\<forall>i\<le>n. c i = 0"
- then have "\<And>x. (\<Sum>i\<le>n. c i * x^i) = 0"
+ moreover have "\<not> finite {x. (\<Sum>i\<le>n. c i * x^i) = 0}" if "\<forall>i\<le>n. c i = 0"
+ proof -
+ from that have "\<And>x. (\<Sum>i\<le>n. c i * x^i) = 0"
by simp
- then have "\<not> finite {x. (\<Sum>i\<le>n. c i * x^i) = 0}"
+ then show ?thesis
using ex_new_if_finite [OF infinite_UNIV_char_0 [where 'a='a]]
by auto
- }
- ultimately show ?rhs
- by metis
+ qed
+ ultimately show ?rhs by metis
next
assume ?rhs
- then show ?lhs
- using polyfun_rootbound
- by blast
+ with polyfun_rootbound show ?lhs by blast
qed
-lemma polyfun_eq_0: (*COMPLEX_POLYFUN_EQ_0 in HOL Light*)
- fixes c :: "nat \<Rightarrow> 'a::{idom,real_normed_div_algebra}"
- shows "(\<forall>x. (\<Sum>i\<le>n. c i * x^i) = 0) \<longleftrightarrow> (\<forall>i\<le>n. c i = 0)"
+lemma polyfun_eq_0: "(\<forall>x. (\<Sum>i\<le>n. c i * x^i) = 0) \<longleftrightarrow> (\<forall>i\<le>n. c i = 0)"
+ for c :: "nat \<Rightarrow> 'a::{idom,real_normed_div_algebra}"
+ (*COMPLEX_POLYFUN_EQ_0 in HOL Light*)
using zero_polynom_imp_zero_coeffs by auto
-lemma polyfun_eq_coeffs:
- fixes c :: "nat \<Rightarrow> 'a::{idom,real_normed_div_algebra}"
- shows "(\<forall>x. (\<Sum>i\<le>n. c i * x^i) = (\<Sum>i\<le>n. d i * x^i)) \<longleftrightarrow> (\<forall>i\<le>n. c i = d i)"
+lemma polyfun_eq_coeffs: "(\<forall>x. (\<Sum>i\<le>n. c i * x^i) = (\<Sum>i\<le>n. d i * x^i)) \<longleftrightarrow> (\<forall>i\<le>n. c i = d i)"
+ for c :: "nat \<Rightarrow> 'a::{idom,real_normed_div_algebra}"
proof -
have "(\<forall>x. (\<Sum>i\<le>n. c i * x^i) = (\<Sum>i\<le>n. d i * x^i)) \<longleftrightarrow> (\<forall>x. (\<Sum>i\<le>n. (c i - d i) * x^i) = 0)"
by (simp add: left_diff_distrib Groups_Big.setsum_subtractf)
- also have "... \<longleftrightarrow> (\<forall>i\<le>n. c i - d i = 0)"
+ also have "\<dots> \<longleftrightarrow> (\<forall>i\<le>n. c i - d i = 0)"
by (rule polyfun_eq_0)
finally show ?thesis
by simp
@@ -5828,7 +5868,7 @@
lemma polyfun_eq_const: (*COMPLEX_POLYFUN_EQ_CONST in HOL Light*)
fixes c :: "nat \<Rightarrow> 'a::{idom,real_normed_div_algebra}"
shows "(\<forall>x. (\<Sum>i\<le>n. c i * x^i) = k) \<longleftrightarrow> c 0 = k \<and> (\<forall>i \<in> {1..n}. c i = 0)"
- (is "?lhs = ?rhs")
+ (is "?lhs = ?rhs")
proof -
have *: "\<forall>x. (\<Sum>i\<le>n. (if i=0 then k else 0) * x^i) = k"
by (induct n) auto
@@ -5848,15 +5888,14 @@
fixes z :: "'a::idom"
assumes "1 \<le> n"
shows "z^n = a \<longleftrightarrow> (\<Sum>i\<le>n. (if i = 0 then -a else if i=n then 1 else 0) * z^i) = 0"
- using assms
- by (cases n) (simp_all add: setsum_head_Suc atLeast0AtMost [symmetric])
+ using assms by (cases n) (simp_all add: setsum_head_Suc atLeast0AtMost [symmetric])
lemma
- fixes zz :: "'a::{idom,real_normed_div_algebra}"
- assumes "1 \<le> n"
+ assumes "SORT_CONSTRAINT('a::{idom,real_normed_div_algebra})"
+ and "1 \<le> n"
shows finite_roots_unity: "finite {z::'a. z^n = 1}"
and card_roots_unity: "card {z::'a. z^n = 1} \<le> n"
- using polyfun_rootbound [of "\<lambda>i. if i = 0 then -1 else if i=n then 1 else 0" n n] assms
- by (auto simp add: root_polyfun [OF assms])
+ using polyfun_rootbound [of "\<lambda>i. if i = 0 then -1 else if i=n then 1 else 0" n n] assms(2)
+ by (auto simp add: root_polyfun [OF assms(2)])
end