# HG changeset patch # User paulson # Date 1519563307 0 # Node ID b342f96e47b5380ddc8a0fc1d5e338c9392828e9 # Parent 17874d43d3b3d0b4fbbd14fca0818ab88031373f# Parent bffb7482faaa0a94e87f77a594fb26e8db1b4e33 merged diff -r 17874d43d3b3 -r b342f96e47b5 src/HOL/Analysis/Ball_Volume.thy --- a/src/HOL/Analysis/Ball_Volume.thy Sun Feb 25 12:59:08 2018 +0100 +++ b/src/HOL/Analysis/Ball_Volume.thy Sun Feb 25 12:55:07 2018 +0000 @@ -17,8 +17,11 @@ definition unit_ball_vol :: "real \ real" where "unit_ball_vol n = pi powr (n / 2) / Gamma (n / 2 + 1)" +lemma unit_ball_vol_pos [simp]: "n \ 0 \ unit_ball_vol n > 0" + by (force simp: unit_ball_vol_def intro: divide_nonneg_pos) + lemma unit_ball_vol_nonneg [simp]: "n \ 0 \ unit_ball_vol n \ 0" - by (auto simp add: unit_ball_vol_def intro!: divide_nonneg_pos Gamma_real_pos) + by (simp add: dual_order.strict_implies_order) text \ We first need the value of the following integral, which is at the core of diff -r 17874d43d3b3 -r b342f96e47b5 src/HOL/Analysis/Cartesian_Euclidean_Space.thy --- a/src/HOL/Analysis/Cartesian_Euclidean_Space.thy Sun Feb 25 12:59:08 2018 +0100 +++ b/src/HOL/Analysis/Cartesian_Euclidean_Space.thy Sun Feb 25 12:55:07 2018 +0000 @@ -7,19 +7,6 @@ lemma subspace_special_hyperplane: "subspace {x. x $ k = 0}" by (simp add: subspace_def) -lemma delta_mult_idempotent: - "(if k=a then 1 else (0::'a::semiring_1)) * (if k=a then 1 else 0) = (if k=a then 1 else 0)" - by simp - -(*move up?*) -lemma sum_UNIV_sum: - fixes g :: "'a::finite + 'b::finite \ _" - shows "(\x\UNIV. g x) = (\x\UNIV. g (Inl x)) + (\x\UNIV. g (Inr x))" - apply (subst UNIV_Plus_UNIV [symmetric]) - apply (subst sum.Plus) - apply simp_all - done - lemma sum_mult_product: "sum h {..i\{..j\{..Inverse matrices (not necessarily square)\ +subsection\Inverse matrices (not necessarily square)\ definition "invertible(A::'a::semiring_1^'n^'m) \ (\A'::'a^'m^'n. A ** A' = mat 1 \ A' ** A = mat 1)" @@ -728,9 +715,86 @@ done -subsection \lambda skolemization on cartesian products\ +subsection\Some bounds on components etc. relative to operator norm.\ + +lemma norm_column_le_onorm: + fixes A :: "real^'n^'m" + shows "norm(column i A) \ onorm(( *v) A)" +proof - + have bl: "bounded_linear (( *v) A)" + by (simp add: linear_linear matrix_vector_mul_linear) + have "norm (\ j. A $ j $ i) \ norm (A *v axis i 1)" + by (simp add: matrix_mult_dot cart_eq_inner_axis) + also have "\ \ onorm (( *v) A)" + using onorm [OF bl, of "axis i 1"] by (auto simp: axis_in_Basis) + finally have "norm (\ j. A $ j $ i) \ onorm (( *v) A)" . + then show ?thesis + unfolding column_def . +qed + +lemma matrix_component_le_onorm: + fixes A :: "real^'n^'m" + shows "\A $ i $ j\ \ onorm(( *v) A)" +proof - + have "\A $ i $ j\ \ norm (\ n. (A $ n $ j))" + by (metis (full_types, lifting) component_le_norm_cart vec_lambda_beta) + also have "\ \ onorm (( *v) A)" + by (metis (no_types) column_def norm_column_le_onorm) + finally show ?thesis . +qed + +lemma component_le_onorm: + fixes f :: "real^'m \ real^'n" + shows "linear f \ \matrix f $ i $ j\ \ onorm f" + by (metis matrix_component_le_onorm matrix_vector_mul) -(* FIXME: rename do choice_cart *) +lemma onorm_le_matrix_component_sum: + fixes A :: "real^'n^'m" + shows "onorm(( *v) A) \ (\i\UNIV. \j\UNIV. \A $ i $ j\)" +proof (rule onorm_le) + fix x + have "norm (A *v x) \ (\i\UNIV. \(A *v x) $ i\)" + by (rule norm_le_l1_cart) + also have "\ \ (\i\UNIV. \j\UNIV. \A $ i $ j\ * norm x)" + proof (rule sum_mono) + fix i + have "\(A *v x) $ i\ \ \\j\UNIV. A $ i $ j * x $ j\" + by (simp add: matrix_vector_mult_def) + also have "\ \ (\j\UNIV. \A $ i $ j * x $ j\)" + by (rule sum_abs) + also have "\ \ (\j\UNIV. \A $ i $ j\ * norm x)" + by (rule sum_mono) (simp add: abs_mult component_le_norm_cart mult_left_mono) + finally show "\(A *v x) $ i\ \ (\j\UNIV. \A $ i $ j\ * norm x)" . + qed + finally show "norm (A *v x) \ (\i\UNIV. \j\UNIV. \A $ i $ j\) * norm x" + by (simp add: sum_distrib_right) +qed + +lemma onorm_le_matrix_component: + fixes A :: "real^'n^'m" + assumes "\i j. abs(A$i$j) \ B" + shows "onorm(( *v) A) \ real (CARD('m)) * real (CARD('n)) * B" +proof (rule onorm_le) + fix x :: "(real, 'n) vec" + have "norm (A *v x) \ (\i\UNIV. \(A *v x) $ i\)" + by (rule norm_le_l1_cart) + also have "\ \ (\i::'m \UNIV. real (CARD('n)) * B * norm x)" + proof (rule sum_mono) + fix i + have "\(A *v x) $ i\ \ norm(A $ i) * norm x" + by (simp add: matrix_mult_dot Cauchy_Schwarz_ineq2) + also have "\ \ (\j\UNIV. \A $ i $ j\) * norm x" + by (simp add: mult_right_mono norm_le_l1_cart) + also have "\ \ real (CARD('n)) * B * norm x" + by (simp add: assms sum_bounded_above mult_right_mono) + finally show "\(A *v x) $ i\ \ real (CARD('n)) * B * norm x" . + qed + also have "\ \ CARD('m) * real (CARD('n)) * B * norm x" + by simp + finally show "norm (A *v x) \ CARD('m) * real (CARD('n)) * B * norm x" . +qed + +subsection \lambda skolemization on cartesian products\ lemma lambda_skolem: "(\i. \x. P i x) \ (\x::'a ^ 'n. \i. P i (x $ i))" (is "?lhs \ ?rhs") @@ -751,6 +815,32 @@ ultimately show ?thesis by metis qed +lemma rational_approximation: + assumes "e > 0" + obtains r::real where "r \ \" "\r - x\ < e" + using Rats_dense_in_real [of "x - e/2" "x + e/2"] assms by auto + +lemma matrix_rational_approximation: + fixes A :: "real^'n^'m" + assumes "e > 0" + obtains B where "\i j. B$i$j \ \" "onorm(\x. (A - B) *v x) < e" +proof - + have "\i j. \q \ \. \q - A $ i $ j\ < e / (2 * CARD('m) * CARD('n))" + using assms by (force intro: rational_approximation [of "e / (2 * CARD('m) * CARD('n))"]) + then obtain B where B: "\i j. B$i$j \ \" and Bclo: "\i j. \B$i$j - A $ i $ j\ < e / (2 * CARD('m) * CARD('n))" + by (auto simp: lambda_skolem Bex_def) + show ?thesis + proof + have "onorm (( *v) (A - B)) \ real CARD('m) * real CARD('n) * + (e / (2 * real CARD('m) * real CARD('n)))" + apply (rule onorm_le_matrix_component) + using Bclo by (simp add: abs_minus_commute less_imp_le) + also have "\ < e" + using \0 < e\ by (simp add: divide_simps) + finally show "onorm (( *v) (A - B)) < e" . + qed (use B in auto) +qed + lemma vector_sub_project_orthogonal_cart: "(b::real^'n) \ (x - ((b \ x) / (b \ b)) *s b) = 0" unfolding inner_simps scalar_mult_eq_scaleR by auto @@ -1139,7 +1229,7 @@ and "box a b \ box c d = {} \ (\i. (b$i \ a$i \ d$i \ c$i \ b$i \ c$i \ d$i \ a$i))" (is ?th4) using disjoint_interval[of a b c d] by (simp_all add: Basis_vec_def inner_axis) -lemma inter_interval_cart: +lemma Int_interval_cart: fixes a :: "real^'n" shows "cbox a b \ cbox c d = {(\ i. max (a$i) (c$i)) .. (\ i. min (b$i) (d$i))}" unfolding Int_interval @@ -1225,6 +1315,11 @@ by (auto simp: axis_eq_axis inj_on_def *) qed +lemma dim_subset_UNIV_cart: + fixes S :: "(real^'n) set" + shows "dim S \ CARD('n)" + by (metis dim_subset_UNIV DIM_cart DIM_real mult.right_neutral) + lemma affinity_inverses: assumes m0: "m \ (0::'a::field)" shows "(\x. m *s x + c) \ (\x. inverse(m) *s x + (-(inverse(m) *s c))) = id" @@ -1430,13 +1525,7 @@ unfolding vector_def by simp_all lemma forall_vector_1: "(\v::'a::zero^1. P v) \ (\x. P(vector[x]))" - apply auto - apply (erule_tac x="v$1" in allE) - apply (subgoal_tac "vector [v$1] = v") - apply simp - apply (vector vector_def) - apply simp - done + by (metis vector_1 vector_one) lemma forall_vector_2: "(\v::'a::zero^2. P v) \ (\x y. P(vector[x, y]))" apply auto diff -r 17874d43d3b3 -r b342f96e47b5 src/HOL/Analysis/Great_Picard.thy --- a/src/HOL/Analysis/Great_Picard.thy Sun Feb 25 12:59:08 2018 +0100 +++ b/src/HOL/Analysis/Great_Picard.thy Sun Feb 25 12:55:07 2018 +0000 @@ -46,7 +46,7 @@ have "(n-1)^2 \ n^2 - 1" using assms by (simp add: algebra_simps power2_eq_square) then have "real (n - 1) \ sqrt (real (n\<^sup>2 - 1))" - by (metis Extended_Nonnegative_Real.of_nat_le_iff of_nat_power real_le_rsqrt) + by (metis of_nat_le_iff of_nat_power real_le_rsqrt) then have "n-1 \ sqrt(real n ^ 2 - 1)" by (simp add: Suc_leI assms of_nat_diff) then show ?thesis diff -r 17874d43d3b3 -r b342f96e47b5 src/HOL/Analysis/Henstock_Kurzweil_Integration.thy --- a/src/HOL/Analysis/Henstock_Kurzweil_Integration.thy Sun Feb 25 12:59:08 2018 +0100 +++ b/src/HOL/Analysis/Henstock_Kurzweil_Integration.thy Sun Feb 25 12:55:07 2018 +0000 @@ -46,6 +46,14 @@ lemma content_cbox_if: "content (cbox a b) = (if cbox a b = {} then 0 else \i\Basis. b\i - a\i)" by (simp add: content_cbox') +lemma content_cbox_cart: + "cbox a b \ {} \ content(cbox a b) = prod (\i. b$i - a$i) UNIV" + by (simp add: content_cbox_if Basis_vec_def cart_eq_inner_axis axis_eq_axis prod.UNION_disjoint) + +lemma content_cbox_if_cart: + "content(cbox a b) = (if cbox a b = {} then 0 else prod (\i. b$i - a$i) UNIV)" + by (simp add: content_cbox_cart) + lemma content_division_of: assumes "K \ \" "\ division_of S" shows "content K = (\i \ Basis. interval_upperbound K \ i - interval_lowerbound K \ i)" @@ -357,6 +365,9 @@ unfolding integral_def by (rule some_equality) (auto intro: has_integral_unique) +lemma has_integral_iff: "(f has_integral i) S \ (f integrable_on S \ integral S f = i)" + by blast + lemma eq_integralD: "integral k f = y \ (f has_integral y) k \ ~ f integrable_on k \ y=0" unfolding integral_def integrable_on_def apply (erule subst) @@ -3005,7 +3016,6 @@ shows "f integrable_on {c..d}" by (metis assms box_real(2) integrable_subinterval) - subsection \Combining adjacent intervals in 1 dimension.\ lemma has_integral_combine: @@ -4673,6 +4683,46 @@ using as by auto qed +subsection\Integrals on set differences\ + +lemma has_integral_setdiff: + fixes f :: "'a::euclidean_space \ 'b::banach" + assumes S: "(f has_integral i) S" and T: "(f has_integral j) T" + and neg: "negligible (T - S)" + shows "(f has_integral (i - j)) (S - T)" +proof - + show ?thesis + unfolding has_integral_restrict_UNIV [symmetric, of f] + proof (rule has_integral_spike [OF neg]) + have eq: "(\x. (if x \ S then f x else 0) - (if x \ T then f x else 0)) = + (\x. if x \ T - S then - f x else if x \ S - T then f x else 0)" + by (force simp add: ) + have "((\x. if x \ S then f x else 0) has_integral i) UNIV" + "((\x. if x \ T then f x else 0) has_integral j) UNIV" + using S T has_integral_restrict_UNIV by auto + from has_integral_diff [OF this] + show "((\x. if x \ T - S then - f x else if x \ S - T then f x else 0) + has_integral i-j) UNIV" + by (simp add: eq) + qed force +qed + +lemma integral_setdiff: + fixes f :: "'a::euclidean_space \ 'b::banach" + assumes "f integrable_on S" "f integrable_on T" "negligible(T - S)" + shows "integral (S - T) f = integral S f - integral T f" + by (rule integral_unique) (simp add: assms has_integral_setdiff integrable_integral) + +lemma integrable_setdiff: + fixes f :: "'a::euclidean_space \ 'b::banach" + assumes "(f has_integral i) S" "(f has_integral j) T" "negligible (T - S)" + shows "f integrable_on (S - T)" + using has_integral_setdiff [OF assms] + by (simp add: has_integral_iff) + +lemma negligible_setdiff [simp]: "T \ S \ negligible (T - S)" + by (metis Diff_eq_empty_iff negligible_empty) + lemma negligible_on_intervals: "negligible s \ (\a b. negligible(s \ cbox a b))" (is "?l \ ?r") proof assume ?r @@ -4757,9 +4807,7 @@ lemma has_integral_closure: fixes f :: "'a :: euclidean_space \ 'b :: banach" shows "negligible(frontier S) \ (f has_integral y) (closure S) \ (f has_integral y) S" - apply (rule has_integral_spike_set_eq) - apply (auto simp: Un_Diff closure_Un_frontier negligible_diff) - by (simp add: Diff_eq closure_Un_frontier) + by (rule has_integral_spike_set_eq) (simp add: Un_Diff closure_Un_frontier negligible_diff) lemma has_integral_open_interval: fixes f :: "'a :: euclidean_space \ 'b :: banach" @@ -5344,9 +5392,6 @@ subsection \Also tagged divisions\ -lemma has_integral_iff: "(f has_integral i) S \ (f integrable_on S \ integral S f = i)" - by blast - lemma has_integral_combine_tagged_division: fixes f :: "'n::euclidean_space \ 'a::banach" assumes "p tagged_division_of S" diff -r 17874d43d3b3 -r b342f96e47b5 src/HOL/HOL.thy --- a/src/HOL/HOL.thy Sun Feb 25 12:59:08 2018 +0100 +++ b/src/HOL/HOL.thy Sun Feb 25 12:55:07 2018 +0000 @@ -1404,6 +1404,9 @@ lemma ex_if_distrib: "(\x. if x = a then P x else Q x) \ P a \ (\x. x\a \ Q x)" by auto +lemma if_if_eq_conj: "(if P then if Q then x else y else y) = (if P \ Q then x else y)" + by simp + text \As a simplification rule, it replaces all function equalities by first-order equalities.\ lemma fun_eq_iff: "f = g \ (\x. f x = g x)" diff -r 17874d43d3b3 -r b342f96e47b5 src/HOL/Library/Extended_Nonnegative_Real.thy --- a/src/HOL/Library/Extended_Nonnegative_Real.thy Sun Feb 25 12:59:08 2018 +0100 +++ b/src/HOL/Library/Extended_Nonnegative_Real.thy Sun Feb 25 12:55:07 2018 +0000 @@ -158,17 +158,6 @@ using tendsto_cmult_ereal[of c f "f x" "at x within A" for x] by (auto simp: continuous_on_def simp del: tendsto_cmult_ereal) -context linordered_nonzero_semiring -begin - -lemma of_nat_nonneg [simp]: "0 \ of_nat n" - by (induct n) simp_all - -lemma of_nat_mono[simp]: "i \ j \ of_nat i \ of_nat j" - by (auto simp add: le_iff_add intro!: add_increasing2) - -end - lemma real_of_nat_Sup: assumes "A \ {}" "bdd_above A" shows "of_nat (Sup A) = (SUP a:A. of_nat a :: real)" @@ -181,21 +170,6 @@ by (intro cSUP_upper bdd_above_image_mono assms) (auto simp: mono_def) qed -\ \These generalise their counterparts in \Nat.linordered_semidom_class\\ -lemma of_nat_less[simp]: - "m < n \ of_nat m < (of_nat n::'a::{linordered_nonzero_semiring, semiring_char_0})" - by (auto simp: less_le) - -lemma of_nat_le_iff[simp]: - "of_nat m \ (of_nat n::'a::{linordered_nonzero_semiring, semiring_char_0}) \ m \ n" -proof (safe intro!: of_nat_mono) - assume "of_nat m \ (of_nat n::'a)" then show "m \ n" - proof (intro leI notI) - assume "n < m" from less_le_trans[OF of_nat_less[OF this] \of_nat m \ of_nat n\] show False - by blast - qed -qed - lemma (in complete_lattice) SUP_sup_const1: "I \ {} \ (SUP i:I. sup c (f i)) = sup c (SUP i:I. f i)" using SUP_sup_distrib[of "\_. c" I f] by simp