11594 using insert(5) |
11592 using insert(5) |
11595 apply auto |
11593 apply auto |
11596 done |
11594 done |
11597 qed |
11595 qed |
11598 qed auto |
11596 qed auto |
|
11597 |
|
11598 |
|
11599 subsection \<open>differentiation under the integral sign\<close> |
|
11600 |
|
11601 lemma tube_lemma: |
|
11602 assumes "compact K" |
|
11603 assumes "open W" |
|
11604 assumes "{x0} \<times> K \<subseteq> W" |
|
11605 shows "\<exists>X0. x0 \<in> X0 \<and> open X0 \<and> X0 \<times> K \<subseteq> W" |
|
11606 proof - |
|
11607 { |
|
11608 fix y assume "y \<in> K" |
|
11609 then have "(x0, y) \<in> W" using assms by auto |
|
11610 with \<open>open W\<close> |
|
11611 have "\<exists>X0 Y. open X0 \<and> open Y \<and> x0 \<in> X0 \<and> y \<in> Y \<and> X0 \<times> Y \<subseteq> W" |
|
11612 by (rule open_prod_elim) blast |
|
11613 } then obtain X0 Y where |
|
11614 "\<forall>y \<in> K. open (X0 y) \<and> open (Y y) \<and> x0 \<in> X0 y \<and> y \<in> Y y \<and> X0 y \<times> Y y \<subseteq> W" |
|
11615 by metis |
|
11616 moreover |
|
11617 then have "\<forall>t\<in>Y ` K. open t" "K \<subseteq> \<Union>(Y ` K)" by auto |
|
11618 with \<open>compact K\<close> obtain CC where "CC \<subseteq> Y ` K" "finite CC" "K \<subseteq> \<Union>CC" |
|
11619 by (rule compactE) |
|
11620 moreover |
|
11621 then obtain c where c: |
|
11622 "\<And>C. C \<in> CC \<Longrightarrow> c C \<in> K \<and> C = Y (c C)" |
|
11623 by (force intro!: choice) |
|
11624 ultimately show ?thesis |
|
11625 by (force intro!: exI[where x="\<Inter>C\<in>CC. X0 (c C)"]) |
|
11626 qed |
|
11627 |
|
11628 lemma eventually_closed_segment: |
|
11629 fixes x0::"'a::real_normed_vector" |
|
11630 assumes "open X0" "x0 \<in> X0" |
|
11631 shows "\<forall>\<^sub>F x in at x0 within U. closed_segment x0 x \<subseteq> X0" |
|
11632 proof - |
|
11633 from openE[OF assms] |
|
11634 obtain e where e: "0 < e" "ball x0 e \<subseteq> X0" . |
|
11635 then have "\<forall>\<^sub>F x in at x0 within U. x \<in> ball x0 e" |
|
11636 by (auto simp: dist_commute eventually_at) |
|
11637 then show ?thesis |
|
11638 proof eventually_elim |
|
11639 case (elim x) |
|
11640 have "x0 \<in> ball x0 e" using \<open>e > 0\<close> by simp |
|
11641 from convex_ball[unfolded convex_contains_segment, rule_format, OF this elim] |
|
11642 have "closed_segment x0 x \<subseteq> ball x0 e" . |
|
11643 also note \<open>\<dots> \<subseteq> X0\<close> |
|
11644 finally show ?case . |
|
11645 qed |
|
11646 qed |
|
11647 |
|
11648 lemma leibniz_rule: |
|
11649 fixes f::"'a::banach \<times> 'b::euclidean_space \<Rightarrow> 'c::banach" |
|
11650 assumes fx: "\<And>x t. x \<in> U \<Longrightarrow> t \<in> (cbox a b) \<Longrightarrow> |
|
11651 ((\<lambda>x. f (x, t)) has_derivative blinfun_apply (fx (x, t))) (at x within U)" |
|
11652 assumes integrable_f2: "\<And>x. x \<in> U \<Longrightarrow> (\<lambda>t. f (x, t)) integrable_on cbox a b" |
|
11653 assumes cont_fx: "continuous_on (U \<times> (cbox a b)) fx" |
|
11654 assumes [intro]: "x0 \<in> U" |
|
11655 assumes "convex U" |
|
11656 notes [continuous_intros] = continuous_on_compose2[OF cont_fx] |
|
11657 shows |
|
11658 "((\<lambda>x. integral (cbox a b) (\<lambda>t. f (x, t))) has_derivative integral (cbox a b) (\<lambda>t. fx (x0, t))) |
|
11659 (at x0 within U)" |
|
11660 (is "(?F has_derivative ?dF) _") |
|
11661 proof cases |
|
11662 assume "content (cbox a b) \<noteq> 0" |
|
11663 then have ne: "cbox a b \<noteq> {}" by auto |
|
11664 show ?thesis |
|
11665 proof (intro has_derivativeI bounded_linear_scaleR_left tendstoI, fold norm_conv_dist) |
|
11666 have cont_f1: "\<And>t. t \<in> cbox a b \<Longrightarrow> continuous_on U (\<lambda>x. f (x, t))" |
|
11667 by (auto simp: continuous_on_eq_continuous_within intro!: has_derivative_continuous fx) |
|
11668 note [continuous_intros] = continuous_on_compose2[OF cont_f1] |
|
11669 fix e'::real |
|
11670 assume "e' > 0" |
|
11671 def e \<equiv> "e' / (content (cbox a b) + 1)" |
|
11672 have "e > 0" using \<open>e' > 0\<close> by (auto simp: e_def intro!: divide_pos_pos add_nonneg_pos) |
|
11673 def psi \<equiv> "\<lambda>(x, t). fx (x, t) - fx (x0, t)" |
|
11674 def W0 \<equiv> "{(x, t) \<in> U \<times> (cbox a b). norm (psi (x, t)) < e}" |
|
11675 have W0_eq: "W0 = (\<lambda>(x, t). norm (psi (x, t))) -` {..<e} \<inter> U \<times> (cbox a b)" |
|
11676 by (auto simp: vimage_def W0_def) |
|
11677 have "open {..<e}" by simp |
|
11678 have "continuous_on (U \<times> (cbox a b)) (\<lambda>(x, t). norm (psi (x, t)))" |
|
11679 by (auto intro!: continuous_intros simp: psi_def split_beta') |
|
11680 from this[unfolded continuous_on_open_invariant, rule_format, OF \<open>open {..<e}\<close>] |
|
11681 obtain W where W: "open W" "W \<inter> U \<times> (cbox a b) = W0 \<inter> U \<times> (cbox a b)" |
|
11682 unfolding W0_eq by blast |
|
11683 have "{x0} \<times> (cbox a b) \<subseteq> W \<inter> U \<times> (cbox a b)" |
|
11684 unfolding W |
|
11685 by (auto simp: W0_def psi_def \<open>0 < e\<close>) |
|
11686 then have "{x0} \<times> cbox a b \<subseteq> W" by blast |
|
11687 from tube_lemma[OF compact_cbox[of a b] \<open>open W\<close> this] |
|
11688 obtain X0 where X0: "x0 \<in> X0" "open X0" "X0 \<times> cbox a b \<subseteq> W" |
|
11689 by blast |
|
11690 |
|
11691 note eventually_closed_segment[OF \<open>open X0\<close> \<open>x0 \<in> X0\<close>, of U] |
|
11692 moreover |
|
11693 have "\<forall>\<^sub>F x in at x0 within U. x \<in> X0" |
|
11694 using \<open>open X0\<close> \<open>x0 \<in> X0\<close> eventually_at_topological by blast |
|
11695 moreover have "\<forall>\<^sub>F x in at x0 within U. x \<noteq> x0" |
|
11696 by (auto simp: eventually_at_filter) |
|
11697 moreover have "\<forall>\<^sub>F x in at x0 within U. x \<in> U" |
|
11698 by (auto simp: eventually_at_filter) |
|
11699 ultimately |
|
11700 show "\<forall>\<^sub>F x in at x0 within U. norm ((?F x - ?F x0 - ?dF (x - x0)) /\<^sub>R norm (x - x0)) < e'" |
|
11701 proof eventually_elim |
|
11702 case (elim x) |
|
11703 from elim have "0 < norm (x - x0)" by simp |
|
11704 have "closed_segment x0 x \<subseteq> U" |
|
11705 by (rule \<open>convex U\<close>[unfolded convex_contains_segment, rule_format, OF \<open>x0 \<in> U\<close> \<open>x \<in> U\<close>]) |
|
11706 from elim have [intro]: "x \<in> U" by auto |
|
11707 |
|
11708 have "?F x - ?F x0 - ?dF (x - x0) = |
|
11709 integral (cbox a b) (\<lambda>xa. f (x, xa) - f (x0, xa) - fx (x0, xa) (x - x0))" |
|
11710 (is "_ = ?id") |
|
11711 using \<open>x \<noteq> x0\<close> |
|
11712 by (subst blinfun_apply_integral integral_diff, |
|
11713 auto intro!: integrable_diff integrable_f2 continuous_intros |
|
11714 intro: integrable_continuous)+ |
|
11715 also |
|
11716 { |
|
11717 fix t assume t: "t \<in> (cbox a b)" |
|
11718 have seg: "\<And>t. t \<in> {0..1} \<Longrightarrow> x0 + t *\<^sub>R (x - x0) \<in> closed_segment x0 x \<inter> U" |
|
11719 using \<open>closed_segment x0 x \<subseteq> U\<close> |
|
11720 by (force simp: closed_segment_def algebra_simps) |
|
11721 from t have deriv: |
|
11722 "((\<lambda>x. f (x, t)) has_derivative (fx (y, t))) (at y within closed_segment x0 x \<inter> U)" |
|
11723 if "y \<in> closed_segment x0 x \<inter> U" for y |
|
11724 unfolding has_vector_derivative_def[symmetric] |
|
11725 using that \<open>x \<in> X0\<close> |
|
11726 by (intro has_derivative_within_subset[OF fx]) auto |
|
11727 have "\<forall>x\<in>closed_segment x0 x \<inter> U. norm (fx (x, t) - fx (x0, t)) \<le> e" |
|
11728 proof |
|
11729 fix y assume y: "y \<in> closed_segment x0 x \<inter> U" |
|
11730 have "norm (fx (y, t) - fx (x0, t)) = norm (psi (y, t))" |
|
11731 by (auto simp: psi_def) |
|
11732 also |
|
11733 { |
|
11734 have "(y, t) \<in> X0 \<times> (cbox a b)" |
|
11735 using t \<open>closed_segment x0 x \<subseteq> X0\<close> y |
|
11736 by auto |
|
11737 also note \<open>\<dots> \<subseteq> W\<close> |
|
11738 finally have "(y, t) \<in> W" . |
|
11739 with t y have "(y, t) \<in> W \<inter> U \<times> (cbox a b)" |
|
11740 by blast |
|
11741 also note \<open>W \<inter> U \<times> (cbox a b) = W0 \<inter> U \<times> (cbox a b)\<close> |
|
11742 finally have "norm (psi (y, t)) < e" |
|
11743 by (auto simp: W0_def) |
|
11744 } |
|
11745 finally show "norm (fx (y, t) - fx (x0, t)) \<le> e" by simp |
|
11746 qed |
|
11747 then have onorm: |
|
11748 "\<forall>x\<in>closed_segment x0 x \<inter> U. |
|
11749 onorm (blinfun_apply (fx (x, t)) - blinfun_apply (fx (x0, t))) \<le> e" |
|
11750 by (auto simp: norm_blinfun.rep_eq blinfun.diff_left[abs_def] fun_diff_def) |
|
11751 |
|
11752 from differentiable_bound_linearization[OF seg deriv onorm] |
|
11753 have "norm (f (x, t) - f (x0, t) - fx (x0, t) (x - x0)) \<le> e * norm (x - x0)" |
|
11754 by (auto simp add: ac_simps) |
|
11755 } |
|
11756 then have "norm ?id \<le> integral (cbox a b) (\<lambda>_. e * norm (x - x0))" |
|
11757 by (intro integral_norm_bound_integral) |
|
11758 (auto intro!: continuous_intros integrable_diff integrable_f2 |
|
11759 intro: integrable_continuous) |
|
11760 also have "\<dots> = content (cbox a b) * e * norm (x - x0)" |
|
11761 by simp |
|
11762 also have "\<dots> < e' * norm (x - x0)" |
|
11763 using \<open>e' > 0\<close> content_pos_le[of a b] |
|
11764 by (intro mult_strict_right_mono[OF _ \<open>0 < norm (x - x0)\<close>]) |
|
11765 (auto simp: divide_simps e_def) |
|
11766 finally have "norm (?F x - ?F x0 - ?dF (x - x0)) < e' * norm (x - x0)" . |
|
11767 then show ?case |
|
11768 by (auto simp: divide_simps) |
|
11769 qed |
|
11770 qed (rule blinfun.bounded_linear_right) |
|
11771 qed (auto intro!: derivative_eq_intros simp: blinfun.bilinear_simps) |
|
11772 |
|
11773 lemma |
|
11774 has_vector_derivative_eq_has_derivative_blinfun: |
|
11775 "(f has_vector_derivative f') (at x within U) \<longleftrightarrow> |
|
11776 (f has_derivative blinfun_scaleR_left f') (at x within U)" |
|
11777 by (simp add: has_vector_derivative_def) |
|
11778 |
|
11779 lemma leibniz_rule_vector_derivative: |
|
11780 fixes f::"real \<times> 'b::euclidean_space \<Rightarrow> 'c::banach" |
|
11781 assumes fx: "\<And>x t. x \<in> U \<Longrightarrow> t \<in> (cbox a b) \<Longrightarrow> |
|
11782 ((\<lambda>x. f (x, t)) has_vector_derivative (fx (x, t))) (at x within U)" |
|
11783 assumes integrable_f2: "\<And>x. x \<in> U \<Longrightarrow> (\<lambda>t. f (x, t)) integrable_on cbox a b" |
|
11784 assumes cont_fx: "continuous_on (U \<times> (cbox a b)) fx" |
|
11785 assumes U: "x0 \<in> U" "convex U" |
|
11786 notes [continuous_intros] = continuous_on_compose2[OF cont_fx] |
|
11787 shows |
|
11788 "((\<lambda>x. integral (cbox a b) (\<lambda>t. f (x, t))) has_vector_derivative |
|
11789 integral (cbox a b) (\<lambda>t. fx (x0, t))) (at x0 within U)" |
|
11790 proof - |
|
11791 have *: "blinfun_scaleR_left (integral (cbox a b) (\<lambda>t. fx (x0, t))) = |
|
11792 integral (cbox a b) (\<lambda>t. blinfun_scaleR_left (fx (x0, t)))" |
|
11793 by (subst integral_linear[symmetric]) |
|
11794 (auto simp: has_vector_derivative_def o_def |
|
11795 intro!: integrable_continuous U continuous_intros bounded_linear_intros) |
|
11796 show ?thesis |
|
11797 unfolding has_vector_derivative_eq_has_derivative_blinfun |
|
11798 apply (rule has_derivative_eq_rhs) |
|
11799 apply (rule leibniz_rule[OF _ integrable_f2 _ U, where fx="\<lambda>x. blinfun_scaleR_left (fx x)"]) |
|
11800 using assms(1) |
|
11801 apply (auto simp: has_vector_derivative_def * intro!: continuous_intros) |
|
11802 done |
|
11803 qed |
|
11804 |
|
11805 lemma |
|
11806 has_field_derivative_eq_has_derivative_blinfun: |
|
11807 "(f has_field_derivative f') (at x within U) \<longleftrightarrow> (f has_derivative blinfun_mult_right f') (at x within U)" |
|
11808 by (simp add: has_field_derivative_def) |
|
11809 |
|
11810 lemma leibniz_rule_field_derivative: |
|
11811 fixes f::"'a::{real_normed_field, banach} \<times> 'b::euclidean_space \<Rightarrow> 'a" |
|
11812 assumes fx: "\<And>x t. x \<in> U \<Longrightarrow> t \<in> (cbox a b) \<Longrightarrow> ((\<lambda>x. f (x, t)) has_field_derivative (fx (x, t))) (at x within U)" |
|
11813 assumes integrable_f2: "\<And>x. x \<in> U \<Longrightarrow> (\<lambda>t. f (x, t)) integrable_on cbox a b" |
|
11814 assumes cont_fx: "continuous_on (U \<times> (cbox a b)) fx" |
|
11815 assumes U: "x0 \<in> U" "convex U" |
|
11816 notes [continuous_intros] = continuous_on_compose2[OF cont_fx] |
|
11817 shows "((\<lambda>x. integral (cbox a b) (\<lambda>t. f (x, t))) has_field_derivative integral (cbox a b) (\<lambda>t. fx (x0, t))) (at x0 within U)" |
|
11818 proof - |
|
11819 have *: "blinfun_mult_right (integral (cbox a b) (\<lambda>t. fx (x0, t))) = |
|
11820 integral (cbox a b) (\<lambda>t. blinfun_mult_right (fx (x0, t)))" |
|
11821 by (subst integral_linear[symmetric]) |
|
11822 (auto simp: has_vector_derivative_def o_def |
|
11823 intro!: integrable_continuous U continuous_intros bounded_linear_intros) |
|
11824 show ?thesis |
|
11825 unfolding has_field_derivative_eq_has_derivative_blinfun |
|
11826 apply (rule has_derivative_eq_rhs) |
|
11827 apply (rule leibniz_rule[OF _ integrable_f2 _ U, where fx="\<lambda>x. blinfun_mult_right (fx x)"]) |
|
11828 using assms(1) |
|
11829 apply (auto simp: has_field_derivative_def * intro!: continuous_intros) |
|
11830 done |
|
11831 qed |
11599 |
11832 |
11600 |
11833 |
11601 subsection \<open>Exchange uniform limit and integral\<close> |
11834 subsection \<open>Exchange uniform limit and integral\<close> |
11602 |
11835 |
11603 lemma |
11836 lemma |