# HG changeset patch # User paulson # Date 1744494152 -3600 # Node ID d35d355f733042bbe4383417a657e134bc4c4ffe # Parent b52e57ed7e29ad0a1dcadb53ebbdb408cd15a06f Tidied more messy old proofs diff -r b52e57ed7e29 -r d35d355f7330 src/HOL/Analysis/Inner_Product.thy --- a/src/HOL/Analysis/Inner_Product.thy Fri Apr 11 22:17:06 2025 +0100 +++ b/src/HOL/Analysis/Inner_Product.thy Sat Apr 12 22:42:32 2025 +0100 @@ -87,6 +87,9 @@ lemma power2_norm_eq_inner: "(norm x)\<^sup>2 = inner x x" by (simp add: norm_eq_sqrt_inner) +lemma dot_square_norm: "inner x x = (norm x)\<^sup>2" + by (metis power2_norm_eq_inner) + text \Identities involving real multiplication and division.\ lemma inner_mult_left: "inner (of_real m * a) b = m * (inner a b)" @@ -143,15 +146,15 @@ show "norm x = 0 \ x = 0" unfolding norm_eq_sqrt_inner by simp show "norm (x + y) \ norm x + norm y" - proof (rule power2_le_imp_le) - have "inner x y \ norm x * norm y" - by (rule norm_cauchy_schwarz) - thus "(norm (x + y))\<^sup>2 \ (norm x + norm y)\<^sup>2" - unfolding power2_sum power2_norm_eq_inner - by (simp add: inner_add inner_commute) - show "0 \ norm x + norm y" - unfolding norm_eq_sqrt_inner by simp - qed + proof (rule power2_le_imp_le) + have "inner x y \ norm x * norm y" + by (rule norm_cauchy_schwarz) + thus "(norm (x + y))\<^sup>2 \ (norm x + norm y)\<^sup>2" + unfolding power2_sum power2_norm_eq_inner + by (simp add: inner_add inner_commute) + show "0 \ norm x + norm y" + unfolding norm_eq_sqrt_inner by simp + qed have "sqrt (a\<^sup>2 * inner x x) = \a\ * sqrt (inner x x)" by (simp add: real_sqrt_mult) then show "norm (a *\<^sub>R x) = \a\ * norm x" @@ -184,9 +187,7 @@ by (simp add: norm_eq_sqrt_inner) lemma norm_eq: "norm x = norm y \ inner x x = inner y y" - apply (subst order_eq_iff) - apply (auto simp: norm_le) - done + by (simp add: norm_eq_sqrt_inner) lemma norm_eq_1: "norm x = 1 \ inner x x = 1" by (simp add: norm_eq_sqrt_inner) @@ -231,10 +232,7 @@ show "inner x (scaleR r y) = scaleR r (inner x y)" unfolding real_scaleR_def by (rule inner_scaleR_right) show "\K. \x y::'a. norm (inner x y) \ norm x * norm y * K" - proof - show "\x y::'a. norm (inner x y) \ norm x * norm y * 1" - by (simp add: Cauchy_Schwarz_ineq2) - qed + by (metis Cauchy_Schwarz_ineq2 mult.commute mult_1 real_norm_def) qed lemmas tendsto_inner [tendsto_intros] = @@ -337,7 +335,6 @@ lemma complex_inner_i_right [simp]: "inner x \ = Im x" unfolding inner_complex_def by simp - lemma dot_square_norm: "inner x x = (norm x)\<^sup>2" by (simp only: power2_norm_eq_inner) (* TODO: move? *) @@ -345,16 +342,10 @@ by (auto simp add: norm_eq_sqrt_inner) lemma norm_le_square: "norm x \ a \ 0 \ a \ inner x x \ a\<^sup>2" - apply (simp add: dot_square_norm abs_le_square_iff[symmetric]) - using norm_ge_zero[of x] - apply arith - done + by (metis norm_eq_sqrt_inner norm_ge_zero order_trans real_le_lsqrt sqrt_le_D) lemma norm_ge_square: "norm x \ a \ a \ 0 \ inner x x \ a\<^sup>2" - apply (simp add: dot_square_norm abs_le_square_iff[symmetric]) - using norm_ge_zero[of x] - apply arith - done + by (metis nle_le norm_eq_square norm_le_square) lemma norm_lt_square: "norm x < a \ 0 < a \ inner x x < a\<^sup>2" by (metis not_le norm_ge_square) @@ -368,11 +359,10 @@ inner_scaleR_left inner_scaleR_right lemma dot_norm: "inner x y = ((norm (x + y))\<^sup>2 - (norm x)\<^sup>2 - (norm y)\<^sup>2) / 2" - by (simp only: power2_norm_eq_inner inner_simps inner_commute) auto + by (auto simp: power2_norm_eq_inner inner_simps inner_commute) lemma dot_norm_neg: "inner x y = (((norm x)\<^sup>2 + (norm y)\<^sup>2) - (norm (x - y))\<^sup>2) / 2" - by (simp only: power2_norm_eq_inner inner_simps inner_commute) - (auto simp add: algebra_simps) + by (auto simp: power2_norm_eq_inner inner_simps inner_commute) lemma of_real_inner_1 [simp]: "inner (of_real x) (1 :: 'a :: {real_inner, real_normed_algebra_1}) = x" @@ -403,9 +393,7 @@ "\GDERIV f x :> df; DERIV g (f x) :> dg\ \ GDERIV (\x. g (f x)) x :> scaleR dg df" unfolding gderiv_def has_field_derivative_def - apply (drule (1) has_derivative_compose) - apply (simp add: ac_simps) - done + using has_derivative_compose by fastforce lemma has_derivative_subst: "\FDERIV f x :> df; df = d\ \ FDERIV f x :> d" by simp @@ -434,11 +422,7 @@ "\DERIV f x :> df; GDERIV g x :> dg\ \ GDERIV (\x. scaleR (f x) (g x)) x :> (scaleR (f x) dg + scaleR df (g x))" - unfolding gderiv_def has_field_derivative_def inner_add_right inner_scaleR_right - apply (rule has_derivative_subst) - apply (erule (1) has_derivative_scaleR) - apply (simp add: ac_simps) - done + by (simp add: DERIV_mult') lemma GDERIV_mult: "\GDERIV f x :> df; GDERIV g x :> dg\ diff -r b52e57ed7e29 -r d35d355f7330 src/HOL/Analysis/L2_Norm.thy --- a/src/HOL/Analysis/L2_Norm.thy Fri Apr 11 22:17:06 2025 +0100 +++ b/src/HOL/Analysis/L2_Norm.thy Sat Apr 12 22:42:32 2025 +0100 @@ -66,11 +66,8 @@ lemma L2_set_left_distrib: "0 \ r \ L2_set f A * r = L2_set (\x. f x * r) A" - unfolding L2_set_def - apply (simp add: power_mult_distrib) - apply (simp add: sum_distrib_right [symmetric]) - apply (simp add: real_sqrt_mult sum_nonneg) - done + unfolding L2_set_def power_mult_distrib + by (simp add: real_sqrt_mult sum_nonneg flip: sum_distrib_right) lemma L2_set_eq_0_iff: "finite A \ L2_set f A = 0 \ (\x\A. f x = 0)" unfolding L2_set_def @@ -101,44 +98,36 @@ qed qed -lemma L2_set_le_sum [rule_format]: - "(\i\A. 0 \ f i) \ L2_set f A \ sum f A" - apply (cases "finite A") - apply (induct set: finite) - apply simp - apply clarsimp - apply (erule order_trans [OF sqrt_sum_squares_le_sum]) - apply simp - apply simp - apply simp - done +lemma L2_set_le_sum: + "(\i. i \ A \ 0 \ f i) \ L2_set f A \ sum f A" +proof (induction A rule: infinite_finite_induct) + case (insert a A) + with order_trans [OF sqrt_sum_squares_le_sum] show ?case by force +qed auto lemma L2_set_le_sum_abs: "L2_set f A \ (\i\A. \f i\)" - apply (cases "finite A") - apply (induct set: finite) - apply simp - apply simp - apply (rule order_trans [OF sqrt_sum_squares_le_sum_abs]) - apply simp - apply simp - done +proof (induction A rule: infinite_finite_induct) + case (insert a A) + with order_trans [OF sqrt_sum_squares_le_sum_abs] show ?case by force +qed auto lemma L2_set_mult_ineq: "(\i\A. \f i\ * \g i\) \ L2_set f A * L2_set g A" - apply (cases "finite A") - apply (induct set: finite) - apply simp - apply (rule power2_le_imp_le, simp) - apply (rule order_trans) - apply (rule power_mono) - apply (erule add_left_mono) - apply (simp add: sum_nonneg) - apply (simp add: power2_sum) - apply (simp add: power_mult_distrib) - apply (simp add: distrib_left distrib_right) - apply (rule ord_le_eq_trans) - apply (rule L2_set_mult_ineq_lemma) - apply simp_all - done +proof (induction A rule: infinite_finite_induct) + case (insert a A) + have "(\f a\ * \g a\ + (\i\A. \f i\ * \g i\))\<^sup>2 + \ (\f a\ * \g a\ + L2_set f A * L2_set g A)\<^sup>2" + by (simp add: insert.IH sum_nonneg) + also have "... \ ((f a)\<^sup>2 + (L2_set f A)\<^sup>2) * ((g a)\<^sup>2 + (L2_set g A)\<^sup>2)" + using L2_set_mult_ineq_lemma [of "L2_set f A" "L2_set g A" "\f a\" "\g a\"] + by (simp add: power2_eq_square algebra_simps) + also have "... = (sqrt ((f a)\<^sup>2 + (L2_set f A)\<^sup>2) * sqrt ((g a)\<^sup>2 + (L2_set g A)\<^sup>2))\<^sup>2" + using real_sqrt_mult real_sqrt_sum_squares_mult_squared_eq by presburger + finally have "(\f a\ * \g a\ + (\i\A. \f i\ * \g i\))\<^sup>2 + \ (sqrt ((f a)\<^sup>2 + (L2_set f A)\<^sup>2) * sqrt ((g a)\<^sup>2 + (L2_set g A)\<^sup>2))\<^sup>2" . + then + show ?case + using power2_le_imp_le insert.hyps by fastforce +qed auto lemma member_le_L2_set: "\finite A; i \ A\ \ f i \ L2_set f A" unfolding L2_set_def diff -r b52e57ed7e29 -r d35d355f7330 src/HOL/Analysis/Product_Vector.thy --- a/src/HOL/Analysis/Product_Vector.thy Fri Apr 11 22:17:06 2025 +0100 +++ b/src/HOL/Analysis/Product_Vector.thy Sat Apr 12 22:42:32 2025 +0100 @@ -90,10 +90,7 @@ end lemma module_prod_scale_eq_scaleR: "module_prod.scale (*\<^sub>R) (*\<^sub>R) = scaleR" - apply (rule ext) apply (rule ext) - apply (subst module_prod.scale_def) - subgoal by unfold_locales - by (simp add: scaleR_prod_def) + using module_pair_axioms module_prod.scale_def module_prod_def by fastforce interpretation real_vector?: vector_space_prod "scaleR::_\_\'a::real_vector" "scaleR::_\_\'b::real_vector" rewrites "scale = ((*\<^sub>R)::_\_\('a \ 'b))" @@ -166,8 +163,8 @@ then have \\\<^sub>F ((x'1, y1), (x'2, y2)) in uniformity \\<^sub>F uniformity. (x'1,x'2) = x \ (y1,y2) \ U\ by (simp add: uniformity_prod_def eventually_filtermap case_prod_unfold) then obtain UA UB where \eventually UA uniformity\ and \eventually UB uniformity\ - and UA_UB_U: \UA (a1, a2) \ UB (b1, b2) \ (a1, b1) = x \ (a2, b2) \ U\ for a1 a2 b1 b2 - apply atomize_elim by (simp add: case_prod_beta eventually_prod_filter) + and UA_UB_U: \UA (a1, a2) \ UB (b1, b2) \ (a1, b1) = x \ (a2, b2) \ U\ for a1 a2 b1 b2 + by (force simp: case_prod_beta eventually_prod_filter) have \eventually (\a. UA (fst x, a)) (nhds (fst x))\ using \eventually UA uniformity\ eventually_mono eventually_nhds_uniformity by fastforce then obtain A where \open A\ and A_UA: \A \ {a. UA (fst x, a)}\ and \fst x \ A\ @@ -190,11 +187,13 @@ by (metis surj_pair uniformity_refl) next show \eventually E uniformity \ \\<^sub>F (x::'a\'b, y) in uniformity. E (y, x)\ for E - apply (simp only: uniformity_prod_def eventually_filtermap case_prod_unfold eventually_prod_filter) - apply (erule exE, erule exE, rename_tac Pf Pg) - apply (rule_tac x=\\(x,y). Pf (y,x)\ in exI) - apply (rule_tac x=\\(x,y). Pg (y,x)\ in exI) - by (auto simp add: uniformity_sym) + unfolding uniformity_prod_def eventually_filtermap case_prod_unfold eventually_prod_filter + apply clarify + subgoal for Pf Pg + apply (rule_tac x=\\(x,y). Pf (y,x)\ in exI) + apply (rule_tac x=\\(x,y). Pg (y,x)\ in exI) + by (auto simp add: uniformity_sym) + done next show \\D. eventually D uniformity \ (\x y z. D (x::'a\'b, y) \ D (y, z) \ E (x, z))\ if \eventually E uniformity\ for E @@ -224,11 +223,11 @@ proof - have *: "eventually P (filtercomap (\y. (x, y)) F) \ eventually (\z. fst z = x \ P (snd z)) F" for P :: "'a \ bool" and F - unfolding eventually_filtercomap - by (smt (verit) eventually_elim2 fst_conv prod.collapse snd_conv) + unfolding eventually_filtercomap + by (smt (verit, best) eventually_mono split_pairs2) thus ?thesis - unfolding filter_eq_iff - by (subst *) (auto simp: eventually_nhds_uniformity case_prod_unfold) + unfolding filter_eq_iff * + by (auto simp: eventually_nhds_uniformity case_prod_unfold) qed lemma uniformity_of_uniform_continuous_invariant: @@ -356,8 +355,7 @@ have 1: \\e\{0<..}. {(x,y). dist x y < e} \ {(x,y). dist x y < a} \ {(x,y). dist x y < e} \ {(x,y). dist x y < b}\ if \a>0\ \b>0\ for a b - apply (rule bexI[of _ \min a b\]) - using that by auto + using that by (auto intro: bexI[of _ \min a b\]) have 2: \mono (\P. eventually (\x. P (Q x)) F)\ for F :: \'z filter\ and Q :: \'z \ 'y\ unfolding mono_def using eventually_mono le_funD by fastforce have \\\<^sub>F ((x1::'a,y1),(x2::'b,y2)) in uniformity \\<^sub>F uniformity. dist x1 y1 < e/2 \ dist x2 y2 < e/2\ if \e>0\ for e @@ -383,17 +381,18 @@ have \e > 0\ using \0 < e1\ \0 < e2\ e_def by auto have \dist (x1,x2) (y1,y2) < e \ dist x1 y1 < e1\ for x1 y1 :: 'a and x2 y2 :: 'b - unfolding dist_prod_def e_def apply auto - by (smt (verit, best) real_sqrt_sum_squares_ge1) + unfolding dist_prod_def e_def + by (metis real_sqrt_sum_squares_ge1 fst_conv min_less_iff_conj order_le_less_trans snd_conv) moreover have \dist (x1,x2) (y1,y2) < e \ dist x2 y2 < e2\ for x1 y1 :: 'a and x2 y2 :: 'b - unfolding dist_prod_def e_def apply auto - by (smt (verit, best) real_sqrt_sum_squares_ge1) + unfolding dist_prod_def e_def + using real_sqrt_sum_squares_ge1 [of "dist x1 y1" "dist x2 y2"] + by (metis min_less_iff_conj order_le_less_trans real_sqrt_sum_squares_ge2 snd_conv) ultimately have *: \dist (x1,x2) (y1,y2) < e \ P ((x1, x2), (y1, y2))\ for x1 y1 x2 y2 using e1P1 e2P2 P1P2P by auto show \eventually P (INF e\{0<..}. principal {(x, y). dist x y < e})\ - apply (rule eventually_INF1[where i=e]) - using \e > 0\ * by (auto simp: eventually_principal) + using \e > 0\ * + by (auto simp: eventually_principal intro: eventually_INF1) qed qed end @@ -421,8 +420,8 @@ fix x y z :: "'a \ 'b" show "dist x y \ dist x z + dist y z" unfolding dist_prod_def - by (intro order_trans [OF _ real_sqrt_sum_squares_triangle_ineq] - real_sqrt_le_mono add_mono power_mono dist_triangle2 zero_le_dist) + by (meson add_mono dist_triangle2 order_trans power_mono real_sqrt_le_iff + real_sqrt_sum_squares_triangle_ineq zero_le_dist) next fix S :: "('a \ 'b) set" have *: "open S \ (\x\S. \e>0. \y. dist y x < e \ y \ S)" @@ -525,8 +524,8 @@ by auto show \\d>0. \x\S\T. \y\S\T. dist y x < d \ dist (f y) (f x) < e\ apply (rule exI[of _ d]) - using \d>0\ d[rule_format] apply auto - by (smt (verit, del_insts) dist_fst_le dist_snd_le fst_conv snd_conv) + by (metis SigmaE \0 < d\ d dist_fst_le dist_snd_le fst_eqD order_le_less_trans + snd_conv) next fix e :: real assume \e > 0\ and \\e>0. \d>0. \x\S\T. \x'\S\T. dist x' x < d \ dist (f x') (f x) < e\ @@ -559,8 +558,9 @@ fix e :: real assume \0 < e\ show \\d>0. \x y :: 'a. dist x y < d \ (\x' y'. dist x' y' < d \ dist (x + x') (y + y') < e)\ apply (rule exI[of _ \e/2\]) - using \0 < e\ apply auto - by (smt (verit, ccfv_SIG) dist_add_cancel dist_add_cancel2 dist_commute dist_triangle_lt) + using \0 < e\ + by (smt (verit) dist_add_cancel dist_add_cancel2 dist_commute + dist_triangle_lt field_sum_of_halves) qed subsection \Product is a Complete Metric Space\ @@ -607,10 +607,7 @@ done show "norm (scaleR r x) = \r\ * norm x" unfolding norm_prod_def - apply (simp add: power_mult_distrib) - apply (simp add: distrib_left [symmetric]) - apply (simp add: real_sqrt_mult) - done + by (simp add: power_mult_distrib real_sqrt_mult flip: distrib_left) show "sgn x = scaleR (inverse (norm x)) x" by (rule sgn_prod_def) show "dist x y = norm (x - y)" @@ -654,13 +651,10 @@ using f.pos_bounded by fast obtain Kg where "0 < Kg" and norm_g: "\x. norm (g x) \ norm x * Kg" using g.pos_bounded by fast - have "\x. norm (f x, g x) \ norm x * (Kf + Kg)" - apply (rule allI) - apply (simp add: norm_Pair) - apply (rule order_trans [OF sqrt_add_le_add_sqrt], simp, simp) - apply (simp add: distrib_left) - apply (rule add_mono [OF norm_f norm_g]) - done + have "\x. sqrt ((norm (f x))\<^sup>2) + sqrt ((norm (g x))\<^sup>2) \ norm x * (Kf + Kg)" + by (simp add: add_mono distrib_left norm_f norm_g) + then have "\x. norm (f x, g x) \ norm x * (Kf + Kg)" + by (smt (verit) norm_ge_zero norm_prod_def prod.sel sqrt_add_le_add_sqrt zero_le_power) then show "\K. \x. norm (f x, g x) \ norm x * K" .. qed @@ -730,44 +724,50 @@ by (metis norm_ge_zero sqrt_sum_squares_le_sum) lemma (in vector_space_prod) span_Times_sing1: "p.span ({0} \ B) = {0} \ vs2.span B" - apply (rule p.span_unique) - subgoal by (auto intro!: vs1.span_base vs2.span_base) - subgoal using vs1.subspace_single_0 vs2.subspace_span by (rule subspace_Times) - subgoal for T - proof safe +proof (rule p.span_unique) + show "{0} \ B \ {0} \ vs2.span B" + by (auto intro!: vs1.span_base vs2.span_base) + show "p.subspace ({0} \ vs2.span B)" + using vs1.subspace_single_0 vs2.subspace_span by (rule subspace_Times) + fix T :: "('b \ 'c) set" + assume subset_T: "{0} \ B \ T" and subspace: "p.subspace T" + show "{0} \ vs2.span B \ T" + proof clarify fix b - assume subset_T: "{0} \ B \ T" and subspace: "p.subspace T" and b_span: "b \ vs2.span B" + assume b_span: "b \ vs2.span B" then obtain t r where b: "b = (\a\t. r a *b a)" and t: "finite t" "t \ B" by (auto simp: vs2.span_explicit) have "(0, b) = (\b\t. scale (r b) (0, b))" - unfolding b scale_prod sum_prod - by simp + unfolding b scale_prod sum_prod by simp also have "\ \ T" using \t \ B\ subset_T by (auto intro!: p.subspace_sum p.subspace_scale subspace) finally show "(0, b) \ T" . qed - done +qed lemma (in vector_space_prod) span_Times_sing2: "p.span (A \ {0}) = vs1.span A \ {0}" - apply (rule p.span_unique) - subgoal by (auto intro!: vs1.span_base vs2.span_base) - subgoal using vs1.subspace_span vs2.subspace_single_0 by (rule subspace_Times) - subgoal for T - proof safe +proof (rule p.span_unique) + show "A \ {0} \ vs1.span A \ {0}" + by (auto intro!: vs1.span_base vs2.span_base) + show "p.subspace (vs1.span A \ {0})" + using vs1.subspace_span vs2.subspace_single_0 by (rule subspace_Times) + fix T :: "('b \ 'c) set" + assume subset_T: "A \ {0} \ T" and subspace: "p.subspace T" + show "vs1.span A \ {0} \ T" + proof clarify fix a - assume subset_T: "A \ {0} \ T" and subspace: "p.subspace T" and a_span: "a \ vs1.span A" + assume a_span: "a \ vs1.span A" then obtain t r where a: "a = (\a\t. r a *a a)" and t: "finite t" "t \ A" by (auto simp: vs1.span_explicit) have "(a, 0) = (\a\t. scale (r a) (a, 0))" - unfolding a scale_prod sum_prod - by simp + unfolding a scale_prod sum_prod by simp also have "\ \ T" using \t \ A\ subset_T by (auto intro!: p.subspace_sum p.subspace_scale subspace) finally show "(a, 0) \ T" . qed - done +qed subsection \Product is Finite Dimensional\