src/HOL/Multivariate_Analysis/Integration.thy
changeset 61204 3e491e34a62e
parent 61167 34f782641caa
child 61222 05d28dc76e5c
equal deleted inserted replaced
61203:a8a8eca85801 61204:3e491e34a62e
   493   shows "content (cbox a b) = (\<Prod>i\<in>Basis. b\<bullet>i - a\<bullet>i)"
   493   shows "content (cbox a b) = (\<Prod>i\<in>Basis. b\<bullet>i - a\<bullet>i)"
   494     using assms box_ne_empty(1) content_cbox by blast
   494     using assms box_ne_empty(1) content_cbox by blast
   495 
   495 
   496 lemma content_real: "a \<le> b \<Longrightarrow> content {a..b} = b - a"
   496 lemma content_real: "a \<le> b \<Longrightarrow> content {a..b} = b - a"
   497   by (auto simp: interval_upperbound_def interval_lowerbound_def SUP_def INF_def content_def)
   497   by (auto simp: interval_upperbound_def interval_lowerbound_def SUP_def INF_def content_def)
       
   498 
       
   499 lemma abs_eq_content: "abs (y - x) = (if x\<le>y then content {x .. y} else content {y..x})"
       
   500   by (auto simp: content_real)
   498 
   501 
   499 lemma content_singleton[simp]: "content {a} = 0"
   502 lemma content_singleton[simp]: "content {a} = 0"
   500 proof -
   503 proof -
   501   have "content (cbox a a) = 0"
   504   have "content (cbox a a) = 0"
   502     by (subst content_cbox) (auto simp: ex_in_conv)
   505     by (subst content_cbox) (auto simp: ex_in_conv)
  6412   unfolding integrable_on_def
  6415   unfolding integrable_on_def
  6413   apply rule
  6416   apply rule
  6414   apply (rule has_integral_const)
  6417   apply (rule has_integral_const)
  6415   done
  6418   done
  6416 
  6419 
       
  6420 lemma integral_has_vector_derivative_continuous_at:
       
  6421   fixes f :: "real \<Rightarrow> 'a::banach"
       
  6422   assumes f: "f integrable_on {a..b}"
       
  6423       and x: "x \<in> {a..b}"
       
  6424       and fx: "continuous (at x within {a..b}) f"
       
  6425   shows "((\<lambda>u. integral {a..u} f) has_vector_derivative f x) (at x within {a..b})"
       
  6426 proof -
       
  6427   let ?I = "\<lambda>a b. integral {a..b} f"
       
  6428   { fix e::real 
       
  6429     assume "e > 0"
       
  6430     obtain d where "d>0" and d: "\<And>x'. \<lbrakk>x' \<in> {a..b}; \<bar>x' - x\<bar> < d\<rbrakk> \<Longrightarrow> norm(f x' - f x) \<le> e"
       
  6431       using `e>0` fx by (auto simp: continuous_within_eps_delta dist_norm less_imp_le)
       
  6432     have "norm (integral {a..y} f - integral {a..x} f - (y - x) *\<^sub>R f x) \<le> e * \<bar>y - x\<bar>"
       
  6433            if y: "y \<in> {a..b}" and yx: "\<bar>y - x\<bar> < d" for y  
       
  6434     proof (cases "y < x")
       
  6435       case False
       
  6436       have "f integrable_on {a..y}"
       
  6437         using f y by (simp add: integrable_subinterval_real)
       
  6438       then have Idiff: "?I a y - ?I a x = ?I x y" 
       
  6439         using False x by (simp add: algebra_simps integral_combine)
       
  6440       have fux_int: "((\<lambda>u. f u - f x) has_integral integral {x..y} f - (y - x) *\<^sub>R f x) {x..y}"
       
  6441         apply (rule has_integral_sub)
       
  6442         using x y apply (force intro: integrable_integral [OF integrable_subinterval_real [OF f]])
       
  6443         using has_integral_const_real [of "f x" x y] False
       
  6444         apply (simp add: )
       
  6445         done
       
  6446       show ?thesis
       
  6447         using False
       
  6448         apply (simp add: abs_eq_content del: content_real_if)
       
  6449         apply (rule has_integral_bound_real[where f="(\<lambda>u. f u - f x)"])
       
  6450         using yx False d x y `e>0` apply (auto simp add: Idiff fux_int)
       
  6451         done
       
  6452     next
       
  6453       case True
       
  6454       have "f integrable_on {a..x}"
       
  6455         using f x by (simp add: integrable_subinterval_real)
       
  6456       then have Idiff: "?I a x - ?I a y = ?I y x" 
       
  6457         using True x y by (simp add: algebra_simps integral_combine)
       
  6458       have fux_int: "((\<lambda>u. f u - f x) has_integral integral {y..x} f - (x - y) *\<^sub>R f x) {y..x}"
       
  6459         apply (rule has_integral_sub)
       
  6460         using x y apply (force intro: integrable_integral [OF integrable_subinterval_real [OF f]])
       
  6461         using has_integral_const_real [of "f x" y x] True
       
  6462         apply (simp add: )
       
  6463         done
       
  6464       have "norm (integral {a..x} f - integral {a..y} f - (x - y) *\<^sub>R f x) \<le> e * \<bar>y - x\<bar>"
       
  6465         using True
       
  6466         apply (simp add: abs_eq_content del: content_real_if)
       
  6467         apply (rule has_integral_bound_real[where f="(\<lambda>u. f u - f x)"])
       
  6468         using yx True d x y `e>0` apply (auto simp add: Idiff fux_int)
       
  6469         done
       
  6470       then show ?thesis
       
  6471         by (simp add: algebra_simps norm_minus_commute)
       
  6472     qed
       
  6473     then have "\<exists>d>0. \<forall>y\<in>{a..b}. \<bar>y - x\<bar> < d \<longrightarrow> norm (integral {a..y} f - integral {a..x} f - (y - x) *\<^sub>R f x) \<le> e * \<bar>y - x\<bar>"
       
  6474       using `d>0` by blast 
       
  6475   } 
       
  6476   then show ?thesis
       
  6477     by (simp add: has_vector_derivative_def has_derivative_within_alt bounded_linear_scaleR_left)
       
  6478 qed
       
  6479 
  6417 lemma integral_has_vector_derivative:
  6480 lemma integral_has_vector_derivative:
  6418   fixes f :: "real \<Rightarrow> 'a::banach"
  6481   fixes f :: "real \<Rightarrow> 'a::banach"
  6419   assumes "continuous_on {a .. b} f"
  6482   assumes "continuous_on {a .. b} f"
  6420     and "x \<in> {a .. b}"
  6483     and "x \<in> {a .. b}"
  6421   shows "((\<lambda>u. integral {a .. u} f) has_vector_derivative f(x)) (at x within {a .. b})"
  6484   shows "((\<lambda>u. integral {a .. u} f) has_vector_derivative f(x)) (at x within {a .. b})"
  6422   unfolding has_vector_derivative_def has_derivative_within_alt
  6485 apply (rule integral_has_vector_derivative_continuous_at [OF integrable_continuous_real])
  6423   apply safe
  6486 using assms
  6424   apply (rule bounded_linear_scaleR_left)
  6487 apply (auto simp: continuous_on_eq_continuous_within)
  6425 proof -
  6488 done
  6426   fix e :: real
       
  6427   assume e: "e > 0"
       
  6428   note compact_uniformly_continuous[OF assms(1) compact_Icc,unfolded uniformly_continuous_on_def]
       
  6429   from this[rule_format,OF e] guess d by (elim conjE exE) note d=this[rule_format]
       
  6430   let ?I = "\<lambda>a b. integral {a .. b} f"
       
  6431   show "\<exists>d>0. \<forall>y\<in>{a .. b}. norm (y - x) < d \<longrightarrow>
       
  6432     norm (?I a y - ?I a x - (y - x) *\<^sub>R f x) \<le> e * norm (y - x)"
       
  6433   proof (rule, rule, rule d, safe, goal_cases)
       
  6434     case prems: (1 y)
       
  6435     show ?case
       
  6436     proof (cases "y < x")
       
  6437       case False
       
  6438       have "f integrable_on {a .. y}"
       
  6439         apply (rule integrable_subinterval_real,rule integrable_continuous_real)
       
  6440         apply (rule assms)
       
  6441         unfolding not_less
       
  6442         using assms(2) prems
       
  6443         apply auto
       
  6444         done
       
  6445       then have *: "?I a y - ?I a x = ?I x y"
       
  6446         unfolding algebra_simps
       
  6447         apply (subst eq_commute)
       
  6448         apply (rule integral_combine)
       
  6449         using False
       
  6450         unfolding not_less
       
  6451         using assms(2) prems
       
  6452         apply auto
       
  6453         done
       
  6454       have **: "norm (y - x) = content {x .. y}"
       
  6455         using False by (auto simp: content_real)
       
  6456       show ?thesis
       
  6457         unfolding **
       
  6458         apply (rule has_integral_bound_real[where f="(\<lambda>u. f u - f x)"])
       
  6459         unfolding *
       
  6460         defer
       
  6461         apply (rule has_integral_sub)
       
  6462         apply (rule integrable_integral)
       
  6463         apply (rule integrable_subinterval_real)
       
  6464         apply (rule integrable_continuous_real)
       
  6465         apply (rule assms)+
       
  6466       proof -
       
  6467         show "{x .. y} \<subseteq> {a .. b}"
       
  6468           using prems assms(2) by auto
       
  6469         have *: "y - x = norm (y - x)"
       
  6470           using False by auto
       
  6471         show "((\<lambda>xa. f x) has_integral (y - x) *\<^sub>R f x) {x .. y}"
       
  6472           apply (subst *)
       
  6473           unfolding **
       
  6474           by blast
       
  6475         show "\<forall>xa\<in>{x .. y}. norm (f xa - f x) \<le> e"
       
  6476           apply safe
       
  6477           apply (rule less_imp_le)
       
  6478           apply (rule d(2)[unfolded dist_norm])
       
  6479           using assms(2)
       
  6480           using prems
       
  6481           apply auto
       
  6482           done
       
  6483       qed (insert e, auto)
       
  6484     next
       
  6485       case True
       
  6486       have "f integrable_on cbox a x"
       
  6487         apply (rule integrable_subinterval,rule integrable_continuous)
       
  6488         unfolding box_real
       
  6489         apply (rule assms)+
       
  6490         unfolding not_less
       
  6491         using assms(2) prems
       
  6492         apply auto
       
  6493         done
       
  6494       then have *: "?I a x - ?I a y = ?I y x"
       
  6495         unfolding algebra_simps
       
  6496         apply (subst eq_commute)
       
  6497         apply (rule integral_combine)
       
  6498         using True using assms(2) prems
       
  6499         apply auto
       
  6500         done
       
  6501       have **: "norm (y - x) = content {y .. x}"
       
  6502         apply (subst content_real)
       
  6503         using True
       
  6504         unfolding not_less
       
  6505         apply auto
       
  6506         done
       
  6507       have ***: "\<And>fy fx c::'a. fx - fy - (y - x) *\<^sub>R c = -(fy - fx - (x - y) *\<^sub>R c)"
       
  6508         unfolding scaleR_left.diff by auto
       
  6509       show ?thesis
       
  6510         apply (subst ***)
       
  6511         unfolding norm_minus_cancel **
       
  6512         apply (rule has_integral_bound_real[where f="(\<lambda>u. f u - f x)"])
       
  6513         unfolding *
       
  6514         unfolding o_def
       
  6515         defer
       
  6516         apply (rule has_integral_sub)
       
  6517         apply (subst minus_minus[symmetric])
       
  6518         unfolding minus_minus
       
  6519         apply (rule integrable_integral)
       
  6520         apply (rule integrable_subinterval_real,rule integrable_continuous_real)
       
  6521         apply (rule assms)+
       
  6522       proof -
       
  6523         show "{y .. x} \<subseteq> {a .. b}"
       
  6524           using prems assms(2) by auto
       
  6525         have *: "x - y = norm (y - x)"
       
  6526           using True by auto
       
  6527         show "((\<lambda>xa. f x) has_integral (x - y) *\<^sub>R f x) {y .. x}"
       
  6528           apply (subst *)
       
  6529           unfolding **
       
  6530           apply blast
       
  6531           done
       
  6532         show "\<forall>xa\<in>{y .. x}. norm (f xa - f x) \<le> e"
       
  6533           apply safe
       
  6534           apply (rule less_imp_le)
       
  6535           apply (rule d(2)[unfolded dist_norm])
       
  6536           using assms(2)
       
  6537           using prems
       
  6538           apply auto
       
  6539           done
       
  6540       qed (insert e, auto)
       
  6541     qed
       
  6542   qed
       
  6543 qed
       
  6544 
  6489 
  6545 lemma antiderivative_continuous:
  6490 lemma antiderivative_continuous:
  6546   fixes q b :: real
  6491   fixes q b :: real
  6547   assumes "continuous_on {a .. b} f"
  6492   assumes "continuous_on {a .. b} f"
  6548   obtains g where "\<forall>x\<in>{a .. b}. (g has_vector_derivative (f x::_::banach)) (at x within {a .. b})"
  6493   obtains g where "\<forall>x\<in>{a .. b}. (g has_vector_derivative (f x::_::banach)) (at x within {a .. b})"