src/HOL/Multivariate_Analysis/Cartesian_Euclidean_Space.thy
 changeset 50526 899c9c4e4a4c parent 49962 a8cc904a6820 child 50998 501200635659
```     1.1 --- a/src/HOL/Multivariate_Analysis/Cartesian_Euclidean_Space.thy	Fri Dec 14 14:46:01 2012 +0100
1.2 +++ b/src/HOL/Multivariate_Analysis/Cartesian_Euclidean_Space.thy	Fri Dec 14 15:46:01 2012 +0100
1.3 @@ -328,283 +328,18 @@
1.4    fixes f:: "'a \<Rightarrow> real ^'n"
1.5    assumes fP: "finite P" and fPs: "\<And>Q. Q \<subseteq> P \<Longrightarrow> norm (setsum f Q) \<le> e"
1.6    shows "setsum (\<lambda>x. norm (f x)) P \<le> 2 * real CARD('n) *  e"
1.7 -proof -
1.8 -  let ?d = "real CARD('n)"
1.9 -  let ?nf = "\<lambda>x. norm (f x)"
1.10 -  let ?U = "UNIV :: 'n set"
1.11 -  have th0: "setsum (\<lambda>x. setsum (\<lambda>i. \<bar>f x \$ i\<bar>) ?U) P = setsum (\<lambda>i. setsum (\<lambda>x. \<bar>f x \$ i\<bar>) P) ?U"
1.12 -    by (rule setsum_commute)
1.13 -  have th1: "2 * ?d * e = of_nat (card ?U) * (2 * e)" by (simp add: real_of_nat_def)
1.14 -  have "setsum ?nf P \<le> setsum (\<lambda>x. setsum (\<lambda>i. \<bar>f x \$ i\<bar>) ?U) P"
1.15 -    apply (rule setsum_mono)
1.16 -    apply (rule norm_le_l1_cart)
1.17 -    done
1.18 -  also have "\<dots> \<le> 2 * ?d * e"
1.19 -    unfolding th0 th1
1.20 -  proof(rule setsum_bounded)
1.21 -    fix i assume i: "i \<in> ?U"
1.22 -    let ?Pp = "{x. x\<in> P \<and> f x \$ i \<ge> 0}"
1.23 -    let ?Pn = "{x. x \<in> P \<and> f x \$ i < 0}"
1.24 -    have thp: "P = ?Pp \<union> ?Pn" by auto
1.25 -    have thp0: "?Pp \<inter> ?Pn ={}" by auto
1.26 -    have PpP: "?Pp \<subseteq> P" and PnP: "?Pn \<subseteq> P" by blast+
1.27 -    have Ppe:"setsum (\<lambda>x. \<bar>f x \$ i\<bar>) ?Pp \<le> e"
1.28 -      using component_le_norm_cart[of "setsum (\<lambda>x. f x) ?Pp" i]  fPs[OF PpP]
1.29 -      by (auto intro: abs_le_D1)
1.30 -    have Pne: "setsum (\<lambda>x. \<bar>f x \$ i\<bar>) ?Pn \<le> e"
1.31 -      using component_le_norm_cart[of "setsum (\<lambda>x. - f x) ?Pn" i]  fPs[OF PnP]
1.32 -      by (auto simp add: setsum_negf intro: abs_le_D1)
1.33 -    have "setsum (\<lambda>x. \<bar>f x \$ i\<bar>) P = setsum (\<lambda>x. \<bar>f x \$ i\<bar>) ?Pp + setsum (\<lambda>x. \<bar>f x \$ i\<bar>) ?Pn"
1.34 -      apply (subst thp)
1.35 -      apply (rule setsum_Un_zero)
1.36 -      using fP thp0 apply auto
1.37 -      done
1.38 -    also have "\<dots> \<le> 2*e" using Pne Ppe by arith
1.39 -    finally show "setsum (\<lambda>x. \<bar>f x \$ i\<bar>) P \<le> 2*e" .
1.40 -  qed
1.41 -  finally show ?thesis .
1.42 -qed
1.43 -
1.44 -lemma if_distr: "(if P then f else g) \$ i = (if P then f \$ i else g \$ i)" by simp
1.45 -
1.46 -lemma split_dimensions'[consumes 1]:
1.47 -  assumes "k < DIM('a::euclidean_space^'b)"
1.48 -  obtains i j where "i < CARD('b::finite)"
1.49 -    and "j < DIM('a::euclidean_space)"
1.50 -    and "k = j + i * DIM('a::euclidean_space)"
1.51 -  using split_times_into_modulo[OF assms[simplified]] .
1.52 -
1.53 -lemma cart_euclidean_bound[intro]:
1.54 -  assumes j:"j < DIM('a::euclidean_space)"
1.55 -  shows "j + \<pi>' (i::'b::finite) * DIM('a) < CARD('b) * DIM('a::euclidean_space)"
1.56 -  using linear_less_than_times[OF pi'_range j, of i] .
1.57 -
1.58 -lemma (in euclidean_space) forall_CARD_DIM:
1.59 -  "(\<forall>i<CARD('b) * DIM('a). P i) \<longleftrightarrow> (\<forall>(i::'b::finite) j. j<DIM('a) \<longrightarrow> P (j + \<pi>' i * DIM('a)))"
1.60 -   (is "?l \<longleftrightarrow> ?r")
1.61 -proof (safe elim!: split_times_into_modulo)
1.62 -  fix i :: 'b and j
1.63 -  assume "j < DIM('a)"
1.64 -  note linear_less_than_times[OF pi'_range[of i] this]
1.65 -  moreover assume "?l"
1.66 -  ultimately show "P (j + \<pi>' i * DIM('a))" by auto
1.67 -next
1.68 -  fix i j
1.69 -  assume "i < CARD('b)" "j < DIM('a)" and "?r"
1.70 -  from `?r`[rule_format, OF `j < DIM('a)`, of "\<pi> i"] `i < CARD('b)`
1.71 -  show "P (j + i * DIM('a))" by simp
1.72 -qed
1.73 -
1.74 -lemma (in euclidean_space) exists_CARD_DIM:
1.75 -  "(\<exists>i<CARD('b) * DIM('a). P i) \<longleftrightarrow> (\<exists>i::'b::finite. \<exists>j<DIM('a). P (j + \<pi>' i * DIM('a)))"
1.76 -  using forall_CARD_DIM[where 'b='b, of "\<lambda>x. \<not> P x"] by blast
1.77 -
1.78 -lemma forall_CARD:
1.79 -  "(\<forall>i<CARD('b). P i) \<longleftrightarrow> (\<forall>i::'b::finite. P (\<pi>' i))"
1.80 -  using forall_CARD_DIM[where 'a=real, of P] by simp
1.81 -
1.82 -lemma exists_CARD:
1.83 -  "(\<exists>i<CARD('b). P i) \<longleftrightarrow> (\<exists>i::'b::finite. P (\<pi>' i))"
1.84 -  using exists_CARD_DIM[where 'a=real, of P] by simp
1.85 -
1.86 -lemmas cart_simps = forall_CARD_DIM exists_CARD_DIM forall_CARD exists_CARD
1.87 -
1.88 -lemma cart_euclidean_nth[simp]:
1.89 -  fixes x :: "('a::euclidean_space, 'b::finite) vec"
1.90 -  assumes j:"j < DIM('a)"
1.91 -  shows "x \$\$ (j + \<pi>' i * DIM('a)) = x \$ i \$\$ j"
1.92 -  unfolding euclidean_component_def inner_vec_def basis_eq_pi'[OF j] if_distrib cond_application_beta
1.93 -  by (simp add: setsum_cases)
1.94 -
1.95 -lemma real_euclidean_nth:
1.96 -  fixes x :: "real^'n"
1.97 -  shows "x \$\$ \<pi>' i = (x \$ i :: real)"
1.98 -  using cart_euclidean_nth[where 'a=real, of 0 x i] by simp
1.99 -
1.100 -lemmas nth_conv_component = real_euclidean_nth[symmetric]
1.101 -
1.102 -lemma mult_split_eq:
1.103 -  fixes A :: nat assumes "x < A" "y < A"
1.104 -  shows "x + i * A = y + j * A \<longleftrightarrow> x = y \<and> i = j"
1.105 -proof
1.106 -  assume *: "x + i * A = y + j * A"
1.107 -  { fix x y i j assume "i < j" "x < A" and *: "x + i * A = y + j * A"
1.108 -    hence "x + i * A < Suc i * A" using `x < A` by simp
1.109 -    also have "\<dots> \<le> j * A" using `i < j` unfolding mult_le_cancel2 by simp
1.110 -    also have "\<dots> \<le> y + j * A" by simp
1.111 -    finally have "i = j" using * by simp }
1.112 -  note eq = this
1.113 -
1.114 -  have "i = j"
1.115 -  proof (cases rule: linorder_cases)
1.116 -    assume "i < j"
1.117 -    from eq[OF this `x < A` *] show "i = j" by simp
1.118 -  next
1.119 -    assume "j < i"
1.120 -    from eq[OF this `y < A` *[symmetric]] show "i = j" by simp
1.121 -  qed simp
1.122 -  thus "x = y \<and> i = j" using * by simp
1.123 -qed simp
1.124 +  using setsum_norm_allsubsets_bound[OF assms]
1.125 +  by (simp add: DIM_cart Basis_real_def)
1.126
1.127  instance vec :: (ordered_euclidean_space, finite) ordered_euclidean_space
1.128  proof
1.129    fix x y::"'a^'b"
1.130 -  show "(x \<le> y) = (\<forall>i<DIM(('a, 'b) vec). x \$\$ i \<le> y \$\$ i)"
1.131 -    unfolding less_eq_vec_def apply(subst eucl_le) by (simp add: cart_simps)
1.132 -  show"(x < y) = (\<forall>i<DIM(('a, 'b) vec). x \$\$ i < y \$\$ i)"
1.133 -    unfolding less_vec_def apply(subst eucl_less) by (simp add: cart_simps)
1.134 -qed
1.135 -
1.136 -
1.137 -subsection{* Basis vectors in coordinate directions. *}
1.138 -
1.139 -definition "cart_basis k = (\<chi> i. if i = k then 1 else 0)"
1.140 -
1.141 -lemma basis_component [simp]: "cart_basis k \$ i = (if k=i then 1 else 0)"
1.142 -  unfolding cart_basis_def by simp
1.143 -
1.144 -lemma norm_basis[simp]:
1.145 -  shows "norm (cart_basis k :: real ^'n) = 1"
1.146 -  apply (simp add: cart_basis_def norm_eq_sqrt_inner) unfolding inner_vec_def
1.147 -  apply (vector delta_mult_idempotent)
1.148 -  using setsum_delta[of "UNIV :: 'n set" "k" "\<lambda>k. 1::real"] apply auto
1.149 -  done
1.150 -
1.151 -lemma norm_basis_1: "norm(cart_basis 1 :: real ^'n::{finite,one}) = 1"
1.152 -  by (rule norm_basis)
1.153 -
1.154 -lemma vector_choose_size: "0 <= c ==> \<exists>(x::real^'n). norm x = c"
1.155 -  by (rule exI[where x="c *\<^sub>R cart_basis arbitrary"]) simp
1.156 -
1.157 -lemma vector_choose_dist:
1.158 -  assumes e: "0 <= e"
1.159 -  shows "\<exists>(y::real^'n). dist x y = e"
1.160 -proof -
1.161 -  from vector_choose_size[OF e] obtain c:: "real ^'n" where "norm c = e"
1.162 -    by blast
1.163 -  then have "dist x (x - c) = e" by (simp add: dist_norm)
1.164 -  then show ?thesis by blast
1.165 +  show "(x \<le> y) = (\<forall>i\<in>Basis. x \<bullet> i \<le> y \<bullet> i)"
1.166 +    unfolding less_eq_vec_def apply(subst eucl_le) by (simp add: Basis_vec_def inner_axis)
1.167 +  show"(x < y) = (\<forall>i\<in>Basis. x \<bullet> i < y \<bullet> i)"
1.168 +    unfolding less_vec_def apply(subst eucl_less) by (simp add: Basis_vec_def inner_axis)
1.169  qed
1.170
1.171 -lemma basis_inj[intro]: "inj (cart_basis :: 'n \<Rightarrow> real ^'n)"
1.172 -  by (simp add: inj_on_def vec_eq_iff)
1.173 -
1.174 -lemma basis_expansion: "setsum (\<lambda>i. (x\$i) *s cart_basis i) UNIV = (x::('a::ring_1) ^'n)"
1.175 -  (is "?lhs = ?rhs" is "setsum ?f ?S = _")
1.176 -  by (auto simp add: vec_eq_iff
1.177 -      if_distrib setsum_delta[of "?S", where ?'b = "'a", simplified] cong del: if_weak_cong)
1.178 -
1.179 -lemma smult_conv_scaleR: "c *s x = scaleR c x"
1.180 -  unfolding vector_scalar_mult_def scaleR_vec_def by simp
1.181 -
1.182 -lemma basis_expansion': "setsum (\<lambda>i. (x\$i) *\<^sub>R cart_basis i) UNIV = x"
1.183 -  by (rule basis_expansion [where 'a=real, unfolded smult_conv_scaleR])
1.184 -
1.185 -lemma basis_expansion_unique:
1.186 -  "setsum (\<lambda>i. f i *s cart_basis i) UNIV = (x::('a::comm_ring_1) ^'n) \<longleftrightarrow> (\<forall>i. f i = x\$i)"
1.187 -  by (simp add: vec_eq_iff setsum_delta if_distrib cong del: if_weak_cong)
1.188 -
1.189 -lemma dot_basis: "cart_basis i \<bullet> x = x\$i" "x \<bullet> (cart_basis i) = (x\$i)"
1.190 -  by (auto simp add: inner_vec_def cart_basis_def cond_application_beta if_distrib setsum_delta
1.191 -           cong del: if_weak_cong)
1.192 -
1.193 -lemma inner_basis:
1.194 -  fixes x :: "'a::{real_inner, real_algebra_1} ^ 'n"
1.195 -  shows "inner (cart_basis i) x = inner 1 (x \$ i)"
1.196 -    and "inner x (cart_basis i) = inner (x \$ i) 1"
1.197 -  unfolding inner_vec_def cart_basis_def
1.198 -  by (auto simp add: cond_application_beta if_distrib setsum_delta cong del: if_weak_cong)
1.199 -
1.200 -lemma basis_eq_0: "cart_basis i = (0::'a::semiring_1^'n) \<longleftrightarrow> False"
1.201 -  by (auto simp add: vec_eq_iff)
1.202 -
1.203 -lemma basis_nonzero: "cart_basis k \<noteq> (0:: 'a::semiring_1 ^'n)"
1.204 -  by (simp add: basis_eq_0)
1.205 -
1.206 -text {* some lemmas to map between Eucl and Cart *}
1.207 -lemma basis_real_n[simp]:"(basis (\<pi>' i)::real^'a) = cart_basis i"
1.208 -  unfolding basis_vec_def using pi'_range[where 'n='a]
1.209 -  by (auto simp: vec_eq_iff axis_def)
1.210 -
1.211 -subsection {* Orthogonality on cartesian products *}
1.212 -
1.213 -lemma orthogonal_basis: "orthogonal (cart_basis i) x \<longleftrightarrow> x\$i = (0::real)"
1.214 -  by (auto simp add: orthogonal_def inner_vec_def cart_basis_def if_distrib
1.215 -                     cond_application_beta setsum_delta cong del: if_weak_cong)
1.216 -
1.217 -lemma orthogonal_basis_basis: "orthogonal (cart_basis i :: real^'n) (cart_basis j) \<longleftrightarrow> i \<noteq> j"
1.218 -  unfolding orthogonal_basis[of i] basis_component[of j] by simp
1.219 -
1.220 -subsection {* Linearity on cartesian products *}
1.221 -
1.222 -lemma linear_vmul_component:
1.223 -  assumes "linear f"
1.224 -  shows "linear (\<lambda>x. f x \$ k *\<^sub>R v)"
1.225 -  using assms by (auto simp add: linear_def algebra_simps)
1.226 -
1.227 -
1.228 -subsection {* Adjoints on cartesian products *}
1.229 -
1.230 -text {* TODO: The following lemmas about adjoints should hold for any
1.231 -Hilbert space (i.e. complete inner product space).
1.233 -*}
1.234 -
1.236 -  fixes f:: "real ^'n \<Rightarrow> real ^'m"
1.237 -  assumes lf: "linear f"
1.238 -  shows "\<forall>x y. f x \<bullet> y = x \<bullet> adjoint f y"
1.239 -proof -
1.240 -  let ?N = "UNIV :: 'n set"
1.241 -  let ?M = "UNIV :: 'm set"
1.242 -  have fN: "finite ?N" by simp
1.243 -  have fM: "finite ?M" by simp
1.244 -  { fix y:: "real ^ 'm"
1.245 -    let ?w = "(\<chi> i. (f (cart_basis i) \<bullet> y)) :: real ^ 'n"
1.246 -    { fix x
1.247 -      have "f x \<bullet> y = f (setsum (\<lambda>i. (x\$i) *\<^sub>R cart_basis i) ?N) \<bullet> y"
1.248 -        by (simp only: basis_expansion')
1.249 -      also have "\<dots> = (setsum (\<lambda>i. (x\$i) *\<^sub>R f (cart_basis i)) ?N) \<bullet> y"
1.250 -        unfolding linear_setsum[OF lf fN]
1.251 -        by (simp add: linear_cmul[OF lf])
1.252 -      finally have "f x \<bullet> y = x \<bullet> ?w"
1.253 -        by (simp add: inner_vec_def setsum_left_distrib
1.254 -            setsum_right_distrib setsum_commute[of _ ?M ?N] field_simps)
1.255 -    }
1.256 -  }
1.257 -  then show ?thesis
1.258 -    unfolding adjoint_def some_eq_ex[of "\<lambda>f'. \<forall>x y. f x \<bullet> y = x \<bullet> f' y"]
1.259 -    using choice_iff[of "\<lambda>a b. \<forall>x. f x \<bullet> a = x \<bullet> b "]
1.260 -    by metis
1.261 -qed
1.262 -
1.264 -  fixes f:: "real ^'n \<Rightarrow> real ^'m"
1.265 -  assumes lf: "linear f"
1.266 -  shows "x \<bullet> adjoint f y = f x \<bullet> y"
1.267 -  using adjoint_works_lemma[OF lf] by metis
1.268 -
1.270 -  fixes f:: "real ^'n \<Rightarrow> real ^'m"
1.271 -  assumes lf: "linear f"
1.272 -  shows "linear (adjoint f)"
1.273 -  unfolding linear_def vector_eq_ldot[where 'a="real^'n", symmetric] apply safe
1.274 -  unfolding inner_simps smult_conv_scaleR adjoint_works[OF lf] by auto
1.275 -
1.277 -  fixes f:: "real ^'n \<Rightarrow> real ^'m"
1.278 -  assumes lf: "linear f"
1.279 -  shows "x \<bullet> adjoint f y = f x \<bullet> y"
1.280 -    and "adjoint f y \<bullet> x = y \<bullet> f x"
1.282 -
1.284 -  fixes f:: "real ^'n \<Rightarrow> real ^'m"
1.285 -  assumes lf: "linear f"
1.288 -
1.289 -
1.290  subsection {* Matrix operations *}
1.291
1.292  text{* Matrix notation. NB: an MxN matrix is of type @{typ "'a^'n^'m"}, not @{typ "'a^'m^'n"} *}
1.293 @@ -680,10 +415,10 @@
1.294    apply auto
1.295    apply (subst vec_eq_iff)
1.296    apply clarify
1.297 -  apply (clarsimp simp add: matrix_vector_mult_def cart_basis_def if_distrib cond_application_beta vec_eq_iff cong del: if_weak_cong)
1.298 -  apply (erule_tac x="cart_basis ia" in allE)
1.299 +  apply (clarsimp simp add: matrix_vector_mult_def if_distrib cond_application_beta vec_eq_iff cong del: if_weak_cong)
1.300 +  apply (erule_tac x="axis ia 1" in allE)
1.301    apply (erule_tac x="i" in allE)
1.302 -  apply (auto simp add: cart_basis_def if_distrib cond_application_beta
1.303 +  apply (auto simp add: if_distrib cond_application_beta axis_def
1.304      setsum_delta[OF finite] cong del: if_weak_cong)
1.305    done
1.306
1.307 @@ -728,25 +463,27 @@
1.308    by (simp add: matrix_vector_mult_def vec_eq_iff column_def mult_commute)
1.309
1.310  lemma vector_componentwise:
1.311 -  "(x::'a::ring_1^'n) = (\<chi> j. setsum (\<lambda>i. (x\$i) * (cart_basis i :: 'a^'n)\$j) (UNIV :: 'n set))"
1.312 -  apply (subst basis_expansion[symmetric])
1.313 -  apply (vector vec_eq_iff setsum_component)
1.314 -  done
1.315 +  "(x::'a::ring_1^'n) = (\<chi> j. \<Sum>i\<in>UNIV. (x\$i) * (axis i 1 :: 'a^'n) \$ j)"
1.316 +  by (simp add: axis_def if_distrib setsum_cases vec_eq_iff)
1.317 +
1.318 +lemma basis_expansion: "setsum (\<lambda>i. (x\$i) *s axis i 1) UNIV = (x::('a::ring_1) ^'n)"
1.319 +  by (auto simp add: axis_def vec_eq_iff if_distrib setsum_cases cong del: if_weak_cong)
1.320
1.321  lemma linear_componentwise:
1.322    fixes f:: "real ^'m \<Rightarrow> real ^ _"
1.323    assumes lf: "linear f"
1.324 -  shows "(f x)\$j = setsum (\<lambda>i. (x\$i) * (f (cart_basis i)\$j)) (UNIV :: 'm set)" (is "?lhs = ?rhs")
1.325 +  shows "(f x)\$j = setsum (\<lambda>i. (x\$i) * (f (axis i 1)\$j)) (UNIV :: 'm set)" (is "?lhs = ?rhs")
1.326  proof -
1.327    let ?M = "(UNIV :: 'm set)"
1.328    let ?N = "(UNIV :: 'n set)"
1.329    have fM: "finite ?M" by simp
1.330 -  have "?rhs = (setsum (\<lambda>i.(x\$i) *\<^sub>R f (cart_basis i) ) ?M)\$j"
1.331 -    unfolding vector_smult_component[symmetric] smult_conv_scaleR
1.332 -    unfolding setsum_component[of "(\<lambda>i.(x\$i) *\<^sub>R f (cart_basis i :: real^'m))" ?M]
1.333 -    ..
1.334 +  have "?rhs = (setsum (\<lambda>i.(x\$i) *\<^sub>R f (axis i 1) ) ?M)\$j"
1.335 +    unfolding setsum_component by simp
1.336    then show ?thesis
1.337 -    unfolding linear_setsum_mul[OF lf fM, symmetric] basis_expansion' ..
1.338 +    unfolding linear_setsum_mul[OF lf fM, symmetric]
1.339 +    unfolding scalar_mult_eq_scaleR[symmetric]
1.340 +    unfolding basis_expansion
1.341 +    by simp
1.342  qed
1.343
1.344  text{* Inverse matrices  (not necessarily square) *}
1.345 @@ -761,7 +498,7 @@
1.346  text{* Correspondence between matrices and linear operators. *}
1.347
1.348  definition matrix :: "('a::{plus,times, one, zero}^'m \<Rightarrow> 'a ^ 'n) \<Rightarrow> 'a^'m^'n"
1.349 -  where "matrix f = (\<chi> i j. (f(cart_basis j))\$i)"
1.350 +  where "matrix f = (\<chi> i j. (f(axis j 1))\$i)"
1.351
1.352  lemma matrix_vector_mul_linear: "linear(\<lambda>x. A *v (x::real ^ _))"
1.353    by (simp add: linear_def matrix_vector_mult_def vec_eq_iff
1.354 @@ -831,103 +568,8 @@
1.355    ultimately show ?thesis by metis
1.356  qed
1.357
1.358 -
1.359 -subsection {* Standard bases are a spanning set, and obviously finite. *}
1.360 -
1.361 -lemma span_stdbasis:"span {cart_basis i :: real^'n | i. i \<in> (UNIV :: 'n set)} = UNIV"
1.362 -  apply (rule set_eqI)
1.363 -  apply auto
1.364 -  apply (subst basis_expansion'[symmetric])
1.365 -  apply (rule span_setsum)
1.366 -  apply simp
1.367 -  apply auto
1.368 -  apply (rule span_mul)
1.369 -  apply (rule span_superset)
1.370 -  apply auto
1.371 -  done
1.372 -
1.373 -lemma finite_stdbasis: "finite {cart_basis i ::real^'n |i. i\<in> (UNIV:: 'n set)}" (is "finite ?S")
1.374 -proof -
1.375 -  have "?S = cart_basis ` UNIV" by blast
1.376 -  then show ?thesis by auto
1.377 -qed
1.378 -
1.379 -lemma card_stdbasis: "card {cart_basis i ::real^'n |i. i\<in> (UNIV :: 'n set)} = CARD('n)" (is "card ?S = _")
1.380 -proof -
1.381 -  have "?S = cart_basis ` UNIV" by blast
1.382 -  then show ?thesis using card_image[OF basis_inj] by simp
1.383 -qed
1.384 -
1.385 -lemma independent_stdbasis_lemma:
1.386 -  assumes x: "(x::real ^ 'n) \<in> span (cart_basis ` S)"
1.387 -    and iS: "i \<notin> S"
1.388 -  shows "(x\$i) = 0"
1.389 -proof -
1.390 -  let ?U = "UNIV :: 'n set"
1.391 -  let ?B = "cart_basis ` S"
1.392 -  let ?P = "{(x::real^_). \<forall>i\<in> ?U. i \<notin> S \<longrightarrow> x\$i =0}"
1.393 -  { fix x::"real^_" assume xS: "x\<in> ?B"
1.394 -    from xS have "x \<in> ?P" by auto }
1.395 -  moreover
1.396 -  have "subspace ?P"
1.397 -    by (auto simp add: subspace_def)
1.398 -  ultimately show ?thesis
1.399 -    using x span_induct[of x ?B ?P] iS by blast
1.400 -qed
1.401 -
1.402 -lemma independent_stdbasis: "independent {cart_basis i ::real^'n |i. i\<in> (UNIV :: 'n set)}"
1.403 -proof -
1.404 -  let ?I = "UNIV :: 'n set"
1.405 -  let ?b = "cart_basis :: _ \<Rightarrow> real ^'n"
1.406 -  let ?B = "?b ` ?I"
1.407 -  have eq: "{?b i|i. i \<in> ?I} = ?B" by auto
1.408 -  { assume d: "dependent ?B"
1.409 -    then obtain k where k: "k \<in> ?I" "?b k \<in> span (?B - {?b k})"
1.410 -      unfolding dependent_def by auto
1.411 -    have eq1: "?B - {?b k} = ?B - ?b ` {k}"  by simp
1.412 -    have eq2: "?B - {?b k} = ?b ` (?I - {k})"
1.413 -      unfolding eq1
1.414 -      apply (rule inj_on_image_set_diff[symmetric])
1.415 -      apply (rule basis_inj) using k(1)
1.416 -      apply auto
1.417 -      done
1.418 -    from k(2) have th0: "?b k \<in> span (?b ` (?I - {k}))" unfolding eq2 .
1.419 -    from independent_stdbasis_lemma[OF th0, of k, simplified]
1.420 -    have False by simp }
1.421 -  then show ?thesis unfolding eq dependent_def ..
1.422 -qed
1.423 -
1.424  lemma vector_sub_project_orthogonal_cart: "(b::real^'n) \<bullet> (x - ((b \<bullet> x) / (b \<bullet> b)) *s b) = 0"
1.425 -  unfolding inner_simps smult_conv_scaleR by auto
1.426 -
1.427 -lemma linear_eq_stdbasis_cart:
1.428 -  assumes lf: "linear (f::real^'m \<Rightarrow> _)" and lg: "linear g"
1.429 -    and fg: "\<forall>i. f (cart_basis i) = g(cart_basis i)"
1.430 -  shows "f = g"
1.431 -proof -
1.432 -  let ?U = "UNIV :: 'm set"
1.433 -  let ?I = "{cart_basis i:: real^'m|i. i \<in> ?U}"
1.434 -  { fix x assume x: "x \<in> (UNIV :: (real^'m) set)"
1.435 -    from equalityD2[OF span_stdbasis]
1.436 -    have IU: " (UNIV :: (real^'m) set) \<subseteq> span ?I" by blast
1.437 -    from linear_eq[OF lf lg IU] fg x
1.438 -    have "f x = g x" unfolding Ball_def mem_Collect_eq by metis
1.439 -  }
1.440 -  then show ?thesis by auto
1.441 -qed
1.442 -
1.443 -lemma bilinear_eq_stdbasis_cart:
1.444 -  assumes bf: "bilinear (f:: real^'m \<Rightarrow> real^'n \<Rightarrow> _)"
1.445 -    and bg: "bilinear g"
1.446 -    and fg: "\<forall>i j. f (cart_basis i) (cart_basis j) = g (cart_basis i) (cart_basis j)"
1.447 -  shows "f = g"
1.448 -proof -
1.449 -  from fg have th: "\<forall>x \<in> {cart_basis i| i. i\<in> (UNIV :: 'm set)}.
1.450 -      \<forall>y\<in>  {cart_basis j |j. j \<in> (UNIV :: 'n set)}. f x y = g x y"
1.451 -    by blast
1.452 -  from bilinear_eq[OF bf bg equalityD2[OF span_stdbasis] equalityD2[OF span_stdbasis] th]
1.453 -  show ?thesis by blast
1.454 -qed
1.455 +  unfolding inner_simps scalar_mult_eq_scaleR by auto
1.456
1.457  lemma left_invertible_transpose:
1.458    "(\<exists>(B). B ** transpose (A) = mat (1::'a::comm_semiring_1)) \<longleftrightarrow> (\<exists>(B). A ** B = mat 1)"
1.459 @@ -1043,7 +685,7 @@
1.460          unfolding y[symmetric]
1.461          apply (rule span_setsum[OF fU])
1.462          apply clarify
1.463 -        unfolding smult_conv_scaleR
1.464 +        unfolding scalar_mult_eq_scaleR
1.465          apply (rule span_mul)
1.466          apply (rule span_superset)
1.467          unfolding columns_def
1.468 @@ -1056,7 +698,7 @@
1.469      let ?P = "\<lambda>(y::real ^'n). \<exists>(x::real^'m). setsum (\<lambda>i. (x\$i) *s column i A) ?U = y"
1.470      { fix y
1.471        have "?P y"
1.472 -      proof (rule span_induct_alt[of ?P "columns A", folded smult_conv_scaleR])
1.473 +      proof (rule span_induct_alt[of ?P "columns A", folded scalar_mult_eq_scaleR])
1.474          show "\<exists>x\<Colon>real ^ 'm. setsum (\<lambda>i. (x\$i) *s column i A) ?U = 0"
1.475            by (rule exI[where x=0], simp)
1.476        next
1.477 @@ -1159,25 +801,12 @@
1.478      dot_rowvector_columnvector matrix_transpose_mul matrix_mul_assoc ..
1.479
1.480
1.481 -lemma infnorm_cart:"infnorm (x::real^'n) = Sup {abs(x\$i) |i. i\<in> (UNIV :: 'n set)}"
1.482 -  unfolding infnorm_def apply(rule arg_cong[where f=Sup]) apply safe
1.483 -  apply(rule_tac x="\<pi> i" in exI) defer
1.484 -  apply(rule_tac x="\<pi>' i" in exI)
1.485 -  unfolding nth_conv_component
1.486 -  using pi'_range apply auto
1.487 -  done
1.488 -
1.489 -lemma infnorm_set_image_cart: "{abs(x\$i) |i. i\<in> (UNIV :: _ set)} =
1.490 -  (\<lambda>i. abs(x\$i)) ` (UNIV)" by blast
1.491 -
1.492 -lemma infnorm_set_lemma_cart:
1.493 -  "finite {abs((x::'a::abs ^'n)\$i) |i. i\<in> (UNIV :: 'n set)}"
1.494 -  "{abs(x\$i) |i. i\<in> (UNIV :: 'n::finite set)} \<noteq> {}"
1.495 -  unfolding infnorm_set_image_cart by auto
1.496 +lemma infnorm_cart:"infnorm (x::real^'n) = Sup {abs(x\$i) |i. i\<in>UNIV}"
1.497 +  by (simp add: infnorm_def inner_axis Basis_vec_def) (metis (lifting) inner_axis real_inner_1_right)
1.498
1.499  lemma component_le_infnorm_cart: "\<bar>x\$i\<bar> \<le> infnorm (x::real^'n)"
1.500 -  unfolding nth_conv_component
1.501 -  using component_le_infnorm[of x] .
1.502 +  using Basis_le_infnorm[of "axis i 1" x]
1.503 +  by (simp add: Basis_vec_def axis_eq_axis inner_axis)
1.504
1.505  lemma continuous_component: "continuous F f \<Longrightarrow> continuous F (\<lambda>x. f x \$ i)"
1.506    unfolding continuous_def by (rule tendsto_vec_nth)
1.507 @@ -1371,7 +1000,7 @@
1.508      and "{c .. d} \<subseteq> {a<..<b} \<longleftrightarrow> (\<forall>i. c\$i \<le> d\$i) --> (\<forall>i. a\$i < c\$i \<and> d\$i < b\$i)" (is ?th2)
1.509      and "{c<..<d} \<subseteq> {a .. b} \<longleftrightarrow> (\<forall>i. c\$i < d\$i) --> (\<forall>i. a\$i \<le> c\$i \<and> d\$i \<le> b\$i)" (is ?th3)
1.510      and "{c<..<d} \<subseteq> {a<..<b} \<longleftrightarrow> (\<forall>i. c\$i < d\$i) --> (\<forall>i. a\$i \<le> c\$i \<and> d\$i \<le> b\$i)" (is ?th4)
1.511 -  using subset_interval[of c d a b] by (simp_all add: cart_simps real_euclidean_nth)
1.512 +  using subset_interval[of c d a b] by (simp_all add: Basis_vec_def inner_axis)
1.513
1.514  lemma disjoint_interval_cart:
1.515    fixes a::"real^'n"
1.516 @@ -1379,7 +1008,7 @@
1.517      and "{a .. b} \<inter> {c<..<d} = {} \<longleftrightarrow> (\<exists>i. (b\$i < a\$i \<or> d\$i \<le> c\$i \<or> b\$i \<le> c\$i \<or> d\$i \<le> a\$i))" (is ?th2)
1.518      and "{a<..<b} \<inter> {c .. d} = {} \<longleftrightarrow> (\<exists>i. (b\$i \<le> a\$i \<or> d\$i < c\$i \<or> b\$i \<le> c\$i \<or> d\$i \<le> a\$i))" (is ?th3)
1.519      and "{a<..<b} \<inter> {c<..<d} = {} \<longleftrightarrow> (\<exists>i. (b\$i \<le> a\$i \<or> d\$i \<le> c\$i \<or> b\$i \<le> c\$i \<or> d\$i \<le> a\$i))" (is ?th4)
1.520 -  using disjoint_interval[of a b c d] by (simp_all add: cart_simps real_euclidean_nth)
1.521 +  using disjoint_interval[of a b c d] by (simp_all add: Basis_vec_def inner_axis)
1.522
1.523  lemma inter_interval_cart:
1.524    fixes a :: "'a::linorder^'n"
1.525 @@ -1400,7 +1029,7 @@
1.526  lemma is_interval_cart:
1.527    "is_interval (s::(real^'n) set) \<longleftrightarrow>
1.528      (\<forall>a\<in>s. \<forall>b\<in>s. \<forall>x. (\<forall>i. ((a\$i \<le> x\$i \<and> x\$i \<le> b\$i) \<or> (b\$i \<le> x\$i \<and> x\$i \<le> a\$i))) \<longrightarrow> x \<in> s)"
1.529 -  by (simp add: is_interval_def Ball_def cart_simps real_euclidean_nth)
1.530 +  by (simp add: is_interval_def Ball_def Basis_vec_def inner_axis imp_ex)
1.531
1.532  lemma closed_halfspace_component_le_cart: "closed {x::real^'n. x\$i \<le> a}"
1.534 @@ -1416,27 +1045,15 @@
1.535
1.536  lemma Lim_component_le_cart:
1.537    fixes f :: "'a \<Rightarrow> real^'n"
1.538 -  assumes "(f ---> l) net" "\<not> (trivial_limit net)"  "eventually (\<lambda>x. f(x)\$i \<le> b) net"
1.539 +  assumes "(f ---> l) net" "\<not> (trivial_limit net)"  "eventually (\<lambda>x. f x \$i \<le> b) net"
1.540    shows "l\$i \<le> b"
1.541 -proof -
1.542 -  { fix x
1.543 -    have "x \<in> {x::real^'n. inner (cart_basis i) x \<le> b} \<longleftrightarrow> x\$i \<le> b"
1.544 -      unfolding inner_basis by auto }
1.545 -  then show ?thesis using Lim_in_closed_set[of "{x. inner (cart_basis i) x \<le> b}" f net l]
1.546 -    using closed_halfspace_le[of "(cart_basis i)::real^'n" b] and assms(1,2,3) by auto
1.547 -qed
1.548 +  by (rule tendsto_le[OF assms(2) tendsto_const tendsto_vec_nth, OF assms(1, 3)])
1.549
1.550  lemma Lim_component_ge_cart:
1.551    fixes f :: "'a \<Rightarrow> real^'n"
1.552    assumes "(f ---> l) net"  "\<not> (trivial_limit net)"  "eventually (\<lambda>x. b \<le> (f x)\$i) net"
1.553    shows "b \<le> l\$i"
1.554 -proof -
1.555 -  { fix x
1.556 -    have "x \<in> {x::real^'n. inner (cart_basis i) x \<ge> b} \<longleftrightarrow> x\$i \<ge> b"
1.557 -      unfolding inner_basis by auto }
1.558 -  then show ?thesis using Lim_in_closed_set[of "{x. inner (cart_basis i) x \<ge> b}" f net l]
1.559 -    using closed_halfspace_ge[of b "(cart_basis i)::real^'n"] and assms(1,2,3) by auto
1.560 -qed
1.561 +  by (rule tendsto_le[OF assms(2) tendsto_vec_nth tendsto_const, OF assms(1, 3)])
1.562
1.563  lemma Lim_component_eq_cart:
1.564    fixes f :: "'a \<Rightarrow> real^'n"
1.565 @@ -1449,8 +1066,8 @@
1.566  lemma connected_ivt_component_cart:
1.567    fixes x :: "real^'n"
1.568    shows "connected s \<Longrightarrow> x \<in> s \<Longrightarrow> y \<in> s \<Longrightarrow> x\$k \<le> a \<Longrightarrow> a \<le> y\$k \<Longrightarrow> (\<exists>z\<in>s.  z\$k = a)"
1.569 -  using connected_ivt_hyperplane[of s x y "(cart_basis k)::real^'n" a]
1.570 -  by (auto simp add: inner_basis)
1.571 +  using connected_ivt_hyperplane[of s x y "axis k 1" a]
1.572 +  by (auto simp add: inner_axis inner_commute)
1.573
1.574  lemma subspace_substandard_cart: "subspace {x::real^_. (\<forall>i. P i \<longrightarrow> x\$i = 0)}"
1.575    unfolding subspace_def by auto
1.576 @@ -1468,20 +1085,14 @@
1.577  lemma dim_substandard_cart: "dim {x::real^'n. \<forall>i. i \<notin> d \<longrightarrow> x\$i = 0} = card d"
1.578    (is "dim ?A = _")
1.579  proof -
1.580 -  have *: "{x. \<forall>i<DIM((real, 'n) vec). i \<notin> \<pi>' ` d \<longrightarrow> x \$\$ i = 0} =
1.581 -      {x::real^'n. \<forall>i. i \<notin> d \<longrightarrow> x\$i = 0}"
1.582 -    apply safe
1.583 -    apply (erule_tac x="\<pi>' i" in allE) defer
1.584 -    apply (erule_tac x="\<pi> i" in allE)
1.585 -    unfolding image_iff real_euclidean_nth[symmetric]
1.586 -    apply (auto simp: pi'_inj[THEN inj_eq])
1.587 -    done
1.588 -  have " \<pi>' ` d \<subseteq> {..<DIM((real, 'n) vec)}"
1.589 -    using pi'_range[where 'n='n] by auto
1.590 +  let ?a = "\<lambda>x. axis x 1 :: real^'n"
1.591 +  have *: "{x. \<forall>i\<in>Basis. i \<notin> ?a ` d \<longrightarrow> x \<bullet> i = 0} = ?A"
1.592 +    by (auto simp: image_iff Basis_vec_def axis_eq_axis inner_axis)
1.593 +  have "?a ` d \<subseteq> Basis"
1.594 +    by (auto simp: Basis_vec_def)
1.595    thus ?thesis
1.596 -    using dim_substandard[of "\<pi>' ` d", where 'a="real^'n"]
1.597 -    unfolding * using card_image[of "\<pi>'" d] using pi'_inj unfolding inj_on_def
1.598 -    by auto
1.599 +    using dim_substandard[of "?a ` d"] card_image[of ?a d]
1.600 +    by (auto simp: axis_eq_axis inj_on_def *)
1.601  qed
1.602
1.603  lemma affinity_inverses:
1.604 @@ -1513,32 +1124,24 @@
1.605    using vector_affinity_eq[where m=m and x=x and y=y and c=c]
1.606    by metis
1.607
1.608 -lemma const_vector_cart:"((\<chi> i. d)::real^'n) = (\<chi>\<chi> i. d)"
1.609 -  apply(subst euclidean_eq)
1.610 -proof safe
1.611 -  case goal1
1.612 -  hence *: "(basis i::real^'n) = cart_basis (\<pi> i)"
1.613 -    unfolding basis_real_n[symmetric] by auto
1.614 -  have "((\<chi> i. d)::real^'n) \$\$ i = d" unfolding euclidean_component_def *
1.615 -    unfolding dot_basis by auto
1.616 -  thus ?case using goal1 by auto
1.617 -qed
1.618 -
1.619 +lemma vector_cart:
1.620 +  fixes f :: "real^'n \<Rightarrow> real"
1.621 +  shows "(\<chi> i. f (axis i 1)) = (\<Sum>i\<in>Basis. f i *\<^sub>R i)"
1.622 +  unfolding euclidean_eq_iff[where 'a="real^'n"]
1.623 +  by simp (simp add: Basis_vec_def inner_axis)
1.624 +
1.625 +lemma const_vector_cart:"((\<chi> i. d)::real^'n) = (\<Sum>i\<in>Basis. d *\<^sub>R i)"
1.626 +  by (rule vector_cart)
1.627
1.628  subsection "Convex Euclidean Space"
1.629
1.630 -lemma Cart_1:"(1::real^'n) = (\<chi>\<chi> i. 1)"
1.631 -  apply(subst euclidean_eq)
1.632 -proof safe
1.633 -  case goal1
1.634 -  thus ?case
1.635 -    using nth_conv_component[THEN sym,where i1="\<pi> i" and x1="1::real^'n"] by auto
1.636 -qed
1.637 +lemma Cart_1:"(1::real^'n) = \<Sum>Basis"
1.638 +  using const_vector_cart[of 1] by (simp add: one_vec_def)
1.639
1.640  declare vector_add_ldistrib[simp] vector_ssub_ldistrib[simp] vector_smult_assoc[simp] vector_smult_rneg[simp]
1.642
1.643 -lemmas vector_component_simps = vector_minus_component vector_smult_component vector_add_component less_eq_vec_def vec_lambda_beta basis_component vector_uminus_component
1.644 +lemmas vector_component_simps = vector_minus_component vector_smult_component vector_add_component less_eq_vec_def vec_lambda_beta vector_uminus_component
1.645
1.646  lemma convex_box_cart:
1.647    assumes "\<And>i. convex {x. P i x}"
1.648 @@ -1551,95 +1154,20 @@
1.649  lemma unit_interval_convex_hull_cart:
1.650    "{0::real^'n .. 1} = convex hull {x. \<forall>i. (x\$i = 0) \<or> (x\$i = 1)}" (is "?int = convex hull ?points")
1.651    unfolding Cart_1 unit_interval_convex_hull[where 'a="real^'n"]
1.652 -  apply(rule arg_cong[where f="\<lambda>x. convex hull x"]) apply(rule set_eqI) unfolding mem_Collect_eq
1.653 -  apply safe apply(erule_tac x="\<pi>' i" in allE) unfolding nth_conv_component defer
1.654 -  apply(erule_tac x="\<pi> i" in allE)
1.655 -  apply auto
1.656 -  done
1.657 +  by (rule arg_cong[where f="\<lambda>x. convex hull x"]) (simp add: Basis_vec_def inner_axis)
1.658
1.659  lemma cube_convex_hull_cart:
1.660    assumes "0 < d"
1.661    obtains s::"(real^'n) set"
1.662      where "finite s" "{x - (\<chi> i. d) .. x + (\<chi> i. d)} = convex hull s"
1.663  proof -
1.664 -  obtain s where s: "finite s" "{x - (\<chi>\<chi> i. d)..x + (\<chi>\<chi> i. d)} = convex hull s"
1.665 -    by (rule cube_convex_hull [OF assms])
1.666 -  show thesis
1.667 -    apply(rule that[OF s(1)]) unfolding s(2)[symmetric] const_vector_cart ..
1.668 +  from cube_convex_hull [OF assms, of x] guess s .
1.669 +  with that[of s] show thesis by (simp add: const_vector_cart)
1.670  qed
1.671
1.672 -lemma std_simplex_cart:
1.673 -  "(insert (0::real^'n) { cart_basis i | i. i\<in>UNIV}) =
1.674 -    (insert 0 { basis i | i. i<DIM((real,'n) vec)})"
1.675 -  apply (rule arg_cong[where f="\<lambda>s. (insert 0 s)"])
1.676 -  unfolding basis_real_n[symmetric]
1.677 -  apply safe
1.678 -  apply (rule_tac x="\<pi>' i" in exI) defer
1.679 -  apply (rule_tac x="\<pi> i" in exI) using pi'_range[where 'n='n]
1.680 -  apply auto
1.681 -  done
1.682 -
1.683 -
1.684 -subsection "Brouwer Fixpoint"
1.685 -
1.686 -lemma kuhn_labelling_lemma_cart:
1.687 -  assumes "(\<forall>x::real^_. P x \<longrightarrow> P (f x))"  "\<forall>x. P x \<longrightarrow> (\<forall>i. Q i \<longrightarrow> 0 \<le> x\$i \<and> x\$i \<le> 1)"
1.688 -  shows "\<exists>l. (\<forall>x i. l x i \<le> (1::nat)) \<and>
1.689 -             (\<forall>x i. P x \<and> Q i \<and> (x\$i = 0) \<longrightarrow> (l x i = 0)) \<and>
1.690 -             (\<forall>x i. P x \<and> Q i \<and> (x\$i = 1) \<longrightarrow> (l x i = 1)) \<and>
1.691 -             (\<forall>x i. P x \<and> Q i \<and> (l x i = 0) \<longrightarrow> x\$i \<le> f(x)\$i) \<and>
1.692 -             (\<forall>x i. P x \<and> Q i \<and> (l x i = 1) \<longrightarrow> f(x)\$i \<le> x\$i)"
1.693 -proof -
1.694 -  have and_forall_thm:"\<And>P Q. (\<forall>x. P x) \<and> (\<forall>x. Q x) \<longleftrightarrow> (\<forall>x. P x \<and> Q x)"
1.695 -    by auto
1.696 -  have *: "\<forall>x y::real. 0 \<le> x \<and> x \<le> 1 \<and> 0 \<le> y \<and> y \<le> 1 \<longrightarrow> (x \<noteq> 1 \<and> x \<le> y \<or> x \<noteq> 0 \<and> y \<le> x)"
1.697 -    by auto
1.698 -  show ?thesis
1.699 -    unfolding and_forall_thm apply(subst choice_iff[symmetric])+
1.700 -  proof (rule, rule)
1.701 -    case goal1
1.702 -    let ?R = "\<lambda>y. (P x \<and> Q xa \<and> x \$ xa = 0 \<longrightarrow> y = (0::nat)) \<and>
1.703 -        (P x \<and> Q xa \<and> x \$ xa = 1 \<longrightarrow> y = 1) \<and>
1.704 -        (P x \<and> Q xa \<and> y = 0 \<longrightarrow> x \$ xa \<le> f x \$ xa) \<and>
1.705 -        (P x \<and> Q xa \<and> y = 1 \<longrightarrow> f x \$ xa \<le> x \$ xa)"
1.706 -    { assume "P x" "Q xa"
1.707 -      hence "0 \<le> f x \$ xa \<and> f x \$ xa \<le> 1"
1.708 -        using assms(2)[rule_format,of "f x" xa]
1.709 -        apply (drule_tac assms(1)[rule_format])
1.710 -        apply auto
1.711 -        done
1.712 -    }
1.713 -    hence "?R 0 \<or> ?R 1" by auto
1.714 -    thus ?case by auto
1.715 -  qed
1.716 -qed
1.717 -
1.718 -lemma interval_bij_cart:"interval_bij = (\<lambda> (a,b) (u,v) (x::real^'n).
1.719 -    (\<chi> i. u\$i + (x\$i - a\$i) / (b\$i - a\$i) * (v\$i - u\$i))::real^'n)"
1.720 -  unfolding interval_bij_def apply(rule ext)+ apply safe
1.721 -  unfolding vec_eq_iff vec_lambda_beta unfolding nth_conv_component
1.722 -  apply rule
1.723 -  apply (subst euclidean_lambda_beta)
1.724 -  using pi'_range apply auto
1.725 -  done
1.726 -
1.727 -lemma interval_bij_affine_cart:
1.728 - "interval_bij (a,b) (u,v) = (\<lambda>x. (\<chi> i. (v\$i - u\$i) / (b\$i - a\$i) * x\$i) +
1.729 -            (\<chi> i. u\$i - (v\$i - u\$i) / (b\$i - a\$i) * a\$i)::real^'n)"
1.730 -  apply rule
1.731 -  unfolding vec_eq_iff interval_bij_cart vector_component_simps
1.733 -  done
1.734 -
1.735
1.736  subsection "Derivative"
1.737
1.738 -lemma has_derivative_vmul_component_cart:
1.739 -  fixes c :: "real^'a \<Rightarrow> real^'b" and v :: "real^'c"
1.740 -  assumes "(c has_derivative c') net"
1.741 -  shows "((\<lambda>x. c(x)\$k *\<^sub>R v) has_derivative (\<lambda>x. (c' x)\$k *\<^sub>R v)) net"
1.742 -  unfolding nth_conv_component by (intro has_derivative_intros assms)
1.743 -
1.744  lemma differentiable_at_imp_differentiable_on:
1.745    "(\<forall>x\<in>(s::(real^'n) set). f differentiable at x) \<Longrightarrow> f differentiable_on s"
1.746    unfolding differentiable_on_def by(auto intro!: differentiable_at_withinI)
1.747 @@ -1662,56 +1190,14 @@
1.748  subsection {* Component of the differential must be zero if it exists at a local
1.749    maximum or minimum for that corresponding component. *}
1.750
1.751 -lemma differential_zero_maxmin_component:
1.752 +lemma differential_zero_maxmin_cart:
1.753    fixes f::"real^'a \<Rightarrow> real^'b"
1.754    assumes "0 < e" "((\<forall>y \<in> ball x e. (f y)\$k \<le> (f x)\$k) \<or> (\<forall>y\<in>ball x e. (f x)\$k \<le> (f y)\$k))"
1.755 -    "f differentiable (at x)" shows "jacobian f (at x) \$ k = 0"
1.756 -(* FIXME: reuse proof of generic differential_zero_maxmin_component*)
1.757 -proof (rule ccontr)
1.758 -  def D \<equiv> "jacobian f (at x)"
1.759 -  assume "jacobian f (at x) \$ k \<noteq> 0"
1.760 -  then obtain j where j:"D\$k\$j \<noteq> 0" unfolding vec_eq_iff D_def by auto
1.761 -  hence *: "abs (jacobian f (at x) \$ k \$ j) / 2 > 0"
1.762 -    unfolding D_def by auto
1.763 -  note as = assms(3)[unfolded jacobian_works has_derivative_at_alt]
1.764 -  guess e' using as[THEN conjunct2,rule_format,OF *] .. note e' = this
1.765 -  guess d using real_lbound_gt_zero[OF assms(1) e'[THEN conjunct1]] .. note d = this
1.766 -  { fix c
1.767 -    assume "abs c \<le> d"
1.768 -    hence *:"norm (x + c *\<^sub>R cart_basis j - x) < e'"
1.769 -      using norm_basis[of j] d by auto
1.770 -    have "\<bar>(f (x + c *\<^sub>R cart_basis j) - f x - D *v (c *\<^sub>R cart_basis j)) \$ k\<bar> \<le>
1.771 -        norm (f (x + c *\<^sub>R cart_basis j) - f x - D *v (c *\<^sub>R cart_basis j))"
1.772 -      by (rule component_le_norm_cart)
1.773 -    also have "\<dots> \<le> \<bar>D \$ k \$ j\<bar> / 2 * \<bar>c\<bar>"
1.774 -      using e'[THEN conjunct2,rule_format,OF *] and norm_basis[of j]
1.775 -      unfolding D_def[symmetric] by auto
1.776 -    finally
1.777 -    have "\<bar>(f (x + c *\<^sub>R cart_basis j) - f x - D *v (c *\<^sub>R cart_basis j)) \$ k\<bar> \<le>
1.778 -      \<bar>D \$ k \$ j\<bar> / 2 * \<bar>c\<bar>" by simp
1.779 -    hence "\<bar>f (x + c *\<^sub>R cart_basis j) \$ k - f x \$ k - c * D \$ k \$ j\<bar> \<le>
1.780 -      \<bar>D \$ k \$ j\<bar> / 2 * \<bar>c\<bar>"
1.781 -      unfolding vector_component_simps matrix_vector_mul_component
1.782 -      unfolding smult_conv_scaleR[symmetric]
1.783 -      unfolding inner_simps dot_basis smult_conv_scaleR by simp
1.784 -  } note * = this
1.785 -  have "x + d *\<^sub>R cart_basis j \<in> ball x e" "x - d *\<^sub>R cart_basis j \<in> ball x e"
1.786 -    unfolding mem_ball dist_norm using norm_basis[of j] d by auto
1.787 -  hence **: "((f (x - d *\<^sub>R cart_basis j))\$k \<le> (f x)\$k \<and> (f (x + d *\<^sub>R cart_basis j))\$k \<le> (f x)\$k) \<or>
1.788 -      ((f (x - d *\<^sub>R cart_basis j))\$k \<ge> (f x)\$k \<and> (f (x + d *\<^sub>R cart_basis j))\$k \<ge> (f x)\$k)"
1.789 -    using assms(2) by auto
1.790 -  have ***: "\<And>y y1 y2 d dx::real. (y1\<le>y\<and>y2\<le>y) \<or> (y\<le>y1\<and>y\<le>y2) \<Longrightarrow>
1.791 -    d < abs dx \<Longrightarrow> abs(y1 - y - - dx) \<le> d \<Longrightarrow> (abs (y2 - y - dx) \<le> d) \<Longrightarrow> False" by arith
1.792 -  show False
1.793 -    apply (rule ***[OF **, where dx="d * D \$ k \$ j" and d="\<bar>D \$ k \$ j\<bar> / 2 * \<bar>d\<bar>"])
1.794 -    using *[of "-d"] and *[of d] and d[THEN conjunct1] and j
1.795 -    unfolding mult_minus_left
1.796 -    unfolding abs_mult diff_minus_eq_add scaleR_minus_left
1.797 -    unfolding algebra_simps
1.798 -    apply (auto intro: mult_pos_pos)
1.799 -    done
1.800 -qed
1.801 -
1.802 +    "f differentiable (at x)"
1.803 +  shows "jacobian f (at x) \$ k = 0"
1.804 +  using differential_zero_maxmin_component[of "axis k 1" e x f] assms
1.805 +    vector_cart[of "\<lambda>j. frechet_derivative f (at x) j \$ k"]
1.806 +  by (simp add: Basis_vec_def axis_eq_axis inner_axis jacobian_def matrix_def)
1.807
1.808  subsection {* Lemmas for working on @{typ "real^1"} *}
1.809
1.810 @@ -1775,25 +1261,6 @@
1.811
1.812  end
1.813
1.814 -(* "lift" from 'a to 'a^1 and "drop" from 'a^1 to 'a -- FIXME: potential use of transfer *)
1.815 -
1.816 -abbreviation vec1:: "'a \<Rightarrow> 'a ^ 1" where "vec1 x \<equiv> vec x"
1.817 -
1.818 -abbreviation dest_vec1:: "'a ^1 \<Rightarrow> 'a" where "dest_vec1 x \<equiv> (x\$1)"
1.819 -
1.820 -lemma vec1_dest_vec1[simp]: "vec1(dest_vec1 x) = x"
1.821 -  by (simp add: vec_eq_iff)
1.822 -
1.823 -lemma forall_vec1: "(\<forall>x. P x) \<longleftrightarrow> (\<forall>x. P (vec1 x))"
1.824 -  by (metis vec1_dest_vec1(1))
1.825 -
1.826 -lemma exists_vec1: "(\<exists>x. P x) \<longleftrightarrow> (\<exists>x. P(vec1 x))"
1.827 -  by (metis vec1_dest_vec1(1))
1.828 -
1.829 -lemma dest_vec1_eq[simp]: "dest_vec1 x = dest_vec1 y \<longleftrightarrow> x = y"
1.830 -  by (metis vec1_dest_vec1(1))
1.831 -
1.832 -
1.833  subsection{* The collapse of the general concepts to dimension one. *}
1.834
1.835  lemma vector_one: "(x::'a ^1) = (\<chi> i. (x\$1))"
1.836 @@ -1863,438 +1330,10 @@
1.838    done
1.839
1.840 -lemma range_vec1[simp]:"range vec1 = UNIV"
1.841 -  apply (rule set_eqI,rule) unfolding image_iff defer
1.842 -  apply (rule_tac x="dest_vec1 x" in bexI)
1.843 -  apply auto
1.844 -  done
1.845 -
1.846 -lemma dest_vec1_lambda: "dest_vec1(\<chi> i. x i) = x 1"
1.847 -  by simp
1.848 -
1.849 -lemma dest_vec1_vec: "dest_vec1(vec x) = x"
1.850 -  by simp
1.851 -
1.852 -lemma dest_vec1_sum: assumes fS: "finite S"
1.853 -  shows "dest_vec1(setsum f S) = setsum (dest_vec1 o f) S"
1.854 -  apply (induct rule: finite_induct[OF fS])
1.855 -  apply simp
1.856 -  apply auto
1.857 -  done
1.858 -
1.859 -lemma norm_vec1 [simp]: "norm(vec1 x) = abs(x)"
1.860 -  by (simp add: vec_def norm_real)
1.861 -
1.862 -lemma dist_vec1: "dist(vec1 x) (vec1 y) = abs(x - y)"
1.863 -  by (simp only: dist_real vec_component)
1.864 -lemma abs_dest_vec1: "norm x = \<bar>dest_vec1 x\<bar>"
1.865 -  by (metis vec1_dest_vec1(1) norm_vec1)
1.866 -
1.867 -lemmas vec1_dest_vec1_simps =
1.868 -  forall_vec1 vec_add[symmetric] dist_vec1 vec_sub[symmetric] vec1_dest_vec1 norm_vec1 vector_smult_component
1.869 -  vec_inj[where 'b=1] vec_cmul[symmetric] smult_conv_scaleR[symmetric] o_def dist_real_def real_norm_def
1.870 -
1.871 -lemma bounded_linear_vec1: "bounded_linear (vec1::real\<Rightarrow>real^1)"
1.872 -  unfolding bounded_linear_def additive_def bounded_linear_axioms_def
1.873 -  unfolding smult_conv_scaleR[symmetric]
1.874 -  unfolding vec1_dest_vec1_simps
1.875 -  apply (rule conjI) defer
1.876 -  apply (rule conjI) defer
1.877 -  apply (rule_tac x=1 in exI)
1.878 -  apply auto
1.879 -  done
1.880 -
1.881 -lemma linear_vmul_dest_vec1:
1.882 -  fixes f:: "real^_ \<Rightarrow> real^1"
1.883 -  shows "linear f \<Longrightarrow> linear (\<lambda>x. dest_vec1(f x) *s v)"
1.884 -  unfolding smult_conv_scaleR
1.885 -  by (rule linear_vmul_component)
1.886 -
1.887 -lemma linear_from_scalars:
1.888 -  assumes lf: "linear (f::real^1 \<Rightarrow> real^_)"
1.889 -  shows "f = (\<lambda>x. dest_vec1 x *s column 1 (matrix f))"
1.890 -  unfolding smult_conv_scaleR
1.891 -  apply (rule ext)
1.892 -  apply (subst matrix_works[OF lf, symmetric])
1.893 -  apply (auto simp add: vec_eq_iff matrix_vector_mult_def column_def mult_commute)
1.894 -  done
1.895 -
1.896 -lemma linear_to_scalars:
1.897 -  assumes lf: "linear (f::real ^'n \<Rightarrow> real^1)"
1.898 -  shows "f = (\<lambda>x. vec1(row 1 (matrix f) \<bullet> x))"
1.899 -  apply (rule ext)
1.900 -  apply (subst matrix_works[OF lf, symmetric])
1.901 -  apply (simp add: vec_eq_iff matrix_vector_mult_def row_def inner_vec_def mult_commute)
1.902 -  done
1.903 -
1.904 -lemma dest_vec1_eq_0: "dest_vec1 x = 0 \<longleftrightarrow> x = 0"
1.905 -  by (simp add: dest_vec1_eq[symmetric])
1.906 -
1.907 -lemma setsum_scalars:
1.908 -  assumes fS: "finite S"
1.909 -  shows "setsum f S = vec1 (setsum (dest_vec1 o f) S)"
1.910 -  unfolding vec_setsum[OF fS] by simp
1.911 -
1.912 -lemma dest_vec1_wlog_le:
1.913 -  "(\<And>(x::'a::linorder ^ 1) y. P x y \<longleftrightarrow> P y x)
1.914 -    \<Longrightarrow> (\<And>x y. dest_vec1 x <= dest_vec1 y ==> P x y) \<Longrightarrow> P x y"
1.915 -  apply (cases "dest_vec1 x \<le> dest_vec1 y")
1.916 -  apply simp
1.917 -  apply (subgoal_tac "dest_vec1 y \<le> dest_vec1 x")
1.918 -  apply auto
1.919 -  done
1.920 -
1.921 -text{* Lifting and dropping *}
1.922 -
1.923 -lemma continuous_on_o_dest_vec1:
1.924 -  fixes f::"real \<Rightarrow> 'a::real_normed_vector"
1.925 -  assumes "continuous_on {a..b::real} f"
1.926 -  shows "continuous_on {vec1 a..vec1 b} (f o dest_vec1)"
1.927 -  using assms unfolding continuous_on_iff apply safe
1.928 -  apply (erule_tac x="x\$1" in ballE,erule_tac x=e in allE)
1.929 -  apply safe
1.930 -  apply (rule_tac x=d in exI)
1.931 -  apply safe
1.932 -  unfolding o_def dist_real_def dist_real
1.933 -  apply (erule_tac x="dest_vec1 x'" in ballE)
1.934 -  apply (auto simp add:less_eq_vec_def)
1.935 -  done
1.936 -
1.937 -lemma continuous_on_o_vec1:
1.938 -  fixes f::"real^1 \<Rightarrow> 'a::real_normed_vector"
1.939 -  assumes "continuous_on {a..b} f"
1.940 -  shows "continuous_on {dest_vec1 a..dest_vec1 b} (f o vec1)"
1.941 -  using assms unfolding continuous_on_iff
1.942 -  apply safe
1.943 -  apply (erule_tac x="vec x" in ballE,erule_tac x=e in allE)
1.944 -  apply safe
1.945 -  apply (rule_tac x=d in exI)
1.946 -  apply safe
1.947 -  unfolding o_def dist_real_def dist_real
1.948 -  apply (erule_tac x="vec1 x'" in ballE)
1.949 -  apply (auto simp add:less_eq_vec_def)
1.950 -  done
1.951 -
1.952 -lemma continuous_on_vec1:"continuous_on A (vec1::real\<Rightarrow>real^1)"
1.953 -  by (rule linear_continuous_on[OF bounded_linear_vec1])
1.954 -
1.955 -lemma mem_interval_1:
1.956 -  fixes x :: "real^1"
1.957 -  shows "(x \<in> {a .. b} \<longleftrightarrow> dest_vec1 a \<le> dest_vec1 x \<and> dest_vec1 x \<le> dest_vec1 b)"
1.958 -    and "(x \<in> {a<..<b} \<longleftrightarrow> dest_vec1 a < dest_vec1 x \<and> dest_vec1 x < dest_vec1 b)"
1.959 -  by (simp_all add: vec_eq_iff less_vec_def less_eq_vec_def)
1.960 -
1.961 -lemma vec1_interval:
1.962 -  fixes a::"real"
1.963 -  shows "vec1 ` {a .. b} = {vec1 a .. vec1 b}"
1.964 -    and "vec1 ` {a<..<b} = {vec1 a<..<vec1 b}"
1.965 -  apply (rule_tac[!] set_eqI)
1.966 -  unfolding image_iff less_vec_def
1.967 -  unfolding mem_interval_cart
1.968 -  unfolding forall_1 vec1_dest_vec1_simps
1.969 -  apply rule defer
1.970 -  apply (rule_tac x="dest_vec1 x" in bexI) prefer 3
1.971 -  apply rule defer
1.972 -  apply (rule_tac x="dest_vec1 x" in bexI)
1.973 -  apply auto
1.974 -  done
1.975 -
1.976 -(* Some special cases for intervals in R^1.                                  *)
1.977 -
1.978 -lemma interval_cases_1:
1.979 -  fixes x :: "real^1"
1.980 -  shows "x \<in> {a .. b} ==> x \<in> {a<..<b} \<or> (x = a) \<or> (x = b)"
1.981 -  unfolding vec_eq_iff less_vec_def less_eq_vec_def mem_interval_cart
1.982 -  by (auto simp del:dest_vec1_eq)
1.983 -
1.984 -lemma in_interval_1:
1.985 -  fixes x :: "real^1"
1.986 -  shows "(x \<in> {a .. b} \<longleftrightarrow> dest_vec1 a \<le> dest_vec1 x \<and> dest_vec1 x \<le> dest_vec1 b) \<and>
1.987 -    (x \<in> {a<..<b} \<longleftrightarrow> dest_vec1 a < dest_vec1 x \<and> dest_vec1 x < dest_vec1 b)"
1.988 -  unfolding vec_eq_iff less_vec_def less_eq_vec_def mem_interval_cart
1.989 -  by (auto simp del:dest_vec1_eq)
1.990 -
1.991 -lemma interval_eq_empty_1:
1.992 -  fixes a :: "real^1"
1.993 -  shows "{a .. b} = {} \<longleftrightarrow> dest_vec1 b < dest_vec1 a"
1.994 -    and "{a<..<b} = {} \<longleftrightarrow> dest_vec1 b \<le> dest_vec1 a"
1.995 -  unfolding interval_eq_empty_cart and ex_1 by auto
1.996 -
1.997 -lemma subset_interval_1:
1.998 -  fixes a :: "real^1"
1.999 -  shows "({a .. b} \<subseteq> {c .. d} \<longleftrightarrow>  dest_vec1 b < dest_vec1 a \<or>
1.1000 -    dest_vec1 c \<le> dest_vec1 a \<and> dest_vec1 a \<le> dest_vec1 b \<and> dest_vec1 b \<le> dest_vec1 d)"
1.1001 -   "({a .. b} \<subseteq> {c<..<d} \<longleftrightarrow>  dest_vec1 b < dest_vec1 a \<or>
1.1002 -    dest_vec1 c < dest_vec1 a \<and> dest_vec1 a \<le> dest_vec1 b \<and> dest_vec1 b < dest_vec1 d)"
1.1003 -   "({a<..<b} \<subseteq> {c .. d} \<longleftrightarrow>  dest_vec1 b \<le> dest_vec1 a \<or>
1.1004 -    dest_vec1 c \<le> dest_vec1 a \<and> dest_vec1 a < dest_vec1 b \<and> dest_vec1 b \<le> dest_vec1 d)"
1.1005 -   "({a<..<b} \<subseteq> {c<..<d} \<longleftrightarrow> dest_vec1 b \<le> dest_vec1 a \<or>
1.1006 -    dest_vec1 c \<le> dest_vec1 a \<and> dest_vec1 a < dest_vec1 b \<and> dest_vec1 b \<le> dest_vec1 d)"
1.1007 -  unfolding subset_interval_cart[of a b c d] unfolding forall_1 by auto
1.1008 -
1.1009 -lemma eq_interval_1:
1.1010 -  fixes a :: "real^1"
1.1011 -  shows "{a .. b} = {c .. d} \<longleftrightarrow>
1.1012 -          dest_vec1 b < dest_vec1 a \<and> dest_vec1 d < dest_vec1 c \<or>
1.1013 -          dest_vec1 a = dest_vec1 c \<and> dest_vec1 b = dest_vec1 d"
1.1014 -  unfolding set_eq_subset[of "{a .. b}" "{c .. d}"]
1.1015 -  unfolding subset_interval_1(1)[of a b c d]
1.1016 -  unfolding subset_interval_1(1)[of c d a b]
1.1017 -  by auto
1.1018 -
1.1019 -lemma disjoint_interval_1:
1.1020 -  fixes a :: "real^1"
1.1021 -  shows
1.1022 -    "{a .. b} \<inter> {c .. d} = {} \<longleftrightarrow>
1.1023 -      dest_vec1 b < dest_vec1 a \<or> dest_vec1 d < dest_vec1 c  \<or>  dest_vec1 b < dest_vec1 c \<or> dest_vec1 d < dest_vec1 a"
1.1024 -    "{a .. b} \<inter> {c<..<d} = {} \<longleftrightarrow>
1.1025 -      dest_vec1 b < dest_vec1 a \<or> dest_vec1 d \<le> dest_vec1 c  \<or>  dest_vec1 b \<le> dest_vec1 c \<or> dest_vec1 d \<le> dest_vec1 a"
1.1026 -    "{a<..<b} \<inter> {c .. d} = {} \<longleftrightarrow>
1.1027 -      dest_vec1 b \<le> dest_vec1 a \<or> dest_vec1 d < dest_vec1 c  \<or>  dest_vec1 b \<le> dest_vec1 c \<or> dest_vec1 d \<le> dest_vec1 a"
1.1028 -    "{a<..<b} \<inter> {c<..<d} = {} \<longleftrightarrow>
1.1029 -      dest_vec1 b \<le> dest_vec1 a \<or> dest_vec1 d \<le> dest_vec1 c  \<or>  dest_vec1 b \<le> dest_vec1 c \<or> dest_vec1 d \<le> dest_vec1 a"
1.1030 -  unfolding disjoint_interval_cart and ex_1 by auto
1.1031 -
1.1032 -lemma open_closed_interval_1:
1.1033 -  fixes a :: "real^1"
1.1034 -  shows "{a<..<b} = {a .. b} - {a, b}"
1.1035 -  unfolding set_eq_iff apply simp
1.1036 -  unfolding less_vec_def and less_eq_vec_def and forall_1 and dest_vec1_eq[symmetric]
1.1037 -  apply (auto simp del:dest_vec1_eq)
1.1038 -  done
1.1039 -
1.1040 -lemma closed_open_interval_1:
1.1041 -  "dest_vec1 (a::real^1) \<le> dest_vec1 b ==> {a .. b} = {a<..<b} \<union> {a,b}"
1.1042 -  unfolding set_eq_iff
1.1043 -  apply simp
1.1044 -  unfolding less_vec_def and less_eq_vec_def and forall_1 and dest_vec1_eq[symmetric]
1.1045 -  apply (auto simp del:dest_vec1_eq)
1.1046 -  done
1.1047 -
1.1048 -lemma Lim_drop_le:
1.1049 -  fixes f :: "'a \<Rightarrow> real^1"
1.1050 -  shows "(f ---> l) net \<Longrightarrow> \<not> trivial_limit net \<Longrightarrow>
1.1051 -    eventually (\<lambda>x. dest_vec1 (f x) \<le> b) net ==> dest_vec1 l \<le> b"
1.1052 -  using Lim_component_le_cart[of f l net 1 b] by auto
1.1053 -
1.1054 -lemma Lim_drop_ge:
1.1055 -  fixes f :: "'a \<Rightarrow> real^1"
1.1056 -  shows "(f ---> l) net \<Longrightarrow> \<not> trivial_limit net \<Longrightarrow>
1.1057 -    eventually (\<lambda>x. b \<le> dest_vec1 (f x)) net ==> b \<le> dest_vec1 l"
1.1058 -  using Lim_component_ge_cart[of f l net b 1] by auto
1.1059 -
1.1060 -
1.1061 -text{* Also more convenient formulations of monotone convergence.                *}
1.1062 -
1.1063 -lemma bounded_increasing_convergent:
1.1064 -  fixes s :: "nat \<Rightarrow> real^1"
1.1065 -  assumes "bounded {s n| n::nat. True}"  "\<forall>n. dest_vec1(s n) \<le> dest_vec1(s(Suc n))"
1.1066 -  shows "\<exists>l. (s ---> l) sequentially"
1.1067 -proof -
1.1068 -  obtain a where a:"\<forall>n. \<bar>dest_vec1 (s n)\<bar> \<le>  a"
1.1069 -    using assms(1)[unfolded bounded_iff abs_dest_vec1] by auto
1.1070 -  { fix m::nat
1.1071 -    have "\<And> n. n\<ge>m \<longrightarrow> dest_vec1 (s m) \<le> dest_vec1 (s n)"
1.1072 -      apply (induct_tac n)
1.1073 -      apply simp
1.1074 -      using assms(2) apply (erule_tac x="na" in allE)
1.1075 -      apply (auto simp add: not_less_eq_eq)
1.1076 -      done
1.1077 -  }
1.1078 -  hence "\<forall>m n. m \<le> n \<longrightarrow> dest_vec1 (s m) \<le> dest_vec1 (s n)"
1.1079 -    by auto
1.1080 -  then obtain l where "\<forall>e>0. \<exists>N. \<forall>n\<ge>N. \<bar>dest_vec1 (s n) - l\<bar> < e"
1.1081 -    using convergent_bounded_monotone[OF a] unfolding monoseq_def by auto
1.1082 -  thus ?thesis unfolding LIMSEQ_def apply(rule_tac x="vec1 l" in exI)
1.1083 -    unfolding dist_norm unfolding abs_dest_vec1 by auto
1.1084 -qed
1.1085 -
1.1086 -lemma dest_vec1_simps[simp]:
1.1087 -  fixes a :: "real^1"
1.1088 -  shows "a\$1 = 0 \<longleftrightarrow> a = 0" (*"a \<le> 1 \<longleftrightarrow> dest_vec1 a \<le> 1" "0 \<le> a \<longleftrightarrow> 0 \<le> dest_vec1 a"*)
1.1089 -    "a \<le> b \<longleftrightarrow> dest_vec1 a \<le> dest_vec1 b" "dest_vec1 (1::real^1) = 1"
1.1090 -  by (auto simp add: less_eq_vec_def vec_eq_iff)
1.1091 -
1.1092 -lemma dest_vec1_inverval:
1.1093 -  "dest_vec1 ` {a .. b} = {dest_vec1 a .. dest_vec1 b}"
1.1094 -  "dest_vec1 ` {a<.. b} = {dest_vec1 a<.. dest_vec1 b}"
1.1095 -  "dest_vec1 ` {a ..<b} = {dest_vec1 a ..<dest_vec1 b}"
1.1096 -  "dest_vec1 ` {a<..<b} = {dest_vec1 a<..<dest_vec1 b}"
1.1097 -  apply(rule_tac [!] equalityI)
1.1098 -  unfolding subset_eq Ball_def Bex_def mem_interval_1 image_iff
1.1099 -  apply(rule_tac [!] allI)apply(rule_tac [!] impI)
1.1100 -  apply(rule_tac[2] x="vec1 x" in exI)apply(rule_tac[4] x="vec1 x" in exI)
1.1101 -  apply(rule_tac[6] x="vec1 x" in exI)apply(rule_tac[8] x="vec1 x" in exI)
1.1102 -  apply (auto simp add: less_vec_def less_eq_vec_def)
1.1103 -  done
1.1104 -
1.1105 -lemma dest_vec1_setsum:
1.1106 -  assumes "finite S"
1.1107 -  shows " dest_vec1 (setsum f S) = setsum (\<lambda>x. dest_vec1 (f x)) S"
1.1108 -  using dest_vec1_sum[OF assms] by auto
1.1109 -
1.1110 -lemma open_dest_vec1_vimage: "open S \<Longrightarrow> open (dest_vec1 -` S)"
1.1111 -  unfolding open_vec_def forall_1 by auto
1.1112 -
1.1113 -lemma tendsto_dest_vec1 [tendsto_intros]:
1.1114 -  "(f ---> l) net \<Longrightarrow> ((\<lambda>x. dest_vec1 (f x)) ---> dest_vec1 l) net"
1.1115 -  by (rule tendsto_vec_nth)
1.1116 -
1.1117 -lemma continuous_dest_vec1:
1.1118 -  "continuous net f \<Longrightarrow> continuous net (\<lambda>x. dest_vec1 (f x))"
1.1119 -  unfolding continuous_def by (rule tendsto_dest_vec1)
1.1120 -
1.1121 -lemma forall_dest_vec1: "(\<forall>x. P x) \<longleftrightarrow> (\<forall>x. P(dest_vec1 x))"
1.1122 -  apply safe defer
1.1123 -  apply (erule_tac x="vec1 x" in allE)
1.1124 -  apply auto
1.1125 -  done
1.1126 -
1.1127 -lemma forall_of_dest_vec1: "(\<forall>v. P (\<lambda>x. dest_vec1 (v x))) \<longleftrightarrow> (\<forall>x. P x)"
1.1128 -  apply rule
1.1129 -  apply rule
1.1130 -  apply (erule_tac x="vec1 \<circ> x" in allE)
1.1131 -  unfolding o_def vec1_dest_vec1
1.1132 -  apply auto
1.1133 -  done
1.1134 -
1.1135 -lemma forall_of_dest_vec1': "(\<forall>v. P (dest_vec1 v)) \<longleftrightarrow> (\<forall>x. P x)"
1.1136 -  apply rule
1.1137 -  apply rule
1.1138 -  apply (erule_tac x="(vec1 x)" in allE) defer
1.1139 -  apply rule
1.1140 -  apply (erule_tac x="dest_vec1 v" in allE)
1.1141 -  unfolding o_def vec1_dest_vec1
1.1142 -  apply auto
1.1143 -  done
1.1144 -
1.1145 -lemma dist_vec1_0[simp]: "dist(vec1 (x::real)) 0 = norm x"
1.1146 -  unfolding dist_norm by auto
1.1147 -
1.1148 -lemma bounded_linear_vec1_dest_vec1:
1.1149 -  fixes f :: "real \<Rightarrow> real"
1.1150 -  shows "linear (vec1 \<circ> f \<circ> dest_vec1) = bounded_linear f" (is "?l = ?r")
1.1151 -proof -
1.1152 -  { assume ?l
1.1153 -    then have "\<exists>K. \<forall>x. norm ((vec1 \<circ> f \<circ> dest_vec1) x) \<le> K * norm x" by (rule linear_bounded)
1.1154 -    then guess K ..
1.1155 -    hence "\<exists>K. \<forall>x. \<bar>f x\<bar> \<le> \<bar>x\<bar> * K"
1.1156 -      apply(rule_tac x=K in exI)
1.1157 -      unfolding vec1_dest_vec1_simps by (auto simp add:field_simps)
1.1158 -  }
1.1159 -  thus ?thesis
1.1160 -    unfolding linear_def bounded_linear_def additive_def bounded_linear_axioms_def o_def
1.1161 -    unfolding vec1_dest_vec1_simps by auto
1.1162 -qed
1.1163 -
1.1164 -lemma vec1_le[simp]: fixes a :: real shows "vec1 a \<le> vec1 b \<longleftrightarrow> a \<le> b"
1.1165 -  unfolding less_eq_vec_def by auto
1.1166 -lemma vec1_less[simp]: fixes a :: real shows "vec1 a < vec1 b \<longleftrightarrow> a < b"
1.1167 -  unfolding less_vec_def by auto
1.1168 -
1.1169 -
1.1170 -subsection {* Derivatives on real = Derivatives on @{typ "real^1"} *}
1.1171 -
1.1172 -lemma has_derivative_within_vec1_dest_vec1:
1.1173 -  fixes f :: "real \<Rightarrow> real"
1.1174 -  shows "((vec1 \<circ> f \<circ> dest_vec1) has_derivative (vec1 \<circ> f' \<circ> dest_vec1)) (at (vec1 x) within vec1 ` s)
1.1175 -    = (f has_derivative f') (at x within s)"
1.1176 -  unfolding has_derivative_within
1.1177 -  unfolding bounded_linear_vec1_dest_vec1[unfolded linear_conv_bounded_linear]
1.1178 -  unfolding o_def Lim_within Ball_def unfolding forall_vec1
1.1179 -  unfolding vec1_dest_vec1_simps dist_vec1_0 image_iff
1.1180 -  by auto
1.1181 -
1.1182 -lemma has_derivative_at_vec1_dest_vec1:
1.1183 -  fixes f :: "real \<Rightarrow> real"
1.1184 -  shows "((vec1 \<circ> f \<circ> dest_vec1) has_derivative (vec1 \<circ> f' \<circ> dest_vec1)) (at (vec1 x)) = (f has_derivative f') (at x)"
1.1185 -  using has_derivative_within_vec1_dest_vec1[where s=UNIV, unfolded range_vec1 within_UNIV]
1.1186 -  by auto
1.1187 -
1.1188 -lemma bounded_linear_vec1':
1.1189 -  fixes f :: "'a::real_normed_vector\<Rightarrow>real"
1.1190 -  shows "bounded_linear f = bounded_linear (vec1 \<circ> f)"
1.1191 -  unfolding bounded_linear_def additive_def bounded_linear_axioms_def o_def
1.1192 -  unfolding vec1_dest_vec1_simps by auto
1.1193 -
1.1194 -lemma bounded_linear_dest_vec1:
1.1195 -  fixes f :: "real\<Rightarrow>'a::real_normed_vector"
1.1196 -  shows "bounded_linear f = bounded_linear (f \<circ> dest_vec1)"
1.1197 -  unfolding bounded_linear_def additive_def bounded_linear_axioms_def o_def
1.1198 -  unfolding vec1_dest_vec1_simps
1.1199 -  by auto
1.1200 -
1.1201 -lemma has_derivative_at_vec1:
1.1202 -  fixes f :: "'a::real_normed_vector\<Rightarrow>real"
1.1203 -  shows "(f has_derivative f') (at x) = ((vec1 \<circ> f) has_derivative (vec1 \<circ> f')) (at x)"
1.1204 -  unfolding has_derivative_at
1.1205 -  unfolding bounded_linear_vec1'[unfolded linear_conv_bounded_linear]
1.1206 -  unfolding o_def Lim_at
1.1207 -  unfolding vec1_dest_vec1_simps dist_vec1_0
1.1208 -  by auto
1.1209 -
1.1210 -lemma has_derivative_within_dest_vec1:
1.1211 -  fixes f :: "real\<Rightarrow>'a::real_normed_vector"
1.1212 -  shows "((f \<circ> dest_vec1) has_derivative (f' \<circ> dest_vec1)) (at (vec1 x) within vec1 ` s) =
1.1213 -    (f has_derivative f') (at x within s)"
1.1214 -  unfolding has_derivative_within bounded_linear_dest_vec1
1.1215 -  unfolding o_def Lim_within Ball_def
1.1216 -  unfolding vec1_dest_vec1_simps dist_vec1_0 image_iff
1.1217 -  by auto
1.1218 -
1.1219 -lemma has_derivative_at_dest_vec1:
1.1220 -  fixes f :: "real\<Rightarrow>'a::real_normed_vector"
1.1221 -  shows "((f \<circ> dest_vec1) has_derivative (f' \<circ> dest_vec1)) (at (vec1 x)) =
1.1222 -    (f has_derivative f') (at x)"
1.1223 -  using has_derivative_within_dest_vec1[where s=UNIV] by simp
1.1224 -
1.1225 -
1.1226 -subsection {* In particular if we have a mapping into @{typ "real^1"}. *}
1.1227 -
1.1228 -lemma onorm_vec1:
1.1229 -  fixes f::"real \<Rightarrow> real"
1.1230 -  shows "onorm (\<lambda>x. vec1 (f (dest_vec1 x))) = onorm f"
1.1231 -proof -
1.1232 -  have "\<forall>x::real^1. norm x = 1 \<longleftrightarrow> x\<in>{vec1 -1, vec1 (1::real)}"
1.1233 -    unfolding forall_vec1 by (auto simp add: vec_eq_iff)
1.1234 -  hence 1: "{x. norm x = 1} = {vec1 -1, vec1 (1::real)}" by auto
1.1235 -  have 2: "{norm (vec1 (f (dest_vec1 x))) |x. norm x = 1} =
1.1236 -      (\<lambda>x. norm (vec1 (f (dest_vec1 x)))) ` {x. norm x=1}"
1.1237 -    by auto
1.1238 -  have "\<forall>x::real. norm x = 1 \<longleftrightarrow> x\<in>{-1, 1}" by auto
1.1239 -  hence 3:"{x. norm x = 1} = {-1, (1::real)}" by auto
1.1240 -  have 4:"{norm (f x) |x. norm x = 1} = (\<lambda>x. norm (f x)) ` {x. norm x=1}" by auto
1.1241 -  show ?thesis
1.1242 -    unfolding onorm_def 1 2 3 4 by (simp add:Sup_finite_Max)
1.1243 -qed
1.1244 -
1.1245 -lemma convex_vec1:"convex (vec1 ` s) = convex (s::real set)"
1.1246 -  unfolding convex_def Ball_def forall_vec1
1.1247 -  unfolding vec1_dest_vec1_simps image_iff
1.1248 -  by auto
1.1249 -
1.1250  lemma bounded_linear_component_cart[intro]: "bounded_linear (\<lambda>x::real^'n. x \$ k)"
1.1251    apply (rule bounded_linearI[where K=1])
1.1252    using component_le_norm_cart[of _ k] unfolding real_norm_def by auto
1.1253
1.1254 -lemma bounded_vec1[intro]: "bounded s \<Longrightarrow> bounded (vec1 ` (s::real set))"
1.1255 -  unfolding bounded_def apply safe apply(rule_tac x="vec1 x" in exI,rule_tac x=e in exI)
1.1256 -  apply (auto simp add: dist_real dist_real_def)
1.1257 -  done
1.1258 -
1.1259 -(*lemma content_closed_interval_cases_cart:
1.1260 -  "content {a..b::real^'n} =
1.1261 -  (if {a..b} = {} then 0 else setprod (\<lambda>i. b\$i - a\$i) UNIV)"
1.1262 -proof(cases "{a..b} = {}")
1.1263 -  case True thus ?thesis unfolding content_def by auto
1.1264 -next case Falsethus ?thesis unfolding content_def unfolding if_not_P[OF False]
1.1265 -  proof(cases "\<forall>i. a \$ i \<le> b \$ i")
1.1266 -    case False thus ?thesis unfolding content_def using t by auto
1.1267 -  next case True note interval_eq_empty
1.1268 -   apply auto
1.1269 -
1.1270 -  sorry*)
1.1271 -
1.1272  lemma integral_component_eq_cart[simp]:
1.1273    fixes f :: "'n::ordered_euclidean_space \<Rightarrow> real^'m"
1.1274    assumes "f integrable_on s"
1.1275 @@ -2309,39 +1348,8 @@
1.1276    unfolding vec_lambda_beta
1.1277    by auto
1.1278
1.1279 -(*lemma content_split_cart:
1.1280 -  "content {a..b::real^'n} = content({a..b} \<inter> {x. x\$k \<le> c}) + content({a..b} \<inter> {x. x\$k >= c})"
1.1281 -proof- note simps = interval_split_cart content_closed_interval_cases_cart vec_lambda_beta less_eq_vec_def
1.1282 -  { presume "a\<le>b \<Longrightarrow> ?thesis" thus ?thesis apply(cases "a\<le>b") unfolding simps by auto }
1.1283 -  have *:"UNIV = insert k (UNIV - {k})" "\<And>x. finite (UNIV-{x::'n})" "\<And>x. x\<notin>UNIV-{x}" by auto
1.1284 -  have *:"\<And>X Y Z. (\<Prod>i\<in>UNIV. Z i (if i = k then X else Y i)) = Z k X * (\<Prod>i\<in>UNIV-{k}. Z i (Y i))"
1.1285 -    "(\<Prod>i\<in>UNIV. b\$i - a\$i) = (\<Prod>i\<in>UNIV-{k}. b\$i - a\$i) * (b\$k - a\$k)"
1.1286 -    apply(subst *(1)) defer apply(subst *(1)) unfolding setprod_insert[OF *(2-)] by auto
1.1287 -  assume as:"a\<le>b" moreover have "\<And>x. min (b \$ k) c = max (a \$ k) c
1.1288 -    \<Longrightarrow> x* (b\$k - a\$k) = x*(max (a \$ k) c - a \$ k) + x*(b \$ k - max (a \$ k) c)"
1.1289 -    by  (auto simp add:field_simps)
1.1290 -  moreover have "\<not> a \$ k \<le> c \<Longrightarrow> \<not> c \<le> b \$ k \<Longrightarrow> False"
1.1291 -    unfolding not_le using as[unfolded less_eq_vec_def,rule_format,of k] by auto
1.1292 -  ultimately show ?thesis
1.1293 -    unfolding simps unfolding *(1)[of "\<lambda>i x. b\$i - x"] *(1)[of "\<lambda>i x. x - a\$i"] *(2) by(auto)
1.1294 -qed*)
1.1295 -
1.1296 -lemma has_integral_vec1:
1.1297 -  assumes "(f has_integral k) {a..b}"
1.1298 -  shows "((\<lambda>x. vec1 (f x)) has_integral (vec1 k)) {a..b}"
1.1299 -proof -
1.1300 -  have *: "\<And>p. (\<Sum>(x, k)\<in>p. content k *\<^sub>R vec1 (f x)) - vec1 k =
1.1301 -      vec1 ((\<Sum>(x, k)\<in>p. content k *\<^sub>R f x) - k)"
1.1302 -    unfolding vec_sub vec_eq_iff by (auto simp add: split_beta)
1.1303 -  show ?thesis
1.1304 -    using assms unfolding has_integral
1.1305 -    apply safe
1.1306 -    apply(erule_tac x=e in allE,safe)
1.1307 -    apply(rule_tac x=d in exI,safe)
1.1308 -    apply(erule_tac x=p in allE,safe)
1.1309 -    unfolding * norm_vector_1
1.1310 -    apply auto
1.1311 -    done
1.1312 -qed
1.1313 +lemma interval_bij_bij_cart: fixes x::"real^'n" assumes "\<forall>i. a\$i < b\$i \<and> u\$i < v\$i"
1.1314 +  shows "interval_bij (a,b) (u,v) (interval_bij (u,v) (a,b) x) = x"
1.1315 +  using assms by (intro interval_bij_bij) (auto simp: Basis_vec_def inner_axis)
1.1316
1.1317  end
```